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 D3A02C6FA83 for ; Mon, 12 Sep 2022 22:49:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAEDE6B0072; Mon, 12 Sep 2022 18:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5DF96B0073; Mon, 12 Sep 2022 18:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4D308D0001; Mon, 12 Sep 2022 18:49:40 -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 C699D6B0072 for ; Mon, 12 Sep 2022 18:49:40 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8EFB91C6620 for ; Mon, 12 Sep 2022 22:49:40 +0000 (UTC) X-FDA: 79904926920.19.4C3CF86 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf12.hostedemail.com (Postfix) with ESMTP id 1BF68400B1 for ; Mon, 12 Sep 2022 22:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663022979; x=1694558979; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=NsiOox7nfIPNPbqeXi04s08cExYxbUI6A8GPKqPLH8c=; b=Uf/SR0VCmoWZxvio96+oGGz9Ukdd7lOVch8uJBZXx+a5YwMp4PKBLSQY RoFWbroa8iEGKWBTO2RGrnA909IiR+gc/yxeLChdcEoswzl+kSzXpJGZE bn+KQDI02gQbn+V4AurzukrKUs8NmgXuNMrPIsMolfgl3dkGI6FVQXbbP fzk6RveJ4cpuVLMScy0LOPJ/NioI3E9rYlzww5md2W+qBowpkDn/SaTfI hSfdTs0z/FB8deXorEEWlsXnZiON62tkAOB+4OlHDK2bxVFAd0uoIX61/ jIpk7COyAQMHyER11ZO4wF6jqcgmkoTuacZdvnfQc1jKN7Ta5Lt8+JMd+ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="324227931" X-IronPort-AV: E=Sophos;i="5.93,310,1654585200"; d="scan'208";a="324227931" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 15:49:37 -0700 X-IronPort-AV: E=Sophos;i="5.93,310,1654585200"; d="scan'208";a="616234521" Received: from aburgsta-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.208.142]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 15:49:33 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id E30D610455B; Tue, 13 Sep 2022 01:49:30 +0300 (+03) Date: Tue, 13 Sep 2022 01:49:30 +0300 From: "Kirill A. Shutemov" To: "Kirill A. Shutemov" Cc: 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, Jacon Jun Pan , Ashok Raj Subject: Re: [PATCHv8 00/11] Linear Address Masking enabling Message-ID: <20220912224930.ukakmmwumchyacqc@box.shutemov.name> References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> <20220904003952.fheisiloilxh3mpo@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220904003952.fheisiloilxh3mpo@box.shutemov.name> ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="Uf/SR0VC"; spf=none (imf12.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.88) 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=1663022979; a=rsa-sha256; cv=none; b=5a62LDTakjBaI0P8gG/cOMU/0blTKyXW4qIj4BYPjDFxYp+FStkgwQBfo+WP8j6oVuzEqF VY4VMnsRZFr7dxXfM9a4unQEwx8rPHdgcegv+JXqCCkTQB+07AVmNc5IaiWNQr65nFIq9j ZEOhdlKrOTLTrMVQtr9l+lwyscjx5aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663022979; 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=luUW4YjvcPsbRiIt0gvhMY+kJNuwKI/zyJm3dNL/0Vc=; b=zDpsI21aIPfSZHGDo3LePMUeuFcjA3EIX2+BniAaW8N7bS29NJ0Ncb4c9hbagHXDrvyRvy Ynv8TfzTOgl7D7VlRUewtiC2MWrKN8UMVOvx8vkmFRb4nX83GpZzhi+8RhfO3tM9YUn4er ccE3Z3Ct5akiimb6ZNashswYaVz8vRo= Authentication-Results: imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="Uf/SR0VC"; spf=none (imf12.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-Rspam-User: X-Rspamd-Queue-Id: 1BF68400B1 X-Rspamd-Server: rspam04 X-Stat-Signature: cmq6x45d5q71tuzpbx8a4es3eh4cjw6m X-HE-Tag: 1663022978-136510 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 Sun, Sep 04, 2022 at 03:39:52AM +0300, Kirill A. Shutemov wrote: > On Thu, Sep 01, 2022 at 05:45:08PM +0000, Ashok Raj wrote: > > Hi Kirill, > > > > On Tue, Aug 30, 2022 at 04:00:53AM +0300, Kirill A. Shutemov wrote: > > > Linear Address Masking[1] (LAM) modifies the checking that is applied to > > > 64-bit linear addresses, allowing software to use of the untranslated > > > address bits for metadata. > > > > We discussed this internally, but didn't bubble up here. > > > > Given that we are working on enabling Shared Virtual Addressing (SVA) > > within the IOMMU. This permits user to share VA directly with the device, > > and the device can participate even in fixing page-faults and such. > > > > IOMMU enforces canonical addressing, since we are hijacking the top order > > bits for meta-data, it will fail sanity check and we would return a failure > > back to device on any page-faults from device. > > > > It also complicates how device TLB and ATS work, and needs some major > > improvements to detect device capability to accept tagged pointers, adjust > > the devtlb to act accordingly. > > > > > > Both are orthogonal features, but there is an intersection of both > > that are fundamentally incompatible. > > > > Its even more important, since an application might be using SVA under the > > cover provided by some library that's used without their knowledge. > > > > The path would be: > > > > 1. Ensure both LAM and SVM are incompatible by design, without major > > changes. > > - If LAM is enabled already and later SVM enabling is requested by > > user, that should fail. and Vice versa. > > - Provide an API to user to ask for opt-out. Now they know they > > must sanitize the pointers before sending to device, or the > > working set is already isolated and needs no work. > > 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? -- Kiryl Shutsemau / Kirill A. Shutemov