From patchwork Wed Feb 7 20:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Agrawal X-Patchwork-Id: 13549068 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 A94B3C4828D for ; Wed, 7 Feb 2024 20:48:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3793F6B0098; Wed, 7 Feb 2024 15:48:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 302FF6B0099; Wed, 7 Feb 2024 15:48:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 155376B009A; Wed, 7 Feb 2024 15:48:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F11B46B0098 for ; Wed, 7 Feb 2024 15:48:12 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 80011A0E2E for ; Wed, 7 Feb 2024 20:48:12 +0000 (UTC) X-FDA: 81766195224.21.BDBE50B Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) by imf16.hostedemail.com (Postfix) with ESMTP id A1EFE18000B for ; Wed, 7 Feb 2024 20:48:09 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FUi7Kqd3; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.hostedemail.com: domain of ankita@nvidia.com designates 40.107.223.46 as permitted sender) smtp.mailfrom=ankita@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707338889; 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=pqQFFkNqWF5Job5Q0SDOOd/FxuHJVp3sxKAEjZUkkRs=; b=3R0bA5Ea7d0/Arcd5LNddzkX0ENWtYnHNiR1NEXOciqcwCI7ss8yxypBTU3Q7hWNyPQVJX J3jbset35Bawtw4acTUl/MZOo4Yljf3hC82jp2wOCjH71V7hqmYqLz4jaDYpGjIdgUUSuC /HnRRXKFczqdUWef9jJtfyvtW1XjmpA= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=FUi7Kqd3; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.hostedemail.com: domain of ankita@nvidia.com designates 40.107.223.46 as permitted sender) smtp.mailfrom=ankita@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1707338889; a=rsa-sha256; cv=pass; b=V/J4phXgrAXQYQP1gu5M6hlz5L9ngIa+/K0ZivHLjiWz48OJD0eH/7Q1IbYLMnAUvE8J2g +5WBw2db2WMY0a013cIbqjR7b9WWlXfa5aPJN9O5311ovV43aEoGJP8zXwbLSgdGe6Vwd2 YfDakWJwqRGFE57OIrXbdEeZlLm62kQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJqc6ACS8wnsRqgC5y6rYRt7UEjGiyQrAXnaiS9NxS5Wmim5Y59gtZ6pTx1+Mx4KQyQFeXe8JndQu8fH/J7iZt+0j2mWFnlYC/bEGFw1vOdPjFQpnzmDVrrMP2vGKmgL9gK3ZqZ4W3xugwHTi/40FMmSMQ9mOHPcLs5Xq086KaF8Mg75OJT84LLcg2PEHbmYlIR+oB9MBj3VTs8w5HBvcLEdXFr3PnI82KUXeI/Ph6IerPaBRQIemS2/WAt1H5RG9q1nAhkpY+fuL3MYASeIji2T1yD3S0crfiJTgFnJxTtZCZA7H8kZdNqpQYD9zHWzhofwNiPrp9aUQzm06lqf8w== 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=pqQFFkNqWF5Job5Q0SDOOd/FxuHJVp3sxKAEjZUkkRs=; b=dqJk/C3eAgLgkRFoeUY14oh5i8SclT6bm/MHsTmwBKBikjkcQ9Y0DUWg+doTZpejLPWNzdVsN1I/V3h3bUHfaVo6CMQ2+Q2qEywTyRW/sPn5QxMOzQ65DyqSPtI1EdOhm2ZnvExsHboegMcCJOM9nyZeA5b04/Iw9+v10mrDtaGJFuUdWT3nF3B0/ZiRV47LAn0ONMEMujGsi6SIsmh/NNWQAKNuhg6hv+KCoiTQwK2Wxn+3rUckGZWCKsPyZcPlvXFXwutNnlLSQslLF5kDOXFsM3IpDE8kNa6rf6xiPv2SeQ6IVuNAD5A91LiKGlsJufpzTG0XJCEMT2kpkrV5cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=kvack.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=pqQFFkNqWF5Job5Q0SDOOd/FxuHJVp3sxKAEjZUkkRs=; b=FUi7Kqd3X0s6wbNmkt87MU9WR0XqoVx+G/joxdm24h0f/yZ/QlWRnj+ITIn2t2lEMsfqMEIcS3jr+WgPLKJtLvQV89czu0S3OXS44UVViJ1ifHwU3N4p1gzGt9at/C6qez8NODo3IoUsBeuTM8+dZ8Cvzc9PIdwPStnQ9igqYfgd+rAXoifD3dD9xMYwmRDIYBOB9nNzURNUceb4CyZpM9LLGguYJri21mTIf0wKMQT9ZDr4rk/s4TojFCBaGHQPMm44y0e+u+dhtxri6u1vH1OctXyag3S85vM0jKqgfUYW8RoWVUCmORdvyxQYOq83a49NguCU3zXOZ7eZCbWA5w== Received: from MN2PR22CA0012.namprd22.prod.outlook.com (2603:10b6:208:238::17) by DS0PR12MB7851.namprd12.prod.outlook.com (2603:10b6:8:14a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.17; Wed, 7 Feb 2024 20:48:07 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:238:cafe::5) by MN2PR22CA0012.outlook.office365.com (2603:10b6:208:238::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.38 via Frontend Transport; Wed, 7 Feb 2024 20:48:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.19 via Frontend Transport; Wed, 7 Feb 2024 20:48:06 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 7 Feb 2024 12:47:49 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 7 Feb 2024 12:47:49 -0800 Received: from sgarnayak-dt.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12 via Frontend Transport; Wed, 7 Feb 2024 12:47:38 -0800 From: To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , Subject: [PATCH v6 4/4] vfio: convey kvm that the vfio-pci device is wc safe Date: Thu, 8 Feb 2024 02:16:52 +0530 Message-ID: <20240207204652.22954-5-ankita@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240207204652.22954-1-ankita@nvidia.com> References: <20240207204652.22954-1-ankita@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|DS0PR12MB7851:EE_ X-MS-Office365-Filtering-Correlation-Id: fa88e2fd-4575-45db-e55f-08dc281e164c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uWhH2LZU962uRd42//LULo0F2zaUHFQQKkIJEUwvJJYl+T6ihNDJQF3OYwBc79OqY1i8DCEF353H3rDxXZ5akqjXcsvEO6CQan9FCv1POe0HuVISBQdTLHVKE9IhHivz/ROigMfDXp/P2V1Wah5XWChvrJB5e1M1hugIGXQlBOgBErK7u8GmRCJvKvsGop797ewyAivaZBlNmQJ9wTyzoq+lCokl/q37jY4sW/gPDpE0TMpapYdoWsE3Morwt4mTGF97EgQqUa38pP1dADtctACyek6Ea5IvPpBvpOQbVDg7NWTnAovsoAVu9FVhuot7zsx+hnN7B/6dAJqM+00IQ/lR2fuL68wBiv6RrSHjOrDiinXBpduFevCPADygQtYqCt/Boj86dlNXhkyCwVLbZStaZuymFR69emiTNa3XT9+cdV+om2XS5Nv327galAhRfZGRwY1thVzn9fLWWExpkQCXKQvdTKfk6gDlmWMFUzfvzE/3joQp8bohiVah18p2jqqtwQ5XffCXNj0tLk8NXcX2eQxVUqv4ST/ZAPrSYS2n18vZLtdGaEKbGoI7wYQmaWYTyS8j6dBqXTIPp4tep8kYjiVs/2uF+tuDHrt4rtAkEuk1+Qj8yHh9vsVLbHFOuI7Uv6ddITpRMq42cOynFQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(39860400002)(396003)(346002)(230922051799003)(82310400011)(186009)(1800799012)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(6666004)(426003)(7636003)(2616005)(921011)(336012)(478600001)(26005)(1076003)(5660300002)(82740400003)(7416002)(356005)(8936002)(8676002)(4326008)(41300700001)(2906002)(86362001)(36756003)(83380400001)(2876002)(70586007)(110136005)(7696005)(316002)(70206006)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2024 20:48:06.6160 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa88e2fd-4575-45db-e55f-08dc281e164c 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.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7851 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A1EFE18000B X-Stat-Signature: t14umhfw3rbe8eysmpomzb9d9ojayq7r X-HE-Tag: 1707338889-873223 X-HE-Meta: U2FsdGVkX19P2xyn4rXYxRbSN605jyOONW4EweLc82CzIF1LL3bkRAbU6D3dND4X5gXlG81Qsv/e5inp5QmPEAoXPBNs9ZWk7AyIcK6E1hoxwQozdf4YkIMEX8c1PzBOCUoi2Hp23fkja7ReiQbh80Gia+3Kl3qZaXq+s/OQQStguvaaF5W/SPRhk22ykjyHMtSAFtS4PZEy8Xq6UfvYoaDOSSaat628XowruMS9nm2cT1xmaax+MC5Y7Mu5piDWGXHQRpK/57rd4PoAXLNp8oAr8Q30EcfORa5MzCj/5wXUv+oA5fj53w+L33VktUUzrh7fp/vvqNHsHDEDBNwUqk2pFkC0/tG2JpiNihRxOIhe3DQtdegyLHEiKxsZruCWCQ5u788ykZlHrF+ufLTV6w7KTQSXepJalYIEvcwVdZu99lF3SdYVkhQ8n732SegSqSnCe9S3RFMiImmn4+THMlXi49AOyPFsm/dyHA/8IS91QNBQiUyH5NU7NpiOVBxmpwGobZ9txsXY1+xRwLCsV2jy9hMeHt4xawyDtLz49WWtTcqvz1X5+dVuu7b4B3sN3Y13n3lDsXaWy4Kdwa4pI3beRW4hqj1W9YrJ5Z6vqdfJguFLe4T+A5FiSLZqizcoldGMpTEPTuoKQj+CIxwBpzrXQAvXboxyvpEutF6qGSBjJF6Z6Lh5+BuofAxYfveWqslON+Szapn1CsIrPjQrcBm+85GCLKQ2csr5pzbZmsuMo66p/bdC3usCABNHksAxUOQZkSuqFyR2Xpnk3UgEPlkgBalEmz5p2Igg6XBczYncwinHznFPYFcfVAVY8BVckxLYjLpIR67bLcHJBHzq+2qvrI5srmmTt92YEIjLDXCQuUEC7Vh5UulP7TaSXYo/Nsq9AYu2aQ26tD80pyVu7OgnNIpRwM9RwzL7zooG8gS/9WFJoLipHeYpXC6gmix8rdYH+ESg43MKA0HRby5 imDvrOtp vyKLSqfqkuBO/4balCtRJMAm5gSCCwXGC2n5qXZ+VONN1fDcmaQ1N0926/YZQRnF6twz+eeAEqDfRSdYVw791vDyiJJn1nARlHIp9CTyHAz2WOcmurbiiXxMyxBDmkLbdmvIxPK+PTPgzQ6AlGSEzQVW+UctVbjeNfRaDxTy+aQmMjjW0X+KoFQpFdcvygWmS6PdvVeerp/Ox4SwujHtfBafQ9IaEg12nbOL7WzobLYEfBkgYoOgrUo/PTYaEE+25EJHpRuvUdaEZmSjbPsvUAdGmLw== 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 Acked-by: Catalin Marinas --- 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 1cbc990d42e0..c3f95ec7fc3a 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;