From patchwork Thu Dec 21 15:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Agrawal X-Patchwork-Id: 13502315 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 A5035C46CCD for ; Thu, 21 Dec 2023 15:40:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C3948D0001; Thu, 21 Dec 2023 10:40:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24C948D0005; Thu, 21 Dec 2023 10:40:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECC938D0002; Thu, 21 Dec 2023 10:40:54 -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 D11D58D0001 for ; Thu, 21 Dec 2023 10:40:54 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id ACB18140728 for ; Thu, 21 Dec 2023 15:40:54 +0000 (UTC) X-FDA: 81591238428.28.20E6BD7 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) by imf12.hostedemail.com (Postfix) with ESMTP id BE30A40006 for ; Thu, 21 Dec 2023 15:40:51 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=t7hky1AU; spf=pass (imf12.hostedemail.com: domain of ankita@nvidia.com designates 40.107.243.85 as permitted sender) smtp.mailfrom=ankita@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703173251; 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=98NcKXWiESUpXBqxBe7E+UCrgHbpvfJcYL9onUUx6HE=; b=K3CFlZ/lzN4yaiAbd1vidPeWTZI5Wj+l2twHe/G16AoDF0o8NFNR29OvhugLH99h/Aoasn w24e9uGY2xOK5T831LM/HMldiBqXjfDDyEinUgI6rt6DnK9OKAfvDIstADWo0C0De3GfjI OYiXQ06oCfc58ni0AL2/YVeG15sRnkk= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1703173251; a=rsa-sha256; cv=pass; b=ylTVfkRqk8pyOA/0SnKLvyDhdilRI5+h/EgBWnUcjDsqJPVD4BW8dHvdpdP4RfvSLjeExQ IoiSLwobwTaszfLtbsjrMfYqnScZl6ORl2KfnilHdJ7otGGfLGATRtPVZP+bJ+Zoei5Qws O8jnDr/45ARX46IhVxnqU8bdJ1A1Sis= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=t7hky1AU; spf=pass (imf12.hostedemail.com: domain of ankita@nvidia.com designates 40.107.243.85 as permitted sender) smtp.mailfrom=ankita@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NglnIY/uhT4MgIrW/82SRHbDtvo2O6Z2Ssb1OMf3kJWTecPTBkhbyDtKbQx6tWiArkWH227f/jzg+q1zeIeWPOzB/8c7XFpCBIz0oUxbAL1jgtfexFxt4rIFnCrZs75ix/tpyC6YToYdLrzKiV4AM60mDSBVGURhEAam3mnEwaDqNj1u0vr0goxjWBaW9rbuMiig5QbAaf+WgsLlhPNyW3I97LoXuBD4sQQqrnhynC4u6kYKY+0qUFbalNvvjlO11RHZcufuGyprk4Rg6rxaSdEvIyodw1DYd4S36jznibWwc54pwyl3H+gZA3pWhteXPeV9IWunl8Fr5uNkJN9n0w== 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=98NcKXWiESUpXBqxBe7E+UCrgHbpvfJcYL9onUUx6HE=; b=mrzAn0i64CCa4rlpxR60WL6oboGcttVnpq/Jp2HQZxaHEw3xqp5hZqrUeVZY7yRSXjzhB7DZwAj96ww02Y9NUzEyajTN9CNqdop5LnEXg/myciot+dfl1+fF70fuua0cDfgRy0V/LjcEf68jpi4nNNS+b2ibrkNXnKL16C0XqWHX3lDmn3YQrkYW+MrzhewfxBWaJG70ag1gg4O5ZyHY6ICfbWIFwKiNrwRX4nj+PZAZ98rcFx+rrFkCDvb1jfqxj7vY2tt6SKQ9XEXFApme8d4EW6Tge2wjPh6e1wCtz3pllr4nSVXKsBW/LhwfqpXdZX1oaVYx0kDY8OPdu+Kdhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=98NcKXWiESUpXBqxBe7E+UCrgHbpvfJcYL9onUUx6HE=; b=t7hky1AUYxa2+XVH8qH86yEs4euYsQfbAAzVEcFnnQyOw1Hk655p86yQfkk2sG3ew4a/G0DsjPgs+Kj4NpjXbGdacGQNR62OLOXcv9sb/hWgdxu18yqwRkbnIAtIKgSxcJsosoI7sFGb0StH0/mV6wVKbfFez6fNzFNyw94yllrwocinJxQYWkLUUtxiRztLVryMbvNSvJIoSBCLS1XGTk6ktqmNB8NSJyyTleC4hv51dK6JuUsP4MFrOjFOkGkXqGy+H3Ew4tYVw0X6LeE5Mu1DLf+1VVtfvArjyAIqPdhBrDAOWJZ9WOW1a30kSvZmaJttisUoQ+Sh7/QvoUtcWg== Received: from SA9PR03CA0026.namprd03.prod.outlook.com (2603:10b6:806:20::31) by DS0PR12MB7770.namprd12.prod.outlook.com (2603:10b6:8:138::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21; Thu, 21 Dec 2023 15:40:47 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:20:cafe::a7) by SA9PR03CA0026.outlook.office365.com (2603:10b6:806:20::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.21 via Frontend Transport; Thu, 21 Dec 2023 15:40:46 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) 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:40:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Thu, 21 Dec 2023 07:40:32 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail201.nvidia.com (10.129.68.8) 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:31 -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:23 -0800 From: To: , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v5 2/4] mm: introduce new flag to indicate wc safe Date: Thu, 21 Dec 2023 21:10:00 +0530 Message-ID: <20231221154002.32622-3-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: SN1PEPF00026367:EE_|DS0PR12MB7770:EE_ X-MS-Office365-Filtering-Correlation-Id: 97e4db02-b274-461b-048c-08dc023b3360 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yBXR3VJxgIwu0ZLrHcsoPmGsdTjM11BpuiekZWYzvrf4jPuIas4jgcfKO1niuz4jAXvRD+hoc+fdbp4Hb+GFp453afnIJroAzbMbCZnD/ovVxZBLY37GFxQYDr61cgRTfiB5loLizn+dZE5WWo/qgdWdtokAhAxW+sYrZMdvExc17lzD+i0oGzp/RgYrTBKztJRLWvTC27HKlEBI7om2cFlWjzw06rIw3vzhzC+PHBgQtYQURwkGATX40JbtyTha94wEFvCO7kRTtDfexsMOKN4uczGlxSedqrvZeey7rZKuXuT3faKNyLtBo/ATyC4Y8hCRJd2Rdr9WKnXfxaPC8R/cT6TM3UhHJYyf6EbXk3Ld3m6x7y1Fvzt8K/ocj51oJ2zH+84wqegF6lpLvzQ5NwbV8+ESd1igGGy98Y4qeZ4zAZ5XG4zOrzPcl5w5ZFGe3tmRH+I23JkRa285oE/pMFa4CkE6AvylYL6rJvX6+6S+maA5HSbJR893e4sQJKXjFKPTsTK/zbHkH+3NflIL3HrVpHMbqBNiKxTGSA9/v7bjpexU/xA2ylOz6IHh50zAafFXCCTOCu8RPhVat9WzIS5rrZhdvSN02bUZ/N9V2dU+t0w+RqUvJhuMcrwOSoichL1ahM/eTIi3B5K6OMdQVSP2BUJnmwtON7+427kBQ7bvoWcGKS+cB+DCmIRhsfuZ/1Yeg7WZ8YxV8YqXF5zs7QgBQ3CBD80rrnQ2kBvyTV+9gJbN1ybxwLkdSErlAM6aytIdhZ1Lp+XfYFMykF9E9NCrS43Ym1mGw/vIWvxqKFtkAj4dfQ+STvpcz0LQ3izy 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)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(40470700004)(46966006)(36840700001)(356005)(7636003)(82740400003)(41300700001)(86362001)(8676002)(8936002)(83380400001)(4326008)(70206006)(70586007)(54906003)(110136005)(426003)(336012)(7416002)(316002)(40480700001)(5660300002)(2876002)(2906002)(47076005)(478600001)(36756003)(6666004)(7696005)(26005)(1076003)(2616005)(921008)(40460700003)(36860700001)(2101003)(83996005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 15:40:46.6774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97e4db02-b274-461b-048c-08dc023b3360 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7770 X-Rspamd-Queue-Id: BE30A40006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: otpby6w8udck5ny1dh1ypeomwmpchgqu X-HE-Tag: 1703173251-77364 X-HE-Meta: U2FsdGVkX1/Dq8ajoZW5qvhhTbVnggy7BSgHmJZ8FgPOSt/0TnU3fn9tRJxp8FW21oa7vdb4sRiHD+A785EENDXg/Ipt7v9lAlxIKk6EMcIURUNztSHSvr6rcj43IoGSRSoouCjIz4q+LM64AgV6VH0VqsenS5VoKBthZUMwBAQ8HL6ZNCnqLKGDnWaoTlZvY7KK07BezfOp4+rhYYGu2M+nvwCWdifnH8SXEstzNlZOkC7wEmx5kco8vkqPK/FeWIm5drcRAX/asNjRHsVsUAO3gLtBYK30J19j0fUkk7So88Ni22hTRr20icUnTdlePaUFpBs+dQkE6XTL7Enp6njdv0ez+7z5o5WC1I9YVSnDPeL1TnxVku+0bStTOaw3fvCKuD9IeKLzbvB03cN2q6ZCmqwQ2tbvzikzzvvG1ZWGKavnAKJsWBoY84tQ7L6rrfLELUhrykIuKX0QhcL/Y+sw21hXkQJ7kD0iS8xqO4k4egO1ooCNE22I/OFLRyE1WrY5HOpW20PJAt21WGtLlmBp/T98Hl0mtAeN9vERp7RHskA6NPvDrLIpcQYQr2NX4dwGu9M8ij1akoEqWNdzzROiyVfeMHEPi2Q+Xm4xgkE8AurTk5wOo5+uKpuVLy3Q9vN1F/rXvPvJtB2mKAsAvUORtCvqMMFSUtbmBH+S+gwNZtyU/ho9OyRvrIZILQjWZsWjvWhwab9TPEPCTOliCAF888liJf+6IDFXXmXGMy89wJdP7UqZdWm1q7gIXh0lMrT29YrMGDMIcDz473KFqPoHIR7j/ShVxXz68Ee8UWGho21joxN9AiOafsYK/LRkk8gphgjCNTzHA2RRPa+gaKjthKohpprAjarIH89t0GMAMEVGy94V8+Eu/FQ2JBLUBtLF/rNOS0rvlMfPTZH9tzDi7IxVhWw1r6ndLRRGScJf+p2B5zbcePTG9zolZcku4+5owyMH9s/RWYiAsxZ +LXuRYu2 jtdDJ6IU6l2ygTcBXtwDHXZ4aHkziOFSs5ttHM8n1HJSxTHfAiUJd0mWLpaP5RywQsgYVzpM8KSizeHEKhajOE5mK4c7RDHzSbunWYXuRVXuMVsa5Mo8ftwhCqImw8S++AkgqWJslE2w+WD51AQy0eoiwJS4+rG5fIrGm0jZeRYOkeSLDLgNUDZOlXaVXWGOTbZ6UBt3+8jb4NNqbvNMrMxQdttUrZLqyZ3GeoTINq9XEPj53anGoVsbZRlOCuoQwZ1M4Jywnwh8RJDMOewgQVIzy9w== 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 Generalizing S2 setting from DEVICE_nGnRE to NormalNc for non PCI devices may be problematic. E.g. GICv2 vCPU interface, which is effectively a shared peripheral, can allow a guest to affect another guest's interrupt distribution. The issue may be solved by limiting the relaxation to mappings that have a user VMA. Still there is insufficient information and uncertainity in the behavior of non PCI drivers. Add a new flag VM_VFIO_ALLOW_WC to indicate KVM that the device is WC capable and these S2 changes can be extended to it. KVM can use this flag to activate the code. Signed-off-by: Ankit Agrawal Suggested-by: Catalin Marinas Acked-by: Jason Gunthorpe Tested-by: Ankit Agrawal --- include/linux/mm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 418d26608ece..49277e845b21 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -391,6 +391,20 @@ extern unsigned int kobjsize(const void *objp); # define VM_UFFD_MINOR VM_NONE #endif /* CONFIG_HAVE_ARCH_USERFAULTFD_MINOR */ +/* + * This flag is used to connect VFIO to arch specific KVM code. It + * indicates that the memory under this VMA is safe for use with any + * non-cachable memory type inside KVM. Some VFIO devices, on some + * platforms, are thought to be unsafe and can cause machine crashes if + * KVM does not lock down the memory type. + */ +#ifdef CONFIG_64BIT +#define VM_VFIO_ALLOW_WC_BIT 39 +#define VM_VFIO_ALLOW_WC BIT(VM_VFIO_ALLOW_WC_BIT) +#else +#define VM_VFIO_ALLOW_WC VM_NONE +#endif + /* Bits set in the VMA until the stack is in its final location */ #define VM_STACK_INCOMPLETE_SETUP (VM_RAND_READ | VM_SEQ_READ | VM_STACK_EARLY)