Skip to content

Commit 82db90b

Browse files
bibo-maochenhuacai
authored andcommitted
LoongArch: KVM: Move feature detection in kvm_vm_init_features()
VM feature detection is sparsed in function kvm_vm_init_features() and kvm_vm_feature_has_attr(). Here move all the features detection in function kvm_vm_init_features(), and there is only feature checking in function kvm_vm_feature_has_attr(). Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent de0c513 commit 82db90b

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

  • arch/loongarch/kvm

arch/loongarch/kvm/vm.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ static void kvm_vm_init_features(struct kvm *kvm)
2929
{
3030
unsigned long val;
3131

32+
if (cpu_has_lsx)
33+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_LSX);
34+
if (cpu_has_lasx)
35+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_LASX);
36+
if (cpu_has_lbt_x86)
37+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_X86BT);
38+
if (cpu_has_lbt_arm)
39+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_ARMBT);
40+
if (cpu_has_lbt_mips)
41+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_MIPSBT);
42+
if (cpu_has_ptw)
43+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_PTW);
44+
if (cpu_has_msgint)
45+
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_MSGINT);
46+
3247
val = read_csr_gcfg();
3348
if (val & CSR_GCFG_GPMP)
3449
kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_PMU);
@@ -131,33 +146,12 @@ static int kvm_vm_feature_has_attr(struct kvm *kvm, struct kvm_device_attr *attr
131146
{
132147
switch (attr->attr) {
133148
case KVM_LOONGARCH_VM_FEAT_LSX:
134-
if (cpu_has_lsx)
135-
return 0;
136-
return -ENXIO;
137149
case KVM_LOONGARCH_VM_FEAT_LASX:
138-
if (cpu_has_lasx)
139-
return 0;
140-
return -ENXIO;
141150
case KVM_LOONGARCH_VM_FEAT_X86BT:
142-
if (cpu_has_lbt_x86)
143-
return 0;
144-
return -ENXIO;
145151
case KVM_LOONGARCH_VM_FEAT_ARMBT:
146-
if (cpu_has_lbt_arm)
147-
return 0;
148-
return -ENXIO;
149152
case KVM_LOONGARCH_VM_FEAT_MIPSBT:
150-
if (cpu_has_lbt_mips)
151-
return 0;
152-
return -ENXIO;
153153
case KVM_LOONGARCH_VM_FEAT_PTW:
154-
if (cpu_has_ptw)
155-
return 0;
156-
return -ENXIO;
157154
case KVM_LOONGARCH_VM_FEAT_MSGINT:
158-
if (cpu_has_msgint)
159-
return 0;
160-
return -ENXIO;
161155
case KVM_LOONGARCH_VM_FEAT_PMU:
162156
case KVM_LOONGARCH_VM_FEAT_PV_IPI:
163157
case KVM_LOONGARCH_VM_FEAT_PV_STEALTIME:

0 commit comments

Comments
 (0)