2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 05:34:00 +08:00

KVM: PPC: Book3S HV: Fix updates of vcpu->cpu

This removes the powerpc "generic" updates of vcpu->cpu in load and
put, and moves them to the various backends.

The reason is that "HV" KVM does its own sauce with that field
and the generic updates might corrupt it. The field contains the
CPU# of the -first- HW CPU of the core always for all the VCPU
threads of a core (the one that's online from a host Linux
perspective).

However, the preempt notifiers are going to be called on the
threads VCPUs when they are running (due to them sleeping on our
private waitqueue) causing unload to be called, potentially
clobbering the value.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Paul Mackerras 2012-09-20 19:35:51 +00:00 committed by Alexander Graf
parent ed7a8d7a3c
commit a47d72f361
3 changed files with 4 additions and 3 deletions

View File

@ -64,7 +64,7 @@ void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max; svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max;
svcpu_put(svcpu); svcpu_put(svcpu);
#endif #endif
vcpu->cpu = smp_processor_id();
#ifdef CONFIG_PPC_BOOK3S_32 #ifdef CONFIG_PPC_BOOK3S_32
current->thread.kvm_shadow_vcpu = to_book3s(vcpu)->shadow_vcpu; current->thread.kvm_shadow_vcpu = to_book3s(vcpu)->shadow_vcpu;
#endif #endif
@ -84,6 +84,7 @@ void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu)
kvmppc_giveup_ext(vcpu, MSR_FP); kvmppc_giveup_ext(vcpu, MSR_FP);
kvmppc_giveup_ext(vcpu, MSR_VEC); kvmppc_giveup_ext(vcpu, MSR_VEC);
kvmppc_giveup_ext(vcpu, MSR_VSX); kvmppc_giveup_ext(vcpu, MSR_VSX);
vcpu->cpu = -1;
} }
int kvmppc_core_check_requests(struct kvm_vcpu *vcpu) int kvmppc_core_check_requests(struct kvm_vcpu *vcpu)

View File

@ -1509,12 +1509,14 @@ void kvmppc_decrementer_func(unsigned long data)
void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu) void kvmppc_booke_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{ {
vcpu->cpu = smp_processor_id();
current->thread.kvm_vcpu = vcpu; current->thread.kvm_vcpu = vcpu;
} }
void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu) void kvmppc_booke_vcpu_put(struct kvm_vcpu *vcpu)
{ {
current->thread.kvm_vcpu = NULL; current->thread.kvm_vcpu = NULL;
vcpu->cpu = -1;
} }
int __init kvmppc_booke_init(void) int __init kvmppc_booke_init(void)

View File

@ -504,7 +504,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
mtspr(SPRN_VRSAVE, vcpu->arch.vrsave); mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
#endif #endif
kvmppc_core_vcpu_load(vcpu, cpu); kvmppc_core_vcpu_load(vcpu, cpu);
vcpu->cpu = smp_processor_id();
} }
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
@ -513,7 +512,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
#ifdef CONFIG_BOOKE #ifdef CONFIG_BOOKE
vcpu->arch.vrsave = mfspr(SPRN_VRSAVE); vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
#endif #endif
vcpu->cpu = -1;
} }
int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,