Skip to content

KVM: TDX SEPT SEAMCALL retry

Yan Zhao kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 19 repliesIn review

Changes in v1 from the cover letter

- Split patch 1 in RFC into patches 1,2,3,5, and add new fixup patches 6/7.
- Add contention analysis of tdh_mem_page_add() in patch 1 log.
- Provide justification in patch 2 log and add checks for RET_PF_CONTINUE.
- Use "a per-VM flag wait_for_sept_zap + KVM_REQ_OUTSIDE_GUEST_MODE" instead of a arch-specific request to prevent vCPUs from TD entry in patch 4 (Sean).

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7KVM: TDX: Return -EBUSY when tdh_mem_page_add() encounters TDX_OPERAND_BUSYarch/x86/kvm/vmx/tdx.c+4 -62 replies
2/7KVM: x86/mmu: Return RET_PF* instead of 1 in kvm_mmu_page_fault()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/mmu_internal.h+18 -42 replies
3/7KVM: TDX: Retry locally in TDX EPT violation handler on RET_PF_RETRYarch/x86/kvm/vmx/tdx.c+38 -16 replies
4/7KVM: TDX: Kick off vCPUs when SEAMCALL is busy during TD page removalarch/x86/kvm/vmx/tdx.c arch/x86/kvm/vmx/tdx.h+60 -93 replies
5/7fixup! KVM: TDX: Implement hooks to propagate changes of TDP MMU mirror page tablearch/x86/kvm/vmx/tdx.c+3 -21 reply
6/7fixup! KVM: TDX: Implement hooks to propagate changes of TDP MMU mirror page tablearch/x86/kvm/vmx/tdx.c+1 -80 replies
7/7fixup! KVM: TDX: Implement TDX vcpu enter/exit patharch/x86/kvm/vmx/tdx.c+10 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/7] KVM: TDX SEPT SEAMCALL retry

This series aims to provide a clean solution to avoid the blind retries in the previous hack [1] in "TDX MMU Part 2," following the initial discussions to [2], further discussions in the RFC, and the PUCK [3].

A full analysis of the lock status for each SEAMCALL relevant to KVM is available at [4].

This series categorizes the SEPT-related SEAMCALLs (used for page installation and uninstallation) into three groups:

Group 1: tdh_mem_page_add().
- Invoked only during TD build time.
- Proposal: Return -EBUSY on TDX_OPERAND_BUSY.
- Patch 1.

Group 2: tdh_mem_sept_add(), tdh_mem_page_aug().
- Invoked for TD runtime page installation.
- Proposal: Retry locally in the TDX EPT violation handler for RET_PF_RETRY.
- Patches 2-3.

Group 3: tdh_mem_range_block(), tdh_mem_track(), tdh_mem_page_remove().
- Invoked for page uninstallation, with KVM mmu_lock held for write.
- Proposal: Kick off vCPUs and no vCPU entry on TDX_OPERAND_BUSY.
- Patch 4.

Patches 5/6/7 are fixup patches:
Patch 5: Return -EBUSY instead of -EAGAIN when tdh_mem_sept_add() is busy. Patch 6: Remove the retry loop for tdh_phymem_page_wbinvd_hkid(). Patch 7: Warn on force_immediate_exit in tdx_vcpu_run().

Code base: kvm-coco-queue 2f30b837bf7b.
Applies to the tail since the dependence on
commit 8e801e55ba8f ("KVM: TDX: Handle EPT violation/misconfig exit"),

Thanks
Yan

RFC --> v1:
- Split patch 1 in RFC into patches 1,2,3,5, and add new fixup patches 6/7.
- Add contention analysis of tdh_mem_page_add() in patch 1 log.
- Provide justification in patch 2 log and add checks for RET_PF_CONTINUE.
- Use "a per-VM flag wait_for_sept_zap + KVM_REQ_OUTSIDE_GUEST_MODE" instead of a arch-specific request to prevent vCPUs from TD entry in patch 4 (Sean).

RFC: https://lore.kernel.org/all/[email protected]
[1] https://lore.kernel.org/all/[email protected]
[2] https://lore.kernel.org/kvm/[email protected]/
[3] https://drive.google.com/drive/folders/1k0qOarKuZXpzRsKDtVeC5Lpl9-amJ6AJ?resourcekey=0-l9uVpVEBC34Uar1ReaqisQ
[4] https://lore.kernel.org/kvm/[email protected]

Yan Zhao (7):
KVM: TDX: Return -EBUSY when tdh_mem_page_add() encounters
TDX_OPERAND_BUSY
KVM: x86/mmu: Return RET_PF* instead of 1 in kvm_mmu_page_fault()
KVM: TDX: Retry locally in TDX EPT violation handler on RET_PF_RETRY
KVM: TDX: Kick off vCPUs when SEAMCALL is busy during TD page removal fixup! KVM: TDX: Implement hooks to propagate changes of TDP MMU
mirror page table
fixup! KVM: TDX: Implement hooks to propagate changes of TDP MMU
mirror page table
fixup! KVM: TDX: Implement TDX vcpu enter/exit path

 arch/x86/kvm/mmu/mmu.c          |  10 ++-
 arch/x86/kvm/mmu/mmu_internal.h |  12 ++-
 arch/x86/kvm/vmx/tdx.c          | 135 ++++++++++++++++++++++++++------
 arch/x86/kvm/vmx/tdx.h          |   7 ++
 4 files changed, 134 insertions(+), 30 deletions(-)
Signature · 1 line
2.43.2