Re: [PATCH v2 08/11] RISC-V: KVM: Disable all hpmcounter access for VS/VU mode

ye.zhihao1 at zte.com.cn ye.zhihao1 at zte.com.cn
Tue Oct 20 04:39:13 PDT 2026


Questions on KVM PMU Counter Numbering, Hcounteren Setting, and Migration/Conflict Handling

Dear Atish Patra,

I noticed your relevant patches and comments regarding the KVM module in your virtualization work. During my virtualization validation, I have the following questions:

I found that the hardware counter numbers actually used on the host are inconsistent with the virtualized numbers returned after KVM emulation. Is this because you want to ensure that the VM can work properly in migration scenarios and avoid the conflict scenario where the host and guest count simultaneously on the same CPU and share the same hardware counter? Also, why are all virtualized events disguised as sampling events? Is it because SBI PMU does not support the passing of this flag, so KVM cannot distinguish between stat and record events?

In addition, I noticed that in your main.c, Hcounteren is set to 0x02. Is this also because there is no correlation between the logical hardware counters and the virtual counters? Have you considered enabling Hcounteren to reduce the overhead caused by CSR traps? In KVM, is it mandatory to modify the logical hardware counter numbers and the virtual counter numbers so that they match and are consistent, and would it be necessary to reconsider how to solve the migration and conflict issues encountered in the previous scenarios?

Best regards,
ZHIHAO YE



More information about the linux-riscv mailing list