Skip to content

Commit a4bc64d

Browse files
rnavmpe
authored andcommitted
powerpc64/ftrace: Disable ftrace during kvm entry/exit
During guest entry/exit, we switch over to/from the guest MMU context and we cannot take exceptions in the hypervisor code. Since ftrace may be enabled and since it can result in us taking a trap, disable ftrace by setting paca->ftrace_enabled to zero. There are two paths through which we enter/exit a guest: 1. If we are the vcore runner, then we enter the guest via __kvmppc_vcore_entry() and we disable ftrace around this. This is always the case for Power9, and for the primary thread on Power8. 2. If we are a secondary thread in Power8, then we would be in nap due to SMT being disabled. We are woken up by an IPI to enter the guest. In this scenario, we enter the guest through kvm_start_guest(). We disable ftrace at this point. In this scenario, ftrace would only get re-enabled on the secondary thread when SMT is re-enabled (via start_secondary()). Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 424ef01 commit a4bc64d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

arch/powerpc/kvm/book3s_hv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,8 +2911,12 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
29112911

29122912
srcu_idx = srcu_read_lock(&vc->kvm->srcu);
29132913

2914+
this_cpu_disable_ftrace();
2915+
29142916
trap = __kvmppc_vcore_entry();
29152917

2918+
this_cpu_enable_ftrace();
2919+
29162920
srcu_read_unlock(&vc->kvm->srcu, srcu_idx);
29172921

29182922
trace_hardirqs_off();

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ kvm_start_guest:
342342

343343
ld r2,PACATOC(r13)
344344

345+
li r0,0
346+
stb r0,PACA_FTRACE_ENABLED(r13)
347+
345348
li r0,KVM_HWTHREAD_IN_KVM
346349
stb r0,HSTATE_HWTHREAD_STATE(r13)
347350

0 commit comments

Comments
 (0)