mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
LoongArch: KVM: Move host CSR_EENTRY save and restore in context switch
CSR register LOONGARCH_CSR_EENTRY is shared between host CPU and guest vCPU, KVM need save and restore LOONGARCH_CSR_EENTRY register. Here move LOONGARCH_CSR_EENTRY saving in to context switch function rather than VM entry. At most time VM enter/exit is much more frequent than vCPU thread context switch. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
@@ -320,7 +320,6 @@ static int kvm_pre_enter_guest(struct kvm_vcpu *vcpu)
|
||||
* and it may also clear KVM_REQ_TLB_FLUSH_GPA pending bit
|
||||
*/
|
||||
kvm_late_check_requests(vcpu);
|
||||
vcpu->arch.host_eentry = csr_read64(LOONGARCH_CSR_EENTRY);
|
||||
/* Clear KVM_LARCH_SWCSR_LATEST as CSR will change when enter guest */
|
||||
vcpu->arch.aux_inuse &= ~KVM_LARCH_SWCSR_LATEST;
|
||||
|
||||
@@ -1628,9 +1627,11 @@ static int _kvm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
|
||||
* If not, any old guest state from this vCPU will have been clobbered.
|
||||
*/
|
||||
context = per_cpu_ptr(vcpu->kvm->arch.vmcs, cpu);
|
||||
if (migrated || (context->last_vcpu != vcpu))
|
||||
if (migrated || (context->last_vcpu != vcpu)) {
|
||||
context->last_vcpu = vcpu;
|
||||
vcpu->arch.aux_inuse &= ~KVM_LARCH_HWCSR_USABLE;
|
||||
context->last_vcpu = vcpu;
|
||||
vcpu->arch.host_eentry = csr_read64(LOONGARCH_CSR_EENTRY);
|
||||
}
|
||||
|
||||
/* Restore timer state regardless */
|
||||
kvm_restore_timer(vcpu);
|
||||
|
||||
Reference in New Issue
Block a user