From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011019.outbound.protection.outlook.com [52.101.62.19]) (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 484CA238166 for ; Mon, 14 Sep 2026 00:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.19 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789347499; cv=fail; b=FdUpjMKn4bjUr/MywJIoAHeK+QAQV/5+e8vbJGijGW8OF7ow2FU9Nb1mfBIAXM1k4ipKYmepjkZfxgZu2cCHrSeST41Wjdxf37kiEqksc4Cx4P7TLlFua4Y55EXXJi5G7VCyXQ2KE8W3omemZh/uW+1Kqxw/GLB8XAtF7V6codo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789347499; c=relaxed/simple; bh=BG09JZIIbBetqTJBcI+aMtI2R1MROzajIXtuDopScuE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h0MQMQ3ExY6FKAkRC+JvzpGeV7M4ge8zIJifiCE+wMUiaOvFSktboIfs0zuKMkmYDYsK4Yi4ofvXNS/LWk///hr6bJ9kv8FZQ2+XobUVE7qYIdT+o7Znd3sTtThxf1f1bsZaSqyBDDMUcqyDILKmyyJM1uMyxLrm55Ldz2C9/Os= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=q6YXnUcd; arc=fail smtp.client-ip=52.101.62.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="q6YXnUcd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kdwLzxU0jP3PPWWzbR39eC7957KDkA879nR8yzeuBgtpPdmuwM+vEPB7lKm4TzVbOxh6w6hZ9J8zGRKnudQ04LGMgVC11tOkWGqjex8iYIg3aivinL7XtGi08woMtkxoF95kb1550l0SABqWDn6HE0egcYN6bfLEZN+P4k52uqC4pCgWMhxFGAka853neqbP2FGa0NTlqhH5mcTqgG1+tYqVRh3Eo7p8HX0d3yNWGm89xj1TzaVxq8KTbuS0wq9pZU4y1SpGe7gCbsMG3Yk+LO/6qg9zEetTcg2Bg6nrq15hbQcE//cFY/gP3faPNkXwrPmwyWu7hJF5dEFXjNhxHQ== 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=pbbXdWdkIWLt257qHN9QSYT+vatWU5Z6dSlGF2hC1A4=; b=OOein0D9S07cjZGMjFvfNSUkVtnYp1c+ll89hOauL/IsZZ2TUrWY7E2C5g4zc2M/egjIsa09gdZYQZ45Bm4ihno68CoGGHuQiXUMXo/q/lOtGNJxbHahks8hpnLrzpLWaZZVqm6BrdQelQETdJIrgCy6wp5zJAMv4KUkk755b3Nx25b1BmRObkD5Krd1YKPpwIK133Ztz39Sa6yLtUPHdwhit/IIRgtrAdTy0Uphp0WyiiEZdgSg/24JZsHmA57fTqjDvNGm4Hgxo3HkWjXe/6+Al6UOP8Y/NNE/cIrT0X8sR1oRBzWYBUTynZk5fzRSJ6Y745HP7jYX9sul0RJ4OQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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 (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=pbbXdWdkIWLt257qHN9QSYT+vatWU5Z6dSlGF2hC1A4=; b=q6YXnUcdWHENAibwyYlG7Xf1ByuqM2zCGBk88+aC02lEOUEdG6wR6GFAF907fqIFIpXbZaAae4Z8+NZRsdyyCRWQBbGQ5glJR7hWwhTlFCDB5sEUkU32l9xAutUBPIYMq4NYkQsQOTEFKBDvBOPn3BuiThCKQ5sKCDApxuBWsv8= Received: from PH7P220CA0039.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::26) by MW5PR12MB5682.namprd12.prod.outlook.com (2603:10b6:303:19f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.9; Mon, 14 Sep 2026 00:58:12 +0000 Received: from BY1PEPF000264B6.namprd02.prod.outlook.com (2603:10b6:510:32b:cafe::19) by PH7P220CA0039.outlook.office365.com (2603:10b6:510:32b::26) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.10 via Frontend Transport; Mon, 14 Sep 2026 00:58:12 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF000264B6.mail.protection.outlook.com (10.167.242.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.7 via Frontend Transport; Mon, 14 Sep 2026 00:58:11 +0000 Received: from purico-9dcchost.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Sun, 13 Sep 2026 19:58:09 -0500 From: Melody Wang To: CC: LKML , Tom Lendacky , Melody Wang Subject: [PATCH v2 2/8] x86/sev: Add support for Alternate Injection Date: Mon, 14 Sep 2026 00:57:18 +0000 Message-ID: <2879871fc923e791a08d1bf48b9fbfe06ae9ee51.1789345277.git.huibo.wang@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF000264B6:EE_|MW5PR12MB5682:EE_ X-MS-Office365-Filtering-Correlation-Id: 6356990d-ea77-43b6-2f25-08df11fb4010 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|1800799024|23010399003|376014|82310400026|11063799006|10067099003|18002099003|22082099003|56012099006|6133799003; X-Microsoft-Antispam-Message-Info: 8oodsInk0onYfzSNciqASh9gv18V//HPvPpbZ1jm+v14vpval0pAutnaQihCiKIWKtZ8qCul39BoBuF4tTqbssvYCmEBDSt0+UkfCgPBSiGFQqaJjRJ0g5dp7Qo1xSa1BaOvbNfO7g9zzaQllW/AXwWh0GaB6YQIKRs9EHRmn/WJwB67S6hu/vm8ChFC0ZBJdoU+VnKlPsarQu0j4cjyLSoGNe/jHWeEcSY6GbDqMcFamHOqg2PCgsvbZPqHYvI2QWDrIf+7ZbIBusU4janrbk98aAj4XsGVZjsKVQZ64bFxidSRuWQkEtPzdETN80H+c8+PesfJlbjTG4rb/gJ/auFDWhnV9+BRv44y7EX7Z6R0IUqYBs/1HnVS46HOke5ThlQNQENduwpgJhmbbP1zbtxIBKrAjdgBW+16mYwWQTScQWqmJbPUln99ML46UpqMNuaes2WUEEIz+QxMXWQDgDD4ZDMay2ohXT3sFnwD4l/ocXfKllmq06rK9QbKRrhB1vruhvT5e0XuYU1NSkfgKAIOhA7ky5jTtwj3H6SkrKzrDWnNtATdQqTYDUzHFqRDLqEC9tuVtSxQ/mdxsENBS0ScIo4EZ6JIdwVZotfp7Y1tbAb/27tXE3oeX8+PfJqmVj1W/WkXSC3/QdSGinL3iaKxhhcBqwbs+EiJ5iXtSn6FxrHdMxogsC9Oy+pSD+i1sEsFGg4NC2x/06r79bHUWg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700016)(1800799024)(23010399003)(376014)(82310400026)(11063799006)(10067099003)(18002099003)(22082099003)(56012099006)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S904eX/9Pt54hcZ84Y3i1o68dY9w25MaofSsJu41Z6IZWwhaaGkdCmhbOM1YI2sws2DcD+kXVxO7UBVz4XvXn9/BjHFFN20tJqHqWssamME3I/RO+OGAcMgy4ZjsdsJW2GuXI2i608njnzrf8Sg1cvf89WkiDGe+LlP9MSNd08k5TCI4jx7DEw34dZJA6/k8ZDRfvgS73QhbVnr2Bl9GX8ekL6G0TV61w5iGeLoerlVVXsMzIdw6pWnA0w06afPUrfpvvpqQDeyMuLqKY+EtW983M2KlfuszbB8Yau5PXChRLXMNmurGh4ueAhEZ//CUiUG8DfYUC3wbvU5+q9XDz4oybxerAYyKU5zfKDQ22bPR7wDhpgh2QvHcrxWAQjJKvyC6opEZPlKso0/jv3ZUa48KeIaxPvm6EwnaPO+pZWDi8RAsysqC8VlWX25rjLX1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2026 00:58:11.8161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6356990d-ea77-43b6-2f25-08df11fb4010 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF000264B6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5682 The Alternate Injection feature is a method to protect a SNP guest from malicious injection attacks. It allows the guest to control the interrupt injection. When this feature is enabled, interrupts are injected with the help of an agent called a Secure VM Service Module (SVSM) which executes in the security realm of the guest and uses Restricted Injection as the sole method to receive interrupts from the hypervisor. Add support for Alternate Injection. Signed-off-by: Melody Wang --- arch/x86/Kconfig | 14 ++++++++++++++ arch/x86/boot/compressed/sev.c | 2 +- arch/x86/coco/core.c | 3 +++ arch/x86/coco/sev/core.c | 2 +- arch/x86/include/asm/msr-index.h | 4 ++-- include/linux/cc_platform.h | 8 ++++++++ tools/arch/x86/include/asm/msr-index.h | 4 ++-- 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5a84998b6021..330cf9245342 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -496,6 +496,20 @@ config AMD_SECURE_AVIC If you don't know what to do here, say N. +config AMD_ALTERNATE_INJ + bool "Support Alternate Injection" + depends on X86_X2APIC && AMD_MEM_ENCRYPT + help + Enable AMD Alternate Injection support for SNP guests. + + The Alternate Injection feature of SEV-SNP enhances the security of + a confidential VM by preventing the untrusted host from presenting + unexpected interrupts or exceptions, while still preserving the + standard interrupt dispatch semantics inherent to the x86 + architecture. + + If you don't know what to do here, say N. + config X86_POSTED_MSI bool "Enable MSI and MSI-x delivery by posted interrupts" depends on X86_64 && IRQ_REMAP diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c index c6512f2ea31e..fc2029746c50 100644 --- a/arch/x86/boot/compressed/sev.c +++ b/arch/x86/boot/compressed/sev.c @@ -179,7 +179,7 @@ bool sev_es_check_ghcb_fault(unsigned long address) #define SNP_FEATURES_IMPL_REQ (MSR_AMD64_SNP_VTOM | \ MSR_AMD64_SNP_REFLECT_VC | \ MSR_AMD64_SNP_RESTRICTED_INJ | \ - MSR_AMD64_SNP_ALT_INJ | \ + MSR_AMD64_SNP_ALTERNATE_INJ | \ MSR_AMD64_SNP_DEBUG_SWAP | \ MSR_AMD64_SNP_VMPL_SSS | \ MSR_AMD64_SNP_SECURE_TSC | \ diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c index 989ca9f72ba3..aabda3ddc0e2 100644 --- a/arch/x86/coco/core.c +++ b/arch/x86/coco/core.c @@ -107,6 +107,9 @@ static bool noinstr amd_cc_platform_has(enum cc_attr attr) case CC_ATTR_SNP_SECURE_AVIC: return sev_status & MSR_AMD64_SNP_SECURE_AVIC; + case CC_ATTR_SNP_ALTERNATE_INJECTION: + return sev_status & MSR_AMD64_SNP_ALTERNATE_INJ; + default: return false; } diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index cc292d7c6fd1..c54269366278 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -78,7 +78,7 @@ static const char * const sev_status_feat_names[] = { [MSR_AMD64_SNP_VTOM_BIT] = "vTom", [MSR_AMD64_SNP_REFLECT_VC_BIT] = "ReflectVC", [MSR_AMD64_SNP_RESTRICTED_INJ_BIT] = "RI", - [MSR_AMD64_SNP_ALT_INJ_BIT] = "AI", + [MSR_AMD64_SNP_ALTERNATE_INJ_BIT] = "AI", [MSR_AMD64_SNP_DEBUG_SWAP_BIT] = "DebugSwap", [MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT] = "NoHostIBS", [MSR_AMD64_SNP_BTB_ISOLATION_BIT] = "BTBIsol", diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 428eb44106a9..bedc9a62d0b4 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -728,8 +728,8 @@ #define MSR_AMD64_SNP_REFLECT_VC BIT_ULL(MSR_AMD64_SNP_REFLECT_VC_BIT) #define MSR_AMD64_SNP_RESTRICTED_INJ_BIT 5 #define MSR_AMD64_SNP_RESTRICTED_INJ BIT_ULL(MSR_AMD64_SNP_RESTRICTED_INJ_BIT) -#define MSR_AMD64_SNP_ALT_INJ_BIT 6 -#define MSR_AMD64_SNP_ALT_INJ BIT_ULL(MSR_AMD64_SNP_ALT_INJ_BIT) +#define MSR_AMD64_SNP_ALTERNATE_INJ_BIT 6 +#define MSR_AMD64_SNP_ALTERNATE_INJ BIT_ULL(MSR_AMD64_SNP_ALTERNATE_INJ_BIT) #define MSR_AMD64_SNP_DEBUG_SWAP_BIT 7 #define MSR_AMD64_SNP_DEBUG_SWAP BIT_ULL(MSR_AMD64_SNP_DEBUG_SWAP_BIT) #define MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT 8 diff --git a/include/linux/cc_platform.h b/include/linux/cc_platform.h index 559353ad64ac..80d9f1de2ae8 100644 --- a/include/linux/cc_platform.h +++ b/include/linux/cc_platform.h @@ -104,6 +104,14 @@ enum cc_attr { * to run SEV-SNP guests with full Secure AVIC capabilities. */ CC_ATTR_SNP_SECURE_AVIC, + + /** + * @CC_ATTR_SNP_ALTERNATE_INJECTION: AMD Alternate Injection enabled. + * + * A Secure VM Service Module (SVSM) has started the guest with + * Alternate Injection enabled. + */ + CC_ATTR_SNP_ALTERNATE_INJECTION, }; #ifdef CONFIG_ARCH_HAS_CC_PLATFORM diff --git a/tools/arch/x86/include/asm/msr-index.h b/tools/arch/x86/include/asm/msr-index.h index 18c4be75e927..e4eab2210518 100644 --- a/tools/arch/x86/include/asm/msr-index.h +++ b/tools/arch/x86/include/asm/msr-index.h @@ -721,8 +721,8 @@ #define MSR_AMD64_SNP_REFLECT_VC BIT_ULL(MSR_AMD64_SNP_REFLECT_VC_BIT) #define MSR_AMD64_SNP_RESTRICTED_INJ_BIT 5 #define MSR_AMD64_SNP_RESTRICTED_INJ BIT_ULL(MSR_AMD64_SNP_RESTRICTED_INJ_BIT) -#define MSR_AMD64_SNP_ALT_INJ_BIT 6 -#define MSR_AMD64_SNP_ALT_INJ BIT_ULL(MSR_AMD64_SNP_ALT_INJ_BIT) +#define MSR_AMD64_SNP_ALTERNATE_INJ_BIT 6 +#define MSR_AMD64_SNP_ALTERNATE_INJ BIT_ULL(MSR_AMD64_SNP_ALTERNATE_INJ_BIT) #define MSR_AMD64_SNP_DEBUG_SWAP_BIT 7 #define MSR_AMD64_SNP_DEBUG_SWAP BIT_ULL(MSR_AMD64_SNP_DEBUG_SWAP_BIT) #define MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT 8 -- 2.43.0