Skip to content

KVM: x86/mmu: Drop dedicated self-changing mapping code

Sean Christopherson kvm lkml 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 1 replyApplied

Changes in v2 from the cover letter

- Track the "write #PF to shadow page" using an EMULTYPE flag.
- Split the main patch in two.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3KVM: x86/mmu: Use EMULTYPE flag to track write #PFs to shadow pagesarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/mmu_internal.h +2 more+37 -360 replies
2/3KVM: x86/mmu: Detect write #PF to shadow pages during FNAME(fetch) walkarch/x86/kvm/mmu/paging_tmpl.h+5 -70 replies
3/3KVM: x86/mmu: Remove FNAME(is_self_change_mapping)arch/x86/kvm/mmu/paging_tmpl.h+7 -440 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/3] KVM: x86/mmu: Drop dedicated self-changing mapping code

Excise the MMU's one-off self-changing mapping logic and instead detect self-changing mappings in the primary "walk" flow, and rely on kvm_mmu_hugepage_adjust() to naturally handle "disallowed hugepage due to shadow page" conditions.

When is_self_change_mapping() was first added, KVM did hugepage adjustments before the primary walk, and so didn't account for shadow pages that were allocated for the current page fault, i.e. effectively consumed a stale disallow_lpage. Now that KVM adjust after allocating new shadow pages, the one-off code is superfluous.

Dropping the one-off code fixes an issue where KVM will force 4KiB pages for a 1GiB guest page even when using a 2MiB would be safe (1GiB overlaps a shadow page but 2MiB does not).

v2:
- Track the "write #PF to shadow page" using an EMULTYPE flag.
- Split the main patch in two.

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

Lai Jiangshan (2):
KVM: x86/mmu: Detect write #PF to shadow pages during FNAME(fetch)
walk
KVM: x86/mmu: Remove FNAME(is_self_change_mapping)

Sean Christopherson (1):
KVM: x86/mmu: Use EMULTYPE flag to track write #PFs to shadow pages

 arch/x86/include/asm/kvm_host.h | 37 +++++++++++---------
 arch/x86/kvm/mmu/mmu.c          |  5 +--
 arch/x86/kvm/mmu/mmu_internal.h | 12 ++++++-
 arch/x86/kvm/mmu/paging_tmpl.h  | 61 ++++++---------------------------
 arch/x86/kvm/x86.c              | 15 ++------
 5 files changed, 46 insertions(+), 84 deletions(-)

base-commit: 11b36fe7d4500c8ef73677c087f302fd713101c2

Signature · 1 line
2.39.1.519.gcb327c4b5f-goog