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 58746C6FA83 for ; Tue, 13 Sep 2022 00:18:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74B96B0072; Mon, 12 Sep 2022 20:18:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B23EC6B0073; Mon, 12 Sep 2022 20:18:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C4528D0001; Mon, 12 Sep 2022 20:18:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8D27F6B0072 for ; Mon, 12 Sep 2022 20:18:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 52BE7C03AD for ; Tue, 13 Sep 2022 00:18:46 +0000 (UTC) X-FDA: 79905151452.22.00D1421 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf30.hostedemail.com (Postfix) with ESMTP id B274F800C0 for ; Tue, 13 Sep 2022 00:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663028325; x=1694564325; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vyxNfHiu1yBIsD+JdVqtDsM5kvNufgvLVlVtxdTjKnM=; b=gU4VpvwbmomiFdyMiqHq2dPqN9h1yk6k+jlMjQ+WJxhLCC/vOQxPgnAe BCdVLA+PlT1PfwaSKmCKW+GmOaUFpSBVO6AvDMLP9jCHlSWyzu4oa63ku /iheWuiZ9dkErObx3h0x5F1dOhSFtM6U2/ZaFiW/wB3ZLnfNlE7Qn8Il5 AxICWdeDvSwPcT2BVFE/OrC5BvCCoIHFkmYs+edEA2qT5YJLNvLRFYUnj ztKRJKSYa3aAgeF8ebiMs0pX+n/yEwBWuiI9T1VMfG2z2KjKnisNWZFVg K2wbUhIjcAmjbC/GGDAWAfYIDK8udWZhDztSauBcMwKBFUzlae6svjN6x w==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="361952789" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="361952789" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:18:44 -0700 X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="758584323" Received: from aburgsta-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.208.142]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 17:18:40 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id E298810455B; Tue, 13 Sep 2022 03:18:37 +0300 (+03) Date: Tue, 13 Sep 2022 03:18:37 +0300 From: "Kirill A. Shutemov" To: Jacob Pan Cc: "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, Ashok Raj Subject: Re: [PATCHv8 00/11] Linear Address Masking enabling Message-ID: <20220913001837.uvsxevxhcqrkzjed@box.shutemov.name> References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> <20220904003952.fheisiloilxh3mpo@box.shutemov.name> <20220912224930.ukakmmwumchyacqc@box.shutemov.name> <20220912170809.101fa976@jacob-builder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220912170809.101fa976@jacob-builder> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663028325; a=rsa-sha256; cv=none; b=HpqA7z4fKLEfmeLMYbldfR7+I4BTIofdiqdSudO+paT2AjNudduaI638WTmn5tMpeLdIwI Z5kglDP/FfqJ3pQ1v5UDSNttdk5p6YlyDZVKViBnJaoMLE6fI4rudwPLjEc/+JNULUjw0B 2pXZau8QdVtPDLZJpK6TsjCm03ZaNE0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=gU4Vpvwb; spf=none (imf30.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663028325; 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=CGM0WzDVPLNZThgo6X5VlMaExZ/YYlkEqs9adfx+PiI=; b=qBp80IX/W6tA7SgMHhMtVTwkQeO4gTz3uy+7tIrV3iEQf/PHkC/fz4dJnOJahIq6wnBN+9 G3BuWJ/mPOAnb1lwh875CBQ0a26sJOu2nMHr4C0aTyxAlzA5lURi7/AfjCL+bL0AsxwWlF q7w7dpB9hsQWgWjD2hnlJ6HCbOBpPAA= X-Rspamd-Queue-Id: B274F800C0 Authentication-Results: imf30.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=gU4Vpvwb; spf=none (imf30.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.100) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=fail reason="No valid SPF" header.from=intel.com (policy=none) X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: zydazden1fy7y438fakxyjcen6i88s47 X-HE-Tag: 1663028325-988841 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 Mon, Sep 12, 2022 at 05:08:09PM -0700, Jacob Pan wrote: > Hi Kirill, > > On Tue, 13 Sep 2022 01:49:30 +0300, "Kirill A. Shutemov" > wrote: > > > 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. > > > Is there a generic flag LAM can set on the mm? Hm. Not really. I thought we can use untagged_addr(mm, -1UL) != -1UL as such check, but -1UL is kernel address and untagged_addr() would not untag such address for LAM. I guess we can make add a helper for this. But tagged address implementation is rather different across different platforms and semantic can be hard to define. Like if the tagged addresses support per-thread or per-process. Or maybe it is global. Maybe just add arch hook there? arch_can_alloc_pasid(mm) or something. -- Kiryl Shutsemau / Kirill A. Shutemov