Skip to content

KVM: x86/mmu: Make tdp_mmu a read-only parameter

Sean Christopherson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest11 patches 4 repliesIn review

Changes in v4 from the cover letter

- Keep is_tdp_mmu_page() in patch 1.
- Collect reviews. [Isaku]
- Skip "make MMU pages available" for root allocations.
- Rework "is TDP MMU" checks to take advantage of read-only param.
- Use a static key to track TDP MMU enabling.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11KVM: x86/mmu: Change tdp_mmu to a read-only parameterarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu.h arch/x86/kvm/mmu/mmu.c +1 more+48 -361 reply
2/11KVM: x86/mmu: Move TDP MMU VM init/uninit behind tdp_mmu_enabledarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/tdp_mmu.c arch/x86/kvm/mmu/tdp_mmu.h+10 -140 replies
3/11KVM: x86/mmu: Grab mmu_invalidate_seq in kvm_faultin_pfn()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/mmu_internal.h arch/x86/kvm/mmu/paging_tmpl.h+14 -140 replies
4/11KVM: x86/mmu: Handle error PFNs in kvm_faultin_pfn()arch/x86/kvm/mmu/mmu.c+11 -60 replies
5/11KVM: x86/mmu: Avoid memslot lookup during KVM_PFN_ERR_HWPOISON handlingarch/x86/kvm/mmu/mmu.c+9 -70 replies
6/11KVM: x86/mmu: Handle no-slot faults in kvm_faultin_pfn()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+31 -310 replies
7/11KVM: x86/mmu: Pivot on "TDP MMU enabled" when handling direct page faultsarch/x86/kvm/mmu/mmu.c+4 -50 replies
8/11KVM: x86/mmu: Pivot on "TDP MMU enabled" to check if active MMU is TDP MMUarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/tdp_mmu.h+8 -210 replies
9/11KVM: x86/mmu: Replace open coded usage of tdp_mmu_page with is_tdp_mmu_page()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/tdp_mmu.c+2 -20 replies
10/11KVM: x86/mmu: Use static key/branches for checking if TDP MMU is enabledarch/x86/kvm/mmu.h arch/x86/kvm/mmu/mmu.c+13 -60 replies
11/11KVM: x86/mmu: Stop needlessly making MMU pages available for TDP MMUarch/x86/kvm/mmu/mmu.c+13 -90 replies

Reviews trailers per patch

4 of 11 patches have a Reviewed-by or Acked-by.

PatchIsaku YamahataKai Huang
1/11R-b
2/11R-b
3/11R-b
4/11
5/11R-b
6/11
7/11
8/11
9/11
10/11
11/11

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

Read the v4 thread

Cover letter [PATCH v4 00/11] KVM: x86/mmu: Make tdp_mmu a read-only parameter

This is a variation of David's series to change tdp_mmu to a RO param[*]. The key difference is that instead of moving the TDP MMU page fault handler to its own function, use static branches to make TDP MMU page faults (and a few other paths) effectively branch free.

I'm not dead set against having a dedicated TDP MMU page fault handler, but IMO it's not really better once the TDP MMU vs. shadow MMU is reduced to a static branch, just different. The read vs. write mmu_lock is the most visible ugliness, and that can be buried in helpers if we really want to make the page fault handler easier on the eyes, e.g.

	direct_page_fault_mmu_lock(vcpu);

	if (is_page_fault_stale(vcpu, fault))
		goto out_unlock;

	if (is_tdp_mmu_enabled()) {
		r = kvm_tdp_mmu_map(vcpu, fault);
	} else {
		r = make_mmu_pages_available(vcpu);
		if (r)
			goto out_unlock;

		r = __direct_map(vcpu, fault);
	}

out_unlock:

	direct_page_fault_mmu_unlock(vcpu);

v4:
- Keep is_tdp_mmu_page() in patch 1.
- Collect reviews. [Isaku]
- Skip "make MMU pages available" for root allocations.
- Rework "is TDP MMU" checks to take advantage of read-only param.
- Use a static key to track TDP MMU enabling.

[*] https://lkml.kernel.org/r/[email protected]

David Matlack (7):
KVM: x86/mmu: Change tdp_mmu to a read-only parameter
KVM: x86/mmu: Move TDP MMU VM init/uninit behind tdp_mmu_enabled
KVM: x86/mmu: Grab mmu_invalidate_seq in kvm_faultin_pfn()
KVM: x86/mmu: Handle error PFNs in kvm_faultin_pfn()
KVM: x86/mmu: Avoid memslot lookup during KVM_PFN_ERR_HWPOISON
handling
KVM: x86/mmu: Handle no-slot faults in kvm_faultin_pfn()
KVM: x86/mmu: Stop needlessly making MMU pages available for TDP MMU

Sean Christopherson (4):
KVM: x86/mmu: Pivot on "TDP MMU enabled" when handling direct page
faults
KVM: x86/mmu: Pivot on "TDP MMU enabled" to check if active MMU is TDP
MMU
KVM: x86/mmu: Replace open coded usage of tdp_mmu_page with

    is_tdp_mmu_page()

KVM: x86/mmu: Use static key/branches for checking if TDP MMU is
enabled

 arch/x86/include/asm/kvm_host.h |   9 --
 arch/x86/kvm/mmu.h              |  14 ++-
 arch/x86/kvm/mmu/mmu.c          | 212 ++++++++++++++++++++------------
 arch/x86/kvm/mmu/mmu_internal.h |   1 +
 arch/x86/kvm/mmu/paging_tmpl.h  |  12 +-
 arch/x86/kvm/mmu/tdp_mmu.c      |  13 +-
 arch/x86/kvm/mmu/tdp_mmu.h      |  25 +---
 7 files changed, 149 insertions(+), 137 deletions(-)

base-commit: e18d6152ff0f41b7f01f9817372022df04e0d354

Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog