Message ID | 62b77045b205b008946b793fe31effb155b335be.1524121038.git.naveen.n.rao@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | a4bc64d305af40446d0ac792bb8a9b2cd20af3d3 |
Headers | show |
Series | powerpc64/ftrace: Add support for ftrace_modify_call() and a few other fixes | expand |
On Thu, 19 Apr 2018 12:34:05 +0530 "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote: > 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()). > trace_hardirqs_off(); > diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > index bd63fa8a08b5..2c3cbe0067b2 100644 > --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S > +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > @@ -342,6 +342,9 @@ kvm_start_guest: > > ld r2,PACATOC(r13) > You may want to add a comment here about where ftrace gets re-enabled. -- Steve > + li r0,0 > + stb r0,PACA_FTRACE_ENABLED(r13) > + > li r0,KVM_HWTHREAD_IN_KVM > stb r0,HSTATE_HWTHREAD_STATE(r13) >
Steven Rostedt wrote: > On Thu, 19 Apr 2018 12:34:05 +0530 > "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com> wrote: > >> 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()). >> > trace_hardirqs_off(); >> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S >> index bd63fa8a08b5..2c3cbe0067b2 100644 >> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S >> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S >> @@ -342,6 +342,9 @@ kvm_start_guest: >> >> ld r2,PACATOC(r13) >> > > You may want to add a comment here about where ftrace gets re-enabled. Sure. That would be: /* * If this is the primary thread, ftrace will get re-enabled when we * go back to the hypervisor in kvmppc_run_core(). For secondary threads * on Power8, ftrace will get enabled when SMT is re-enabled through the * start_secondary() cpu bringup path. */ - Naveen
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 4d07fca5121c..f604cbd8fc34 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2911,8 +2911,12 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc) srcu_idx = srcu_read_lock(&vc->kvm->srcu); + this_cpu_disable_ftrace(); + trap = __kvmppc_vcore_entry(); + this_cpu_enable_ftrace(); + srcu_read_unlock(&vc->kvm->srcu, srcu_idx); trace_hardirqs_off(); diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index bd63fa8a08b5..2c3cbe0067b2 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -342,6 +342,9 @@ kvm_start_guest: ld r2,PACATOC(r13) + li r0,0 + stb r0,PACA_FTRACE_ENABLED(r13) + li r0,KVM_HWTHREAD_IN_KVM stb r0,HSTATE_HWTHREAD_STATE(r13)
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> --- arch/powerpc/kvm/book3s_hv.c | 4 ++++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 +++ 2 files changed, 7 insertions(+)