Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Move vcpu WFIT flag to the state flag set

The host kernel uses the WFIT flag to remember that a vcpu has used
this instruction and wake it up as required. Move it to the state
set, as nothing in the hypervisor uses this information.

Reviewed-by: Fuad Tabba <tabba@google.com>
Reviewed-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>

+5 -5
+2 -2
arch/arm64/include/asm/kvm_host.h
··· 521 521 #define HOST_SME_ENABLED __vcpu_single_flag(sflags, BIT(1)) 522 522 /* Physical CPU not in supported_cpus */ 523 523 #define ON_UNSUPPORTED_CPU __vcpu_single_flag(sflags, BIT(2)) 524 + /* WFIT instruction trapped */ 525 + #define IN_WFIT __vcpu_single_flag(sflags, BIT(3)) 524 526 525 527 /* Pointer to the vcpu's SVE FFR for sve_{save,load}_state() */ 526 528 #define vcpu_sve_pffr(vcpu) (kern_hyp_va((vcpu)->arch.sve_state) + \ ··· 544 542 __size_ret; \ 545 543 }) 546 544 547 - /* vcpu_arch flags field values: */ 548 - #define KVM_ARM64_WFIT (1 << 17) /* WFIT instruction trapped */ 549 545 #define KVM_GUESTDBG_VALID_MASK (KVM_GUESTDBG_ENABLE | \ 550 546 KVM_GUESTDBG_USE_SW_BP | \ 551 547 KVM_GUESTDBG_USE_HW | \
+1 -1
arch/arm64/kvm/arch_timer.c
··· 242 242 static bool vcpu_has_wfit_active(struct kvm_vcpu *vcpu) 243 243 { 244 244 return (cpus_have_final_cap(ARM64_HAS_WFXT) && 245 - (vcpu->arch.flags & KVM_ARM64_WFIT)); 245 + vcpu_get_flag(vcpu, IN_WFIT)); 246 246 } 247 247 248 248 static u64 wfit_delay_ns(struct kvm_vcpu *vcpu)
+1 -1
arch/arm64/kvm/arm.c
··· 657 657 preempt_enable(); 658 658 659 659 kvm_vcpu_halt(vcpu); 660 - vcpu->arch.flags &= ~KVM_ARM64_WFIT; 660 + vcpu_clear_flag(vcpu, IN_WFIT); 661 661 kvm_clear_request(KVM_REQ_UNHALT, vcpu); 662 662 663 663 preempt_disable();
+1 -1
arch/arm64/kvm/handle_exit.c
··· 120 120 kvm_vcpu_on_spin(vcpu, vcpu_mode_priv(vcpu)); 121 121 } else { 122 122 if (esr & ESR_ELx_WFx_ISS_WFxT) 123 - vcpu->arch.flags |= KVM_ARM64_WFIT; 123 + vcpu_set_flag(vcpu, IN_WFIT); 124 124 125 125 kvm_vcpu_wfi(vcpu); 126 126 }