]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
LoongArch: KVM: Add separate KVM_REQ_LBT_LOAD bit
authorBibo Mao <maobibo@loongson.cn>
Thu, 11 Jun 2026 12:46:39 +0000 (20:46 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 11 Jun 2026 12:46:39 +0000 (20:46 +0800)
There are different structures with FPU and LBT register restore, with
FPU the structure is vcpu::arch::fpu, with LBT the structure is vcpu::
arch::lbt. Moreover, FPU/LSX/LASX saving and restoring share the common
structure vcpu::arch::fpu.

New request bit KVM_REQ_LBT_LOAD is used for LBT register restore, and
rename KVM_REQ_AUX_LOAD with KVM_REQ_FPU_LOAD for FPU register restore.

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

index 776bc487a705277f69a144937a5e257f94afac3e..e76a49d4233ba4cf29f5f52f5e61f34b47096c7f 100644 (file)
@@ -38,7 +38,8 @@
 #define KVM_REQ_TLB_FLUSH_GPA          KVM_ARCH_REQ(0)
 #define KVM_REQ_STEAL_UPDATE           KVM_ARCH_REQ(1)
 #define KVM_REQ_PMU                    KVM_ARCH_REQ(2)
-#define KVM_REQ_AUX_LOAD               KVM_ARCH_REQ(3)
+#define KVM_REQ_FPU_LOAD               KVM_ARCH_REQ(3)
+#define KVM_REQ_LBT_LOAD               KVM_ARCH_REQ(4)
 
 #define KVM_GUESTDBG_SW_BP_MASK                \
        (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)
index 3b95cd0f989b08d7d39ac6c782ee24553cb8dee0..b839c989d3dc413c8d85f68b15f04652d1de259e 100644 (file)
@@ -756,7 +756,7 @@ static int kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu, int ecode)
        }
 
        vcpu->arch.aux_ldtype = KVM_LARCH_FPU;
-       kvm_make_request(KVM_REQ_AUX_LOAD, vcpu);
+       kvm_make_request(KVM_REQ_FPU_LOAD, vcpu);
 
        return RESUME_GUEST;
 }
@@ -798,7 +798,7 @@ static int kvm_handle_lsx_disabled(struct kvm_vcpu *vcpu, int ecode)
                kvm_queue_exception(vcpu, EXCCODE_INE, 0);
        else {
                vcpu->arch.aux_ldtype = KVM_LARCH_LSX;
-               kvm_make_request(KVM_REQ_AUX_LOAD, vcpu);
+               kvm_make_request(KVM_REQ_FPU_LOAD, vcpu);
        }
 
        return RESUME_GUEST;
@@ -818,7 +818,7 @@ static int kvm_handle_lasx_disabled(struct kvm_vcpu *vcpu, int ecode)
                kvm_queue_exception(vcpu, EXCCODE_INE, 0);
        else {
                vcpu->arch.aux_ldtype = KVM_LARCH_LASX;
-               kvm_make_request(KVM_REQ_AUX_LOAD, vcpu);
+               kvm_make_request(KVM_REQ_FPU_LOAD, vcpu);
        }
 
        return RESUME_GUEST;
@@ -828,10 +828,8 @@ static int kvm_handle_lbt_disabled(struct kvm_vcpu *vcpu, int ecode)
 {
        if (!kvm_guest_has_lbt(&vcpu->arch))
                kvm_queue_exception(vcpu, EXCCODE_INE, 0);
-       else {
-               vcpu->arch.aux_ldtype = KVM_LARCH_LBT;
-               kvm_make_request(KVM_REQ_AUX_LOAD, vcpu);
-       }
+       else
+               kvm_make_request(KVM_REQ_LBT_LOAD, vcpu);
 
        return RESUME_GUEST;
 }
index e28084c49e6820180b6e653ea834abaa215962ed..c28aa37f37a982728f1e174e8af0113192fd8061 100644 (file)
@@ -239,7 +239,7 @@ static void kvm_late_check_requests(struct kvm_vcpu *vcpu)
                        vcpu->arch.flush_gpa = INVALID_GPA;
                }
 
-       if (kvm_check_request(KVM_REQ_AUX_LOAD, vcpu)) {
+       if (kvm_check_request(KVM_REQ_FPU_LOAD, vcpu)) {
                switch (vcpu->arch.aux_ldtype) {
                case KVM_LARCH_FPU:
                        kvm_own_fpu(vcpu);
@@ -250,15 +250,15 @@ static void kvm_late_check_requests(struct kvm_vcpu *vcpu)
                case KVM_LARCH_LASX:
                        kvm_own_lasx(vcpu);
                        break;
-               case KVM_LARCH_LBT:
-                       kvm_own_lbt(vcpu);
-                       break;
                default:
                        break;
                }
 
                vcpu->arch.aux_ldtype = 0;
        }
+
+       if (kvm_check_request(KVM_REQ_LBT_LOAD, vcpu))
+               kvm_own_lbt(vcpu);
 }
 
 /*