From patchwork Fri Feb 7 23:34:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 13966076 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5830C02199 for ; Fri, 7 Feb 2025 23:35:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tgXry-0005bR-Gf; Fri, 07 Feb 2025 18:34:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tgXrv-0005b9-Vm for qemu-devel@nongnu.org; Fri, 07 Feb 2025 18:34:44 -0500 Received: from mail-mw2nam04on2061e.outbound.protection.outlook.com ([2a01:111:f403:240a::61e] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tgXrs-0005pq-Up for qemu-devel@nongnu.org; Fri, 07 Feb 2025 18:34:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XMMLyCg+nWuw8BeAE/XHh2JDgAH2RFpNPJTGT0zCdg5kT5D9MwuQ5oyRFepbaxQ8jlLeY2rvlDTq7X4WASpb599obmLvUSYCHO0OKbpvuXiWU8qrzjF/3hv/NYPLy3ZUR1F/mlPRonhoZu0VKKpq6ENO/2D0T9HGbmlcVPd9SkCfBT08hQaJdAcBIDynC8xM9ZVhNG/VernICiJYgh0Ihou8egXQSbPhdeH2hFJScCasFHmG7RjDIJe3qKewZLmiGA6R1nquIZ341iN/sidSbYg4TgKm38JJ8LoRUKKovdY+P7y8SPPZh1kfHXwWFRiUYuBgPQGztHWpsu42kGgN3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Z0xS9rd3QNnBYpqjhQA/EMaz5sY+O/1DMgGIdd9YymA=; b=F1CDsrPjk2uxH4WrvGLk5p/5iXpuI1FCDiAcfZHzBSdl26Ave7ksi1VSkPqAFvvWjeKHLHXfIf7sPIPBdGa5X/6ijjKw9t3dNaT6SNRcPgUEDJh4ros39dloIqzYJpOYMtK43kuNjZ+V7Ah4GZxJEq4AE0AaQmBsWg337i3aElKz0Xh7ndNyB/rOwTinST7fnf/HjlgvgRjAbpz4TZ34D6mf4+Ot573WpwlFnC6AMpKT3Kxy+sB82STTrd1q717kKxr9u2s+J4or4njjNF7uD94sJzuP0QSih9JmeYSBKibkP6O08RVrgUtgqUFqcPkIftSopXf0XQOZZGIw9SCyzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.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 (0) 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=Z0xS9rd3QNnBYpqjhQA/EMaz5sY+O/1DMgGIdd9YymA=; b=fSG3hPvob94QpYfjk0HuUMvKlVeCEvEffqly6H2UFwM8JY9U19M4Gp/caTyOXVsBIc6QAQrTL1oVJ1lKNOlF1ACYeJsNDpNT87PPomi5K0vctqMFh+A3zi3h5Qxp/5YEGWRXFsNI3RRAKxE8spPWYTGQJIV4JzfVf3xAWR2JFoI= Received: from BN9PR03CA0361.namprd03.prod.outlook.com (2603:10b6:408:f7::6) by MN0PR12MB6030.namprd12.prod.outlook.com (2603:10b6:208:3ce::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.10; Fri, 7 Feb 2025 23:34:35 +0000 Received: from BL02EPF0001A0FD.namprd03.prod.outlook.com (2603:10b6:408:f7:cafe::14) by BN9PR03CA0361.outlook.office365.com (2603:10b6:408:f7::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.31 via Frontend Transport; Fri, 7 Feb 2025 23:34:35 +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 BL02EPF0001A0FD.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8398.14 via Frontend Transport; Fri, 7 Feb 2025 23:34:35 +0000 Received: from zweier.amd.com (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.2507.39; Fri, 7 Feb 2025 17:34:34 -0600 From: Kim Phillips To: , CC: Tom Lendacky , Michael Roth , Ashish Kalra , "Nikunj A . Dadhania" , Borislav Petkov , Dave Hansen , Sean Christopherson , "Paolo Bonzini" , Kishon Vijay Abraham I , "Kim Phillips" Subject: [PATCH v3 1/2] x86/cpufeatures: Add "Allowed SEV Features" Feature Date: Fri, 7 Feb 2025 17:34:08 -0600 Message-ID: <20250207233410.130813-2-kim.phillips@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250207233410.130813-1-kim.phillips@amd.com> References: <20250207233410.130813-1-kim.phillips@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: BL02EPF0001A0FD:EE_|MN0PR12MB6030:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f26e1c3-2d3b-4414-610b-08dd47cffb5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700013|376014; X-Microsoft-Antispam-Message-Info: XFE3d0BMgl+n001RhznZpUWbE1VLyICSu8SfEXqqGjAOtPqP8mHjHhG9talfUhfw/FOyXVULH9JQOZOalhQ9s5Ds8K5RHHIIxr7vZzkxugl/8sFJxPo67IbhO5K1W5QL5fP+tOc3jkvwAmaNsQgfgWifsRqtPbTEFy2EqEoZlbctyCca0r+YeKUVMtrsY6EMVt2wiCQV1iAuqHWxg+JYMJjpFZNhns9TQg1zAxbxK1eo3q2/BQ9TVZKbLjjMei+GRkQU+D6ubeTAtqdN4VJN/kg418xdh6zTtZqqBAlS4HGUYjkak7KhN1E9oF38NDH3KRb2Q5AXlUvrMUHV4dbgHqm38r2oJelT/Fe24r5GDHYepLw3DN3b3Zq5tCpbsX7QDSlhVkoABKsxZjFvgIKZSy8FDxQHVt7P8lQ2vgwFnD356WENZxeIzASb2Uwet717bgIvgEGcw9Qj4/eLchXatRf4+n1VlYMYhK0I8ZJUIAqmlPmYIEc39SyrwMunXRPIFjwT8C8TE6C8MucFM7l1q/C/12T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:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2025 23:34:35.6856 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f26e1c3-2d3b-4414-610b-08dd47cffb5d 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: BL02EPF0001A0FD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6030 Received-SPF: permerror client-ip=2a01:111:f403:240a::61e; envelope-from=kim.phillips@amd.com; helo=NAM04-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Kishon Vijay Abraham I Add CPU feature detection for "Allowed SEV Features" to allow the Hypervisor to enforce that SEV-ES and SEV-SNP guest VMs cannot enable features (via SEV_FEATURES) that the Hypervisor does not support or wish to be enabled. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Kim Phillips Reviewed-by: Tom Lendacky --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 508c0dad116b..a80a4164d110 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -453,6 +453,7 @@ #define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */ #define X86_FEATURE_RMPREAD (19*32+21) /* RMPREAD instruction */ #define X86_FEATURE_SEGMENTED_RMP (19*32+23) /* Segmented RMP support */ +#define X86_FEATURE_ALLOWED_SEV_FEATURES (19*32+27) /* Allowed SEV Features */ #define X86_FEATURE_SVSM (19*32+28) /* "svsm" SVSM present */ #define X86_FEATURE_HV_INUSE_WR_ALLOWED (19*32+30) /* Allow Write to in-use hypervisor-owned pages */ From patchwork Fri Feb 7 23:34:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 13966075 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 718E0C0219D for ; Fri, 7 Feb 2025 23:35:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tgXs9-0005ci-FG; Fri, 07 Feb 2025 18:34:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tgXs8-0005c5-IG for qemu-devel@nongnu.org; Fri, 07 Feb 2025 18:34:56 -0500 Received: from mail-bn8nam12on2062e.outbound.protection.outlook.com ([2a01:111:f403:2418::62e] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tgXs6-0005qi-HM for qemu-devel@nongnu.org; Fri, 07 Feb 2025 18:34:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jKCiMuZF5SrJ9C95BYhoSYBMJ0sFvYkIxUHn5rChuHRsjNwlHT1UrcfGsHAnlMaApx5bd29KFfugVk3bs3t6emFtcMOu4b80BBu39z9BYsIB/q2hIDJnPLhrqcwpEq5PA0tqB61zly693z1nibr2hbF/8iS8/fGvweHhZxhJy4wz6cLQRS/3NL0jxgwFBY83KVUCzwv/ocjG8J3WZP/vQ2lDRlvCAg7vQ5lDL8max5iH1U6AS/94tXdsphxQ1x4JfqDtjf+Sjm5gIDBZEXv2yWD6jYUQM16E7UqBrnvOvm6uC5v84r+rJW5PWkREly2oDFkeNnERUkRB32R7Ok508w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5zCyf/9o8EcVmGuPfIo75VZBwAT40Wd68cp9w/rW7hk=; b=g7sNN1nJGZEspruhMdppsGx+dl1cp+PNMVPzcM+7kM8k92oYbdBlebiEHIqY1f+r9N6SrYgQEHIfLOCzk0r9pv6dDfDFfJA3SVhweI6j2QWm6q0wfF2f3CMzBtp82Ue3/dYCsTXflAzTqsMLYfQ/Cx8E06OIjg1LFqD6tCo92qqLEF/bdGdmqx/wxYzP7CoNA82I8aanCkte9zCnCtxIQImjXQE+BjiYG64x/OC41pkBStXRH2cNwJHXysUQeotnJSwgiVQRwOP2z+/bxBNz+bWy6eNPuNrOQ8LtfMTG173IiJjG1RZw2+cOaajxHsmhb5zEUPhowW4utUZ7kSNlUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.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 (0) 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=5zCyf/9o8EcVmGuPfIo75VZBwAT40Wd68cp9w/rW7hk=; b=Hl8qAsoZ/fxfiFvahHH0fggpvfRXgXXC28ZD9IeG++kuym3vQi7rlpZVZX33N9D+tScbb7NOO6D6cKHtff9qQSJOCQ7tkxmtLGiT57M7zIjt3TIJQDA+3s3YkEf1XoPFG0cCqEpBWA5NTFRPhTZ2e8Up9n3BxSPxJPufXSZiwSs= Received: from BL0PR1501CA0032.namprd15.prod.outlook.com (2603:10b6:207:17::45) by DS0PR12MB8454.namprd12.prod.outlook.com (2603:10b6:8:15e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.10; Fri, 7 Feb 2025 23:34:47 +0000 Received: from BL02EPF0001A0FB.namprd03.prod.outlook.com (2603:10b6:207:17:cafe::e4) by BL0PR1501CA0032.outlook.office365.com (2603:10b6:207:17::45) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.30 via Frontend Transport; Fri, 7 Feb 2025 23:34:47 +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 BL02EPF0001A0FB.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8398.14 via Frontend Transport; Fri, 7 Feb 2025 23:34:47 +0000 Received: from zweier.amd.com (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.2507.39; Fri, 7 Feb 2025 17:34:46 -0600 From: Kim Phillips To: , CC: Tom Lendacky , Michael Roth , Ashish Kalra , "Nikunj A . Dadhania" , Borislav Petkov , Dave Hansen , Sean Christopherson , "Paolo Bonzini" , Kim Phillips , "Kishon Vijay Abraham I" Subject: [PATCH v3 2/2] KVM: SEV: Configure "ALLOWED_SEV_FEATURES" VMCB Field Date: Fri, 7 Feb 2025 17:34:09 -0600 Message-ID: <20250207233410.130813-3-kim.phillips@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250207233410.130813-1-kim.phillips@amd.com> References: <20250207233410.130813-1-kim.phillips@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: BL02EPF0001A0FB:EE_|DS0PR12MB8454:EE_ X-MS-Office365-Filtering-Correlation-Id: 0987dc23-2bbc-4ee3-22de-08dd47d0026f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|1800799024|376014|13003099007; X-Microsoft-Antispam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pEHQlL886zBBtRUptG/NnWv6N9pIMO1xmiYd18w56GPpABjo4qxHcgolacSzso8Oz7csiysfiLJVYktu3UWDkl1Sfdq3JwHDgSr1+5i3lJimm+3IkQT0Qv6kL8E+T0+kQY9FOpIz+jiK6/6eO62UgXGq8qj5tJusAKb/DHAnxvpFu/5LSBj/GB8tjSR8THDNBf2WlQGoic3LAcpjSZJ19MxzONuK3bF2TH6nZinfvC2CtdJPycD+GEJQ8mx63XJXAm91NGFSiEXazawFRcwIbtxplXzUEb8OZ9IIC3mBlE5s4nAYDWiROrHQueeN7SIVjvL1TGvwv4ZeCQ5ig6ZMsP4n3GuVj/On8sg6mpEbSAdcAzWES6B/Yq1A= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(1800799024)(376014)(13003099007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2025 23:34:47.5460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0987dc23-2bbc-4ee3-22de-08dd47d0026f 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: BL02EPF0001A0FB.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8454 Received-SPF: permerror client-ip=2a01:111:f403:2418::62e; envelope-from=kim.phillips@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org AMD EPYC 5th generation processors have introduced a feature that allows the hypervisor to control the SEV_FEATURES that are set for, or by, a guest [1]. ALLOWED_SEV_FEATURES can be used by the hypervisor to enforce that SEV-ES and SEV-SNP guests cannot enable features that the hypervisor does not want to be enabled. When ALLOWED_SEV_FEATURES is enabled, a VMRUN will fail if any non-reserved bits are 1 in SEV_FEATURES but are 0 in ALLOWED_SEV_FEATURES. Some SEV_FEATURES - currently PmcVirtualization and SecureAvic (see Appendix B, Table B-4) - require an opt-in via ALLOWED_SEV_FEATURES, i.e. are off-by-default, whereas all other features are effectively on-by-default, but still honor ALLOWED_SEV_FEATURES. [1] Section 15.36.20 "Allowed SEV Features", AMD64 Architecture Programmer's Manual, Pub. 24593 Rev. 3.42 - March 2024: https://bugzilla.kernel.org/attachment.cgi?id=306250 Co-developed-by: Kishon Vijay Abraham I Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Kim Phillips --- arch/x86/include/asm/svm.h | 5 ++++- arch/x86/kvm/svm/sev.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index e2fac21471f5..6d94a727cc1a 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -158,7 +158,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area { u64 avic_physical_id; /* Offset 0xf8 */ u8 reserved_7[8]; u64 vmsa_pa; /* Used for an SEV-ES guest */ - u8 reserved_8[720]; + u8 reserved_8[40]; + u64 allowed_sev_features; /* Offset 0x138 */ + u8 reserved_9[672]; /* * Offset 0x3e0, 32 bytes reserved * for use by hypervisor/software. @@ -289,6 +291,7 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_ #define SVM_SEV_FEAT_RESTRICTED_INJECTION BIT(3) #define SVM_SEV_FEAT_ALTERNATE_INJECTION BIT(4) #define SVM_SEV_FEAT_DEBUG_SWAP BIT(5) +#define SVM_SEV_FEAT_ALLOWED_SEV_FEATURES BIT_ULL(63) #define SVM_SEV_FEAT_INT_INJ_MODES \ (SVM_SEV_FEAT_RESTRICTED_INJECTION | \ diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index a2a794c32050..a9e16792cac0 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -894,9 +894,19 @@ static int sev_es_sync_vmsa(struct vcpu_svm *svm) return 0; } +static u64 allowed_sev_features(struct kvm_sev_info *sev) +{ + if (cpu_feature_enabled(X86_FEATURE_ALLOWED_SEV_FEATURES) && + (sev->vmsa_features & SVM_SEV_FEAT_ALLOWED_SEV_FEATURES)) + return sev->vmsa_features; + + return 0; +} + static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, int *error) { + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; struct sev_data_launch_update_vmsa vmsa; struct vcpu_svm *svm = to_svm(vcpu); int ret; @@ -906,6 +916,8 @@ static int __sev_launch_update_vmsa(struct kvm *kvm, struct kvm_vcpu *vcpu, return -EINVAL; } + svm->vmcb->control.allowed_sev_features = allowed_sev_features(sev); + /* Perform some pre-encryption checks against the VMSA */ ret = sev_es_sync_vmsa(svm); if (ret) @@ -2447,6 +2459,8 @@ static int snp_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) struct vcpu_svm *svm = to_svm(vcpu); u64 pfn = __pa(svm->sev_es.vmsa) >> PAGE_SHIFT; + svm->vmcb->control.allowed_sev_features = allowed_sev_features(sev); + ret = sev_es_sync_vmsa(svm); if (ret) return ret; @@ -3069,6 +3083,9 @@ void __init sev_hardware_setup(void) sev_supported_vmsa_features = 0; if (sev_es_debug_swap_enabled) sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP; + + if (sev_es_enabled && cpu_feature_enabled(X86_FEATURE_ALLOWED_SEV_FEATURES)) + sev_supported_vmsa_features |= SVM_SEV_FEAT_ALLOWED_SEV_FEATURES; } void sev_hardware_unsetup(void)