Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: "Pratik R. Sampat" <prsampat@amd.com>
To: <x86@kernel.org>, <kvm@vger.kernel.org>,
	<linux-hyperv@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <tglx@kernel.org>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <haiyangz@microsoft.com>,
	<wei.liu@kernel.org>, <seanjc@google.com>, <pbonzini@redhat.com>,
	<thomas.lendacky@amd.com>, <kim.phillips@amd.com>,
	<nikunj@amd.com>, <michael.roth@amd.com>, <ashish.kalra@amd.com>,
	<prsampat@amd.com>
Subject: [Patch v5 0/3] Guest support for Enhanced SMT Protection
Date: Tue, 17 Nov 2026 17:56:57 +0000	[thread overview]
Message-ID: <cover.1794935627.git.prsampat@amd.com> (raw)

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/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://lore.kernel.org/qemu-devel/cover.1789399242.git.prsampat@amd.com/
[3]: https://lore.kernel.org/all/avc-5lkQhoR6US9o@google.com/

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(-)

-- 
2.43.0


             reply	other threads:[~2026-11-17 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 17:56 Pratik R. Sampat [this message]
2026-11-17 17:56 ` [Patch v5 1/3] x86/sev: Add Enhanced SMT Protection fields to the VMSA Pratik R. Sampat
2026-11-17 17:56 ` [Patch v5 2/3] x86/sev: Add guest support for Enhanced SMT Protection Pratik R. Sampat
2026-11-17 17:57 ` [Patch v5 3/3] x86/hyperv: " Pratik R. Sampat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1794935627.git.prsampat@amd.com \
    --to=prsampat@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=haiyangz@microsoft.com \
    --cc=kim.phillips@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=nikunj@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=wei.liu@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox