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.193.3 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796510113; b=oB3oEkG7RuIbeA6XMDxfx9dvv6IgrVl1GhKaFCGozJ3EqZiCH7Xdbk6Jun/f7Sth7nKq pDmq0vmwub3rmiHT7sv5uCkq/JQmy15X2tZ9G3S5fTr3jugcb82/4r/MQDjaihXN6r3V6 UVlerYFwSxW+G9WhXnApT4hbjsklWllTdCWNZMrwJxta5Xhw3cZz1HDfzpTyxZUyX3UkQ nB5gWdMjoeCkat4BGJB67BFTF4VY6RQNaFbpKWnjT2aVe9bzWW08vjKe8Hc/QC5z6GG/a F6sJfWTVSQeuPsqFCqsd0tJGCqFxyd6Pn/+XPXmW+jb3cbTezu0aiunXeFsJV6ZWtBg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796510113; 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=79AeaQ8WmVSoiTWl9LiVFFbF6yko5tjPOMRQ5OeEapw=; b=1Z9qt13eylCpUiE3Dh3bPadcWI/rM3m/BqsB9pY/YG48S1M0w9mZMVeqb5+/610pvzBG +xeKfypR0PAyCBBxC28a5Y0vrT4rWptmSpN2wb0tXok8hwEMKI+jR73UZggNLzllkBVVx mAev1AWyw/onLt1SETavHJyWnzDE+dwCnQagwQrPAQ4lA/eJEyALs40CYZhrGQ5wbDzp9 Y9toQauS7DhjHCgv4nHLVrSqXcGoZnyZFwedKFn2OXB/lPlU6JdCmdLeJd96avHcuT6/E Q3c5WjUG86Pae/b7gerCWxXTNL9RgMzwCvMYTjUKIu7XTHlkBHKRhwQ4Mf9LDM9KbHg== 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=Rz8d68aR; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.193.3 Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010003.outbound.protection.outlook.com [52.101.193.3]) (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 92F7B606A31F; Sat, 5 Dec 2026 22:35:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 92F7B606A31F 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=Rz8d68aR ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bm7U69H/GG2UrpdUEhfuFvcuPspdwsSGuZzSw39vpzJ9FQy09zmf87ow2BI+y3lucFFQ2+TDsLI8+j1QwjqRlNKvvYzTRVkD2+Hj/Imh1Qld6Xi+8NIIbeOSzJkPbzMB9hgEHi2GT0AIlXBuYrjdcbIPTyIvBRH8WM/i8U2ERbUaEiLFRaTcXzaXdnEGJkrbygdQlRbNLGYq1k5Hq3YyXkp5c8CzA1UC0ybbcidQOTRZFZTsr2DKYIuPmq3VVnBk6FWLfZw2DsLt7IDgYQEwA/xCNw1xRAx30rVg3QXw0cJ+4wUeGj/X7TuDx54hBI8IYUz6TAOTMWr2uxxfeapg2A== 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=79AeaQ8WmVSoiTWl9LiVFFbF6yko5tjPOMRQ5OeEapw=; b=G5LODBNmGmftGeGRBTGX0PkCrYkVY+oF1xrSoFypIxxn4ypY3wEYAVNOqbMQoAH5B+STKmIqkjqP8CPoOP1Iq745juEa2FZAaOolUxaQsqgv7c4lndAEbXnbDMZSv32WbeQMvmiVGeRaAjK8fUUTOoJ9qmVd7akPu+4/Kp4oVLWo5+Qx820WjgMdWHPynAGGRPH+Jtbt257WilCKYkkpA8p4r383iBjLjtZYnQFVnUvWv678hvNCGWJJl60319o5mKC9shFqByfBdZYQg60B4nyDqt2+6lODJ/N4LE6+HDcg6R1deRFwYNVmdz5q2bjRuyoqf1q0AnR0P6o7ZN1N3Q== 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=79AeaQ8WmVSoiTWl9LiVFFbF6yko5tjPOMRQ5OeEapw=; b=Rz8d68aRGq2zFIsvoVC5uuh+V/YPGNjLCdjIaEr16mfh4dxgdwhok/lBGcx9qJ/Je4K4Axb+sIFg/VHNTkPA+mFHqD3u5OKWpbGRbfb1rQjvzjkmlNkS5E8ix+UvpauSCuK8Ly9yfbh85sfiE5RE/ujWK2d25LIN2Ko18rjO3bE= Received: from BYAPR01CA0051.prod.exchangelabs.com (2603:10b6:a03:94::15) by CY8PR12MB7097.namprd12.prod.outlook.com (2603:10b6:930:51::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Sat, 5 Dec 2026 22:35:07 +0000 Received: from SJ1PEPF000037AD.namprd03.prod.outlook.com (2603:10b6:a03:94:cafe::3a) by BYAPR01CA0051.outlook.office365.com (2603:10b6:a03:94::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Sat, 5 Dec 2026 22:35:07 +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 SJ1PEPF000037AD.mail.protection.outlook.com (10.167.244.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Sat, 5 Dec 2026 22:35:07 +0000 Received: from speedway8455host.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 16:35:06 -0600 From: "Pratik R. Sampat" To: , , , CC: , , , , , , , , , , , , , Subject: [Patch v6 0/3] Host support for SMT and Enhanced SMT Protection Date: Sat, 5 Dec 2026 22:34:57 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-doc@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: 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: SJ1PEPF000037AD:EE_|CY8PR12MB7097:EE_ X-MS-Office365-Filtering-Correlation-Id: 72abf8f4-42b5-47c8-42ad-08df53200376 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|36860700016|7416014|376014|1800799024|11063799006|6133799003|18002099003|3023799007|13003099007|260925021911599003|260925022911599003|10067099003|260925021311599003|56012099006|261022075727099003|261022105027099003|261026140227099003|261026121527099003|261028144727099003|261021121427099003|261102123227099003|261021123027099003|261009223027099003; X-Microsoft-Antispam-Message-Info: 1x2/m8FI6WaUXaGT/zBEI7h+TZSXc0iqxZCNyRNM25G1tCo79BSMco3chZFPF6Y8QtygMyjrp5cLCx1gwTg2+qw90lkos+ZFhFPqHiWKvcXYG9nRX4fwN4NIGchuNKEqR4vPHs1f6ezsiTu5LO9ZfO7+svmOFjGRO8R5iw/fC79kBX824luoKqzhjz548OXZI8asA6um1uqzdNOqIxeIYeAvzeR0b+9Lpj18JVHHSH7JzMErRBouqxl91nG4+LstPzfE/ztl3W2xsJyR9cenRHn20SwqV5N1M4T8s42RkbuRGILxXfxqXNJmwxr3IgbwU7cPBfZawoZacBxCq+JQDVypYkjhL+2pDG6RI3EcBvBYCx6PtkrQUDQodefttDxNSTAgeV6/yKq8XyYKWYlfrD5dnnhg/FHXyUQWz9QMPyrnwXcYKnTNlkgDmjoxTBIZP5yl7WT9V1DLaK8Ql3VgX1p0OWX4WjR2dVY4ZX9RNUn4o1M1NNqpbHeu+87pOZSXo07W3PAQ6Kj/mIdtLcqlyuiOcU7qEAQIljneBC5po9qcHejiQgy+T+ila2rl3Yi/Vf3StCaG2R73LiPnYN1oauVazrTA1ke1nukgb/o6huDjea5kMyezVCDiKyofEjjMy8feBgAkm4UEV5zNn3xW8w== 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)(23010399003)(82310400026)(36860700016)(7416014)(376014)(1800799024)(11063799006)(6133799003)(18002099003)(3023799007)(13003099007)(260925021911599003)(260925022911599003)(10067099003)(260925021311599003)(56012099006)(261022075727099003)(261022105027099003)(261026140227099003)(261026121527099003)(261028144727099003)(261021121427099003)(261102123227099003)(261021123027099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B4rnKVeTmUL74zV+5Es8UvsmNnjzME7RCWX5f073ZRQ31axUy8kQVuO0xR2nLs/K2+SwfgQWQ78CrzDgsEEg4/j6Y/ZhOrxNQO7aIcoE2PyD5SkEtqrXirzhk0UR78yOn6qqUtNWuHbCC7MtnvX5xSC3kacO9JjuLVLlNwXbv/pQ+JpFJ8wGdQ6zMGPACuAqPD23Mdxqi7k8blBpKzKjzMRuaUkRube+GYWo4dayMB7yNa2z/aTet5HEt0zVAnY7CHALHCzkVmbmYnNr51fNOhpqjnQe8blbVQnNMmRenIKcPh8xYMQwc9chIj2ZhZUn+N30LrvXSF8lsrGDm83DhxI3jS5KLGi2xMJRSCaqGuQrN67Ye7o8eDuqyIrqvzX3xYpXMXBKrOIrrP7q1LGoWGpObvmJ3iEa3s5j2DnzFWC5d6szUlzi/slejCpHLyF7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2026 22:35:07.0760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72abf8f4-42b5-47c8-42ad-08df53200376 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: SJ1PEPF000037AD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7097 SMT Protection (SMTP) and Enhanced SMT Protection (ESMTP) let an SEV-SNP VM control what may run on the SMT sibling of a thread that is executing one of its vCPUs. This mitigates the side-channel risk of sharing core resources with untrusted host threads or with another guest. SMTP (Zen 4 and later) requires every sibling thread on the physical core to be idle in host mode while the vCPU is in guest mode, which gives up half of every core the VM runs on. ESMTP (Zen 5 and later) relaxes that: a sibling may also run a vCPU the guest has declared a legal sibling. A legal sibling is another ESMTP vCPU of the same guest (matching ASID) with the same VCPU_SIBLING_MASK and the same VCPU_ID outside that mask. Unlike core scheduling, where co-residency is a host kernel policy expressed with cookies, both features are enforced by hardware. For ESMTP the policy lives in the VMSA. The host is not trusted to keep its own kernel, userspace, or interrupt-handling work off a sibling thread while a protected vCPU is in guest mode. Series ---------- Patch 1 is a prerequisite. KVM has assumed that a #VMEXIT with EVENTINJ still valid only happens on VMEXIT_INVALID, after which the guest is torn down. With SMTP and ESMTP, VMRUN can end with an ordinary exit code without entering guest mode, so the staged event was never delivered. Detect that in svm_complete_interrupts() and requeue the event instead of dropping it. Patch 2 adds SMTP: the CPUID feature bit, IDLE_WAKEUP_ICR, retrying VMRUN on VMEXIT_IDLE_REQUIRED, and advertising SVM_SEV_FEAT_SMTP through KVM_X86_SEV_VMSA_FEATURES so userspace can request it with KVM_SEV_INIT2. IDLE_WAKEUP_ICR is programmed on each CPU when virtualization is enabled on it. Patch 3 adds ESMTP on top: the scattered CPUID bit, the VMCB timeout field, retrying the three new exits, populating VCPU_ID and VCPU_SIBLING_MASK in the launch VMSAs KVM builds, KVM fully sets VCPU_SIBLING_MASK, as the guest does for its APs, so every vCPU of the guest may be co-resident with any other. Merging ------- Following the discussion on v4, guest and host support are now split into separate series to untangle x86 and KVM. Since the guest series from v5 is now pushed to tip, this series adds the KVM host side. 8509996df261 ("x86/sev: Add Enhanced SMT Protection fields to the VMSA") 0d4aa2a4f846 ("x86/sev: Add guest support for Enhanced SMT Protection") SMTP needs no guest changes. Testing ------- It is tested with the v5 guest patches and patched OVMF [1] and QEMU [2] builds. Launch an SEV-SNP guest with ESMTP enabled on the sev-snp-guest object: For SMTP: -object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,smtp=on Or, For ESMTP: -object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,esmtp=on SMTP and ESMTP are mutually exclusive. The guest reports the feature in dmesg among the SNP feature names: # dmesg | grep -i SEV ... SEV-SNP ... SMTProt ... Or, ... SEV-SNP ... ESMTProt ... To check the sibling behaviour on an SMT=2 host: * Identify a sibling pair X and Y on the host: cat /sys/devices/system/cpu/cpuX/topology/thread_siblings_list * Pin two of the guest's vCPUs to X and Y. * Load both vCPUs in the guest, e.g. stress-ng --cpu 2. * With SMTP: host CPUs should show 50% guest utilization each, since the two vCPUs cannot run together at once and one sibling thread must idle when the other runs. * With ESMTP: Both host CPUs should show 100% guest utilization, since the two vCPUs are legal siblings. * Start a host task on one of the pair, e.g. taskset -c X stress-ng --cpu 1. CPU X's time should now be split between host and guest. * With SMTP: guest utilization on CPU Y should remain relatively unchanged since it already must remain idle regardless of what runs on CPU X. * With ESMTP: guest utilization on CPU Y should drop, since the vCPU on Y cannot enter guest mode while the host task runs on X. Based on tip/master. v6: * Host support only. Guest support was split out in v5 and is in tip. * New patch 2: host support for regular SMT Protection. SMTP is less flexible than ESMTP, since it keeps the sibling idle instead of allowing a legal sibling vCPU, but ESMTP needs Zen 5 or later while SMTP is available from Zen 4. * Move IDLE_WAKEUP_ICR programming which is used by both SMTP and ESMTP to the former patch. Since functionally the patch remains the, retaining reviewed-by's. * Patch 1: update the commit message and comment to cover SMTP as well as ESMTP. * Patch 3: reject KVM_SEV_INIT2 requests that set both SMTP and ESMTP, now that KVM can advertise both. v5: https://lore.kernel.org/kvm/cover.1794935627.git.prsampat@amd.com/ * Split guest and host support into separate series, per Sean and Boris [4]. This series carries guest support only. * New patch 1: move the VCPU_ID/VCPU_SIBLING_MASK VMSA definitions out of the KVM host patch so that the guest side builds on its own. Retaining Tom's reviewed-by since it is functionally unchanged. * Drop the sibling-mask comments from patches 2 and 3 - Boris * Rebase onto tip/master. v4: https://lore.kernel.org/all/cover.1794244450.git.prsampat@amd.com/ * Fix conflict of reserved bits introduced by PML support in vmcb_control_area v3: https://lore.kernel.org/kvm/cover.1792184487.git.prsampat@amd.com * Collected Reviewed-by tags - Tom * Use sev_status to determine SNP support for guest as well - Tom * Not syncing the tools/ copy of msr-index.h, since several bits apart from ESMTP differ and the perf tooling maintainers usually sync it. Happy to add a sync patch if needed. v2: https://lore.kernel.org/kvm/cover.1791302373.git.prsampat@amd.com/ * Populate the ESMTP VMSA fields for Hyper-V AP bring-up - Sashiko * Add ESMTP to SNP_FEATURES_IMPL and SNP_FEATURES_IMPL_REQ - local Sashiko instance v1: https://lore.kernel.org/kvm/cover.1789399214.git.prsampat@amd.com [1]: https://github.com/tianocore/edk2/pull/13128 [2]: https://lists.nongnu.org/archive/html/qemu-devel/2026-12/msg01488.html [3]: https://lore.kernel.org/all/avc-5lkQhoR6US9o@google.com/ Pratik R. Sampat (3): KVM: SVM: Re-queue events that were never injected KVM: SVM: Add host support for SMT Protection KVM: SVM: Add host support for Enhanced SMT Protection .../admin-guide/kernel-parameters.txt | 19 ++++++ arch/x86/include/asm/cpufeatures.h | 2 + arch/x86/include/asm/msr-index.h | 1 + arch/x86/include/asm/svm.h | 5 +- arch/x86/include/uapi/asm/svm.h | 11 +++- arch/x86/kernel/cpu/scattered.c | 1 + arch/x86/kvm/svm/sev.c | 58 ++++++++++++++++++- arch/x86/kvm/svm/svm.c | 42 ++++++++++++-- arch/x86/kvm/svm/svm.h | 2 + 9 files changed, 134 insertions(+), 7 deletions(-) -- 2.43.0