Skip to content

Commit 7109f51

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Add PTW feature detection on new hardware
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 <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 07e27ad commit 7109f51

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

arch/loongarch/include/uapi/asm/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ struct kvm_fpu {
103103
#define KVM_LOONGARCH_VM_FEAT_PMU 5
104104
#define KVM_LOONGARCH_VM_FEAT_PV_IPI 6
105105
#define KVM_LOONGARCH_VM_FEAT_PV_STEALTIME 7
106+
#define KVM_LOONGARCH_VM_FEAT_PTW 8
106107

107108
/* Device Control API on vcpu fd */
108109
#define KVM_LOONGARCH_VCPU_CPUCFG 0

arch/loongarch/kvm/vcpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ static int _kvm_get_cpucfg_mask(int id, u64 *v)
680680
*v |= CPUCFG2_ARMBT;
681681
if (cpu_has_lbt_mips)
682682
*v |= CPUCFG2_MIPSBT;
683+
if (cpu_has_ptw)
684+
*v |= CPUCFG2_PTW;
683685

684686
return 0;
685687
case LOONGARCH_CPUCFG3:

arch/loongarch/kvm/vm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ static int kvm_vm_feature_has_attr(struct kvm *kvm, struct kvm_device_attr *attr
146146
if (kvm_pvtime_supported())
147147
return 0;
148148
return -ENXIO;
149+
case KVM_LOONGARCH_VM_FEAT_PTW:
150+
if (cpu_has_ptw)
151+
return 0;
152+
return -ENXIO;
149153
default:
150154
return -ENXIO;
151155
}

0 commit comments

Comments
 (0)