Skip to content

x86/percpu: Share decrypted storage before guest setup

Zack Rusin kvm linux-arch linux-coco linux-doc linux-hyperv linux-mm lkml virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest6 patches 7 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6percpu: Page-align decrypted data in UP kernelsinclude/asm-generic/vmlinux.lds.h+10 -10 replies
2/6percpu: Bound decrypted storage for all x86 encrypted guestsinclude/asm-generic/vmlinux.lds.h include/linux/percpu-defs.h+10 -93 replies
3/6x86/percpu: Require embedded allocation in encrypted guestsDocumentation/admin-guide/kernel-parameters.txt arch/x86/kernel/setup_percpu.c+13 -20 replies
4/6x86/mm: Provide common early memory decryptionarch/x86/coco/sev/core.c arch/x86/include/asm/mem_encrypt.h arch/x86/include/asm/x86_init.h +2 more+149 -50 replies
5/6x86/tdx: Support early sharing of kernel dataarch/x86/coco/tdx/tdx.c+32 -00 replies
6/6x86/percpu: Share decrypted storage before guest CPU setuparch/x86/hyperv/ivm.c arch/x86/include/asm/mem_encrypt.h arch/x86/include/asm/x86_init.h +5 more+35 -360 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/6] x86/percpu: Share decrypted storage before guest setup

VMware publishes its per-CPU steal-time GPA without first sharing the storage in encrypted guests. Following Kiryl's review, this series moves sharing into early per-CPU initialization for both KVM and VMware. This replaces the VMware fix from Bo Gan and Alexey Makhalov:
https://lore.kernel.org/r/[email protected]

The common helper uses boot-time page-table allocation and preserves initial contents on AMD and TDX. Conversion precedes buffer registration on SMP and UP; failures stop boot. Encrypted guests use the embedded allocator, warn on percpu_alloc=page, and never fall back to page mode. There is no driver conversion loop or readiness flag. .bss..decrypted remains outside this series.

I interpreted the allocator requirement as guest-specific, so both it and per-CPU conversion use CC_ATTR_GUEST_MEM_ENCRYPT and leave bare-metal SME behavior unchanged.

Two corrections to v1: its isolation claim missed UP, where ordinary data could share the decrypted objects' page; patch 1 fixes that separately. TDX's vmalloc constraint concerns private aliases and adjacent accesses through load_unaligned_zeropad(), not just GPA lookup. This series removes the unused declaration macro and adds explicit SMP/UP section boundaries. I have not carried the v1 Ack onto the revised patches; renewed review would be appreciated.

Tested on VMware ESXi with SEV-SNP and TDX guests, and on KVM with SEV and SEV-SNP guests, using SMP and UP kernels.

v1: https://lore.kernel.org/r/[email protected]

Zack Rusin (6):
percpu: Page-align decrypted data in UP kernels
percpu: Bound decrypted storage for all x86 encrypted guests x86/percpu: Require embedded allocation in encrypted guests x86/mm: Provide common early memory decryption x86/tdx: Support early sharing of kernel data x86/percpu: Share decrypted storage before guest CPU setup

 .../admin-guide/kernel-parameters.txt         |   3 +
 arch/x86/coco/sev/core.c                      |  16 ++
 arch/x86/coco/tdx/tdx.c                       |  32 ++++
 arch/x86/hyperv/ivm.c                         |   4 +
 arch/x86/include/asm/mem_encrypt.h            |   9 +-
 arch/x86/include/asm/x86_init.h               |   4 +
 arch/x86/kernel/cpu/vmware.c                  |   2 +-
 arch/x86/kernel/kvm.c                         |  35 -----
 arch/x86/kernel/setup.c                       |   2 +
 arch/x86/kernel/setup_percpu.c                |  14 +-
 arch/x86/mm/mem_encrypt.c                     | 139 ++++++++++++++++++
 arch/x86/mm/mem_encrypt_amd.c                 |  12 +-
 include/asm-generic/vmlinux.lds.h             |  19 ++-
 include/linux/percpu-defs.h                   |   7 +-
 14 files changed, 247 insertions(+), 51 deletions(-)

base-commit: 93f51579e7df248780214094418f205253383cc5

Signature · 1 line
2.53.0