KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
Subsystems (2)
PATCH 1/1 KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
Use kvm_arch_vcpu_get_wait() to get a vCPU's rcuwait object instead of using vcpu->wait directly in kvmhv_run_single_vcpu(). Functionally, this is a nop as vcpu->arch.waitp is guaranteed to point at vcpu->wait. But that is not obvious at first glance, and a future change coming in via the KVM tree, commit 510958e99721 ("KVM: Force PPC to define its own rcuwait object"), will hide vcpu->wait from architectures that define __KVM_HAVE_ARCH_WQP to prevent generic KVM from attepting to wake a vCPU with the wrong rcuwait object.
---
Compile tested only. Carrying this in the PPC tree will avoid a build failure due to a silent merge conflict with a change in the KVM tree.
https://lore.kernel.org/all/[email protected]/
arch/powerpc/kvm/book3s_hv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_hv.c +3 -2
@@ -4442,6 +4442,7 @@ static int kvmppc_run_vcpu(struct kvm_vcpu *vcpu)int kvmhv_run_single_vcpu (struct kvm_vcpu *vcpu,u64 time_limit,unsigned long lpcr) { +struct rcuwait *wait =kvm_arch_vcpu_get_wait (vcpu);struct kvm_run *run = vcpu->run;int trap, r, pcpu;int srcu_idx;
@@ -4588,7 +4589,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,if (is_kvmppc_resume_guest (r) && !kvmppc_vcpu_check_block (vcpu)) {kvmppc_set_timer (vcpu); -prepare_to_rcuwait (&vcpu->wait); +prepare_to_rcuwait (wait);for (;;) {set_current_state (TASK_INTERRUPTIBLE );if (signal_pending (current)) {
@@ -4605,7 +4606,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,schedule ();trace_kvmppc_vcore_blocked (vc,1 ); } -finish_rcuwait (&vcpu->wait); +finish_rcuwait (wait); } vcpu->arch.ceded =0 ;
Signature · 1 line
2.34.1.173.g76aa8bc2d0-goog
Quoted 13 lines · Sean Christopherson
Use
kvm_arch_vcpu_get_wait()to get a vCPU's rcuwait object instead of usingvcpu->waitdirectly inkvmhv_run_single_vcpu(). Functionally, this is a nop asvcpu->arch.waitpis guaranteed to point atvcpu->wait. But that is not obvious at first glance, and a future change coming in via the KVM tree, commit510958e99721("KVM: Force PPC to define its own rcuwait object"), will hidevcpu->waitfrom architectures that define__KVM_HAVE_ARCH_WQPto prevent generic KVM from attepting to wake a vCPU with the wrong rcuwait object.
Quoted 7 lines
Reported-by Sachin Sant <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Michael Ellerman <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Sean Christopherson <[email protected]>—
Thanks for the patch.
Michael Ellerman
AppliedQuoted 10 lines · Sean Christopherson
Use
kvm_arch_vcpu_get_wait()to get a vCPU's rcuwait object instead of usingvcpu->waitdirectly inkvmhv_run_single_vcpu(). Functionally, this is a nop asvcpu->arch.waitpis guaranteed to point atvcpu->wait. But that is not obvious at first glance, and a future change coming in via the KVM tree, commit510958e99721("KVM: Force PPC to define its own rcuwait object"), will hidevcpu->waitfrom architectures that define__KVM_HAVE_ARCH_WQPto prevent generic KVM from attepting to wake a vCPU with the wrong rcuwait object.[...]
Applied to powerpc/next.
[1/1] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
https://git.kernel.org/powerpc/c/63fa47ba886b86cbd58f03b3b01b04bd57a1f233
cheers