Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5940253rwn; Mon, 12 Sep 2022 17:36:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR6sXR4CJuex8aiuDFleWDUM5n5Y7Kjobopv0eFZtYIbb9evQy/s3f7jrHyrqKPwVRASQrV8 X-Received: by 2002:a17:907:2cce:b0:77a:6958:5aaa with SMTP id hg14-20020a1709072cce00b0077a69585aaamr10985789ejc.245.1663029374990; Mon, 12 Sep 2022 17:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663029374; cv=none; d=google.com; s=arc-20160816; b=WFDeW0ryEPXLtwWcnBpcfYbBchsm58DI8QpFknPVHXcXkLccSJ68/9z1Vf2tG4rmQk Mg2rsJQDYIO2xwDiUAme44BUYXZUMfRYY1z8qi3CH/NKKW1UjTo2etM6wKAt3explxuo BoZoC4Eptmu99zVebaiOuxb2fYHdsWzHZ2cqfrLFzQo5MOz54x6/Uwv4r2VlJJNs8t60 NMmyVS+AYGJaGNrr7OMQCMMvO3pEfJOp62SAJeWG6LS/4O/jllQgmSU/zQCMW+Zlc+jO pF2RS4j12QvxcCjos7AMoqu3RR7+7a+nopIKRMfY/CZ1LAiE1NbddTTvhU8MFSQYggnX SdHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CGM0WzDVPLNZThgo6X5VlMaExZ/YYlkEqs9adfx+PiI=; b=DHNAZzg20hIcTKGmBMBvapUbddunraffXSSrtzwy/QVCct2Che7dmIVTSyZZTxMiIs sWpvZMJuShgPdxdZEGRQAJ3i0wfX72TKQ42RcNVc1mylcH/Xlul35Y9MnEsPravzaw8c BbTfWqosjpmiGk06i57jNzzHbOF8oijLY1OmBRAk5qv+WTgKWSb/4ALQTEsX9LKKGXNR Zq7QSriufBO5RGfQfpqfsh9RJQgcbjrHZWiRy8JN6ToQZZwMseCIUYXVOOefet3c2Ncs 1m5z3tdM9pryXAIYbi2C1Uma+AGoI1cWJaupFPugHt7oGSwF72xsPJ9HanOBirfcsJKW OdBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Md/CJqNr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020aa7c6c5000000b0045107d5e6f6si6898097eds.162.2022.09.12.17.35.49; Mon, 12 Sep 2022 17:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Md/CJqNr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbiIMASr (ORCPT + 99 others); Mon, 12 Sep 2022 20:18:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiIMASp (ORCPT ); Mon, 12 Sep 2022 20:18:45 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E774D152 for ; Mon, 12 Sep 2022 17:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663028324; x=1694564324; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vyxNfHiu1yBIsD+JdVqtDsM5kvNufgvLVlVtxdTjKnM=; b=Md/CJqNrZZU440j4Cv9Kda68ZErpte7+rs8ov0gk+jRkISX4KBfil+sF 2aeuePpwGmboeQffvgigXzRt0QavJti8in+v/WubMyPtWDl3J2YvQQDTX wkBsaOK/lj6yToXv9e0e9WAkWJClxnd6LNNoG1kZNYJ86L23JsOqVjlbu PlFqkcinynoc6jiQFt9tdJPqERCJ6Dv/IU6jV1Xn5JOMio0fHUz3FgTuV 07VIk8KWd65yKH5c/WMszQx4CTMolZBDAdE+tDfqf4kBfcfNVqMvFJk64 SVFZ1e0NufVT82SUn70xWddtGmDeLUAeopZGHYuMGOfVUCRmMQt35cpL9 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="277734690" X-IronPort-AV: E=Sophos;i="5.93,311,1654585200"; d="scan'208";a="277734690" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.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> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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