Skip to content

Commit

Permalink
KVM: PPC: Book3S HV: Context tracking exit guest context before enabl…
Browse files Browse the repository at this point in the history
…ing irqs

Interrupts that occur in kernel mode expect that context tracking
is set to kernel. Enabling local irqs before context tracking
switches from guest to host means interrupts can come in and trigger
warnings about wrong context, and possibly worse.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210130130852.2952424-3-npiggin@gmail.com
  • Loading branch information
npiggin authored and mpe committed Feb 8, 2021
1 parent c0ef717 commit 1126652
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/powerpc/kvm/book3s_hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3407,8 +3407,9 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)

kvmppc_set_host_core(pcpu);

guest_exit_irqoff();

local_irq_enable();
guest_exit();

/* Let secondaries go back to the offline loop */
for (i = 0; i < controlled_threads; ++i) {
Expand Down Expand Up @@ -4217,8 +4218,9 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,

kvmppc_set_host_core(pcpu);

guest_exit_irqoff();

local_irq_enable();
guest_exit();

cpumask_clear_cpu(pcpu, &kvm->arch.cpu_in_guest);

Expand Down

0 comments on commit 1126652

Please sign in to comment.