Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2815392lqo; Mon, 20 May 2024 19:13:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUE4UQrx2HqR6FElqMai2YfMPMm2JSin0fy60l7ZnUinpyC+RDvwd+sLV1Y+li7aDfv2CTTpKpaDZGsrxGOv05iMsjpcBIEdV+tWYeQlg== X-Google-Smtp-Source: AGHT+IG6Y81tybVz1mhvGLJQFXDEeHp7Ww7vnTgXsTd3PmKJRFddG2ITowi60iZ8LjKAT85WBSpi X-Received: by 2002:ac2:4c31:0:b0:523:8ada:9440 with SMTP id 2adb3069b0e04-5238ada9732mr10215521e87.57.1716257612413; Mon, 20 May 2024 19:13:32 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a3a14065bsi1243111866b.157.2024.05.20.19.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 19:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=EYbiWrqf; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-184361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.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 am.mirrors.kernel.org (Postfix) with ESMTPS id E27511F21C89 for ; Tue, 21 May 2024 02:13:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F83F11CA9; Tue, 21 May 2024 02:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="EYbiWrqf" Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11020003.outbound.protection.outlook.com [52.101.193.3]) (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 A3336D51D; Tue, 21 May 2024 02:13:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.193.3 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716257602; cv=fail; b=AP2MvNsYGwXfyLnQCAPeh7kuYPlEoo8gGoszMrwqXKNEWyffXXVQgOcRpuUNd9yvavmT52w2UigNwLZxpsTp6hgJSrvdYqX+7N70niARTXCopbfTql0+FZ87X9WKWLrPDp9zAj/RH671VnZh4dndznrGV4ssEm9BuMr/nmqjonw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716257602; c=relaxed/simple; bh=uSlQBDrHTlw3N42DFNwtTZmTye9XNXE2fd7Vv53V8qk=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=rUi9fHYiD7FJPfwM4lrjAqlzFhLWIbKOZwKI0zjQrDN2HWMafMXmt69pvpm6bLERBbr7c6E4T8q78ueXAa1aF9TkAmBYeVXutFXdgX255kq5Z1r3rx/LmirHvYZLxoj2i9DlCeelyqC8o3q3/8Mu0oQsln9YvJifih5A6oSxjV8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com; spf=pass smtp.mailfrom=microsoft.com; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b=EYbiWrqf; arc=fail smtp.client-ip=52.101.193.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microsoft.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBRHf4q+rzWF9X4v8o35js1IJxfR2LIjCrYZGAYa0TfXcq1cjnid4qZ2lVUV8FZeklXruuXQmdQRgdRAHTSHb7GLiWpb+YSZoRXDlhw/dZYBaQ3U9rGm2Pe+BtDBsPkSHUHqu28B22N2/ZBM2XFEzJFa61xsyaRdM1u/dLWSC/3KJj+Mqm75j/SIudQkNqNn/7MLopJI+f0uEMANlS36iUND1uWMrMf9qcMQG6qe0yZlwM+ZnTPYB/AAWN+Ti3U8EW5ALKRjrmgInluOuk3mfGt8ABfAdpD/fLe9FPlM+pDZUQOjWievR9ng6sUJYnXyY6/GK+tmjiygo+jRgLBxqw== 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=XBUTd9CdcHN6fDYgNQw4R53ZbNCowUioiGsfsLqaeKI=; b=bMGUrbSnfPgx/dNa8roZ+WcqOr9JRVHz8SCXmIa++BsaU8Yd5kziKVs26KzZNuAwGQSCvdQqqAZSxUC1DTG1zn1TFLK3qb4NMATtlBd3tIAxZ8PTeuGOs0kEVb0+MdwlVf21GAT5ZUtuDCoVuSa+K9uzV5dVFbTULqrXNC1hi/F3/StNdke2XtpYYKTHc32qAgmqClC2Pf5jFF4NGPhZam1cxPeo4LssbXuid/X3EUCwEohtyC5bf+0AA8FjoIMIPBpXZg6JkgMKzhTioZFYef9zXE7e/SFJuuF8nFmhq1RJFRz64lNAZNfFILuJ9k0qYfE5457TMBf7+ayMAz63Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XBUTd9CdcHN6fDYgNQw4R53ZbNCowUioiGsfsLqaeKI=; b=EYbiWrqfqeTV4w+LwJRXdqNdmVlyjM/xuPgRXdeIFeiKsVitr4nIHukabRlSmT471o1ew8/bfPlPHdUYF01rOnvKtltkFNuzkLysvNAMzITLHC4UC17Mzt0sa3hoi36/tYNEMZ21720ZIbWFfJxs6unTvT4vdG8aRhdUpKSiquA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from SA3PR21MB3915.namprd21.prod.outlook.com (2603:10b6:806:300::22) by MWHPR21MB4429.namprd21.prod.outlook.com (2603:10b6:303:278::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.2; Tue, 21 May 2024 02:13:16 +0000 Received: from SA3PR21MB3915.namprd21.prod.outlook.com ([fe80::47c8:8c49:be38:ed21]) by SA3PR21MB3915.namprd21.prod.outlook.com ([fe80::47c8:8c49:be38:ed21%3]) with mapi id 15.20.7544.029; Tue, 21 May 2024 02:13:16 +0000 From: Dexuan Cui To: x86@kernel.org, linux-coco@lists.linux.dev, ak@linux.intel.com, arnd@arndb.de, bp@alien8.de, brijesh.singh@amd.com, dan.j.williams@intel.com, dave.hansen@intel.com, dave.hansen@linux.intel.com, haiyangz@microsoft.com, hpa@zytor.com, jane.chu@oracle.com, kirill.shutemov@linux.intel.com, kys@microsoft.com, luto@kernel.org, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, sathyanarayanan.kuppuswamy@linux.intel.com, seanjc@google.com, tglx@linutronix.de, tony.luck@intel.com, wei.liu@kernel.org, Jason@zx2c4.com, nik.borisov@suse.com, mhklinux@outlook.com Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, Tianyu.Lan@microsoft.com, rick.p.edgecombe@intel.com, andavis@redhat.com, mheslin@redhat.com, vkuznets@redhat.com, xiaoyao.li@intel.com, Dexuan Cui , stable@vger.kernel.org Subject: [PATCH] x86/tdx: Support vmalloc() for tdx_enc_status_changed() Date: Mon, 20 May 2024 19:12:38 -0700 Message-Id: <20240521021238.1803-1-decui@microsoft.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: CYZPR14CA0023.namprd14.prod.outlook.com (2603:10b6:930:8f::20) To SA3PR21MB3915.namprd21.prod.outlook.com (2603:10b6:806:300::22) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA3PR21MB3915:EE_|MWHPR21MB4429:EE_ X-MS-Office365-Filtering-Correlation-Id: e4ffacd0-1034-4052-85fe-08dc793b92a8 X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|7416005|366007|52116005|1800799015|376005|921011; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iMl6jadRFBDbmdxnaDDVxVwgNXwB3gVKZWKspCpE6C6d3Xdh0N9DYnr39akJ?= =?us-ascii?Q?W7qW5swzkaX8+xLhHNvD16TbTAVylwSgivsTeG/OztlVIuH1IIURv+Frs0RD?= =?us-ascii?Q?16ocJMYO7WD0o5cbaEq6j+2djDYxr6M/C5XWijUpKhX0h3IjxE93xHdOb5Dk?= =?us-ascii?Q?rKapcT5u7K0ECSTWbParN4KKIEUu6UTwc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Q?3TwxD2beu8ZZ9Gc9mJ18H3rV0pa0tF7SsF0/AoOj3/mOwr7bxKFJL8nTKMvH?= =?us-ascii?Q?MAeCk4/eaHExxrFoTkzp2CdIhBGdz5nvH40UskLI41NKAb4bqZRX3l0EIqWQ?= =?us-ascii?Q?vJT3DITvhRtmlJnP6usK4uk9EqCfP6FIAxg4L9bl/Di0iMdSPGcINIdeUw/1?= =?us-ascii?Q?lGcHwJiigVH0SNF5O5HCwylPgQwOnf6yOXxyVIp1hQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA3PR21MB3915.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(366007)(52116005)(1800799015)(376005)(921011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X5BV8fpf1XVkGPMjK+9pLk6VMG4EF2+mpjEmhQV7nQgPMwL4VHMi69a+UKM1?= =?us-ascii?Q?Ci9O7oO6p2Qf6+Bjlyj39NyD0PnBqeCM4WDvt6w3ZUidi55vBUA7T6xY+yxU?= =?us-ascii?Q?Lz+68zZMPXTHqbMzlAsPma07jp9Ru23a4+4npGnRfKpWn7N1VH2k9S/M6VFm?= =?us-ascii?Q?U9p5fg3+9YzMP9bjm65s55FjkN143CnQQCrdRhPzXw6eDM3FCNgA6wMIf38X?= =?us-ascii?Q?0c61iUJfI3oRGBiO2pK3Xdxm3kuATBLFhHT96wNHsUd7A1J5OVnxxkbHUkcw?= =?us-ascii?Q?2ZmDEIHjp08w9yystD3aFguERiwSCO2E2Zmue3/ypvAq/HEG80Vz1NPyzHHn?= =?us-ascii?Q?QokheDzoAUEdWmWioONpKHa786qOlFqXyja7vz5WIq0ypxvmz6Xy1ewn+273?= =?us-ascii?Q?jSZVI7qTECDvpacLRjXlHzq+bD6y6tmdGQ7Hj1R+Tf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r5o69qEZweb90QaIG1+RaWbRml/OTQKp3yLlo/qIXqA+dEzhT00CirUXL0V?= =?us-ascii?Q?jEt8JA0LtRBNIHb6tEL6JuZmGgZh7hgEgK2sGC8BmD0ZU6pjFvPrqp9yJj1j?= =?us-ascii?Q?MsWZExhZHYDisjiBxu2fiFh0ZD+U1AKC2Vw2cAbkCFs0jnBEOrK1DMQQW+AW?= =?us-ascii?Q?bW7s3JfH80nwp9xmNPIZXlb+gvmoRcwzDoukBcgVdDA7nqH1W2xUz8LIJL27?= =?us-ascii?Q?D8GmTXtJFk56X1/r/JRE9WmQsujuvkVQXqH2O5/J+VI4swneQKjC1BWBZkH1?= =?us-ascii?Q?MiT1ztw3QmNbXidrb1ekDJf/Qxbmw9dBcsUydfJUct7m?= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4ffacd0-1034-4052-85fe-08dc793b92a8 X-MS-Exchange-CrossTenant-AuthSource: SA3PR21MB3915.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2024 02:13:15.8041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I+KOyFaO/MBahOG+jjJ0gMe1Mp8QXfd0zniXiyiqnKDIHsAQ5pOslMIf71O+mzXh1euXd9A6PVj4fMSL4udpTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB4429 When a TDX guest runs on Hyper-V, the hv_netvsc driver's netvsc_init_buf() allocates buffers using vzalloc(), and needs to share the buffers with the host OS by calling set_memory_decrypted(), which is not working for vmalloc() yet. Add the support by handling the pages one by one. Co-developed-by: Kirill A. Shutemov Signed-off-by: Kirill A. Shutemov Reviewed-by: Michael Kelley Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Rick Edgecombe Reviewed-by: Dave Hansen Acked-by: Kai Huang Cc: stable@vger.kernel.org # 6.6+ Signed-off-by: Dexuan Cui --- This is basically a repost of the second patch of the 2023 patchset: https://lwn.net/ml/linux-kernel/20230811214826.9609-3-decui@microsoft.com/ The first patch of the patchset got merged into mainline, but unluckily the second patch didn't, and I kind of lost track of it. Sorry. Changes since the previous patchset (please refer to the link above): Added Rick's and Dave's Reviewed-by. Added Kai's Acked-by. Removeda the test "if (offset_in_page(start) != 0)" since we know the 'start' is page-aligned: see __set_memory_enc_pgtable(). Please review. Thanks! Dexuan arch/x86/coco/tdx/tdx.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index c1cb90369915b..abf3cd591afd3 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -778,6 +779,19 @@ static bool tdx_map_gpa(phys_addr_t start, phys_addr_t end, bool enc) return false; } +static bool tdx_enc_status_changed_phys(phys_addr_t start, phys_addr_t end, + bool enc) +{ + if (!tdx_map_gpa(start, end, enc)) + return false; + + /* shared->private conversion requires memory to be accepted before use */ + if (enc) + return tdx_accept_memory(start, end); + + return true; +} + /* * Inform the VMM of the guest's intent for this physical page: shared with * the VMM or private to the guest. The VMM is expected to change its mapping @@ -785,15 +799,22 @@ static bool tdx_map_gpa(phys_addr_t start, phys_addr_t end, bool enc) */ static bool tdx_enc_status_changed(unsigned long vaddr, int numpages, bool enc) { - phys_addr_t start = __pa(vaddr); - phys_addr_t end = __pa(vaddr + numpages * PAGE_SIZE); + unsigned long start = vaddr; + unsigned long end = start + numpages * PAGE_SIZE; + unsigned long step = end - start; + unsigned long addr; - if (!tdx_map_gpa(start, end, enc)) - return false; + /* Step through page-by-page for vmalloc() mappings */ + if (is_vmalloc_addr((void *)vaddr)) + step = PAGE_SIZE; - /* shared->private conversion requires memory to be accepted before use */ - if (enc) - return tdx_accept_memory(start, end); + for (addr = start; addr < end; addr += step) { + phys_addr_t start_pa = slow_virt_to_phys((void *)addr); + phys_addr_t end_pa = start_pa + step; + + if (!tdx_enc_status_changed_phys(start_pa, end_pa, enc)) + return false; + } return true; } -- 2.25.1