From patchwork Wed Dec 14 19:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13073385 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 4B987C4332F for ; Wed, 14 Dec 2022 19:48:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0F368E0005; Wed, 14 Dec 2022 14:48:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B97CF8E0002; Wed, 14 Dec 2022 14:48:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EA818E0005; Wed, 14 Dec 2022 14:48:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8AD2B8E0002 for ; Wed, 14 Dec 2022 14:48:41 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 57CFE1C67E6 for ; Wed, 14 Dec 2022 19:48:41 +0000 (UTC) X-FDA: 80241949242.22.E1D3D86 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by imf29.hostedemail.com (Postfix) with ESMTP id B05F4120012 for ; Wed, 14 Dec 2022 19:48:37 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=E47+Jt7q; spf=pass (imf29.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.244.62 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671047318; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=983qr7kV4HVkhdJdw8Aarr87tNHNQaHp+YAL3C1s1I4=; b=aD5JsLC3mZt5zoVyskEcLZ49T4mxupelLm7fMPj6R6bxd3RqQpeCx82EAYWZNaCilhgkKj DZo2FKicrcZj5jaNjJJYNOU2KhSe4TRL3Iw5tu2PFgIzIOKDnGzgIT+kmBm5GHWM3gRSsY /SMOPExWjVvDspo+rYVR5jVz+3X2uHg= ARC-Authentication-Results: i=2; imf29.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=E47+Jt7q; spf=pass (imf29.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.244.62 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671047318; a=rsa-sha256; cv=pass; b=l6JmWZo+RiKsBRiYPzOeWqetngvozaOjook+DS0S0zYI9OFF2K9ymMjfKNVnHs6TMhU0s3 W/I35j9MCMlluANPspybEfN620SQBZcX8XOCbavleW2Kr+n/NpghixcQWMfeDSdmLoD3bD n1zu3rovrzOQAH0sxsntAOmnAsHlTrs= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bCm9YrXcX3m9lNJ5FWuxRXQ1gER2NxhsNqYdtjTBq4F6DiYUlIO8X9TJmJJYb+FNdiirQCHBh8SOAQ0ie3LKyc6lGPB96Z0Hj3Mc77T8rQ28BIsqW173Rm+0q5TMx2/kaVs7fbIjnNa47Kc1j6MC0a4S/Srq5sGUXCaHGia9K5Ut94uFJaSOi3Xv8xH4qH4DjOzNv9vGJyyITdqP+d9aoBjg1ICg9GDvzvu5y9paGTBUvPsoaLG6LUGYwy1JkQO8aMlm1ZJqu8YakF0Ihst1bL4v128+IScS7TaL2zrxh39iJcvXgbZ8dXYuG9Ldtcju0/BMzW7HPVfUjjo6JyQXJQ== 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=983qr7kV4HVkhdJdw8Aarr87tNHNQaHp+YAL3C1s1I4=; b=AcqpnMPy+gINK4owICMtVRjvYReCf0nWoNIOxVrujL4pjnkW4SpuRlJktbZdvJFppVT7Z28OLgvjGZNx4foWARXRmSlhLtbMOJgB2mbdX3JdUlvq3KGlHTWdTQPOw790czWSM7trNI5rbLAdYkp0Shd/o0ZjH+ywOGJtl1gSQKlG6V3us9zFRDluZsNEuzw5IjloGwIqY4ta/DMK3KMJkbSdhj83GYn0WLo2trBxV+kio3m+KU6qycN7cKG1oDuWED173YPP6lqp9u9eD/IMPt7h05uIL/0qTB3eFkwqHeTEQbwpxyoVJ3VQYI44yT7POflvHD4I9ZR2YfBzUkLfGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=983qr7kV4HVkhdJdw8Aarr87tNHNQaHp+YAL3C1s1I4=; b=E47+Jt7q/qDwLoOGWYV3iRNujtqrIj0YCSPevpHVoaU3OYN1TgVjmhJ1apmFHzm2XneNejJJGhsM7XNUfVLCrHh0vuvYaSjJaes15ntRRZBohGf6g4V3Z3Z5CutCG5a/VgNLsxYMPD3Q01wiq9CqRnzeRiT+jY/zcJB+5Of5DxE= Received: from BL1PR13CA0101.namprd13.prod.outlook.com (2603:10b6:208:2b9::16) by DS0PR12MB8344.namprd12.prod.outlook.com (2603:10b6:8:fe::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 19:48:31 +0000 Received: from BL02EPF0000EE3D.namprd05.prod.outlook.com (2603:10b6:208:2b9:cafe::87) by BL1PR13CA0101.outlook.office365.com (2603:10b6:208:2b9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 19:48:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0000EE3D.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5880.8 via Frontend Transport; Wed, 14 Dec 2022 19:48:29 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 14 Dec 2022 13:48:28 -0600 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Brijesh Singh , Jarkko Sakkinen , Ashish Kalra Subject: [PATCH RFC v7 13/64] x86/cpufeatures: Add SEV-SNP CPU feature Date: Wed, 14 Dec 2022 13:40:05 -0600 Message-ID: <20221214194056.161492-14-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000EE3D:EE_|DS0PR12MB8344:EE_ X-MS-Office365-Filtering-Correlation-Id: a99d12b9-a925-4ca9-300f-08dade0c2c9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HElM6bhJpfNO3PYjnq1Wd2gUmXVIfRnKJj1Lnq0YvdVxc1tCHG+GDXM/5HGZpfO11wXSo97QWbuUsvgyXGffsVh8V2uluz3sZsO6M2HjVNwHEPR3hlnhWGv5ydsLgIT5q5Tws5GUR6uafV4Be1cDNyqS8TOAGdfV6l0nT/KREJh4Wt0G1fpiKrGRZo80P3WbpXZLQcvM3PHGsNWJl2sQUWUAOUmQjC4X6FYKcYVrbOaUodMVPk7Poz2PGQ52aXRYqc/TNVPWavTtvV1yfhy9RY2NuPVEbqPMxPyx6s/FHX7E9h6Y4zhMnIp5lYmavleSIaxWCxHm9HVnzVPme/72Bnz3M9jJonOEcpRU+DDN3FtT5xFkl9S/kUIppKBZovyguFkZCNMnG/CdrFNny840gzHGagpOZhKgevMm9DRcAa5WCqkTU5AufDGGq4mWXtOhVhMjnzzv+hHpcyPLMc15R7W4DQhAwt9dTMY3RCV8fEoSMGYTd/UgHoRF1pmt5pEQb6IP3YG8ZIPfaq9/ZFwaeU/4hnA/ZWQLf9tivYN/FymXr+D2nUgQX62q40TmQaj6VNMTBYB79Z4aP5z8dSanisBdKkBU3mt3oCrnDwxgGhkEgT5jgZ9Lt6N5df2Dbx+d17rSZYwTXDdr3IX7ybqvBLp/60zNTDeqr+eRjWY4ggHyTW1RdfSfNw1i2SW8CaSTcINQWOHQgeqBz3iK9hasUqiQ5oZZwsLjVFjgcPQm7/0e9512X1WGu1ITPah/OkTGOfV6pRcXFSIfgi5tyNP6ig== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199015)(40470700004)(46966006)(36840700001)(82310400005)(478600001)(44832011)(8936002)(83380400001)(81166007)(16526019)(2616005)(7406005)(41300700001)(86362001)(8676002)(40460700003)(70206006)(70586007)(1076003)(26005)(426003)(36756003)(5660300002)(47076005)(4326008)(356005)(82740400003)(186003)(336012)(7416002)(36860700001)(6666004)(966005)(40480700001)(6916009)(316002)(2906002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 19:48:29.5126 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a99d12b9-a925-4ca9-300f-08dade0c2c9c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000EE3D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8344 X-Rspamd-Queue-Id: B05F4120012 X-Stat-Signature: uckyx1pn6tgpbtz5mx8j9o9h1euzy1uj X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1671047317-66739 X-HE-Meta: U2FsdGVkX1+DQWZTN9JNXmQJxtRVhHms2cqBFcofom4vNjnWzllLyeHOcCywt0JsKzHALRFcQxHKXsND3fgtyp7W/kWBG+MKZetO72I9CCBWB9HiO8sYUpQH1hUn5TVowVFYm1FTx4/8FK6IXoBvSB4BNMXfcS2yr23nADBaXRzKsn6wWuyOaCn+0mksgRq/wzY39Dz7Gbm+4OsP29k7043luKHVNOZ/Gdy3XvyXdLVFGatn29OoR7qJj/sb3ZK5/MMsJcGBQ1gi9Ty6TzVEr8sP63nL2iFtE9XMpDKE5tsHI7jEWRsueI1ddSVMbwoCRIBMpUWqCKCMdwQqF8RG7mbBv08cGSpEE6Duc95HQ6AFlcyn16oi6Mln3G+oncy/63GwDf96QZCFSwj7TLtMUfeIXliEa2pIvX2oUrLhj/Yl6F//HQJQfGL88kncXCnjb9whkimT8+tpeHRxJgGMO8XNU74zs6upDXw1toHYmN7n+uQrZGDmyHQ+KI8uASciDuo3brjBELX45YIQn7MaQvBPcbmo2poee62TAUONWd7q5ssYybfNYFsCfbenRotuv0BC0+id7hH7ObC7m00ChTLGNahCVE6+WKQKtgERSjUMWa4IbA4RfolKHtGQMzd493/VjTb9B4JxTFfoLxct/EczyYm+OeFe92cKLHMI+QWHvIRWdc1QC8iG/6RoBUH2TlSRNQzd7X2TqoeSKLivMKZMn0KWFEeCdq0lKjuAiRTHkj6KQNIHNlAdwFjnbzfKsfLnJm6yC2l2QfrBpi3McaX5Da5HbFJpU9OMNT0WaMEa8Lup951BcUzEr7KlAMi8hTrZ/o9/W+sDarDyYuWdiGh0XjTh3RS7szjcYqSpeK+wfwNVyLM+IVhHOonphjBndkB9ChRdJBtOaomBkslHmhciIiaUj3hJN3b+t0zIBhweRELMSS2xtD4hFOMhHob6CtcsccbA4tFG6CIqcon ADcKz86y RcN5g 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: From: Brijesh Singh Add CPU feature detection for Secure Encrypted Virtualization with Secure Nested Paging. This feature adds a strong memory integrity protection to help prevent malicious hypervisor-based attacks like data replay, memory re-mapping, and more. Link: https://lore.kernel.org/all/YrGINaPc3cojG6%2F3@zn.tnic/ Signed-off-by: Brijesh Singh Signed-off-by: Jarkko Sakkinen Signed-off-by: Ashish Kalra Signed-off-by: Michael Roth --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/amd.c | 5 +++-- tools/arch/x86/include/asm/cpufeatures.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 1419c4e04d45..480b4eaef310 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -420,6 +420,7 @@ #define X86_FEATURE_SEV (19*32+ 1) /* AMD Secure Encrypted Virtualization */ #define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* "" VM Page Flush MSR is supported */ #define X86_FEATURE_SEV_ES (19*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_SEV_SNP (19*32+ 4) /* AMD Secure Encrypted Virtualization - Secure Nested Paging */ #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* "" Virtual TSC_AUX */ #define X86_FEATURE_SME_COHERENT (19*32+10) /* "" AMD hardware-enforced cache coherency */ diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 860b60273df3..c7884198ad5b 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -558,8 +558,8 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c) * SME feature (set in scattered.c). * If the kernel has not enabled SME via any means then * don't advertise the SME feature. - * For SEV: If BIOS has not enabled SEV then don't advertise the - * SEV and SEV_ES feature (set in scattered.c). + * For SEV: If BIOS has not enabled SEV then don't advertise SEV and + * any additional functionality based on it. * * In all cases, since support for SME and SEV requires long mode, * don't advertise the feature under CONFIG_X86_32. @@ -594,6 +594,7 @@ static void early_detect_mem_encrypt(struct cpuinfo_x86 *c) clear_sev: setup_clear_cpu_cap(X86_FEATURE_SEV); setup_clear_cpu_cap(X86_FEATURE_SEV_ES); + setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); } } diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h index b71f4f2ecdd5..e81606fcd2ab 100644 --- a/tools/arch/x86/include/asm/cpufeatures.h +++ b/tools/arch/x86/include/asm/cpufeatures.h @@ -417,6 +417,7 @@ #define X86_FEATURE_SEV (19*32+ 1) /* AMD Secure Encrypted Virtualization */ #define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* "" VM Page Flush MSR is supported */ #define X86_FEATURE_SEV_ES (19*32+ 3) /* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_SEV_SNP (19*32+ 4) /* AMD Secure Encrypted Virtualization - Secure Nested Paging */ #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* "" Virtual TSC_AUX */ #define X86_FEATURE_SME_COHERENT (19*32+10) /* "" AMD hardware-enforced cache coherency */