Skip to content

x86/hyperv: Add AMD sev-snp enlightened guest support on hyperv

Tianyu Lan linux-arch linux-hyperv lkml 7 versions – Applied

Status from this message: Applied to hyperv-next. Thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest8 patches 4 repliesApplied
  2. v68 patches 9 repliesSuperseded
  3. v58 patches 10 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v49 patches4 repliesApplied
v39 patches8 repliesSuperseded
v29 patches13 repliesSuperseded
v19 patches28 repliesSuperseded

Changes in v7 from the cover letter

* Fix code sytle in the get_vtl()
* Rework code into smp patch

Patches in v7 Applied

#Subject and filesSizeRepliesApplied
1/8x86/hyperv: Add sev-snp enlightened guest static keyarch/x86/hyperv/ivm.c arch/x86/include/asm/mshyperv.h arch/x86/kernel/cpu/mshyperv.c +2 more+36 -50 replies
2/8x86/hyperv: Set Virtual Trust Level in VMBus init messagearch/x86/hyperv/hv_init.c arch/x86/include/asm/hyperv-tlfs.h drivers/hv/connection.c +2 more+45 -20 replies
3/8x86/hyperv: Mark Hyper-V vp assist page unencrypted in SEV-SNP enlightened guestarch/x86/hyperv/hv_init.c+15 -10 replies
4/8drivers: hv: Mark percpu hvcall input arg page unencrypted in SEV-SNP enlightened guestdrivers/hv/hv.c drivers/hv/hv_common.c+67 -30 replies
5/8x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guestarch/x86/include/asm/mshyperv.h+27 -31 reply
6/8clocksource: hyper-v: Mark hyperv tsc page unencrypted in sev-snp enlightened guestdrivers/clocksource/hyperv_timer.c+1 -10 replies
7/8x86/hyperv: Add smp support for SEV-SNP guestarch/x86/hyperv/ivm.c arch/x86/include/asm/mshyperv.h arch/x86/kernel/cpu/mshyperv.c +1 more+157 -10 replies
8/8x86/hyperv: Add hyperv-specific handling for VMMCALL under SEV-ESarch/x86/kernel/cpu/mshyperv.c+21 -00 replies

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchDexuan CuiMichael Kelley
1/8R-b R-b
2/8R-b R-b
3/8R-b R-b
4/8R-b R-b
5/8R-b
6/8R-b R-b
7/8R-b R-b
8/8R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 0/8] x86/hyperv: Add AMD sev-snp enlightened guest support on hyperv

From: Tianyu Lan <[email protected]>

Hyper-V provides two modes for running SEV-SNP VMs:

1) In vTOM mode with a paravisor (see Section 15.36.8 of [1])
2) In "fully enlightened" mode with normal "C" bit control over page encryption, and no paravisor

For #1, the paravisor runs in VMPL 0, while Linux runs in VMPL 2 (see Section 15.36.7 of [1]). The paravisor is typically provided by Hyper-V and handles most of the SNP-related functionality. As such, most of the SNP functionality in the Linux guest is bypassed. The guest operates in vTOM mode, where encryption is enabled by default. The guest must still request page transitions between private and shared, but there is relatively less SNP machinery required in the guest. Support for this mode of operation first went upstream in the 5.15 kernel.

For #2, this patch set provides the initial support. The existing SEV-SNP machinery in the kernel is fully used, but Hyper-V specific updates are required to properly share Hyper-V communication pages between the guest and host and to start APs at boot time.

In either mode, Hyper-V requires that the guest implement the SEV-SNP Restricted Interrupt Injection feature (see Section 15.36.16 of [1], and Section 5 of [2]). Without this feature, the guest is subject to attack by a compromised hypervisor that can inject any exception at any time, such as injecting an interrupt while the guest has interrupts disabled. In vTOM mode, Restricted Interrupt Injection is implemented by the paravisor, so no Linux guest changes are required. But in fully enlightened mode, the Linux guest must provide the implementation.

This patch set is derived from an earlier patch set that includes both the Hyper-V specific changes and Restricted Interrupt Injection support.[3] But it is now limited to only the Hyper-V specific changes. The Restricted Interrupt Injection support will come later in a separate patch set.

[1] https://www.amd.com/system/files/TechDocs/24593.pdf
[2] https://www.amd.com/system/files/TechDocs/56421-guest-hypervisor-communication-block-standardization.pdf
[3] https://lore.kernel.org/lkml/[email protected]/

Change since v6:
* Fix code sytle in the get_vtl()
* Rework code into smp patch

Change since v5:
* Remove input page check in the get_vtl()
* Convert alternative back to if else check in the hypercall implementation.

Change since v3:
* Fix fossil comment

Change since v2:
* Update Change log.
* Rework Hyper-V hypercall implementation.

Change since v1:
* vTOM case uses paravisor_present flag and HV_ISOLATION_TYPE_SNP type.
* Rework some patches' change log
* Fix some comments in the patches

Tianyu Lan (8):
x86/hyperv: Add sev-snp enlightened guest static key x86/hyperv: Set Virtual Trust Level in VMBus init message x86/hyperv: Mark Hyper-V vp assist page unencrypted in SEV-SNP
enlightened guest
drivers: hv: Mark percpu hvcall input arg page unencrypted in SEV-SNP
enlightened guest
x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp
enlightened guest
clocksource: hyper-v: Mark hyperv tsc page unencrypted in sev-snp
enlightened guest
x86/hyperv: Add smp support for SEV-SNP guest
x86/hyperv: Add hyperv-specific handling for VMMCALL under SEV-ES

 arch/x86/hyperv/hv_init.c          |  50 +++++++++-
 arch/x86/hyperv/ivm.c              | 149 +++++++++++++++++++++++++++++
 arch/x86/include/asm/hyperv-tlfs.h |   7 ++
 arch/x86/include/asm/mshyperv.h    |  38 +++++++-
 arch/x86/kernel/cpu/mshyperv.c     |  41 +++++++-
 drivers/clocksource/hyperv_timer.c |   2 +-
 drivers/hv/connection.c            |   1 +
 drivers/hv/hv.c                    |  57 ++++++++++-
 drivers/hv/hv_common.c             |  19 ++++
 include/asm-generic/hyperv-tlfs.h  |   1 +
 include/asm-generic/mshyperv.h     |  14 ++-
 include/linux/hyperv.h             |   4 +-
 12 files changed, 368 insertions(+), 15 deletions(-)
Signature · 1 line
2.25.1