Skip to content

KVM: x86/mmu: Huge page fixes, cleanup, and DAX

Sean Christopherson kvm kvm-ppc kvmarm linux-arm-kernel linux-mm linux-nvdimm lkml nvdimm 1 version Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 7 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/14KVM: x86/mmu: Enforce max_level on HugeTLB mappingsarch/x86/kvm/mmu/mmu.c+3 -20 replies
2/14mm: thp: KVM: Explicitly check for THP when populating secondary MMUarch/x86/kvm/mmu/mmu.c include/linux/huge_mm.h include/linux/kvm_host.h +3 more+31 -90 replies
3/14KVM: Use vcpu-specific gva->hva translation when querying host page sizearch/powerpc/kvm/book3s_xive_native.c arch/x86/kvm/mmu/mmu.c include/linux/kvm_host.h +1 more+7 -70 replies
4/14KVM: Play nice with read-only memslots when querying host page sizevirt/kvm/kvm_main.c+10 -21 reply
5/14x86/mm: Introduce lookup_address_in_mm()arch/x86/include/asm/pgtable_types.h arch/x86/mm/pageattr.c+15 -02 replies
6/14KVM: x86/mmu: Refactor THP adjust to prep for changing queryarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+23 -240 replies
7/14KVM: x86/mmu: Walk host page tables to find THP mappingsarch/x86/kvm/mmu/mmu.c+38 -21 reply
8/14KVM: x86/mmu: Drop level optimization from fast_page_fault()arch/x86/kvm/mmu/mmu.c+3 -40 replies
9/14KVM: x86/mmu: Rely on host page tables to find HugeTLB mappingsarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+29 -700 replies
10/14KVM: x86/mmu: Remove obsolete gfn restoration in FNAME(fetch)arch/x86/kvm/mmu/paging_tmpl.h+3 -100 replies
11/14KVM: x86/mmu: Zap any compound page when collapsing sptesarch/x86/kvm/mmu/mmu.c+1 -10 replies
12/14KVM: x86/mmu: Fold max_mapping_level() into kvm_mmu_hugepage_adjust()arch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+24 -381 reply
13/14KVM: x86/mmu: Remove lpage_is_disallowed() check from set_spte()arch/x86/kvm/mmu/mmu.c+3 -360 replies
14/14KVM: x86/mmu: Use huge pages for DAX-backed filesarch/x86/kvm/mmu/mmu.c+4 -50 replies

Reviews trailers per patch

1 of 14 patches has a Reviewed-by or Acked-by.

PatchThomas Gleixner
1/14
2/14
3/14
4/14
5/14R-b
6/14
7/14
8/14
9/14
10/14
11/14
12/14
13/14
14/14

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

Read the v1 thread

Cover letter [PATCH 00/14] KVM: x86/mmu: Huge page fixes, cleanup, and DAX

This series is a mix of bug fixes, cleanup and new support in KVM's handling of huge pages. The series initially stemmed from a syzkaller bug report[1], which is fixed by patch 02, "mm: thp: KVM: Explicitly check for THP when populating secondary MMU".

While investigating options for fixing the syzkaller bug, I realized KVM could reuse the approach from Barret's series to enable huge pages for DAX mappings in KVM[2] for all types of huge mappings, i.e. walk the host page tables instead of querying metadata (patches 05 - 09).

Walking the host page tables sidesteps the issues with refcounting and identifying THP mappings (in theory), and using a common method for identifying huge mappings should improve (haven't actually measured) KVM's overall page fault latency by eliminating the vma lookup that is currently used to identify HugeTLB mappings. Eliminating the HugeTLB specific code also allows for additional cleanup (patches 10 - 13).

Testing the page walk approach revealed several pre-existing bugs that are included here (patches 01, 03 and 04) because the changes interact with the rest of the series, e.g. without the read-only memslots fix, walking the host page tables without explicitly filtering out HugeTLB mappings would pick up read-only memslots and introduce a completely unintended functional change.

Lastly, with the page walk infrastructure in place, supporting DAX-based huge mappings becomes a trivial change (patch 14).

Based on kvm/queue, commit e41a90be9659 ("KVM: x86/mmu: WARN if root_hpa is invalid when handling a page fault")

Paolo, assuming I understand your workflow, patch 01 can be squashed with the buggy commit as it's still sitting in kvm/queue.

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

Sean Christopherson (14):
KVM: x86/mmu: Enforce max_level on HugeTLB mappings
mm: thp: KVM: Explicitly check for THP when populating secondary MMU
KVM: Use vcpu-specific gva->hva translation when querying host page
size
KVM: Play nice with read-only memslots when querying host page size x86/mm: Introduce lookup_address_in_mm()
KVM: x86/mmu: Refactor THP adjust to prep for changing query
KVM: x86/mmu: Walk host page tables to find THP mappings
KVM: x86/mmu: Drop level optimization from fast_page_fault()
KVM: x86/mmu: Rely on host page tables to find HugeTLB mappings
KVM: x86/mmu: Remove obsolete gfn restoration in FNAME(fetch)
KVM: x86/mmu: Zap any compound page when collapsing sptes
KVM: x86/mmu: Fold max_mapping_level() into kvm_mmu_hugepage_adjust()
KVM: x86/mmu: Remove lpage_is_disallowed() check from set_spte()
KVM: x86/mmu: Use huge pages for DAX-backed files

 arch/powerpc/kvm/book3s_xive_native.c |   2 +-
 arch/x86/include/asm/pgtable_types.h  |   4 +
 arch/x86/kvm/mmu/mmu.c                | 208 ++++++++++----------------
 arch/x86/kvm/mmu/paging_tmpl.h        |  29 +---
 arch/x86/mm/pageattr.c                |  11 ++
 include/linux/huge_mm.h               |   6 +
 include/linux/kvm_host.h              |   3 +-
 mm/huge_memory.c                      |  11 ++
 virt/kvm/arm/mmu.c                    |   8 +-
 virt/kvm/kvm_main.c                   |  24 ++-
 10 files changed, 145 insertions(+), 161 deletions(-)
Signature · 1 line
2.24.1