Received: by 2002:a05:6500:4c4:b0:1ed:114f:4c4b with SMTP id y4csp18042lqc; Thu, 29 Feb 2024 08:34:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcXFec4Y5Aknu5ubjuqK/knDRa5AOFZ6XpqYRbx7W6dl8wVvXBXQgkEGqPYjvZHFqoDsr3f7+WIxNisxY5vxa0juoz4Zm7dkRlSsmyuQ== X-Google-Smtp-Source: AGHT+IFpFa6jU7O3kxyRAhnv5UphxrtB3VhCdj/oxqrfGQVK0zdXauTclyc+8fFRRJcGKbF/MXFO X-Received: by 2002:a05:6102:c49:b0:470:a136:5c00 with SMTP id y9-20020a0561020c4900b00470a1365c00mr3163267vss.17.1709224467141; Thu, 29 Feb 2024 08:34:27 -0800 (PST) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m20-20020a67bb14000000b00472716f793csi270493vsn.476.2024.02.29.08.34.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 08:34:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@Nvidia.com header.s=selector2 header.b="oOT/Llwk"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-87092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=REJECT dis=QUARANTINE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C4B061C235A1 for ; Thu, 29 Feb 2024 16:34:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 951637A122; Thu, 29 Feb 2024 16:31:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="oOT/Llwk" Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A92846CBF4; Thu, 29 Feb 2024 16:31:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.76 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709224274; cv=fail; b=BZ31Hqa49WcJS4aGt+n3qOgmHaxMvRrTnMCJlP/wnRkquIv48xoGzoMSAeTRMiOVwweUSBkzqfZddVRZM3pzSHiqCkFtJhxqfwmV5nFGg00ZErP/odZ2ru0+tSI/1TymCBmIaMSN5aC5eZUbSntzOG9nz/5QHQRRE+Ke6J6zLQU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709224274; c=relaxed/simple; bh=Ff2sNFQW+idcYqc0Cf7TGscr2eX0Y5u1hP5Oh+UpWp8=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=akBsucMgsD8VXjh9PZy3EZMV3oMH9in5o3DAn2DvQ589/m6xpUnyWHMEqVbct534Wg8BQxzHKXaTWHI6269J7q3uN2iszFMPlFr5MWjPs/U6sNk7K+wUL9fYBvopdrpO2okqFtPgMLyQLDr8aqyQnH1xB1EMUwmxNLxoQ3Ltd58= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=oOT/Llwk; arc=fail smtp.client-ip=40.107.220.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kzTF65pxz93ep7e7HYsndxQU4cnbStjGwrnSN9VV9aK9ejnNca9I/oh3bZ1LvS+W+Nmx7jL3NDCG7/UTyg63udCfQi0asReVd4jC8L0D+DfperBnlg06151Y32wTEVFKpLSj+OyGyfRUIHg0w7PSZbsVSFaTv5Z72Ce9L3rXvxXRmBhACp42lnlbuQ1wh+VT7Dv+a626NTZLxAYlO5opg+5O4zFFy6Xu+2b+gWdIgAdEQ0dmXfXWm0PO3yDvt6C+WG5d4e/5vzX0TpyKQcaQ8mpF78gBnOMHvibyd68qMtAd+AcLoYErv+FuaHw4aL36Wi2fmoEj+ZdN27sTN1huMw== 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=Ff2sNFQW+idcYqc0Cf7TGscr2eX0Y5u1hP5Oh+UpWp8=; b=D/k04H6Zcg3Ohn5ygbJStrNwzwEwHpG7EtZvKFEPwa0OcoLbop84R8swDh4Z6f9w2nJPn0ABlc7WBQ263I5Ph4nE9dG+7JzGAiSVoZO4lPHL2kuBAym5MFddcl6FAg4gj+0ORvbqUp5r7LjQ2sD7vIy9jpjBpMmGdcJV7tCU//wyvklmlPpVXpJM7dq/wpQ5yp3eAsU26AOIDXAiy66qFg73NAz7+/t9T7vSgCoBHjmgzCRwZQzzBGQmjzJC0CGhYoHEZZ+ywBEt69VBfmhW9m7vjrlVyAf7FsJxBOC4CvOL7HnngHatUOIexehuXRpffaZRou7rDxfq8KvH5wnFeQ== 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=Ff2sNFQW+idcYqc0Cf7TGscr2eX0Y5u1hP5Oh+UpWp8=; b=oOT/Llwk2Sts9kRPBvxQhcCITqELidm0cu8CLWmByeSFYkawof4oak8tclJq74merrdO5ZgwCPC+uq+xHakWtYVZFYu/97n1Qiln8iNMIJucK0Uw7jnOOdcEa3KjBAITBXTglci8t3ANdowEiGlBYkBMZc7EkuzrJCVD2qT7x6Y+cwdsL7VKCjjy5BJEeihqcu3/Wxozq0WtfHr1fuhGJicqr5XVr/BMcAR3/xHK5PrJr38P0kthjZWFI4KxcEuEivq+CFEMqFJTNRxcLfftW/dm6IjoJ88Nrm7DZK+gNdsvlVYGwa6bvJQFPpCUzRk6FGG1/3BzuxMrB3xZwW5LEw== Received: from SA1PR12MB7199.namprd12.prod.outlook.com (2603:10b6:806:2bc::21) by PH7PR12MB6465.namprd12.prod.outlook.com (2603:10b6:510:1f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Thu, 29 Feb 2024 16:31:09 +0000 Received: from SA1PR12MB7199.namprd12.prod.outlook.com ([fe80::284c:211f:16dc:f7b2]) by SA1PR12MB7199.namprd12.prod.outlook.com ([fe80::284c:211f:16dc:f7b2%5]) with mapi id 15.20.7316.032; Thu, 29 Feb 2024 16:31:09 +0000 From: Ankit Agrawal To: Alex Williamson CC: Jason Gunthorpe , Yishai Hadas , "shameerali.kolothum.thodi@huawei.com" , "kevin.tian@intel.com" , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , Rahul Rameshbabu , Zhi Wang , "Anuj Aggarwal (SW-GPU)" , Matt Ochs , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v1 1/1] vfio/nvgrace-gpu: Convey kvm that the device is wc safe Thread-Topic: [PATCH v1 1/1] vfio/nvgrace-gpu: Convey kvm that the device is wc safe Thread-Index: AQHaan8STeXbyerayU2Kw+zSatmIBbEhesSAgAAC+YCAAAYi6Q== Date: Thu, 29 Feb 2024 16:31:09 +0000 Message-ID: References: <20240228194801.2299-1-ankita@nvidia.com> <20240229085639.484b920c.alex.williamson@redhat.com> <20240229090717.67b9c2ca.alex.williamson@redhat.com> In-Reply-To: <20240229090717.67b9c2ca.alex.williamson@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR12MB7199:EE_|PH7PR12MB6465:EE_ x-ms-office365-filtering-correlation-id: e1388342-dd08-4dc6-5c40-08dc3943d5f9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Cx0FFJ3LgH4IwPLC+ozsSIfjcv+rI4hKZnMC3UUic5BHNK5oTJdP4/RmnA62udFBgB5QMDShGuKoHjqp1nO4DbNx6ubCSAJ6NK5lnIGHEBDkRCaBu88s/3g24BlsJjI05Xgnqw5JZxEDFuLxi9xVJrDw0n7p82uQ9a5YcDHxP/wRBGgWjNlauInTbz2OXmxPxc44p4Enfx17O48q5sRPs0w8rwh/UMsijFKCnD0afgW7hyiSEujXMRl8jjGBDZpCAuPA6+fPAsu0O9ypmD/vqlIkE7jMUVdKVVt+ju+mXepECXDIm8Mvmyb3fwzS3N15SuMECYHI8Wy+oyxqjLQlifNr2Sj+GMOju5QHKun3ouPrDVKnGVEgAwbKSibzZdgH9FuHEuWtVomcbIftUZqO/S2oO/4aCRBsm43C7DGBUGF800U6CGg9DcKdwoK57ND1omBhuLOOZJXggIdJwjOLoDPZHjNQwr28Q44IqF4KsLoXUyDitw5F0kD9gLmsxgA29QzCk4lJXHwpXKErhlyIJ2RH07Yc+fbgyVNNtlP/r/FBuojsybbdHSD6EZeA1dEvWC1C+kmG17hLxpi//KYZM7E6AQq4j4wxOOCAplrj4rJZ4HmmDntb8NP2n2Mj/7BMm5b3tyKgElnmOwRhqgBVsi5m9hCj4Qhm22BG5VNvOaKReueIgYpylqOljkGcsRaI3i2WSDKziMJXiH7rUbqyDQSyFEbbyrqyN5JbQD9fn74= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR12MB7199.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ukYf7fQIn5fbQ9WDJds07NrAByw6q9sSIGvhchw5EP0WqOTIzkrR3qkGGA?= =?iso-8859-1?Q?Ve7GWYhlNmXt3AYy6dxVBgsIruQ1OmH/+E9aMx9dkCV1CP6rgMQEJLq8Lp?= =?iso-8859-1?Q?coyZDMX/sDKi9pudxnjuHp4zTMqFHtErVPxW7oa+sCYAqYWTvKQt2BIl/I?= =?iso-8859-1?Q?bN+LzNbRo4THfgei7lZB68yNMAye5G3XV3bw2zTavyn7krLVetShT5Bb7f?= =?iso-8859-1?Q?lrsbUZ1wFvDFcPFWuqoM+hfcSUVDfiNn6aJTKdpEWmOaafIo7ULj2uDmZ9?= =?iso-8859-1?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1Lpkm7oMM6HUUIdpPk?= =?iso-8859-1?Q?Grln9t6ACW+d6hP1io0yhWXSvX08We3UbI7JfhW5seUC5ZJj/5BV49RmvX?= =?iso-8859-1?Q?Iw5dn4sNEwhImEfax++wAkHOmkRVlBAk1dSzRiA2bcLFhNzqHwcwInL9Mw?= =?iso-8859-1?Q?QWpcTy0IfSfSO5O/jTHmN3loMpIUVe6zakwzs0p8bbAXJekS0Vm7wiF18Y?= =?iso-8859-1?Q?rQIhaMWUj3NLq2zn4xkSHb5VPmE9wAQqnCatNMh0QiHDPvQW8S7mxUhgu/?= =?iso-8859-1?Q?cnpjKhzlsgsiUBLRpE6ydjEWd4YW/hXc7rXGmmy3qpvy8b5L2/mL7Wi5Ui?= =?iso-8859-1?Q?EcPx9z4QYZYKFMGNSx+dcKY1KcBJNg0M3Ef1eEvsyfSsbM4qm3RIPn5g0f?= =?iso-8859-1?Q?7QygrBVLy9rB2tcpHRpCBXZ5961l0f53S37yYyOc2fkpoUuisf3304VD+l?= =?iso-8859-1?Q?RPnBSq9IaMlTg=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR12MB7199.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1388342-dd08-4dc6-5c40-08dc3943d5f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Feb 2024 16:31:09.5168 (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: wxI60WQ5djiSttmEXA9uNQKapU1UFrlb+Jhfe5vLmHKqLIgDfC8qjN+HFRpv+zXr8q8hXnPSb2S1DKgMdwNOEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6465 >> > +=A0=A0 /*=0A= >> > +=A0=A0=A0 * The VM_ALLOW_ANY_UNCACHED VMA flag is implemented for ARM= 64,=0A= >> > +=A0=A0=A0 * allowing KVM stage 2 device mapping attributes to use Nor= mal-NC=0A= >> > +=A0=A0=A0 * rather than DEVICE_nGnRE, which allows guest mappings=0A= >> > +=A0=A0=A0 * supporting write-combining attributes (WC). This also=0A= >> > +=A0=A0=A0 * unlocks memory-like operations such as unaligned accesses= =0A= >> > +=A0=A0=A0 * This setting suits the fake BARs as they are expected to= =0A= >> > +=A0=A0=A0 * demonstrate such properties within the guest.=0A= >> > +=A0=A0=A0 *=0A= >> > +=A0=A0=A0 * ARM does not architecturally guarantee this is safe, and = indeed=0A= >> > +=A0=A0=A0 * some MMIO regions like the GICv2 VCPU interface can trigg= er=0A= >> > +=A0=A0=A0 * uncontained faults if Normal-NC is used. The nvgrace-gpu= =0A= >> > +=A0=A0=A0 * however is safe in that the platform guarantees that no= =0A= >> > +=A0=A0=A0 * action taken on the MMIO mapping can trigger an uncontain= ed=0A= >> > +=A0=A0=A0 * failure. Hence VM_ALLOW_ANY_UNCACHED is set in the VMA fl= ags.=0A= >> > +=A0=A0=A0 */=0A= >> > +=A0=A0 vm_flags_set(vma, VM_ALLOW_ANY_UNCACHED);=0A= >> > +=0A= >> >=A0=A0=A0=A0 return 0;=0A= >> >=A0 }=0A= >> >=0A= >>=0A= >> The commit log sort of covers it, but this comment doesn't seem to=0A= >> cover why we're setting an uncached attribute to the usemem region=0A= >> which we're specifically mapping as coherent... did we end up giving=0A= >> this flag a really poor name if it's being used here to allow unaligned= =0A= >> access?=A0 Thanks,=0A= >=0A= > Also, this is setting the vma flag *after* the call to=0A= > remap_pfn_range(), which seems quite sketchy.=A0 Thanks,=0A= =0A= I will move it to the block that Jason pointed.=0A= =0A= > Alex=0A=