* [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
@ 2021-12-13 17:45 Sean Christopherson
2021-12-14 8:07 ` Sachin Sant
2021-12-15 0:40 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-12-13 17:45 UTC (permalink / raw)
To: Michael Ellerman
Cc: Sachin Sant, Sean Christopherson, linux-kernel, Nicholas Piggin,
Paolo Bonzini, linuxppc-dev
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.
Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
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/496ECBB3-36F3-4F07-83B2-875F683BC446@linux.vnet.ibm.com/
arch/powerpc/kvm/book3s_hv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 7986911b873c..f64e45d6c0f4 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -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;
--
2.34.1.173.g76aa8bc2d0-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
2021-12-13 17:45 [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object Sean Christopherson
@ 2021-12-14 8:07 ` Sachin Sant
2021-12-15 0:40 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Sachin Sant @ 2021-12-14 8:07 UTC (permalink / raw)
To: Sean Christopherson
Cc: linuxppc-dev, linux-kernel, Nicholas Piggin, Paolo Bonzini
> On 13-Dec-2021, at 11:15 PM, Sean Christopherson <seanjc@google.com> wrote:
>
> 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.
>
> Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> —
>
Thanks for the patch.
Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object
2021-12-13 17:45 [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object Sean Christopherson
2021-12-14 8:07 ` Sachin Sant
@ 2021-12-15 0:40 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2021-12-15 0:40 UTC (permalink / raw)
To: Sean Christopherson, Michael Ellerman
Cc: Sachin Sant, Paolo Bonzini, linuxppc-dev, linux-kernel,
Nicholas Piggin
On Mon, 13 Dec 2021 17:45:56 +0000, Sean Christopherson wrote:
> 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.
>
> [...]
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-15 0:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-13 17:45 [PATCH] KVM: PPC: Book3S HV P9: Use kvm_arch_vcpu_get_wait() to get rcuwait object Sean Christopherson
2021-12-14 8:07 ` Sachin Sant
2021-12-15 0:40 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox