powerpc64/ftrace: Add a field in paca to disable ftrace in unsafe code paths
We have some C code that we call into from real mode where we cannot take any exceptions. Though the C functions themselves are mostly safe, if these functions are traced, there is a possibility that we may take an exception. For instance, in certain conditions, the ftrace code uses WARN(), which uses a 'trap' to do its job. For such scenarios, introduce a new field in paca 'ftrace_enabled', which is checked on ftrace entry before continuing. This field can then be set to zero to disable/pause ftrace, and set to a non-zero value to resume ftrace. Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
Родитель
6da6c0db53
Коммит
ea678ac627
|
@ -223,6 +223,7 @@ struct paca_struct {
|
||||||
u8 hmi_event_available; /* HMI event is available */
|
u8 hmi_event_available; /* HMI event is available */
|
||||||
u8 hmi_p9_special_emu; /* HMI P9 special emulation */
|
u8 hmi_p9_special_emu; /* HMI P9 special emulation */
|
||||||
#endif
|
#endif
|
||||||
|
u8 ftrace_enabled; /* Hard disable ftrace */
|
||||||
|
|
||||||
/* Stuff for accurate time accounting */
|
/* Stuff for accurate time accounting */
|
||||||
struct cpu_accounting_data accounting;
|
struct cpu_accounting_data accounting;
|
||||||
|
|
|
@ -180,6 +180,7 @@ int main(void)
|
||||||
OFFSET(PACAKMSR, paca_struct, kernel_msr);
|
OFFSET(PACAKMSR, paca_struct, kernel_msr);
|
||||||
OFFSET(PACAIRQSOFTMASK, paca_struct, irq_soft_mask);
|
OFFSET(PACAIRQSOFTMASK, paca_struct, irq_soft_mask);
|
||||||
OFFSET(PACAIRQHAPPENED, paca_struct, irq_happened);
|
OFFSET(PACAIRQHAPPENED, paca_struct, irq_happened);
|
||||||
|
OFFSET(PACA_FTRACE_ENABLED, paca_struct, ftrace_enabled);
|
||||||
#ifdef CONFIG_PPC_BOOK3S
|
#ifdef CONFIG_PPC_BOOK3S
|
||||||
OFFSET(PACACONTEXTID, paca_struct, mm_ctx_id);
|
OFFSET(PACACONTEXTID, paca_struct, mm_ctx_id);
|
||||||
#ifdef CONFIG_PPC_MM_SLICES
|
#ifdef CONFIG_PPC_MM_SLICES
|
||||||
|
|
|
@ -252,6 +252,9 @@ static void cpu_ready_for_interrupts(void)
|
||||||
|
|
||||||
/* Set IR and DR in PACA MSR */
|
/* Set IR and DR in PACA MSR */
|
||||||
get_paca()->kernel_msr = MSR_KERNEL;
|
get_paca()->kernel_msr = MSR_KERNEL;
|
||||||
|
|
||||||
|
/* We are now ok to enable ftrace */
|
||||||
|
get_paca()->ftrace_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long spr_default_dscr = 0;
|
unsigned long spr_default_dscr = 0;
|
||||||
|
|
|
@ -47,6 +47,12 @@ _GLOBAL(ftrace_caller)
|
||||||
/* Save all gprs to pt_regs */
|
/* Save all gprs to pt_regs */
|
||||||
SAVE_GPR(0, r1)
|
SAVE_GPR(0, r1)
|
||||||
SAVE_10GPRS(2, r1)
|
SAVE_10GPRS(2, r1)
|
||||||
|
|
||||||
|
/* Ok to continue? */
|
||||||
|
lbz r3, PACA_FTRACE_ENABLED(r13)
|
||||||
|
cmpdi r3, 0
|
||||||
|
beq ftrace_no_trace
|
||||||
|
|
||||||
SAVE_10GPRS(12, r1)
|
SAVE_10GPRS(12, r1)
|
||||||
SAVE_10GPRS(22, r1)
|
SAVE_10GPRS(22, r1)
|
||||||
|
|
||||||
|
@ -168,6 +174,14 @@ _GLOBAL(ftrace_graph_stub)
|
||||||
_GLOBAL(ftrace_stub)
|
_GLOBAL(ftrace_stub)
|
||||||
blr
|
blr
|
||||||
|
|
||||||
|
ftrace_no_trace:
|
||||||
|
mflr r3
|
||||||
|
mtctr r3
|
||||||
|
REST_GPR(3, r1)
|
||||||
|
addi r1, r1, SWITCH_FRAME_SIZE
|
||||||
|
mtlr r0
|
||||||
|
bctr
|
||||||
|
|
||||||
#ifdef CONFIG_LIVEPATCH
|
#ifdef CONFIG_LIVEPATCH
|
||||||
/*
|
/*
|
||||||
* This function runs in the mcount context, between two functions. As
|
* This function runs in the mcount context, between two functions. As
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
|
|
||||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||||
_GLOBAL_TOC(ftrace_caller)
|
_GLOBAL_TOC(ftrace_caller)
|
||||||
|
lbz r3, PACA_FTRACE_ENABLED(r13)
|
||||||
|
cmpdi r3, 0
|
||||||
|
beqlr
|
||||||
|
|
||||||
/* Taken from output of objdump from lib64/glibc */
|
/* Taken from output of objdump from lib64/glibc */
|
||||||
mflr r3
|
mflr r3
|
||||||
ld r11, 0(r1)
|
ld r11, 0(r1)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче