Message ID | 20220908132545.4085849-1-npiggin@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/5] KVM: PPC: Book3S HV P9: Clear vcpu cpu fields before enabling host irqs | expand |
On Thu, 8 Sep 2022 23:25:41 +1000, Nicholas Piggin wrote: > On guest entry, vcpu->cpu and vcpu->arch.thread_cpu are set after > disabling host irqs. On guest exit there is a window whre tick time > accounting briefly enables irqs before these fields are cleared. > > Move them up to ensure they are cleared before host irqs are run. > This is possibly not a problem, but is more symmetric and makes the > fields less surprising. > > [...] Patch 5 applied to powerpc/next. [5/5] KVM: PPC: Book3S HV: Implement scheduling wait interval counters in the VPA https://git.kernel.org/powerpc/c/e4335f53198fa0c0aefb2a38bb5518e94253412c cheers
On Thu, 8 Sep 2022 23:25:41 +1000, Nicholas Piggin wrote: > On guest entry, vcpu->cpu and vcpu->arch.thread_cpu are set after > disabling host irqs. On guest exit there is a window whre tick time > accounting briefly enables irqs before these fields are cleared. > > Move them up to ensure they are cleared before host irqs are run. > This is possibly not a problem, but is more symmetric and makes the > fields less surprising. > > [...] Patches 1-4 applied to powerpc/topic/ppc-kvm. [1/5] KVM: PPC: Book3S HV P9: Clear vcpu cpu fields before enabling host irqs https://git.kernel.org/powerpc/c/bc91c04bfff7cdf676011b97bb21b2861d7b21c9 [2/5] KVM: PPC: Book3S HV P9: Fix irq disabling in tick accounting https://git.kernel.org/powerpc/c/c953f7500b65f2b157d1eb468ca8b86328834cce [3/5] KVM: PPC: Book3S HV: Update guest state entry/exit accounting to new API https://git.kernel.org/powerpc/c/b31bc24a49037aad7aa00d2b0354e9704d8134dc [4/5] KVM: PPC: Book3S HV P9: Restore stolen time logging in dtl https://git.kernel.org/powerpc/c/1a5486b3c3517aa1f608a10003ade4da122cb175 cheers
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 57d0835e56fd..014575b31651 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -4615,6 +4615,9 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit, set_irq_happened(trap); + vcpu->cpu = -1; + vcpu->arch.thread_cpu = -1; + context_tracking_guest_exit(); if (!vtime_accounting_enabled_this_cpu()) { local_irq_enable(); @@ -4630,9 +4633,6 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit, } vtime_account_guest_exit(); - vcpu->cpu = -1; - vcpu->arch.thread_cpu = -1; - powerpc_local_irq_pmu_restore(flags); preempt_enable();
On guest entry, vcpu->cpu and vcpu->arch.thread_cpu are set after disabling host irqs. On guest exit there is a window whre tick time accounting briefly enables irqs before these fields are cleared. Move them up to ensure they are cleared before host irqs are run. This is possibly not a problem, but is more symmetric and makes the fields less surprising. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- arch/powerpc/kvm/book3s_hv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)