]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
RISC-V: KVM: Cache gstage pgd_levels in struct kvm_gstage
authorFangyu Yu <fangyu.yu@linux.alibaba.com>
Fri, 3 Apr 2026 15:30:17 +0000 (23:30 +0800)
committerAnup Patel <anup@brainfault.org>
Sat, 4 Apr 2026 08:16:46 +0000 (13:46 +0530)
commitec92248431be7ad08742e0d1dff5109cec5ef905
treea0eb7ed80518fb1e7a1bbc254378259f4d0d3383
parentefcac8424ba6ab75f2e16be9b0ccfdf60b13b294
RISC-V: KVM: Cache gstage pgd_levels in struct kvm_gstage

Gstage page-table helpers frequently chase gstage->kvm->arch to
fetch pgd_levels. This adds noise and repeats the same dereference
chain in hot paths.

Add pgd_levels to struct kvm_gstage and initialize it from kvm->arch
when setting up a gstage instance. Introduce kvm_riscv_gstage_init()
to centralize initialization and switch gstage code to use
gstage->pgd_levels.

Suggested-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Link: https://lore.kernel.org/r/20260403153019.9916-3-fangyu.yu@linux.alibaba.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/include/asm/kvm_gstage.h
arch/riscv/kvm/gstage.c
arch/riscv/kvm/mmu.c