]> www.infradead.org Git - users/hch/misc.git/commitdiff
LoongArch: KVM: Add PTW feature detection on new hardware
authorBibo Mao <maobibo@loongson.cn>
Tue, 23 Sep 2025 15:37:08 +0000 (23:37 +0800)
committerHuacai Chen <chenhuacai@kernel.org>
Tue, 23 Sep 2025 15:37:08 +0000 (23:37 +0800)
With new Loongson-3A6000/3C6000 hardware platforms (or later), hardware
page table walking (PTW) feature is supported on host. So here add this
feature detection on KVM host.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/uapi/asm/kvm.h
arch/loongarch/kvm/vcpu.c
arch/loongarch/kvm/vm.c

index 5f354f5c684701c353a1bfe2eb213025aa834a1c..57ba1a563bb1a2563f77f1317b1d60b60866e52a 100644 (file)
@@ -103,6 +103,7 @@ struct kvm_fpu {
 #define  KVM_LOONGARCH_VM_FEAT_PMU             5
 #define  KVM_LOONGARCH_VM_FEAT_PV_IPI          6
 #define  KVM_LOONGARCH_VM_FEAT_PV_STEALTIME    7
+#define  KVM_LOONGARCH_VM_FEAT_PTW             8
 
 /* Device Control API on vcpu fd */
 #define KVM_LOONGARCH_VCPU_CPUCFG      0
index ce478151466c00d3f0a363affb3137bd265625df..9c802f7103c629ff6d04de99f62a88bbfa606ef5 100644 (file)
@@ -680,6 +680,8 @@ static int _kvm_get_cpucfg_mask(int id, u64 *v)
                        *v |= CPUCFG2_ARMBT;
                if (cpu_has_lbt_mips)
                        *v |= CPUCFG2_MIPSBT;
+               if (cpu_has_ptw)
+                       *v |= CPUCFG2_PTW;
 
                return 0;
        case LOONGARCH_CPUCFG3:
index edccfc8c9cd804906c53f905cb005a4e98ca3e14..a49b1c1a3dd1f7c7738237cb76c52a0d68b69879 100644 (file)
@@ -146,6 +146,10 @@ static int kvm_vm_feature_has_attr(struct kvm *kvm, struct kvm_device_attr *attr
                if (kvm_pvtime_supported())
                        return 0;
                return -ENXIO;
+       case KVM_LOONGARCH_VM_FEAT_PTW:
+               if (cpu_has_ptw)
+                       return 0;
+               return -ENXIO;
        default:
                return -ENXIO;
        }