All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] KVM: riscv: Fix hugetlb G-stage block mapping eligibility
@ 2026-06-04 14:26 ` Jinyu Tang
  0 siblings, 0 replies; 11+ messages in thread
From: Jinyu Tang @ 2026-06-04 14:26 UTC (permalink / raw)
  To: Anup Patel, Anup Patel, Paolo Bonzini
  Cc: Atish Patra, Paul Walmsley, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Alexandre Ghiti, Shuah Khan, Sean Christopherson,
	Radim Krčmář, Andrew Jones, Conor Dooley,
	Yong-Xuan Wang, Nutty Liu, kvm, kvm-riscv, linux-riscv,
	linux-kernel, linux-kselftest, Jinyu Tang

RISC-V KVM checks memslot alignment and head/tail coverage before
installing THP-backed PMD G-stage block mappings, but the hugetlb path
has used the hugetlb VMA size directly. That can be wrong for memslots
whose HVA and GPA have different offsets within the target block, or for
partial head/tail blocks.

Generalize the existing block eligibility helper so it can check a
caller-provided target size, use it to select hugetlb mappings with a
PUD -> PMD -> PAGE_SIZE fallback, and add a selftest mode that creates a
hugetlb memslot with a deliberate HVA/GPA offset mismatch.

Tested on a QEMU RISC-V host with 8 pre-allocated 2MB hugepages:

  # ./kvm_page_table_test -m 19 -s anonymous -b 4M -v 1
  # ./kvm_page_table_test -m 19 -s anonymous_hugetlb_2mb -b 4M -v 1
  # timeout 30s ./kvm_page_table_test \
        -m 19 -s anonymous_hugetlb_2mb -b 4M -v 1 -u

  base + selftest:
    anonymous:                 PASS
    aligned hugetlb:           PASS
    misaligned hugetlb:        timeout

  patched:
    anonymous:                 PASS
    aligned hugetlb:           PASS
    misaligned hugetlb:        PASS

v1 -> v2:
  - Squash the helper parameterization into the hugetlb fix
  - Use the ALIGN()/ALIGN_DOWN() form suggested by Nutty Liu and Anup
    for the memslot boundary check.

Jinyu Tang (2):
  KVM: riscv: Check hugetlb block mappings against memslot bounds
  KVM: selftests: Add a hugetlb memslot alignment test mode

 arch/riscv/kvm/mmu.c                          | 54 +++++++++++++++----
 .../selftests/kvm/kvm_page_table_test.c       | 28 +++++++---
 2 files changed, 66 insertions(+), 16 deletions(-)

-- 
2.43.0


-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-06-04 14:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 14:26 [PATCH v2 0/2] KVM: riscv: Fix hugetlb G-stage block mapping eligibility Jinyu Tang
2026-06-04 14:26 ` Jinyu Tang
2026-06-04 14:26 ` Jinyu Tang
2026-06-04 14:26 ` [PATCH v2 1/2] KVM: riscv: Check hugetlb block mappings against memslot bounds Jinyu Tang
2026-06-04 14:26   ` Jinyu Tang
2026-06-04 14:26   ` Jinyu Tang
2026-06-04 14:52   ` sashiko-bot
2026-06-04 14:26 ` [PATCH v2 2/2] KVM: selftests: Add a hugetlb memslot alignment test mode Jinyu Tang
2026-06-04 14:26   ` Jinyu Tang
2026-06-04 14:26   ` Jinyu Tang
2026-06-04 14:42   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.