Re: [PATCH] LoongArch: KVM: Advertise already-supported capabilities

From: Bibo Mao

Date: Tue Aug 04 2026 - 22:37:06 EST


On 2026/8/4 下午4:26, Tao Cui wrote:
Several LoongArch KVM features are fully implemented but were never
reported through their standard KVM_CHECK_EXTENSION probes, so userspace
cannot discover them and either ignores them or takes a slower path.
Advertise the ones that already work:

- KVM_CAP_STEAL_TIME: steal time is fully implemented (host-side
record plus guest paravirt), gated on kvm_pvtime_supported().

- KVM_CAP_IRQFD_RESAMPLE: the resampler is generic code backed by the
in-kernel irqchip; advertise it so userspace can use irqfd with
resample for level-triggered interrupts.

- KVM_CAP_VM_GPA_BITS: the guest physical address width is already
computed as BIT(cpu_vabits), so return cpu_vabits directly.

- KVM_CAP_VCPU_ATTRIBUTES: per-vCPU device-attribute ioctls are
implemented (CPUCFG, PVTIME control); advertise the discovery cap.

This adds no new functionality; it only makes existing features
discoverable via the standard probe.

Signed-off-by: Tao Cui <cui.tao@xxxxxxxxx>
---
arch/loongarch/kvm/vm.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/loongarch/kvm/vm.c b/arch/loongarch/kvm/vm.c
index 1317c718f896..d7dd08d9be5b 100644
--- a/arch/loongarch/kvm/vm.c
+++ b/arch/loongarch/kvm/vm.c
@@ -120,8 +120,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_READONLY_MEM:
case KVM_CAP_IMMEDIATE_EXIT:
case KVM_CAP_IOEVENTFD:
+ case KVM_CAP_IRQFD_RESAMPLE:
By my understanding, KVM_CAP_IRQFD_RESAMPLE is used for VFIO intx irqline interrupt injection, is that true? now IOMMU and VFIO is not supported on LoongArch.

case KVM_CAP_MP_STATE:
case KVM_CAP_SET_GUEST_DEBUG:
+ case KVM_CAP_VCPU_ATTRIBUTES:
this is ok.
r = 1;
break;
case KVM_CAP_NR_VCPUS:
@@ -136,6 +138,12 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_NR_MEMSLOTS:
r = KVM_USER_MEM_SLOTS;
break;
+ case KVM_CAP_STEAL_TIME:
+ r = kvm_pvtime_supported();
+ break;
this is ok.

+ case KVM_CAP_VM_GPA_BITS:
+ r = cpu_vabits;
Feature KVM_CAP_VM_GPA_BITS is also to control max supported GPA bit of VM, only only max supported PA bit on host. For example max PA bit is 48 on host, it is ok to set GPA bit with 40 or 48, only if it is smaller than one on host.
If my understanding is correct, it is not supported on LoongArch now.

Regards
Bibo Mao
+ break;
default:
r = 0;
break;