From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D891C6FA86 for ; Thu, 15 Sep 2022 09:01:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3B028D0002; Thu, 15 Sep 2022 05:01:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEACC6B0074; Thu, 15 Sep 2022 05:01:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8AD08D0002; Thu, 15 Sep 2022 05:01:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C9C2D6B0073 for ; Thu, 15 Sep 2022 05:01:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A1FE81409DA for ; Thu, 15 Sep 2022 09:01:45 +0000 (UTC) X-FDA: 79913726970.27.BED8544 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf15.hostedemail.com (Postfix) with ESMTP id 3FD51A00AE for ; Thu, 15 Sep 2022 09:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663232504; x=1694768504; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=eXSem49F4lIICp1fQTxA40fFD7UcgAWqfAetQ90xX8M=; b=ENadim8EC996EDyZyJUvuVJBJqqFwdqclQ/nD/17ke0vGRx48nS4vXTd 3ITY66rQRhTBAIzSvw1iYcgGEvxJrEzletLq/F8cYfpG1NIYECiGRpX15 YoV6wEINXH27tlyPbn8UAi3jO0LZdeR7laJBCvojtr3DlKTj3W4e88f6D iROKpEpIX5CLoHyk76Mg/0usu0ASartGabrK0lSK790aIn6AY/AuijNPe PlBRV0ASf2B0xGK/BKylJozW6u+f186eYfaFoD8ZqEcxDavom75p/OiQT 7k3jpFootMNLucgsBwla4d4lhP+8K6aRxwA8vkbU3LxNiOdtqpESCZ776 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10470"; a="300017891" X-IronPort-AV: E=Sophos;i="5.93,317,1654585200"; d="scan'208";a="300017891" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 02:01:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,317,1654585200"; d="scan'208";a="679423455" Received: from gnogale1-mobl2.amr.corp.intel.com (HELO box.shutemov.name) ([10.251.209.66]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2022 02:01:38 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id D76AB10466F; Thu, 15 Sep 2022 12:01:35 +0300 (+03) Date: Thu, 15 Sep 2022 12:01:35 +0300 From: "Kirill A. Shutemov" To: Jacob Pan Cc: Ashok Raj , "Kirill A. Shutemov" , Ashok Raj , Dave Hansen , Andy Lutomirski , Peter Zijlstra , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jason Gunthorpe , Joerg Roedel Subject: Re: [PATCHv8 00/11] Linear Address Masking enabling Message-ID: <20220915090135.fpeokbokkdljv7rw@box.shutemov.name> References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> <20220904003952.fheisiloilxh3mpo@box.shutemov.name> <20220912224930.ukakmmwumchyacqc@box.shutemov.name> <20220914144518.46rhhyh7zmxieozs@box.shutemov.name> <20220914151818.uupzpyd333qnnmlt@box.shutemov.name> <20220914154532.mmxfsr7eadgnxt3s@box.shutemov.name> <20220914165116.24f82d74@jacob-builder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220914165116.24f82d74@jacob-builder> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663232505; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qJyFNQHTHm/OIFKPHnADo+bWFewLXoRdXuDdZj9iICA=; b=Vmv5vU/pqACed/2QrF5ppernKioxUsYF+HdGrE5KOnBDi6S9CVVr7hAPorktjxJs7O+ToU askwLqo5vChLlHMRsDZ8aSVoyqDkqs6qI925WeFEhUckCksMRF1Vz/IMpGIOpRjjYb/xvK 9Ko8OtI/SBDrYwGczK4jxQPgE4dDhMk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ENadim8E; spf=none (imf15.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.65) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663232505; a=rsa-sha256; cv=none; b=Xh9YBHzKG3PeuQ/W6d2DUgpIIG+w0EWKg55UCbvjH/Z5AdbY0JcZZKx/SM9O0x4CkEUgTc 2TxwVBnQfQ98AGdkvVyGXgBTzLDUPGt4cnwpUqCX/Sjav4uK2s1Rb8p5e7reR6/iRsJMLt aMuHSHV6nrhXQdotM4nmSu3D5OZRx1k= Authentication-Results: imf15.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=ENadim8E; spf=none (imf15.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.65) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-Rspamd-Server: rspam08 X-Rspam-User: X-Stat-Signature: sxosysr1nxqeab45u1dx3fzsfmhnq4gm X-Rspamd-Queue-Id: 3FD51A00AE X-HE-Tag: 1663232504-588479 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 14, 2022 at 04:51:16PM -0700, Jacob Pan wrote: > Hi Kirill, > > On Wed, 14 Sep 2022 18:45:32 +0300, "Kirill A. Shutemov" > wrote: > > > On Wed, Sep 14, 2022 at 08:31:56AM -0700, Ashok Raj wrote: > > > On Wed, Sep 14, 2022 at 06:18:18PM +0300, Kirill A. Shutemov wrote: > > > > > > > > > > > > > > > > The patch below implements something like this. It is PoC, > > > > > > > > build-tested only. > > > > > > > > > > > > > > > > To be honest, I hate it. It is clearly a layering violation. > > > > > > > > It feels dirty. But I don't see any better way as we tie > > > > > > > > orthogonal features together. > > > > > > > > > > > > > > > > Also I have no idea how to make forced PASID allocation if > > > > > > > > LAM enabled. What the API has to look like? > > > > > > > > > > > > > > Jacob, Ashok, any comment on this part? > > > > > > > > > > > > > > I expect in many cases LAM will be enabled very early (like > > > > > > > before malloc is functinal) in process start and it makes PASID > > > > > > > allocation always fail. > > > > > > > > > > > > > > Any way out? > > > > > > > > > > > > We need closure on this to proceed. Any clue? > > > > > > > > > > Failing PASID allocation seems like the right thing to do here. If > > > > > the application is explicitly allocating PASID's it can opt-out > > > > > using the similar mechanism you have for LAM enabling. So user takes > > > > > responsibility for sanitizing pointers. > > > > > > > > > > If some library is using an accelerator without application > > > > > knowledge, that would use the failure as a mechanism to use an > > > > > alternate path if one exists. > > > > > > > > > > I don't know if both LAM and SVM need a separate forced opt-in (or i > > > > > don't have an opinion rather). Is this what you were asking? > > > > > > > > > > + Joerg, JasonG in case they have an opinion. > > > > > > > > My point is that the patch provides a way to override LAM vs. PASID > > > > mutual exclusion, but only if PASID allocated first. If we enabled > > > > LAM before PASID is allcoated there's no way to forcefully allocate > > > > PASID, bypassing LAM check. I think there should be one, no? > > > > > > Yes, we should have one for force enabling SVM too if the application > > > asks for forgiveness. > > > > What is the right API here? > > > It seems very difficult to implement a UAPI for the applications to > override at a runtime. Currently, SVM bind is under the control of > individual drivers. It could be at the time of open or some ioctl. > > Perhaps, this can be a platform policy via some commandline option. e.g. > intel_iommu=sva_lam_coexist. I think it has to be per-process, not a system-wide handle. Maybe a separate arch_prctl() to allow to enable LAM/SVM coexisting? It would cover both sides of the API, relaxing check for both. -- Kiryl Shutsemau / Kirill A. Shutemov