From patchwork Thu Dec 21 15:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Agrawal X-Patchwork-Id: 13502317 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 447D8C35274 for ; Thu, 21 Dec 2023 15:41:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4B518D0006; Thu, 21 Dec 2023 10:41:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFB828D0002; Thu, 21 Dec 2023 10:41:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C34E8D0006; Thu, 21 Dec 2023 10:41:17 -0500 (EST) 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 8C4628D0002 for ; Thu, 21 Dec 2023 10:41:17 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5546C160CF6 for ; Thu, 21 Dec 2023 15:41:17 +0000 (UTC) X-FDA: 81591239394.23.9F15DDB Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by imf04.hostedemail.com (Postfix) with ESMTP id 435E840005 for ; Thu, 21 Dec 2023 15:41:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=dvBnDAZD; spf=pass (imf04.hostedemail.com: domain of ankita@nvidia.com designates 40.107.93.85 as permitted sender) smtp.mailfrom=ankita@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703173274; 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=A2y4ICxI7rCvs7zkEJV8fbXDdlk8MaBO0x9/XhapvEk=; b=67bupLnKR8IHKN9sdeGPQyLtL+ed7pkwpw1HZuYCwCSrsF9+/ZrwX+qpYNiriIJ0mzODIC M70OprEhcL6YswhTItUgIlx5wSqS4UN0hLindWa9GunJQB+Kx94RorVV+EvpujqzCJ58xN lWXlkIUASNUyAL//SbisetA2NR7lC4M= ARC-Authentication-Results: i=2; imf04.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=dvBnDAZD; spf=pass (imf04.hostedemail.com: domain of ankita@nvidia.com designates 40.107.93.85 as permitted sender) smtp.mailfrom=ankita@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1703173274; a=rsa-sha256; cv=pass; b=MAaRvl5nXNqN8cELjFu2sX04DgosnTprCP2aa42jgh/UFWvUF3LUkclgWtdW80sd7+wwxg XZZ8k98orMCGg1+ZraqTSruTaaT4n9YgMV9FkH7fsxHe6a2nmG/W2JRWJiUo6VXbfme2nz yAtDcFuo7xXcS4G/rjdeTPt4bWLnWMk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gxvgwQ150iyoxc4y2M/YPtdlzQ0aqb7AuBHjRpETDejzrUmWu6mchnvVdRDoGFyNK+2c0iXokgkAVLPTTTazCfluTfBXcJ1basceiFkOtQGQ/3PcJLueMw5CrWRDFJerLi5SLBoRCDGpws5JjhP0Z1WAhQPXa0CAkvmHruztp1jahnJcvQPMEFJ7xSRvnUYjqA+KZZo6UoIPYnyYeJUaOUJWFN20y4fpj8SIIuZnE6jSUUun+tZphGVtZGl6Rjz93pk/2D3CZP6vQyKmfkSzHFbt9fGqWFZlTpQ9xe1KHZ1/j8b+a+6xDE7a7y9D2+6f+VbyJJrl6M6AYzywg12KJQ== 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=A2y4ICxI7rCvs7zkEJV8fbXDdlk8MaBO0x9/XhapvEk=; b=nfpvjW9BXP02lfBEm5U1/pUs7TFNqcoHyBJCXUK3sofNFwl2Qu8RHdYzi+0tRPhRU8ZjsprwaxuxW1FXTVHtEy8qGN5rpyiXeoQKacm539tEQqxpoxEnKQLxLMGCElYLW1p1DnN6NeZi3zV/1xkQLfIdcDPGdGynRKGOIVAznssa+aF9JImcrYpQ/AUA9jZU1SH5Y/odF9fNUa8lKCLts6OfhY0zAjnxuQ7aDCpK10H+P6cm+YPHbM+fX5sAnxCd0TwjVTK3fhdlnWcTv8O0tBVKOQFBEvyzHsMxom7pG+Hof9QDkfg3Kn8p6Cvyr/E7tBwbYELYxGDzYd59wBMHUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=A2y4ICxI7rCvs7zkEJV8fbXDdlk8MaBO0x9/XhapvEk=; b=dvBnDAZDbfaOy0SFfizJ+CGtdD44oPuiax4Uk/B5hzSCKTG9uvYVUgxhEoKH3mW09w3aSpB890IAlrFc4aqPdYOXA4ezposkVslEmDKr2H8Uj2lq+da5086rQde6OL0/6aC3oxkAtLVEG8G1GZRTqUaZkeIW6y5MTfxGb6AYA0JntfgsTw5F+vLnhkEEvBoUzlNuNvFdK4s/d6XxngAEMibi9df7wM2zUwCAu1tJFRSOi+VVTaMvN+7Hk21DIsGhFT3e5uiDKSvb0WKFbJBChSgYUcwxp2jFohCNM+G6WZhjf0T/Lf7kDmTCWgFItBRXkKI0VIjiq1a5JMNkNFQQWw== Received: from DM6PR03CA0038.namprd03.prod.outlook.com (2603:10b6:5:100::15) by PH8PR12MB7255.namprd12.prod.outlook.com (2603:10b6:510:224::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20; Thu, 21 Dec 2023 15:41:09 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:5:100:cafe::db) by DM6PR03CA0038.outlook.office365.com (2603:10b6:5:100::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.20 via Frontend Transport; Thu, 21 Dec 2023 15:41:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.14 via Frontend Transport; Thu, 21 Dec 2023 15:41:08 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 21 Dec 2023 07:40:51 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 21 Dec 2023 07:40:50 -0800 Received: from sgarnayak-dt.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Thu, 21 Dec 2023 07:40:42 -0800 From: To: , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v5 4/4] vfio: convey kvm that the vfio-pci device is wc safe Date: Thu, 21 Dec 2023 21:10:02 +0530 Message-ID: <20231221154002.32622-5-ankita@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231221154002.32622-1-ankita@nvidia.com> References: <20231221154002.32622-1-ankita@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|PH8PR12MB7255:EE_ X-MS-Office365-Filtering-Correlation-Id: 453895de-1891-4115-a72c-08dc023b4084 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CTZgWefPMY73vO3gv05CbkVLWHZuPIY1w1h7cJVnF/57L5xnoBQzSpLoXn55tg/bdkoUBa6/jpMsqw8AcadCUJTHWx/jmEBl9bk7TVQhZy0NatJFwK6Xc26KTGh16OEWqJIYcvcgsOJPVBGq7ajnoi9XIGpofwD0tzwQ9BIgKk8KdO2/1+DoCPbAGzzeiXxlLdAdp22lpBGdIMhfP+VJW+z6otHxJ03ZQBavq1l/s+8bbktqbD+WtmW/RGDrCIjP6Nepz2hshFoUF1IjfF7xNo/Z0szSlfqbv/6jtewUwQo3i8IApmzgDtX6djCAQGfAJejhwQqFO3/BXOi2sImjjb0bTlUxviSqqyVh8L0TlqY9NDV5cBUrL74agkK1vvwwGypBELLns5gqbKkJXG7tc2pr9UEdCSiVU9oKZ2HEFV9XFi5c4UWoBXImTEpgSRT8f25/CK+FQYv9GMyHTem/SdtI3HOoXzfLHt5WVh0LVOX0ERYDj4+b8UyRBwQxKYaSPDxkmNUlwvzWDOSzU7a9+4buoarm2VboK9wK89oD4FbVdptEWytJDC4IMReLiQqvRo4fYNDGhqszRSOX1gxsHSJg80ZI1HiKW62uvv9q+81MTB85tXhmLf74g/ypzSU/42ZrjiFcqeeKeNBWpntEh7Oh7+Okb0S3bTMXxxqYxVUYuGrx1DYhs+mTAsV49biY4hilc15aRngmGE6wOuC4O2WoCbGHzQgF6tdcAvv49KlrbDOhJsYnkepWTUU7dL1yOB6VdlHMCD/nr0NoCZ/E2E67+cVsHNo1SwbzUOH7LvLZ3E+36OJDtgz+i2hQzZHQ X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(396003)(346002)(136003)(39860400002)(230922051799003)(186009)(64100799003)(451199024)(82310400011)(1800799012)(40470700004)(46966006)(36840700001)(921008)(86362001)(40480700001)(82740400003)(356005)(7636003)(40460700003)(36756003)(36860700001)(47076005)(83380400001)(1076003)(2616005)(26005)(336012)(426003)(7696005)(8676002)(110136005)(54906003)(478600001)(316002)(6666004)(70586007)(70206006)(8936002)(2906002)(2876002)(7416002)(5660300002)(4326008)(41300700001)(83996005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 15:41:08.7591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 453895de-1891-4115-a72c-08dc023b4084 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7255 X-Rspamd-Queue-Id: 435E840005 X-Rspam-User: X-Stat-Signature: rchwqxxhgzt46tbdzstqfo17tfbi3hnp X-Rspamd-Server: rspam01 X-HE-Tag: 1703173274-70361 X-HE-Meta: U2FsdGVkX19+piJIdtTjl3Ysygx6HLQZq1c8wbKP8/0lTI0I5gDhXZzHnTnFvS0KRV33te/vR3S3THXU7Iau+zmkT1ZOxwboLuy2pKI/u20KqdyLiabCK6VE29qy2Z+bCkjH1+8RniF+kPzzzVFjKi88F2xDLmW3hyCsSlOHN3T47Ib/j/WFiVsRp6KF3QwwSIDA+k8U2Uuvc2iXt6edJKJQRnDEMZNFeZVMcJVrBrPtjllC9r+9WFxpeYPthlVbE4lbZttbeC7DbBGNE/HBE3T+T3k0tsSNTooOEmoOlE5SnQBSJxvj9K2M39LPKn6Jptxs2mJLK/KehwauHFQtRusVGf4MTIfetpHL2v69g4ONRwWwAGHXu93gM2f3dPn2vAPaIG/niJL5myUoOsrKEafiU1v7tRn1NzG/3+lHD8G19SLF/uBTLuIXW3lhORGH6afyqY/dSAT9mC01kb9Y8NGXh4Od4van6yd7exvJkpwXpti0kNm/RMxpaw3lECiAU5kNfqrfxraeR4H54+Hp/wNULr2ZTc7E0vfUDWTCOnJyYXux8I2zDIqRxBD46C/Z/20qljJ3aigXJYZbJfPFdy1qd5aRDOYkQ5k1D+x8JB5z2WGg8x06yIwrQJwBMkkJPEyUSsuIIPSEn8/kE/NVKVFc3sqVl3ZbadGtXZ3jGMBH2Lo6TZPH6646PHR8mOHILEB/98/+S7lDhCYQmNVBQtObgF4YnZzV1VyYEfA8o22HLYLVnyvyc4htInPycHJSQOKxDhH0RXPXFHndEGAOLc2/wlRIWaUAf++UCzt1hStWbQ3ntt3JD4IR0JbxAM9pUfse/sLk3c5ephKtAWArLtOLkz4sc/0YpnOggbSp6ES06tW1jdFUjdVbHMTlTfwsX7z4evJwG4+EK/xVcfvxNEn2pKukH01UtA1cDiiC0cNtlGfyWErft/6PgpugqPxebgVzFAVNew0Tr5CWt+C 1rEgNf3A bwJR5UTduD+qhU3I7z1ZVACQ2XpMEwtp5H404a8N3uMBfP6hzJKBwi1Yw6y0UoCaDrWhcUqyCE2gJj75RqCEj/lDHjXvyNkjkJVyugKPAjk5I2dYUpz1xgcsKINPsc+f6Q1O0WtPhLVlHmjRAO1U06FrIGOecCMeOhLOsDNTbH7y+hVJIHYOFtzGxQGH9i+AojEtBDzuqmFLZ686x+n0RxDkGcFigOv4fVDhrn/x8catF22PyuZF5FUGuEJ8FCK6Jb+agrKvKEExj6qv2gg8WRIIMMw== 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: List-Subscribe: List-Unsubscribe: From: Ankit Agrawal The code to map the MMIO in S2 as NormalNC is enabled when conveyed that the device is WC safe using a new flag VM_VFIO_ALLOW_WC. Make vfio-pci set the VM_VFIO_ALLOW_WC flag. This could be extended to other devices in the future once that is deemed safe. Signed-off-by: Ankit Agrawal Suggested-by: Catalin Marinas Acked-by: Jason Gunthorpe Tested-by: Ankit Agrawal --- drivers/vfio/pci/vfio_pci_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 1929103ee59a..c5ebca74b8a8 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1863,7 +1863,8 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma * See remap_pfn_range(), called from vfio_pci_fault() but we can't * change vm_flags within the fault handler. Set them now. */ - vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); + vm_flags_set(vma, VM_VFIO_ALLOW_WC | VM_IO | VM_PFNMAP | + VM_DONTEXPAND | VM_DONTDUMP); vma->vm_ops = &vfio_pci_mmap_ops; return 0;