Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1037636rdb; Fri, 20 Oct 2023 06:56:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlv6dx7Tt4WuB7+dmuRT5Kg91Jzr+0T3F9MNsCfQPjxINjH//clmkHslYiEKPsSkwUenv9 X-Received: by 2002:a05:6358:5284:b0:143:3845:e6fb with SMTP id g4-20020a056358528400b001433845e6fbmr2058151rwa.27.1697810173807; Fri, 20 Oct 2023 06:56:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697810173; cv=pass; d=google.com; s=arc-20160816; b=NCm3PV4DFgC9eoZDS/oNaHfFU9F6kaO/slskFzmSl9MdnsZLTF1l5lij8+xezCpoN9 tC5/kcDJKr9quVeoqBtJ5JowPmQH6aX8J2T6qms0khl/6CGC9iyOsm1V7P40+qlKPY65 TekPgFY7UnVCaA+d12InEsGusyv4i/p/oimJXsk+hNa8uK3WUTIO+f6v3BJO2w03Pev/ Xmrx1m4gcUXtBRUsak+VSBmuJf0iVGDhjrUjVGkaZS/S9oOfrIjKqXld4rmrwcnxHK3y WPhtjllQpFeqyM827LFFwHd2gYmvkn7pY4pBHJ35lMppQ56uJI0BZxq/iRpHnKYGzIvw pDbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=Y+G9ltDunlJEV+CdkMQrzqQZwqTINUmGvyd4w1hl5E4=; fh=2UN7IjYuijkJBvyh9pz7V8dcFsArKSxF7HU9xR+3p68=; b=wv20NQxDorydcJ8ruqGW6oHO9fJqwPx5Hs3gsbj0G7vEkswBc9Qcj5OYIPAJUC6yrP Yu+vHTIMUwTQ5uThTHqVLM0pL4RpkPZFsLItvuJzbbO94gpShQGaLLtHohuMtQ7Tkv3f IjEoKbILlOZSNJjd3eacr9wCH/uhYIOobUaz3FjA8ElhDMlRW2a7G0xexnrjLAjeedmL GKe62/NAK4DtNy/Dbo26jyBzIbxaP0gFJVIgc+b/XUBxDdB2sme1afjlsYWTCUfo4iDd OtJR+OmTI57uqH/hhvb3k/GwZ4qJhjXRY1JslQzBjRj1GTkmPE2O5zPCFG7SX7Tm9ziI FDKg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=aNsJ0Qf7; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d20-20020a056a00199400b0068ff659af62si2040736pfl.106.2023.10.20.06.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 06:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=aNsJ0Qf7; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BE32D80725A5; Fri, 20 Oct 2023 06:55:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377419AbjJTNzJ (ORCPT + 99 others); Fri, 20 Oct 2023 09:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377274AbjJTNzH (ORCPT ); Fri, 20 Oct 2023 09:55:07 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D2D293; Fri, 20 Oct 2023 06:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RvkZVyjO7JNd6Onf8/mIxM/rBolIPWC5NMa90Nbm/gqelM4Cz9YelEP84sniYbZrVOxNa1E0eL66C4PqzEMWssqOyZu+w0dF5qgj7zBK54tqzOWM4Il6dEKkNhCF6l0BhRrpvKwS1q8lbt1TKSS7oqPLDlQ6MjpUX81tkAsceVn1ab5oRDN9CueJfmBGNCkaIZJNFZFEev1RTU8Yf2WdsvSLaBQrFxVqzenDekkHzWygqNvdWaQCALj0FKgO8++4ggtHKK1hmBCRO18omrV/yJgqsYd3KqlssIMzHJBo4Jm5dGApl5afu4N98IyYhLvgus2Emt9W15sTlGJJkv5xmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y+G9ltDunlJEV+CdkMQrzqQZwqTINUmGvyd4w1hl5E4=; b=dgHjTfcvz2is5ap+0D4N3UNBl1eoAEG2iAbyeFBhabfK6VAqKiqobtGDVk0eK4gNe63+RtrwamPKRacojwMqWr6NU2pbPPQzhvDWsYWbIew1b1gidtLNW6pfj6TLVM3ON/teBOJel92My160G1fnQ43vFyONccMSZma8e3vbqIiZC6c8ic/9AanrPd6IrUWQWrRgD5OyfRqPdIHXCgtW5XGzAgIzqFazKVPk7ubYbWJ4CcE2wuZUVzwwjkb5RGrTIYNaRpi63TKmd8//DpxT8oeU22XMjEbe9Ieg+85DerW9tFrKo638iF5iudwOCDloTsk1534PGAsKXkTgNrYs2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y+G9ltDunlJEV+CdkMQrzqQZwqTINUmGvyd4w1hl5E4=; b=aNsJ0Qf7cxfQO21+IeowhhmZ49C9woxqZkj+AMjJVXdzXiEe+4T2qv9tCJ4cLq1J2qP8LsbNjpc9OMV+yfkXs0bOMOrnixt9mnMBweyVOBx9lWena5GJB7Yx1XjSkxEI4LwYXUh0xKzC8dBKV//ZALBeeTrXcqThmDY8edn0M0/N6RHMCo8v4S4Tsg+PbOcP9Cnnbnj1kedu7QW18JQgU8J8EWdGxSbfJI25Hdo5h9qi0GrVW70F/OOOuPjIbqrgBwCa4F1HcFBw/vmFmbczewRqI2xrb2ZDAOOP929jtIcq03vR5AD4DMppWuFAOtOqNjNG8VlT41joAYMfMWsLvg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by DM4PR12MB5071.namprd12.prod.outlook.com (2603:10b6:5:38a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Fri, 20 Oct 2023 13:55:03 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3f66:c2b6:59eb:78c2]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::3f66:c2b6:59eb:78c2%6]) with mapi id 15.20.6886.034; Fri, 20 Oct 2023 13:55:02 +0000 Date: Fri, 20 Oct 2023 10:55:01 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: Nicolin Chen , "Liu, Yi L" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "robin.murphy@arm.com" , "baolu.lu@linux.intel.com" , "cohuck@redhat.com" , "eric.auger@redhat.com" , "kvm@vger.kernel.org" , "mjrosato@linux.ibm.com" , "chao.p.peng@linux.intel.com" , "yi.y.sun@linux.intel.com" , "peterx@redhat.com" , "jasowang@redhat.com" , "shameerali.kolothum.thodi@huawei.com" , "lulu@redhat.com" , "suravee.suthikulpanit@amd.com" , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "Duan, Zhenzhong" , "Martins, Joao" Subject: Re: [PATCH v4 08/17] iommufd: Always setup MSI and anforce cc on kernel-managed domains Message-ID: <20231020135501.GG3952@nvidia.com> References: <20231016115736.GP3952@nvidia.com> <20231017155301.GH3952@nvidia.com> <20231018165113.GB3952@nvidia.com> <20231019235350.GY3952@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: BN9P223CA0021.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::26) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5071:EE_ X-MS-Office365-Filtering-Correlation-Id: 47d0c505-381e-4b87-21ae-08dbd1742869 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q3ZKUoNvIuYJ/Aup2Nb1eR+qNM6MdwdrYFSWT79IX0aiYuEKuIn+yjOc/T6t/xwsJtap4JVRazM7YR5FhndxHfQvSbu9yJsTRiCB/zfwW6BMkit2JTX9qVOYTycfHozrRcfynm4j/+8Poic2HESNgVwTQQuvZe6KdWMERRvNei1WqCY4bKtH53itO1ttXveD2AuYAohJFt+5RtUCCLGXiJnXUThDjmA4RLB1En1/ksc6/op6u6eZY+zRHZGv3ghlD9AUfIfW4Jpt/aLu9d2jh8me2yVDTs1osQ6VQaN3ES64YBr/Xy57uUm9f5vaV3iiUqeUkWrREXd2L7whdqagYx0dtO/IValRa+WdViaEUBd3JeFR8qEZt63jEtbw7ULOS07gGa5yQyX2oU4QQOd9UzJw7YSqxdHQY+whILHHsR/2TO5gB6ddvaIcjN+t24BBCyt5/RgFSy8QpAnd3QUPI4rZ4bBCybmnSUh6bomClzf2XPYT1J3cr1RBJrEgIX7iJrAyIFudu8MTjQ4147Sa5sQIa/40nz49lKYMWKrlhwzDV1nFGgU4kBTSdYV4Cnq2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(346002)(136003)(396003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(66946007)(66476007)(66556008)(54906003)(316002)(478600001)(6916009)(41300700001)(6486002)(5660300002)(8936002)(8676002)(4326008)(33656002)(86362001)(83380400001)(7416002)(36756003)(2906002)(6506007)(6512007)(38100700002)(2616005)(1076003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eVh1L2J0alBQbnRkZUxSSkRMTXgrMGI4VEpsYVhSNHhTMnJNd2VqN3Vta05F?= =?utf-8?B?dExYUDRPVjE1S29zSVZVd3FkMkxrQ0dNQlZ3S0RieWZGeVFRa0JYaXIySzZ1?= =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WHJZVFIvdFJ5Si9LK1hHY1pNd01WMkoyRHJ1RmJ0?= =?utf-8?B?bEhjZVFzM2JLeGIxbFllOHVnamVudlYzZ3FsS3hDS1JFNlVpVWNGcVpSaEs2?= =?utf-8?B?dTd6eFZ3MXkrcS8yN05aUTFwa1FOVWtucVRmZDhUZHNVVk5sKzZBUjRTVVFh?= =?utf-8?B?blphTVlNaGJNUHQzQTQ5azZsWEhBdWtERUN2RjNRQlJialdFSEFFT1JHVm9R?= =?utf-8?Q?lsQyRjNUh8op1UeKVedOg8vnT?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47d0c505-381e-4b87-21ae-08dbd1742869 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 13:55:02.8593 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dyrhWTiOI2K22Z7x9wX56U1ItKhwy0Q9x+XwnJ+oJje5DDGueh+D4hJ7qPmhG03q X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5071 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 06:55:26 -0700 (PDT) On Fri, Oct 20, 2023 at 02:43:58AM +0000, Tian, Kevin wrote: > What we want to prevent is attaching a non-CC device to a CC domain > or upgrade a non-CC domain to CC since in both case the non-CC > device will be broken due to incompatible page table format. [..] > Who cares about such consistency? sure the result is different due to order: > > 1) creating hwpt for dev1 (non-CC) then later attaching hwpt to > dev2 (CC) will succeed; > > 2) creating hwpt for dev2 (CC) then later attaching hwpt to > dev1 (non-CC) will fail then the user should create a new hwpt > for dev1; AH... So really what the Intel driver wants is not upgrade to CC but *downgrade* from CC. non-CC is the type that is universally applicable, so if we come across a non-CC capable device the proper/optimal thing is to degrade the HWPT and re-use it, not allocate a new HWPT. So the whole thing is upside down. As changing the IOPTEs in flight seems hard, and I don't want to see the Intel driver get slowed down to accomodate this, I think you are right to say this should be a creation time property only. I still think userspace should be able to select it so it can minimize the number of HWPTs required. > But the user shouldn't assume such explicit consistency since it's not > defined in our uAPI. All we defined is that the attaching may > fail due to incompatibility for whatever reason then the user can > always try creating a new hwpt for the to-be-attached device. From > this regard I don't see providing consistency of result is > necessary. ???? Anyhow, OK, lets add a comment summarizing your points and remove the cc upgrade at attach time (sorry Nicolin/Yi!) It is easy to add a HWPT flag for this later if someone wants to optimize it. Jason