From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.51 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796534013; b=LUBtruU13wFMVkva0MCnq2bCXuzF7oh0uk8lNJgS4GTsCR4E2vSqJ9sRdP5NaviPoMzO GVmoQF6DBvDo9aOReXy/FR+DQ/+LLqTZfhvc3RzU2BEG+AfygXzZiuAxK5xJ+196xU1bk JcqgSd1TgCZQbywHD1mOe2wxknRTili0rJxfGZiXbUw0OZAo72t61BR+Xh3CPs/B8cfit yVYo7VVLuTU7+Tnpfj2S5QWxLtnoxIzj9lRHgOplmyF8BnyfySQCC9kPu4w5KRsDdU7dP MQzw/Mjyx1isrokXzlsxt7S0G2j9Fha2rz3m5S7DT2QrYFTjhgZzW0W/WdN2Gtvf+hg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796534013; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=iCFMzjgjz5gOpGAk427IDjYtKLkwNHTuvkmU/LLCpYU=; b=XxCJXfbvQ5U04MOb30fxFqjw7KCDexhjySFpe7By41aotDAAugjW9h2W+4vKDcRjVnsQ xjJnaCZjqDud780g2yLVovD1EAnpLaQe3eRHUKD9RJIdjLUgy1yQG5X8pd7Ji8NX3pU5c RCi0xbXl29a88J1euqUtFcDBK5MeaHhn3ucN+8oZ4ZqNlTw96C2Iw0zwBBmbKNRdkqs9z Cs/Mb+sJZf7hFRGVH1x/Yb4lqFdf4yYOZ6eGBwQFBSKoBgM8AaymhbRofKYR6WlK4JbL7 REO7Jx8nQ6MVyd/cZ3n9dcj2LQxjNPOVD8rKtz3CjxC6+Js0WLF3hgyOlEUDV0kBR9g== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Ec3ZwKJs; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.51 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011051.outbound.protection.outlook.com [52.101.57.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2912606A31F for ; Sun, 6 Dec 2026 05:13:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C2912606A31F 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Ec3ZwKJs ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P27xBMWxue4vwzjR4SuadoUunsFqxF2lvObFenZbptAgZ2axm1BDp7/fb/QP3SYOKh3PuiUsh0yXIccSToaxIIawsVB/ZXaR31xRjCM7LBm3X7BE9M7NWkpO38Xw4tYuqt2kAaO57DVX+5EZaToxvaOw4EfShU33amlrenaeN1nNHsoLTSsYi4J6h77M4hcMOtUD/FT5HKELpAHR9x835EEe6JffFRXO7rcGhxQKan0Y6nO555G1WwNPJl7Mfbio0zs76VP59ACq0f0opTVYGQZUxO1yaqev45FxNSQrXDedsSERfJrwLO2oAoWZnHoFH+CaFZXhp996ALslcciKIw== 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=iCFMzjgjz5gOpGAk427IDjYtKLkwNHTuvkmU/LLCpYU=; b=bjUPH68g1XCZWxn8k/zGWvD7v/fF77/yBTRhhpRE6+bQgWc9fFkJAlSOCmX1/jCYY8k2hMsLuZ5KBlHkj+5ma+wNDT9lh/nRga/VFNGpLG0Rezv0p5qaWkao9+D4zdO/p2ya8zRF0LaMbCPW377dzD1gGB/CoMIdQQLmY7NK/T5hTPdnq6tNrJAlgaEt8//sNpdEUucW7+in7HKrvTllnqD1DaPF1pL6XORDcp2Fl8h4eTzDNLOBJ645ITxZ39yawryTMD0aH5NgV4aQsL2EgaT9E8FCQbFsVedE5UHMLyZ78MA/ddAE+auIZFnaXDh8kKy3X3HG4DTvAtnXBbnvJg== 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=iCFMzjgjz5gOpGAk427IDjYtKLkwNHTuvkmU/LLCpYU=; b=Ec3ZwKJsNtpojyzQOrkJ9SmuO5pm/tDAFDtrD8y9r5f+D2J0jBeqka7K6zr+ox4OjXFm/AMAUCM/SBvX/jkSCX4a+4yYhPHJjvVXwQYh71A24/yQj1EoSZpQl0bSezsKf9glEtXKQJ31w7SdX76r/oQKUAiwzeg7bEYxhAnLXsg= Received: from CH0PR07CA0026.namprd07.prod.outlook.com (2603:10b6:610:32::31) by CH3PR12MB8355.namprd12.prod.outlook.com (2603:10b6:610:131::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.15; Sun, 6 Dec 2026 05:13:28 +0000 Received: from CH1PEPF0005BD5B.namprd02.prod.outlook.com (2603:10b6:610:32:cafe::49) by CH0PR07CA0026.outlook.office365.com (2603:10b6:610:32::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.15 via Frontend Transport; Sun, 6 Dec 2026 05:13:28 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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 CH1PEPF0005BD5B.mail.protection.outlook.com (10.167.244.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Sun, 6 Dec 2026 05:13:27 +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.57; Sat, 5 Dec 2026 23:13:26 -0600 From: Melody Wang To: CC: LKML , Tom Lendacky , , Melody Wang Subject: [PATCH v7 00/10] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Date: Sun, 6 Dec 2026 05:13:02 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0005BD5B:EE_|CH3PR12MB8355:EE_ X-MS-Office365-Filtering-Correlation-Id: 5207b0d6-0ace-409b-d99d-08df5357a968 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|23010399003|1800799024|36860700016|11063799006|6133799003|261009223027099003|261021135927099003|261021121427099003|261021123027099003|261021130227099003|3023799007|18002099003|56012099006|261102130727099003|261102123227099003|261026121527099003|261026140227099003|261022115727099003|261026130827099003|261022113327099003|261022075727099003|261022105027099003|261028144727099003|10067099003; X-Microsoft-Antispam-Message-Info: HImHylufqIl7SIoXl/VR5W2GwFcYH43A6ne0OWHr4rzAkleA0xQGI9IWz5I1TZvFJRBlT1yvTNHb0f+O5H+BYeeC/JVbg6g1t+FjQ9K5/XGwsfNc+CRbwGm9FeZbqx17tsd5ktL/aPSoB7ts/sgYiVKgdUGP30tgq9F7rltAXc5L1E/3294ZMCUhWprihdzEJxMd2qPKCTI9jNe2VBFC0YFn3fwfaA9FM+q6xRYbhMYYaiZKuP3j1UA+XAd7TYaR62C7M/IoZZGGBURi8q2Pmrav9HBNAKZKN5amJA1cdMAIxY3CEAgkeEWK9sse0l01UDo7UBDbcOubUqPkxAJr9iWILhCpcvVBpFzxdKCkkgLTavQimkVN7oq4A/+ZQcyVYEpsfPVXyDQD/4UAni+9wua8l7wUu1NUD6PHVj3CikvWBVri05076crXdacUhOXdseE+AOVmaF3z1iHUUSMgSMFSZzPV2RzOfRucPzedW5Wzx5mr42j75URsG0oGFmqUdyoS2s+pbmtIhvdTOed2npG/b8wPdPgk4Ab5q9pFxmE6hhxRuY3aFcxFN1YQYY+YjgP56KD5vpo2GuLdYtFO8WckBotUpDCP68TA59JgEy3tayHw6Ee3zHg6YJc35coPGqYTSIXSrUClxziYFwYK5uW8Om1DY9AAkc17WtnPOysWm0WRdsqj3W0hkkoH8Km2MtR3wljsPiBDpWFmfDEUZg== 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)(82310400026)(376014)(23010399003)(1800799024)(36860700016)(11063799006)(6133799003)(261009223027099003)(261021135927099003)(261021121427099003)(261021123027099003)(261021130227099003)(3023799007)(18002099003)(56012099006)(261102130727099003)(261102123227099003)(261026121527099003)(261026140227099003)(261022115727099003)(261026130827099003)(261022113327099003)(261022075727099003)(261022105027099003)(261028144727099003)(10067099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cf1uZHq3V/NYW1CSRn7/QpRT3yn6Rq8gmUUO1lY17T/edYsV/WGsQZLwcCYYnAUFo5Fn/H5L2fNg34RlURs+aWj08ViHDFwaHEBnEV+prHsV4R8iDSpAp4kQAVt5ac1YMPdGbRVSSafiG0FmIe3WEJ5HaICSU6+i+0AKmya5AY3vdFcj8y7Sr7yKWyzidEzNC2TAslCNFszZKfAWjrz9+M+2DBUmApZ//Wuq+Dc5eqSKHSgZs47esxXdEqEOmUj7ycDVQl2i9LMxDLhjVjDJGRw1PHJ65e6yWOYrqpy2QWauCGMRluOoyzPF0jx+YuPHBIVhoARiht0+EX9qG2xaAfd8F+z0yZxGBJ6eFrfCY45OXjNInGW2ZAFYNIwQxIKQc0SHuLYjvl1A+OscyOeH5g7+wkyoC+jwO7qmxUXQqVIHB8Nwn/YjgOFkeVqCHIox X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2026 05:13:27.8794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5207b0d6-0ace-409b-d99d-08df5357a968 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: CH1PEPF0005BD5B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8355 Hi all, This revision addresses all review comments from version 6. 1. Added three pre-patches to fix the problem that a nested SVSM call on the same CPU clobbers the arguments of the call it interrupted. 2. Changed some commit messages for better understanding. 3. Some minor code fixes from the review comments of Tom and Boris. Thanks, Melody Changelog: v6 -- This revision addresses all version 5 review comments from Sashiko. Key Changes 1. svsm_apic driver cleanups: Removed the read-only MSR from the SVSM APIC filter in svsm_apic_msr_write(), and the write-only MSR from svsm_apic_msr_read(). 2. Clarified and updated the commit message for patch 5 to improve readability and context. v5 -- This revision addresses all review comments from version 4. 1. As Ard suggested, used a bool as return value for svsm_register_alt_inj() instead of int. Adjusted code with it. 2. Added more comments here for better understanding. v4 -- This revision addresses all review comments from version 3. 1. As Ard suggested, handed over the registeration of kernel guest for Alternate Injection with the SVSM to the OVMF insteading of calling the SVSM for registration from kernel guest before ExitBootsService(). 2. Added a common function for SVSM APIC ICR read and write. 3. Added a common function for sev_apic_ghcb_msr_read/write. 4. Changed some comments for better understanding. 5. Patch "Make-SVSM-calls-preemption-safe.patch" was merged to the tip tree. v3 -- This revision addresses all review comments from version 2. The changes include: 1. Moved sev_prepare() from decompressor to EFI stub. 2. Changed "Register Alternate Injection" and "configure all interrupt vectors" as two APIs located in compressed/sev.c since they are self-contained, avoiding exporting functions. 3. Added more comments for better understanding. v2 -- This revision fixes all the review comments from version 1. The changes include: 1. Changed a few comments for better understanding, deleted some unnecessary code, corrected some typos, and some minor code fixes from the review comments by Sashiko and Boris. 2. Unified sev_apic_ghcb_msr_write() and sev_apic_ghcb_msr_read(). 3. Move x2apic_svsm.o after x2apic_savic.o so that the secure AVIC gets preferred on machines supporting it. 4. Reworked svsm_apic_probe() as Boris suggested. 5. Updated tools with renamed MSR_AMD64_SNP_ALTERNATE_INJ_BIT and MSR_AMD64_SNP_ALT_INJ for completeness' sake. 6. Changed svsm_apic_send_IPI_self() with writing to the dedicated APIC_SELF_IPI instead of writing to APIC_ICR. v1 -- The revision fixes all of the review comments from version 0. The changes include: 1. Changed a few commit messages, new file names, variables name and order, function names and more comments for better understanding. 2. Added a pre-patch to fix the problem that in two functions in the the SVSM vTPM guest implementation do not disable preemption when fetching CAA. It is moving the CAA fetching operation inside svsm_perform_call_protocol(). This series relies on this fix too. 3. Removed svsm_do_call() helper function and some intermediary layer functions in SVSM APIC driver. 4. Removed the Secure AVIC check in SVSM APIC driver since it will never be touched. 5. Terminate boot when Alternate Injection is enabled in vmpl0. 6. Added a common function for SVSM APIC read and write. 7. Added a new SEV_TERM_SET_LINUX value for Alternate Injection and APIC ghcb msr read/write. 8. Reworked sev_prepare() to reflect the error conditions correctly. 9. Moved allowing all of interrupts right after registering the SVSM APIC protocol. v0 -- Alternate Injection is a method to provide secure interrupt delivery for SEV-SNP guests against malicious injection attacks. By handing over the control of the interrupt injection to the guest itself, the security is applied. Alternate Injection use Secure VM Service Module (SVSM), and APIC emulation in the SVSM to secure interrupt delivery. This is the guest side patches. The patch set includes the following: 1. Add support for enabling Alternate Injection. 2. Add support for the SVSM APIC protocol which uses a subset of the X2APIC MSRs. 3. Add support to allow the guest OS to request Alternate Injection. Melody Wang (10): x86/sev: Add per-CPU CA runtime data and CA get/put helpers x86/sev: Switch the CA from per-CPU variables to the per-CPU runtime data x86/sev: Implement backup CA x86/sev: Add a config option for Alternate Injection x86/apic: Add an SVSM APIC driver x86/sev: Route unsupported APIC register accesses to the hypervisor APIC emulation x86/sev: Add a function to contain all SEV-specific setup operations x86/sev: Register Alternate Injection protocol during OVMF boot x86/sev: Allow the guest to configure interrupt vectors for the hypervisor x86/sev: Indicate that Alternate Injection is supported in the guest arch/x86/Kconfig | 14 ++ arch/x86/boot/compressed/sev.c | 11 +- arch/x86/boot/startup/sev-startup.c | 20 ++ arch/x86/boot/startup/sme.c | 3 + arch/x86/coco/core.c | 3 + arch/x86/coco/sev/core.c | 96 +++++----- arch/x86/coco/sev/internal.h | 74 +++++-- arch/x86/coco/sev/noinstr.c | 76 ++++++++ arch/x86/coco/sev/svsm.c | 17 +- arch/x86/coco/sev/vc-handle.c | 4 +- arch/x86/include/asm/msr-index.h | 4 +- arch/x86/include/asm/sev-common.h | 2 + arch/x86/include/asm/sev.h | 26 ++- arch/x86/kernel/apic/Makefile | 1 + arch/x86/kernel/apic/x2apic_savic.c | 8 +- arch/x86/kernel/apic/x2apic_svsm.c | 245 ++++++++++++++++++++++++ drivers/firmware/efi/libstub/efistub.h | 11 ++ drivers/firmware/efi/libstub/x86-stub.c | 45 ++++- include/linux/cc_platform.h | 8 + include/linux/efi.h | 2 + tools/arch/x86/include/asm/msr-index.h | 4 +- 21 files changed, 591 insertions(+), 83 deletions(-) create mode 100644 arch/x86/kernel/apic/x2apic_svsm.c -- 2.43.0