linux-next/Documentation/virt
Paolo Bonzini 5932ca411e KVM: x86: disallow pre-fault for SNP VMs before initialization
KVM_PRE_FAULT_MEMORY for an SNP guest can race with
sev_gmem_post_populate() in bad ways. The following sequence for
instance can potentially trigger an RMP fault:

  thread A, sev_gmem_post_populate: called
  thread B, sev_gmem_prepare: places below 'pfn' in a private state in RMP
  thread A, sev_gmem_post_populate: *vaddr = kmap_local_pfn(pfn + i);
  thread A, sev_gmem_post_populate: copy_from_user(vaddr, src + i * PAGE_SIZE, PAGE_SIZE);
  RMP #PF

Fix this by only allowing KVM_PRE_FAULT_MEMORY to run after a guest's
initial private memory contents have been finalized via
KVM_SEV_SNP_LAUNCH_FINISH.

Beyond fixing this issue, it just sort of makes sense to enforce this,
since the KVM_PRE_FAULT_MEMORY documentation states:

  "KVM maps memory as if the vCPU generated a stage-2 read page fault"

which sort of implies we should be acting on the same guest state that a
vCPU would see post-launch after the initial guest memory is all set up.

Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-07-26 14:46:14 -04:00
..
acrn docs: acrn: Introduce ACRN 2021-02-09 10:58:18 +01:00
coco crypto: ccp: Add the SNP_VLEK_LOAD command 2024-07-17 12:46:26 -04:00
hyperv Documentation: hyperv: Improve synic and interrupt handling description 2024-05-28 05:28:42 +00:00
kvm KVM: x86: disallow pre-fault for SNP VMs before initialization 2024-07-26 14:46:14 -04:00
uml Documentation: Fix typos 2023-08-18 11:29:03 -06:00
guest-halt-polling.rst Documentation: virt: correct location of haltpoll module params 2023-06-16 08:17:21 -06:00
index.rst Docs/subsystem-apis: Remove '[The ]Linux' prefixes from titles of listed documents 2023-01-24 15:27:08 -07:00
ne_overview.rst nitro_enclaves: Update documentation for Arm64 support 2021-09-14 11:11:20 +02:00
paravirt_ops.rst Documentation: virt: Clean up paravirt_ops doc 2023-06-19 12:09:54 +02:00