Re: [RFC v1 08/25] target/arm/kvm: Use kvm_vm_check_extension() where necessary

Mathieu Poirier <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.kernel.vger.kvm,org.nongnu.qemu-devel
Message-ID <allE_PUn5T4FRTXr@p14s>
On Mon, Jul 13, 2026 at 10:43:37AM +1000, Gavin Shan wrote:
> On 7/8/26 8:42 AM, Mathieu Poirier wrote:
> > From: Jean-Philippe Brucker <[email protected]>
> > 
> > The Arm KVM code can return different values from KVM_CHECK_EXTENSION
> > depending on the VM type. Use kvm_vm_check_extension() where necessary
> > to ensure we get the right response from KVM.
> > 
> > Signed-off-by: Jean-Philippe Brucker <[email protected]>
> > Signed-off-by: Mathieu Poirier <[email protected]>
> > ---
> >   target/arm/kvm.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> 
> I'm putting a note here so that we won't forget. The following changes are needed
> so that capability KVM_CAP_ARM_NISV_TO_USER won't be enabled for realm guest since
> it has been hidden from the realm guest in (v14) host series.
> 
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index 3d5e16a21c..4c52ee7e1b 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -623,7 +623,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>          return -EINVAL;
>      }
> -    if (kvm_check_extension(s, KVM_CAP_ARM_NISV_TO_USER)) {
> +    if (kvm_vm_check_extension(s, KVM_CAP_ARM_NISV_TO_USER)) {

Addressed.

>          if (kvm_vm_enable_cap(s, KVM_CAP_ARM_NISV_TO_USER, 0)) {
>              error_report("Failed to enable KVM_CAP_ARM_NISV_TO_USER cap");
>          } else {
> 
> > diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> > index 6aa1cd04e484..c69b5310c184 100644
> > --- a/target/arm/kvm.c
> > +++ b/target/arm/kvm.c
> > @@ -328,7 +328,7 @@ static void kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
> >                                1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
> >       }
> > -    if (kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3)) {
> > +    if (kvm_vm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3)) {
> >           init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3;
> >           pmu_supported = true;
> >           features |= 1ULL << ARM_FEATURE_PMU;
> > @@ -654,11 +654,11 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
> >           }
> >       }
> > -    max_hw_wps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
> > +    max_hw_wps = kvm_vm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_WPS);
> >       hw_watchpoints = g_array_sized_new(true, true,
> >                                          sizeof(HWWatchpoint), max_hw_wps);
> > -    max_hw_bps = kvm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_BPS);
> > +    max_hw_bps = kvm_vm_check_extension(s, KVM_CAP_GUEST_DEBUG_HW_BPS);
> >       hw_breakpoints = g_array_sized_new(true, true,
> >                                          sizeof(HWBreakpoint), max_hw_bps);
> > @@ -1905,7 +1905,7 @@ void kvm_arm_pvtime_init(ARMCPU *cpu, uint64_t ipa)
> >   void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)
> >   {
> > -    bool has_steal_time = kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME);
> > +    bool has_steal_time = kvm_vm_check_extension(kvm_state, KVM_CAP_STEAL_TIME);
> >       if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) {
> >           if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.