<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Nov 26, 2025 at 2:16 AM Radim Krčmář <<a href="mailto:rkrcmar@ventanamicro.com">rkrcmar@ventanamicro.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2025-11-25T22:18:11+08:00, <<a href="mailto:fangyu.yu@linux.alibaba.com" target="_blank">fangyu.yu@linux.alibaba.com</a>>:<br>
>>> On Sat, Nov 22, 2025 at 3:50 PM <<a href="mailto:fangyu.yu@linux.alibaba.com" target="_blank">fangyu.yu@linux.alibaba.com</a>> wrote:<br>
>>> ><br>
>>> > From: Fangyu Yu <<a href="mailto:fangyu.yu@linux.alibaba.com" target="_blank">fangyu.yu@linux.alibaba.com</a>><br>
>>> ><br>
>>> > Currently, HGATP mode uses the maximum value detected by the hardware<br>
>>> > but often such a wide GPA is unnecessary, just as a host sometimes<br>
>>> > doesn't need sv57.<br>
>>> > It's likely that no additional parameters (like no5lvl and no4lvl) are<br>
>>> > needed, aligning HGATP mode to SATP mode should meet the requirements<br>
>>> > of most scenarios.<br>
>>> Yes, no5/4lvl is not clear about satp or hgatp. So, covering HGPATP is<br>
>>> reasonable.<br>
>><br>
>>The documentation should be improved, but I don't think we want to state<br>
>>that these parameters apply to both s- and g-stage. If we need parameters<br>
>>to dictate KVM behavior (g-stage management), then we should add KVM<br>
>>module parameters.<br>
><br>
> Right, adding new parameters for g-stage management is clear.<br>
><br>
> Or we could discuss this topic, from a virtual machine perspective,<br>
> it may not be necessary to provide all hardware configuration<br>
> combinations. For example, when SATP is configured as sv48,<br>
> configuring HGATP as sv57*4 is not very meaningful, Because the<br>
> VM cannot actually use more than 48 bits of GPA range.<br>
<br>
The choice of hgatp mode depends on how users configure guest's memory<br>
map, regardless of what satp or vsatp modes are.<br>
(All RV64 SvXY modes map XY bit VA to 56 bit PA.)<br>
<br>
If the machine model maps memory with set bit 55, then KVM needs to<br>
configure Sv57x4, and if nothing is mapped above 2 TiB, then KVM is<br>
completely fine with Sv39x4.<br>
<br>
A module parameter works, but I think it would be nicer to set the hgatp<br>
mode per-VM, because most VMs could use the efficient Sv39x4, while it's<br>
not a good idea to pick it as the default.<br>
I think KVM has enough information to do it automatically (and without<br>
too much complexity) by starting with Sv39x4, and expanding as needed.<br></blockquote><div>Good point; if only a 128GB GPA memory region is needed, there is no need for Sv57x4, which costs PTW cycles.<br><br>So, the detection should start from Sv39x4 to Sv57x4 with the guest memory size.</div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Best Regards<br> Guo Ren<br></div></div></div>