2026-02-02T22:07:14+08:00, [off-list ref]:
quoted hunk ↗ jump to hunk
From: Fangyu Yu <redacted>
Extend kvm_riscv_gstage_mode_detect() to probe all HGATP.MODE values
supported by the host and record them in a bitmask. Keep tracking the
maximum supported G-stage page table level for existing internal users.
Also provide lightweight helpers to retrieve the supported-mode bitmask
and validate a requested HGATP.MODE against it.
Signed-off-by: Fangyu Yu <redacted>
---
diff --git a/arch/riscv/include/asm/kvm_gstage.h b/arch/riscv/include/asm/kvm_gstage.h
@@ -75,4 +76,40 @@ void kvm_riscv_gstage_wp_range(struct kvm_gstage *gstage, gpa_t start, gpa_t end
+enum kvm_riscv_hgatp_mode_bit {
+ HGATP_MODE_SV39X4_BIT = 0,
+ HGATP_MODE_SV48X4_BIT = 1,
+ HGATP_MODE_SV57X4_BIT = 2,
I think it's a bit awkward to pass 9 when selecting the hgatp mode, but
then look for bit 0 when detecting it...
Why not to use the RVI defined values for this UABI as well?
There are only 16 possible hgatp.mode values, so we're fine storing them
in a bitmap even on RV32.
Thanks.