Guest support for Enhanced SMT Protection
Get series with b4
b4 am [email protected]Versions newest first
- v5 Latest3 patches 0 repliesNew
Changes in v5 from the cover letter
* 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.
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | x86/sev: Add Enhanced SMT Protection fields to the VMSAarch/ | +7 | 0 replies | |
| 2/3 | x86/sev: Add guest support for Enhanced SMT Protectionarch/ arch/ arch/ | +14 | 0 replies | |
| 3/3 | x86/hyperv: Add guest support for Enhanced SMT Protectionarch/ | +5 | 0 replies |
Reviews trailers per patch
2 of 3 patches have a Reviewed-by or Acked-by.
| Patch | Tom Lendacky |
|---|---|
| 1/3 | R-b |
| 2/3 | R-b |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [Patch v5 0/3] Guest support for Enhanced SMT Protection
Enhanced SMT Protection (ESMTP) allows an SEV-SNP VM to require that, while one of its vCPUs is in guest mode, every SMT sibling thread on that physical core is either idle in host mode or running a vCPU the guest itself has declared a legal sibling. This mitigates the side-channel risk of sharing core resources with untrusted host threads or with another guest.
Unlike core scheduling, where co-residency is a host kernel policy expressed with cookies, ESMTP is enforced by hardware. The sibling mask lives in the VMSA. The host is not trusted to run arbitrary kernel, userspace, or interrupt-handling work on a sibling thread while an ESMTP vCPU is active on that core.
This series adds the guest side. The VMM enables ESMTP for an SNP guest through SEV_FEATURES[17], and the guest observes it as SEV_STATUS[19]. Two new VMSA fields carry the policy: VCPU_ID identifies the vCPU within the guest, and VCPU_SIBLING_MASK selects which of its peers it may share a physical core with. Two vCPUs are legal siblings when both are ESMTP vCPUs of the same guest (matching ASID), their VCPU_SIBLING_MASK values match, and their VCPU_IDs agree outside that mask.
Merging
-------
Following the discussion on v4 [4], guest and host support are now split into separate series to untangle x86 and KVM. This series only touches guest code and the VMSA definitions it needs, has no dependency on KVM, and is meant to go through tip. Nothing changes for a guest unless the hypervisor enables ESMTP, so it is safe to merge ahead of host support. KVM host support will be posted separately, potentially on top of the scattered.c rework as suggested by Boris and Sean.
Testing
-------
End-to-end testing needs the host support, which is not part of this series. It was tested with the v4 host patches and patched OVMF [1] and QEMU [2] builds. Launch an SEV-SNP guest with ESMTP enabled on the sev-snp-guest object:
-object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,esmtp=on
The guest reports the feature in dmesg among the SNP feature names:
# dmesg | grep -i SEV ... 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. 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, and 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.
v5:
* 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.
Host-side changes from v1-v4 are left out below and will be listed in the KVM series.
v4: https://lore.kernel.org/all/[email protected]/
* Fix conflict of reserved bits introduced by PML support in vmcb_control_area
v3: https://lore.kernel.org/kvm/[email protected]
* 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/[email protected]/
* 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/[email protected]
[1]: https://github.com/tianocore/edk2/pull/13128
[2]: https://lore.kernel.org/qemu-devel/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/
Pratik R. Sampat (3):
x86/sev: Add Enhanced SMT Protection fields to the VMSA x86/sev: Add guest support for Enhanced SMT Protection x86/hyperv: Add guest support for Enhanced SMT Protection
arch/x86/boot/compressed/sev.c | 6 ++++-- arch/x86/coco/sev/core.c | 7 +++++++ arch/x86/hyperv/ivm.c | 5 +++++ arch/x86/include/asm/msr-index.h | 4 +++- arch/x86/include/asm/svm.h | 8 +++++++- 5 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0