* [PATCH v4 09/10] powerpc64/ftrace: Use the generic version of ftrace_replace_code()
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
Our implementation matches that of the generic version, which also
handles FTRACE_UPDATE_MODIFY_CALL. So, remove our implementation in
favor of the generic version.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kernel/trace/ftrace.c | 36 ------------------------------------
1 file changed, 36 deletions(-)
diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index 4741fe112f05..80667128db3d 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -485,42 +485,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ret;
}
-static int __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
-{
- unsigned long ftrace_addr = (unsigned long)FTRACE_ADDR;
- int ret;
-
- ret = ftrace_update_record(rec, enable);
-
- switch (ret) {
- case FTRACE_UPDATE_IGNORE:
- return 0;
- case FTRACE_UPDATE_MAKE_CALL:
- return ftrace_make_call(rec, ftrace_addr);
- case FTRACE_UPDATE_MAKE_NOP:
- return ftrace_make_nop(NULL, rec, ftrace_addr);
- }
-
- return 0;
-}
-
-void ftrace_replace_code(int enable)
-{
- struct ftrace_rec_iter *iter;
- struct dyn_ftrace *rec;
- int ret;
-
- for (iter = ftrace_rec_iter_start(); iter;
- iter = ftrace_rec_iter_next(iter)) {
- rec = ftrace_rec_iter_record(iter);
- ret = __ftrace_replace_code(rec, enable);
- if (ret) {
- ftrace_bug(ret, rec);
- return;
- }
- }
-}
-
/*
* Use the default ftrace_modify_all_code, but without
* stop_machine().
--
2.16.2
^ permalink raw reply related
* [PATCH v4 08/10] powerpc64/module: Tighten detection of mcount call sites with -mprofile-kernel
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
For R_PPC64_REL24 relocations, we suppress emitting instructions for TOC
load/restore in the relocation stub if the relocation is for _mcount()
call when using -mprofile-kernel ABI.
To detect this, we check if the preceding instructions are per the
standard set of instructions emitted by gcc: either the two instruction
sequence of 'mflr r0; std r0,16(r1)', or the more optimized variant of a
single 'mflr r0'. This is not sufficient since nothing prevents users
from hand coding sequences involving a 'mflr r0' followed by a 'bl'.
For removing the toc save instruction from the stub, we additionally
check if the symbol is "_mcount". Add the same check here as well.
Also rename is_early_mcount_callsite() to is_mprofile_mcount_callsite()
since that is what is being checked. The use of "early" is misleading
since there is nothing involving this function that qualifies as early.
Fixes: 153086644fd1f ("powerpc/ftrace: Add support for -mprofile-kernel ftrace ABI")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kernel/module_64.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index a2636c250b7b..8413be31d6a4 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -463,8 +463,11 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs,
}
#ifdef CC_USING_MPROFILE_KERNEL
-static bool is_early_mcount_callsite(u32 *instruction)
+static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
{
+ if (strcmp("_mcount", name))
+ return false;
+
/*
* Check if this is one of the -mprofile-kernel sequences.
*/
@@ -496,8 +499,7 @@ static void squash_toc_save_inst(const char *name, unsigned long addr)
#else
static void squash_toc_save_inst(const char *name, unsigned long addr) { }
-/* without -mprofile-kernel, mcount calls are never early */
-static bool is_early_mcount_callsite(u32 *instruction)
+static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
{
return false;
}
@@ -505,11 +507,11 @@ static bool is_early_mcount_callsite(u32 *instruction)
/* We expect a noop next: if it is, replace it with instruction to
restore r2. */
-static int restore_r2(u32 *instruction, struct module *me)
+static int restore_r2(const char *name, u32 *instruction, struct module *me)
{
u32 *prev_insn = instruction - 1;
- if (is_early_mcount_callsite(prev_insn))
+ if (is_mprofile_mcount_callsite(name, prev_insn))
return 1;
/*
@@ -650,7 +652,8 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
value = stub_for_addr(sechdrs, value, me);
if (!value)
return -ENOENT;
- if (!restore_r2((u32 *)location + 1, me))
+ if (!restore_r2(strtab + sym->st_name,
+ (u32 *)location + 1, me))
return -ENOEXEC;
squash_toc_save_inst(strtab + sym->st_name, value);
--
2.16.2
^ permalink raw reply related
* [PATCH v4 07/10] powerpc64/kexec: Hard disable ftrace before switching to the new kernel
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
If function_graph tracer is enabled during kexec, we see the below
exception in the simulator:
root@(none):/# kexec -e
kvm: exiting hardware virtualization
kexec_core: Starting new kernel
[ 19.262020070,5] OPAL: Switch to big-endian OS
kexec: Starting switchover sequence.
Interrupt to 0xC000000000004380 from 0xC000000000004380
** Execution stopped: Continuous Interrupt, Instruction caused exception, **
Now that we have a more effective way to completely disable ftrace on
ppc64, let's also use that before switching to a new kernel during
kexec.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kernel/machine_kexec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 2694d078741d..936c7e2d421e 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -98,12 +98,14 @@ void machine_kexec(struct kimage *image)
int save_ftrace_enabled;
save_ftrace_enabled = __ftrace_enabled_save();
+ this_cpu_disable_ftrace();
if (ppc_md.machine_kexec)
ppc_md.machine_kexec(image);
else
default_machine_kexec(image);
+ this_cpu_enable_ftrace();
__ftrace_enabled_restore(save_ftrace_enabled);
/* Fall back to normal restart if we're still alive. */
--
2.16.2
^ permalink raw reply related
* [PATCH v4 06/10] powerpc64/ftrace: Disable ftrace during hotplug
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
Disable ftrace when a cpu is about to go offline. When the cpu is woken
up, ftrace will get enabled in start_secondary().
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kernel/smp.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index d90195dddc57..09a7ef12ff33 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -1122,6 +1122,8 @@ int __cpu_disable(void)
if (!smp_ops->cpu_disable)
return -ENOSYS;
+ this_cpu_disable_ftrace();
+
err = smp_ops->cpu_disable();
if (err)
return err;
@@ -1140,6 +1142,12 @@ void __cpu_die(unsigned int cpu)
void cpu_die(void)
{
+ /*
+ * Disable on the down path. This will be re-enabled by
+ * start_secondary() via start_secondary_resume() below
+ */
+ this_cpu_disable_ftrace();
+
if (ppc_md.cpu_die)
ppc_md.cpu_die();
--
2.16.2
^ permalink raw reply related
* [PATCH v4 05/10] powerpc64/ftrace: Delay enabling ftrace on secondary cpus
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
On the boot cpu, though we enable paca->ftrace_enabled in early_setup()
(via cpu_ready_for_interrupts()), we don't start tracing until much
later since ftrace is not initialized yet and since we only support
DYNAMIC_FTRACE on powerpc. However, it is possible that ftrace has been
initialized by the time some of the secondary cpus start up. In this
case, we will try to trace some of the early boot code which can cause
problems.
To address this, move setting paca->ftrace_enabled from
cpu_ready_for_interrupts() to early_setup() for the boot cpu, and towards
the end of start_secondary() for secondary cpus.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kernel/setup_64.c | 10 +++++++---
arch/powerpc/kernel/smp.c | 4 ++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index a96ea3bab8f4..625833f4099a 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -252,9 +252,6 @@ static void cpu_ready_for_interrupts(void)
/* Set IR and DR in PACA MSR */
get_paca()->kernel_msr = MSR_KERNEL;
-
- /* We are now ok to enable ftrace */
- get_paca()->ftrace_enabled = 1;
}
unsigned long spr_default_dscr = 0;
@@ -349,6 +346,13 @@ void __init early_setup(unsigned long dt_ptr)
*/
cpu_ready_for_interrupts();
+ /*
+ * We enable ftrace here, but since we only support DYNAMIC_FTRACE, it
+ * will only actually get enabled on the boot cpu much later once
+ * ftrace itself has been initialized.
+ */
+ this_cpu_enable_ftrace();
+
DBG(" <- early_setup()\n");
#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index cfc08b099c49..d90195dddc57 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -59,6 +59,7 @@
#include <asm/kexec.h>
#include <asm/asm-prototypes.h>
#include <asm/cpu_has_feature.h>
+#include <asm/ftrace.h>
#ifdef DEBUG
#include <asm/udbg.h>
@@ -1022,6 +1023,9 @@ void start_secondary(void *unused)
local_irq_enable();
+ /* We can enable ftrace for secondary cpus now */
+ this_cpu_enable_ftrace();
+
cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
BUG();
--
2.16.2
^ permalink raw reply related
* [PATCH v4 04/10] powerpc64/ftrace: Add helpers to hard disable ftrace
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
Add some helpers to enable/disable ftrace through paca->ftrace_enabled.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/ftrace.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index ebfc0b846bb5..3b5e85a72e10 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -82,6 +82,23 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
return !strcmp(sym + 4, name + 3);
}
#endif /* CONFIG_FTRACE_SYSCALLS && PPC64_ELF_ABI_v1 */
+
+#ifdef CONFIG_PPC64
+#include <asm/paca.h>
+
+static inline void this_cpu_disable_ftrace(void)
+{
+ get_paca()->ftrace_enabled = 0;
+}
+
+static inline void this_cpu_enable_ftrace(void)
+{
+ get_paca()->ftrace_enabled = 1;
+}
+#else /* CONFIG_PPC64 */
+static inline void this_cpu_disable_ftrace(void) { }
+static inline void this_cpu_enable_ftrace(void) { }
+#endif /* CONFIG_PPC64 */
#endif /* !__ASSEMBLY__ */
#endif /* _ASM_POWERPC_FTRACE */
--
2.16.2
^ permalink raw reply related
* [PATCH v4 03/10] powerpc64/ftrace: Rearrange #ifdef sections in ftrace.h
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
Re-arrange the last #ifdef section in preparation for a subsequent
change.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/ftrace.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index 9abddde372ab..ebfc0b846bb5 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -68,8 +68,8 @@ struct dyn_arch_ftrace {
#endif
#endif
-#if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
-#ifdef PPC64_ELF_ABI_v1
+#ifndef __ASSEMBLY__
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(PPC64_ELF_ABI_v1)
#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
{
@@ -81,7 +81,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
*/
return !strcmp(sym + 4, name + 3);
}
-#endif
-#endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
+#endif /* CONFIG_FTRACE_SYSCALLS && PPC64_ELF_ABI_v1 */
+#endif /* !__ASSEMBLY__ */
#endif /* _ASM_POWERPC_FTRACE */
--
2.16.2
^ permalink raw reply related
* [PATCH v4 02/10] powerpc64/ftrace: Disable ftrace during kvm guest entry/exit
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
During guest entry/exit, we switch over to/from the guest MMU context.
While doing so, we set our state to KVM_GUEST_MODE_HOST_HV to note down
the fact that we cannot take any 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. Once we exit the
guest and restore host MMU context, we re-enable ftrace.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index bd63fa8a08b5..6f2d7206a12b 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -598,6 +598,10 @@ kvmppc_hv_entry:
/* Save R1 in the PACA */
std r1, HSTATE_HOST_R1(r13)
+ /* Disable ftrace since we can't take a trap any more */
+ li r6, 0
+ stb r6, PACA_FTRACE_ENABLED(r13)
+
li r6, KVM_GUEST_MODE_HOST_HV
stb r6, HSTATE_IN_GUEST(r13)
@@ -2078,6 +2082,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
/* Unset guest mode */
li r0, KVM_GUEST_MODE_NONE
stb r0, HSTATE_IN_GUEST(r13)
+ li r0, 1
+ stb r0, PACA_FTRACE_ENABLED(r13)
lwz r12, STACK_SLOT_TRAP(r1) /* return trap # in r12 */
ld r0, SFS+PPC_LR_STKOFF(r1)
@@ -3547,6 +3553,8 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX)
ld r8, KVM_HOST_LPCR(r10)
mtspr SPRN_LPCR, r8
isync
+ li r0, 1
+ stb r0, PACA_FTRACE_ENABLED(r13)
li r0, KVM_GUEST_MODE_NONE
stb r0, HSTATE_IN_GUEST(r13)
--
2.16.2
^ permalink raw reply related
* [PATCH v4 01/10] powerpc64/ftrace: Add a field in paca to disable ftrace in unsafe code paths
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
In-Reply-To: <cover.1522784883.git.naveen.n.rao@linux.vnet.ibm.com>
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>
---
arch/powerpc/include/asm/paca.h | 1 +
arch/powerpc/kernel/asm-offsets.c | 1 +
arch/powerpc/kernel/setup_64.c | 3 +++
arch/powerpc/kernel/trace/ftrace_64_mprofile.S | 14 ++++++++++++++
arch/powerpc/kernel/trace/ftrace_64_pg.S | 4 ++++
5 files changed, 23 insertions(+)
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 4185f1c96125..163f13f31255 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -223,6 +223,7 @@ struct paca_struct {
u8 hmi_event_available; /* HMI event is available */
u8 hmi_p9_special_emu; /* HMI P9 special emulation */
#endif
+ u8 ftrace_enabled; /* Hard disable ftrace */
/* Stuff for accurate time accounting */
struct cpu_accounting_data accounting;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 6bee65f3cfd3..262c44a90ea1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -180,6 +180,7 @@ int main(void)
OFFSET(PACAKMSR, paca_struct, kernel_msr);
OFFSET(PACAIRQSOFTMASK, paca_struct, irq_soft_mask);
OFFSET(PACAIRQHAPPENED, paca_struct, irq_happened);
+ OFFSET(PACA_FTRACE_ENABLED, paca_struct, ftrace_enabled);
#ifdef CONFIG_PPC_BOOK3S
OFFSET(PACACONTEXTID, paca_struct, mm_ctx_id);
#ifdef CONFIG_PPC_MM_SLICES
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 66f2b6299c40..a96ea3bab8f4 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -252,6 +252,9 @@ static void cpu_ready_for_interrupts(void)
/* Set IR and DR in PACA MSR */
get_paca()->kernel_msr = MSR_KERNEL;
+
+ /* We are now ok to enable ftrace */
+ get_paca()->ftrace_enabled = 1;
}
unsigned long spr_default_dscr = 0;
diff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
index 3f3e81852422..ae1cbe783ab6 100644
--- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
+++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S
@@ -47,6 +47,12 @@ _GLOBAL(ftrace_caller)
/* Save all gprs to pt_regs */
SAVE_GPR(0, 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(22, r1)
@@ -168,6 +174,14 @@ _GLOBAL(ftrace_graph_stub)
_GLOBAL(ftrace_stub)
blr
+ftrace_no_trace:
+ mflr r3
+ mtctr r3
+ REST_GPR(3, r1)
+ addi r1, r1, SWITCH_FRAME_SIZE
+ mtlr r0
+ bctr
+
#ifdef CONFIG_LIVEPATCH
/*
* This function runs in the mcount context, between two functions. As
diff --git a/arch/powerpc/kernel/trace/ftrace_64_pg.S b/arch/powerpc/kernel/trace/ftrace_64_pg.S
index f095358da96e..b7ba51a0f3b6 100644
--- a/arch/powerpc/kernel/trace/ftrace_64_pg.S
+++ b/arch/powerpc/kernel/trace/ftrace_64_pg.S
@@ -16,6 +16,10 @@
#ifdef CONFIG_DYNAMIC_FTRACE
_GLOBAL_TOC(ftrace_caller)
+ lbz r3, PACA_FTRACE_ENABLED(r13)
+ cmpdi r3, 0
+ beqlr
+
/* Taken from output of objdump from lib64/glibc */
mflr r3
ld r11, 0(r1)
--
2.16.2
^ permalink raw reply related
* [PATCH v4 00/10] powerpc64/ftrace: Add support for ftrace_modify_call() and a few other fixes
From: Naveen N. Rao @ 2018-04-03 20:12 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt
Cc: linuxppc-dev, Paul Mackerras, Nicholas Piggin, Anton Blanchard,
sathnaga
This is v4 of the patches posted at:
https://www.mail-archive.com/linuxppc-dev@lists.ozlabs.org/msg130739.html
This series has been tested using mambo for p8 (hash) and p9 (radix).
v4 changes:
- flip the paca field from 'ftrace_disabled' to 'ftrace_enabled' to
signify a default disable policy to address early boot
- add and use helpers to disable/enable ftrace, which addresses 32-bit
build issues
- a new patch to address issues with function_graph tracing during cpu
hotplug.
The last three patches are unchanged from the previous series, for the
most part (except for the ftrace_disabled -> ftrace_enabled adjustment).
The last two patches implement support for ftrace_caller() to
conditionally save the register state. This speeds up the function
tracer a bit. The existing ftrace_caller() is renamed to
ftrace_regs_caller() since we save the entire pt_regs today. A new
implementation of ftrace_caller() that saves the minimum register state
is provided. We switch between the two variants through
ftrace_modify_call(). The necessary support to call into the two
different variants from modules is also added.
- Naveen
Naveen N. Rao (10):
powerpc64/ftrace: Add a field in paca to disable ftrace in unsafe code
paths
powerpc64/ftrace: Disable ftrace during kvm guest entry/exit
powerpc64/ftrace: Rearrange #ifdef sections in ftrace.h
powerpc64/ftrace: Add helpers to hard disable ftrace
powerpc64/ftrace: Delay enabling ftrace on secondary cpus
powerpc64/ftrace: Disable ftrace during hotplug
powerpc64/kexec: Hard disable ftrace before switching to the new
kernel
powerpc64/module: Tighten detection of mcount call sites with
-mprofile-kernel
powerpc64/ftrace: Use the generic version of ftrace_replace_code()
powerpc64/ftrace: Implement support for ftrace_regs_caller()
arch/powerpc/include/asm/ftrace.h | 27 +++-
arch/powerpc/include/asm/module.h | 3 +
arch/powerpc/include/asm/paca.h | 1 +
arch/powerpc/kernel/asm-offsets.c | 1 +
arch/powerpc/kernel/machine_kexec.c | 2 +
arch/powerpc/kernel/module_64.c | 43 +++--
arch/powerpc/kernel/setup_64.c | 7 +
arch/powerpc/kernel/smp.c | 12 ++
arch/powerpc/kernel/trace/ftrace.c | 210 ++++++++++++++++++++-----
arch/powerpc/kernel/trace/ftrace_64_mprofile.S | 85 +++++++++-
arch/powerpc/kernel/trace/ftrace_64_pg.S | 4 +
arch/powerpc/kvm/book3s_hv_rmhandlers.S | 8 +
12 files changed, 336 insertions(+), 67 deletions(-)
--
2.16.2
^ permalink raw reply
* Re: [PATCH v9 15/24] mm: Introduce __vm_normal_page()
From: Jerome Glisse @ 2018-04-03 19:39 UTC (permalink / raw)
To: Laurent Dufour
Cc: paulmck, peterz, akpm, kirill, ak, mhocko, dave, jack,
Matthew Wilcox, benh, mpe, paulus, Thomas Gleixner, Ingo Molnar,
hpa, Will Deacon, Sergey Senozhatsky, Andrea Arcangeli,
Alexei Starovoitov, kemi.wang, sergey.senozhatsky.work,
Daniel Jordan, linux-kernel, linux-mm, haren, khandual, npiggin,
bsingharora, Tim Chen, linuxppc-dev, x86
In-Reply-To: <1520963994-28477-16-git-send-email-ldufour@linux.vnet.ibm.com>
On Tue, Mar 13, 2018 at 06:59:45PM +0100, Laurent Dufour wrote:
> When dealing with the speculative fault path we should use the VMA's field
> cached value stored in the vm_fault structure.
>
> Currently vm_normal_page() is using the pointer to the VMA to fetch the
> vm_flags value. This patch provides a new __vm_normal_page() which is
> receiving the vm_flags flags value as parameter.
>
> Note: The speculative path is turned on for architecture providing support
> for special PTE flag. So only the first block of vm_normal_page is used
> during the speculative path.
Might be a good idea to explicitly have SPECULATIVE Kconfig option depends
on ARCH_PTE_SPECIAL and a comment for !HAVE_PTE_SPECIAL in the function
explaining that speculative page fault should never reach that point.
Cheers,
Jérôme
^ permalink raw reply
* Re: [PATCH v3 1/7] powerpc/fadump: Move the metadata region to start of the reserved area.
From: Hari Bathini @ 2018-04-03 19:26 UTC (permalink / raw)
To: Mahesh J Salgaonkar, linuxppc-dev
Cc: Ananth Narayan, kernelfans, Aneesh Kumar K.V, Nathan Fontenot,
Anshuman Khandual, Srikar Dronamraju
In-Reply-To: <152265058069.23251.1496677151481459154.stgit@jupiter.in.ibm.com>
Mahesh, I think we should explicitly document that production and
capture kernel
versions should be same. For changes like below, older/newer production
kernel vs
capture kernel is bound to fail. Of course, production and capture
kernel versions
would be the same case usually but for the uninitiated, mentioning that
explicitly
in documentation would help..?
Thanks
Hari
On Monday 02 April 2018 11:59 AM, Mahesh J Salgaonkar wrote:
> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>
> Currently the metadata region that holds crash info structure and ELF core
> header is placed towards the end of reserved memory area. This patch places
> it at the beginning of the reserved memory area.
>
> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/fadump.h | 4 ++
> arch/powerpc/kernel/fadump.c | 92 ++++++++++++++++++++++++++++++++-----
> 2 files changed, 83 insertions(+), 13 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
> index 5a23010af600..44b6ebfe9be6 100644
> --- a/arch/powerpc/include/asm/fadump.h
> +++ b/arch/powerpc/include/asm/fadump.h
> @@ -61,6 +61,9 @@
> #define FADUMP_UNREGISTER 2
> #define FADUMP_INVALIDATE 3
>
> +/* Number of dump sections requested by kernel */
> +#define FADUMP_NUM_SECTIONS 4
> +
> /* Dump status flag */
> #define FADUMP_ERROR_FLAG 0x2000
>
> @@ -119,6 +122,7 @@ struct fadump_mem_struct {
> struct fadump_section cpu_state_data;
> struct fadump_section hpte_region;
> struct fadump_section rmr_region;
> + struct fadump_section metadata_region;
> };
>
> /* Firmware-assisted dump configuration details. */
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index 3c2c2688918f..80552fd7d5f8 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -188,17 +188,48 @@ static void fadump_show_config(void)
> pr_debug("Boot memory size : %lx\n", fw_dump.boot_memory_size);
> }
>
> +static unsigned long get_fadump_metadata_size(void)
> +{
> + unsigned long size = 0;
> +
> + /*
> + * If fadump is active then look into fdm_active to get metadata
> + * size set by previous kernel.
> + */
> + if (fw_dump.dump_active) {
> + size = fdm_active->cpu_state_data.destination_address -
> + fdm_active->metadata_region.source_address;
> + goto out;
> + }
> + size += sizeof(struct fadump_crash_info_header);
> + size += sizeof(struct elfhdr); /* ELF core header.*/
> + size += sizeof(struct elf_phdr); /* place holder for cpu notes */
> + /* Program headers for crash memory regions. */
> + size += sizeof(struct elf_phdr) * (memblock_num_regions(memory) + 2);
> +
> + size = PAGE_ALIGN(size);
> +out:
> + pr_debug("fadump Metadata size is %ld\n", size);
> + return size;
> +}
> +
> static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
> unsigned long addr)
> {
> + uint16_t num_sections = 0;
> + unsigned long metadata_base = 0;
> +
> if (!fdm)
> return 0;
>
> + /* Skip the fadump metadata area. */
> + metadata_base = addr;
> + addr += get_fadump_metadata_size();
> +
> memset(fdm, 0, sizeof(struct fadump_mem_struct));
> addr = addr & PAGE_MASK;
>
> fdm->header.dump_format_version = cpu_to_be32(0x00000001);
> - fdm->header.dump_num_sections = cpu_to_be16(3);
> fdm->header.dump_status_flag = 0;
> fdm->header.offset_first_dump_section =
> cpu_to_be32((u32)offsetof(struct fadump_mem_struct, cpu_state_data));
> @@ -222,6 +253,7 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
> fdm->cpu_state_data.source_address = 0;
> fdm->cpu_state_data.source_len = cpu_to_be64(fw_dump.cpu_state_data_size);
> fdm->cpu_state_data.destination_address = cpu_to_be64(addr);
> + num_sections++;
> addr += fw_dump.cpu_state_data_size;
>
> /* hpte region section */
> @@ -230,6 +262,7 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
> fdm->hpte_region.source_address = 0;
> fdm->hpte_region.source_len = cpu_to_be64(fw_dump.hpte_region_size);
> fdm->hpte_region.destination_address = cpu_to_be64(addr);
> + num_sections++;
> addr += fw_dump.hpte_region_size;
>
> /* RMA region section */
> @@ -238,8 +271,25 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
> fdm->rmr_region.source_address = cpu_to_be64(RMA_START);
> fdm->rmr_region.source_len = cpu_to_be64(fw_dump.boot_memory_size);
> fdm->rmr_region.destination_address = cpu_to_be64(addr);
> + num_sections++;
> addr += fw_dump.boot_memory_size;
>
> + /*
> + * fadump metadata section.
> + * Add an entry with source len a zero. We are only intereseted in
> + * source address which will help us to detect the location of
> + * metadata area where faump header and elf core header is placed.
> + */
> + fdm->metadata_region.request_flag = cpu_to_be32(FADUMP_REQUEST_FLAG);
> + fdm->metadata_region.source_data_type =
> + cpu_to_be16(FADUMP_REAL_MODE_REGION);
> + fdm->metadata_region.source_address = cpu_to_be64(metadata_base);
> + fdm->metadata_region.source_len = 0;
> + fdm->metadata_region.destination_address = cpu_to_be64(addr);
> + num_sections++;
> +
> + fdm->header.dump_num_sections = cpu_to_be16(num_sections);
> + BUILD_BUG_ON(num_sections != FADUMP_NUM_SECTIONS);
> return addr;
> }
>
> @@ -325,16 +375,17 @@ static unsigned long get_fadump_area_size(void)
> size += fw_dump.cpu_state_data_size;
> size += fw_dump.hpte_region_size;
> size += fw_dump.boot_memory_size;
> - size += sizeof(struct fadump_crash_info_header);
> - size += sizeof(struct elfhdr); /* ELF core header.*/
> - size += sizeof(struct elf_phdr); /* place holder for cpu notes */
> - /* Program headers for crash memory regions. */
> - size += sizeof(struct elf_phdr) * (memblock_num_regions(memory) + 2);
> -
> + size += get_fadump_metadata_size();
> size = PAGE_ALIGN(size);
> return size;
> }
>
> +static inline unsigned long get_fadump_metadata_base(
> + const struct fadump_mem_struct *fdm)
> +{
> + return be64_to_cpu(fdm->metadata_region.source_address);
> +}
> +
> int __init fadump_reserve_mem(void)
> {
> unsigned long base, size, memory_boundary;
> @@ -395,9 +446,9 @@ int __init fadump_reserve_mem(void)
> (unsigned long)(size >> 20),
> (unsigned long)(base >> 20));
>
> - fw_dump.fadumphdr_addr =
> - be64_to_cpu(fdm_active->rmr_region.destination_address) +
> - be64_to_cpu(fdm_active->rmr_region.source_len);
> + pr_info("Number of kernel Dump sections: %d\n",
> + be16_to_cpu(fdm_active->header.dump_num_sections));
> + fw_dump.fadumphdr_addr = get_fadump_metadata_base(fdm_active);
> pr_debug("fadumphdr_addr = %p\n",
> (void *) fw_dump.fadumphdr_addr);
> } else {
> @@ -803,14 +854,24 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
> static int __init process_fadump(const struct fadump_mem_struct *fdm_active)
> {
> struct fadump_crash_info_header *fdh;
> + uint16_t num_sections = 0;
> int rc = 0;
>
> if (!fdm_active || !fw_dump.fadumphdr_addr)
> return -EINVAL;
>
> + /* Check if platform has honored all 4 dump sections requested. */
> + num_sections = be16_to_cpu(fdm_active->header.dump_num_sections);
> + if (num_sections < FADUMP_NUM_SECTIONS) {
> + printk(KERN_ERR "Dump taken by platform does not "
> + "contain all requested sections\n");
> + return -EINVAL;
> + }
> +
> /* Check if the dump data is valid. */
> if ((be16_to_cpu(fdm_active->header.dump_status_flag) == FADUMP_ERROR_FLAG) ||
> (fdm_active->cpu_state_data.error_flags != 0) ||
> + (fdm_active->metadata_region.error_flags != 0) ||
> (fdm_active->rmr_region.error_flags != 0)) {
> printk(KERN_ERR "Dump taken by platform is not valid\n");
> return -EINVAL;
> @@ -821,6 +882,11 @@ static int __init process_fadump(const struct fadump_mem_struct *fdm_active)
> printk(KERN_ERR "Dump taken by platform is incomplete\n");
> return -EINVAL;
> }
> + if ((fdm_active->metadata_region.bytes_dumped !=
> + fdm_active->metadata_region.source_len)) {
> + printk(KERN_ERR "Dump taken by platform is incomplete\n");
> + return -EINVAL;
> + }
>
> /* Validate the fadump crash info header */
> fdh = __va(fw_dump.fadumphdr_addr);
> @@ -1082,7 +1148,7 @@ static int register_fadump(void)
>
> fadump_setup_crash_memory_ranges();
>
> - addr = be64_to_cpu(fdm.rmr_region.destination_address) + be64_to_cpu(fdm.rmr_region.source_len);
> + addr = get_fadump_metadata_base(&fdm);
> /* Initialize fadump crash info header. */
> addr = init_fadump_header(addr);
> vaddr = __va(addr);
> @@ -1153,7 +1219,7 @@ void fadump_cleanup(void)
> /* Invalidate the registration only if dump is active. */
> if (fw_dump.dump_active) {
> init_fadump_mem_struct(&fdm,
> - be64_to_cpu(fdm_active->cpu_state_data.destination_address));
> + get_fadump_metadata_base(fdm_active));
> fadump_invalidate_dump(&fdm);
> }
> }
> @@ -1236,7 +1302,7 @@ static void fadump_invalidate_release_mem(void)
> return;
> }
>
> - destination_address = be64_to_cpu(fdm_active->cpu_state_data.destination_address);
> + destination_address = get_fadump_metadata_base(fdm_active);
> fadump_cleanup();
> mutex_unlock(&fadump_mutex);
>
>
^ permalink raw reply
* Re: [PATCH v9 06/24] mm: make pte_unmap_same compatible with SPF
From: Jerome Glisse @ 2018-04-03 19:10 UTC (permalink / raw)
To: Laurent Dufour
Cc: paulmck, peterz, akpm, kirill, ak, mhocko, dave, jack,
Matthew Wilcox, benh, mpe, paulus, Thomas Gleixner, Ingo Molnar,
hpa, Will Deacon, Sergey Senozhatsky, Andrea Arcangeli,
Alexei Starovoitov, kemi.wang, sergey.senozhatsky.work,
Daniel Jordan, linux-kernel, linux-mm, haren, khandual, npiggin,
bsingharora, Tim Chen, linuxppc-dev, x86
In-Reply-To: <1520963994-28477-7-git-send-email-ldufour@linux.vnet.ibm.com>
On Tue, Mar 13, 2018 at 06:59:36PM +0100, Laurent Dufour wrote:
> pte_unmap_same() is making the assumption that the page table are still
> around because the mmap_sem is held.
> This is no more the case when running a speculative page fault and
> additional check must be made to ensure that the final page table are still
> there.
>
> This is now done by calling pte_spinlock() to check for the VMA's
> consistency while locking for the page tables.
>
> This is requiring passing a vm_fault structure to pte_unmap_same() which is
> containing all the needed parameters.
>
> As pte_spinlock() may fail in the case of a speculative page fault, if the
> VMA has been touched in our back, pte_unmap_same() should now return 3
> cases :
> 1. pte are the same (0)
> 2. pte are different (VM_FAULT_PTNOTSAME)
> 3. a VMA's changes has been detected (VM_FAULT_RETRY)
>
> The case 2 is handled by the introduction of a new VM_FAULT flag named
> VM_FAULT_PTNOTSAME which is then trapped in cow_user_page().
> If VM_FAULT_RETRY is returned, it is passed up to the callers to retry the
> page fault while holding the mmap_sem.
>
> Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
> ---
> include/linux/mm.h | 1 +
> mm/memory.c | 29 +++++++++++++++++++----------
> 2 files changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 2f3e98edc94a..b6432a261e63 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1199,6 +1199,7 @@ static inline void clear_page_pfmemalloc(struct page *page)
> #define VM_FAULT_NEEDDSYNC 0x2000 /* ->fault did not modify page tables
> * and needs fsync() to complete (for
> * synchronous page faults in DAX) */
> +#define VM_FAULT_PTNOTSAME 0x4000 /* Page table entries have changed */
>
> #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \
> VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \
> diff --git a/mm/memory.c b/mm/memory.c
> index 21b1212a0892..4bc7b0bdcb40 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2309,21 +2309,29 @@ static bool pte_map_lock(struct vm_fault *vmf)
> * parts, do_swap_page must check under lock before unmapping the pte and
> * proceeding (but do_wp_page is only called after already making such a check;
> * and do_anonymous_page can safely check later on).
> + *
> + * pte_unmap_same() returns:
> + * 0 if the PTE are the same
> + * VM_FAULT_PTNOTSAME if the PTE are different
> + * VM_FAULT_RETRY if the VMA has changed in our back during
> + * a speculative page fault handling.
> */
> -static inline int pte_unmap_same(struct mm_struct *mm, pmd_t *pmd,
> - pte_t *page_table, pte_t orig_pte)
> +static inline int pte_unmap_same(struct vm_fault *vmf)
> {
> - int same = 1;
> + int ret = 0;
> +
> #if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
> if (sizeof(pte_t) > sizeof(unsigned long)) {
> - spinlock_t *ptl = pte_lockptr(mm, pmd);
> - spin_lock(ptl);
> - same = pte_same(*page_table, orig_pte);
> - spin_unlock(ptl);
> + if (pte_spinlock(vmf)) {
> + if (!pte_same(*vmf->pte, vmf->orig_pte))
> + ret = VM_FAULT_PTNOTSAME;
> + spin_unlock(vmf->ptl);
> + } else
> + ret = VM_FAULT_RETRY;
> }
> #endif
> - pte_unmap(page_table);
> - return same;
> + pte_unmap(vmf->pte);
> + return ret;
> }
>
> static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)
> @@ -2913,7 +2921,8 @@ int do_swap_page(struct vm_fault *vmf)
> int exclusive = 0;
> int ret = 0;
>
> - if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte))
> + ret = pte_unmap_same(vmf);
> + if (ret)
> goto out;
>
This change what do_swap_page() returns ie before it was returning 0
when locked pte lookup was different from orig_pte. After this patch
it returns VM_FAULT_PTNOTSAME but this is a new return value for
handle_mm_fault() (the do_swap_page() return value is what ultimately
get return by handle_mm_fault())
Do we really want that ? This might confuse some existing user of
handle_mm_fault() and i am not sure of the value of that information
to caller.
Note i do understand that you want to return retry if anything did
change from underneath and thus need to differentiate from when the
pte value are not the same.
Cheers,
Jérôme
^ permalink raw reply
* Re: [RESEND v2 3/4] doc/devicetree: Persistent memory region bindings
From: Dan Williams @ 2018-04-03 17:37 UTC (permalink / raw)
To: Oliver O'Halloran; +Cc: linuxppc-dev, Device Tree, linux-nvdimm
In-Reply-To: <20180403142415.30083-3-oohall@gmail.com>
On Tue, Apr 3, 2018 at 7:24 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> Add device-tree binding documentation for the nvdimm region driver.
>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
> v2: Changed name from nvdimm-region to pmem-region.
> Cleaned up the example binding and fixed the overlapping regions.
> Added support for multiple regions in a single reg.
> ---
> .../devicetree/bindings/pmem/pmem-region.txt | 80 ++++++++++++++++++++++
> MAINTAINERS | 1 +
> 2 files changed, 81 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/pmem/pmem-region.txt
Device-tree folks, does this look, ok?
Oliver, is there any concept of a management interface to the
device(s) backing these regions? libnvdimm calls these "nmem" devices
and support operations like health status and namespace label
management.
^ permalink raw reply
* Re: [RESEND v2 2/4] libnvdimm: Add device-tree based driver
From: Dan Williams @ 2018-04-03 17:34 UTC (permalink / raw)
To: Oliver O'Halloran; +Cc: linuxppc-dev, linux-nvdimm
In-Reply-To: <20180403142415.30083-2-oohall@gmail.com>
On Tue, Apr 3, 2018 at 7:24 AM, Oliver O'Halloran <oohall@gmail.com> wrote:
> This patch adds peliminary device-tree bindings for persistent memory
> regions. The driver registers a libnvdimm bus for each pmem-region
> node and each address range under the node is converted to a region
> within that bus.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
> v2: Made each bus have a separate node rather having a shared bus.
> Renamed to of_pmem rather than of_nvdimm.
> Changed log level of happy-path messages to debug.
> ---
[..]
> +static struct platform_driver of_nd_region_driver = {
> + .probe = of_nd_region_probe,
> + .remove = of_nd_region_remove,
> + .driver = {
> + .name = "of_pmem",
> + .owner = THIS_MODULE,
> + .of_match_table = of_nd_region_match,
> + },
> +};
This and the other patches look good to me. Just a nit on the
naming... since you name the regions pmem-regions in the device-tree
description shouldn't this be the "of_pmem_region" or "of_pmem_range"
driver? Otherwise, it is confusing to me that anything named
*nd_region would be creating an nvdimm_bus. In general An nd_region is
always a child of a bus.
That said, with an ack/reviewed-by on the device-tree bindings I can
take these through the nvdimm tree. I'll reply to patch 4 with that
request for ack.
^ permalink raw reply
* Re: [1/3] powerpc/64s/idle: POWER9 implement a separate idle stop function for hotplug
From: Nicholas Piggin @ 2018-04-03 17:13 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Gautham R . Shenoy
In-Reply-To: <40Fv5c0X41z9s4b@ozlabs.org>
On Wed, 4 Apr 2018 02:03:18 +1000 (AEST)
Michael Ellerman <patch-notifications@ellerman.id.au> wrote:
> On Fri, 2017-11-17 at 14:08:05 UTC, Nicholas Piggin wrote:
> > Implement a new function to invoke stop, power9_offline_stop, which is
> > like power9_idle_stop but used by the cpu hotplug code.
> >
> > Move KVM secondary state manipulation code to the offline case.
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
>
> Applied to powerpc next, thanks.
>
> https://git.kernel.org/powerpc/c/3d4fbffdd703d2b968db443911f214
>
> cheers
I sent out a new series for this which is rebased and a bit cleaner.
I probably wasn't clear enough about the change, sorry.
This patch will need to be adjusted for the force SMT4 change. The
end result should look like this,
https://patchwork.ozlabs.org/patch/893948/
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH] cxl: Fix possible deadlock when processing page faults from cxllib
From: Frederic Barrat @ 2018-04-03 16:40 UTC (permalink / raw)
To: Aneesh Kumar K.V, Frederic Barrat, linuxppc-dev, mpe
Cc: ldufour, clombard, andrew.donnellan, vaibhav
In-Reply-To: <606e7509-5c37-b38e-9b6c-a60a5694c652@linux.ibm.com>
Le 03/04/2018 à 16:40, Aneesh Kumar K.V a écrit :
> On 04/03/2018 03:13 PM, Frederic Barrat wrote:
>> cxllib_handle_fault() is called by an external driver when it needs to
>> have the host process page faults for a buffer which may cover several
>> pages. Currently the function holds the mm->mmap_sem semaphore with
>> read access while iterating over the buffer, since it could spawn
>> several VMAs. When calling a lower-level function to handle the page
>> fault for a single page, the semaphore is accessed again in read
>> mode. That is wrong and can lead to deadlocks if a writer tries to
>> sneak in while a buffer of several pages is being processed.
>>
>> The fix is to release the semaphore once cxllib_handle_fault() got the
>> information it needs from the current vma. The address space/VMAs
>> could evolve while we iterate over the full buffer, but in the
>> unlikely case where we miss a page, the driver will raise a new page
>> fault when retrying.
>>
>> Fixes: 3ced8d730063 ("cxl: Export library to support IBM XSL")
>> Cc: stable@vger.kernel.org # 4.13+
>> Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
>> ---
>> drivers/misc/cxl/cxllib.c | 85
>> ++++++++++++++++++++++++++++++-----------------
>> 1 file changed, 55 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/misc/cxl/cxllib.c b/drivers/misc/cxl/cxllib.c
>> index 30ccba436b3b..55cd35d1a9cc 100644
>> --- a/drivers/misc/cxl/cxllib.c
>> +++ b/drivers/misc/cxl/cxllib.c
>> @@ -208,49 +208,74 @@ int cxllib_get_PE_attributes(struct task_struct
>> *task,
>> }
>> EXPORT_SYMBOL_GPL(cxllib_get_PE_attributes);
>> -int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64
>> flags)
>> +static int get_vma_info(struct mm_struct *mm, u64 addr,
>> + u64 *vma_start, u64 *vma_end,
>> + unsigned long *page_size)
>> {
>> - int rc;
>> - u64 dar;
>> struct vm_area_struct *vma = NULL;
>> - unsigned long page_size;
>> -
>> - if (mm == NULL)
>> - return -EFAULT;
>> + int rc = 0;
>> down_read(&mm->mmap_sem);
>> vma = find_vma(mm, addr);
>> if (!vma) {
>> - pr_err("Can't find vma for addr %016llx\n", addr);
>> rc = -EFAULT;
>> goto out;
>> }
>> - /* get the size of the pages allocated */
>> - page_size = vma_kernel_pagesize(vma);
>> -
>> - for (dar = (addr & ~(page_size - 1)); dar < (addr + size); dar +=
>> page_size) {
>> - if (dar < vma->vm_start || dar >= vma->vm_end) {
>> - vma = find_vma(mm, addr);
>> - if (!vma) {
>> - pr_err("Can't find vma for addr %016llx\n", addr);
>> - rc = -EFAULT;
>> - goto out;
>> - }
>> - /* get the size of the pages allocated */
>> - page_size = vma_kernel_pagesize(vma);
>> + *page_size = vma_kernel_pagesize(vma);
>> + *vma_start = vma->vm_start;
>> + *vma_end = vma->vm_end;
>> +out:
>> + up_read(&mm->mmap_sem);
>> + return rc;
>> +}
>> +
>> +int cxllib_handle_fault(struct mm_struct *mm, u64 addr, u64 size, u64
>> flags)
>> +{
>> + int rc;
>> + u64 dar, vma_start, vma_end;
>> + unsigned long page_size;
>> +
>> + if (mm == NULL)
>> + return -EFAULT;
>> +
>> + /*
>> + * The buffer we have to process can extend over several pages
>> + * and may also cover several VMAs.
>> + * We iterate over all the pages. The page size could vary
>> + * between VMAs.
>> + */
>> + rc = get_vma_info(mm, addr, &vma_start, &vma_end, &page_size);
>> + if (rc)
>> + return rc;
>> +
>> + for (dar = (addr & ~(page_size - 1)); dar < (addr + size);
>> + dar += page_size) {
>> + if (dar < vma_start || dar >= vma_end) {
>
>
> IIUC, we are fetching the vma to get just the page_size with which it is
> mapped? Can't we iterate with PAGE_SIZE? Considering hugetlb page size
> will be larger than PAGE_SIZE, we might call into cxl_handle_mm_fault
> multiple times for a hugetlb page. Does that cause any issue? Also can
> cxl be used with hugetlb mappings?
I discussed it with Aneesh, but for the record:
- huge pages could be used, cxl has no control over it.
- incrementing the loop with PAGE_SIZE if it's a huge page would be a
waste, as only the first call to cxl_handle_mm_fault() would be useful.
- having to account for several VMAs and potentially page sizes make it
more complicated. An idea is to check with Mellanox if we can reduce the
scope, in case the caller can rule out some cases. It's too late for
coral, but something we can look into for the future/upstream.
Fred
>> + /*
>> + * We don't hold the mm->mmap_sem semaphore
>> + * while iterating, since the semaphore is
>> + * required by one of the lower-level page
>> + * fault processing functions and it could
>> + * create a deadlock.
>> + *
>> + * It means the VMAs can be altered between 2
>> + * loop iterations and we could theoretically
>> + * miss a page (however unlikely). But that's
>> + * not really a problem, as the driver will
>> + * retry access, get another page fault on the
>> + * missing page and call us again.
>> + */
>> + rc = get_vma_info(mm, dar, &vma_start, &vma_end,
>> + &page_size);
>> + if (rc)
>> + return rc;
>> }
>> rc = cxl_handle_mm_fault(mm, flags, dar);
>> - if (rc) {
>> - pr_err("cxl_handle_mm_fault failed %d", rc);
>> - rc = -EFAULT;
>> - goto out;
>> - }
>> + if (rc)
>> + return -EFAULT;
>> }
>> - rc = 0;
>> -out:
>> - up_read(&mm->mmap_sem);
>> - return rc;
>> + return 0;
>> }
>> EXPORT_SYMBOL_GPL(cxllib_handle_fault);
>>
>
> -aneesh
>
^ permalink raw reply
* Re: selftests/powerpc: Fix copyloops build since Power4 assembler change
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
In-Reply-To: <20180403155318.18266-1-mpe@ellerman.id.au>
On Tue, 2018-04-03 at 15:53:18 UTC, Michael Ellerman wrote:
> The recent commit 15a3204d24a3 ("powerpc/64s: Set assembler machine
> type to POWER4") set the machine type in our ASFLAGS when building the
> kernel, and removed some ".machine power4" directives from various asm
> files.
>
> This broke the selftests build on old toolchains (that don't assume
> Power4), because we build the kernel source files into the selftests
> using different ASFLAGS.
>
> The fix is simply to add -mpower4 to the selftest ASFLAGS as well.
>
> Fixes: 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/b6f534d1a642a9b6263fd52df30806
cheers
^ permalink raw reply
* Re: [V2] powerpc: Fix oops due to wrong access of lppaca on non virtualized platform
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Aneesh Kumar K.V, benh, paulus, npiggin; +Cc: Aneesh Kumar K.V, linuxppc-dev
In-Reply-To: <20180402073337.22568-1-aneesh.kumar@linux.ibm.com>
On Mon, 2018-04-02 at 07:33:37 UTC, "Aneesh Kumar K.V" wrote:
> Commit 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not
> virtualized") removed allocation of lppaca on non virtualized platform. But with
> CONFIG_PPC_SPLPAR enabled, we do access lppaca non-virtualized platform in some
> code paths.
>
> Fix this but adding runtime check for virtualized platform.
>
> Fixes: 8e0b634b1327 ("powerpc/64s: Do not allocate lppaca if we are not virtualized")
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/a6201da34ff9366680e97392efd06a
cheers
^ permalink raw reply
* Re: [1/2] KVM: PPC: Book3S HV: Fix ppc_breakpoint_available compile error
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Michael Neuling, Nicholas Piggin
In-Reply-To: <20180401055036.18078-2-npiggin@gmail.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
On Sun, 2018-04-01 at 05:50:35 UTC, Nicholas Piggin wrote:
> arch/powerpc/kvm/book3s_hv.c: In function ‘kvmppc_h_set_mode’:
> arch/powerpc/kvm/book3s_hv.c:745:8: error: implicit declaration of function ‘ppc_breakpoint_available’; did you mean ‘hw_breakpoint_disable’? [-Werror=implicit-function-declaration]
> if (!ppc_breakpoint_available())
> ^~~~~~~~~~~~~~~~~~~~~~~~
> hw_breakpoint_disable
>
> Cc: Michael Neuling <mikey@neuling.org>
> Fixes: 398e712c00 ("KVM: PPC: Book3S HV: Return error from h_set_mode(SET_DAWR) on POWER9")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/e303c08787c4cbe1ca07912817dff2
cheers
^ permalink raw reply
* Re: [1/2] powerpc: Move default security feature flags
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Mauricio Faria de Oliveira, linuxppc-dev
In-Reply-To: <1522430905-32131-1-git-send-email-mauricfo@linux.vnet.ibm.com>
On Fri, 2018-03-30 at 17:28:24 UTC, Mauricio Faria de Oliveira wrote:
> This moves the definition of the default security feature flags
> (i.e., enabled by default) closer to the security feature flags.
>
> This can be used to restore current flags to the default flags.
>
> Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/e7347a86830f38dc3e40c8f7e28c04
cheers
^ permalink raw reply
* Re: powerpc: Clear branch trap (MSR.BE) before delivering SIGTRAP
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Matt Evans, linuxppc-dev
In-Reply-To: <74EBF461-0D94-4C2D-ABA7-0B9BE010F173@ozlabs.org>
On Mon, 2018-03-26 at 16:55:21 UTC, Matt Evans wrote:
> When using SIG_DBG_BRANCH_TRACING, MSR.BE is left enabled in the
> user context when single_step_exception() prepares the SIGTRAP
> delivery. The resulting branch-trap-within-the-SIGTRAP-handler
> isn't healthy.
>
> Commit 2538c2d08f46141550a1e68819efa8fe31c6e3dc broke this, by
> replacing an MSR mask operation of ~(MSR_SE | MSR_BE) with a call
> to clear_single_step() which only clears MSR_SE.
>
> This patch adds a new helper, clear_br_trace(), which clears the
> debug trap before invoking the signal handler. This helper is a
> NOP for BookE as SIG_DBG_BRANCH_TRACING isn't supported on BookE.
>
> Signed-off-by: Matt Evans <matt@ozlabs.org>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/0e524e761fc2157f1037e0f5d616cd
cheers
^ permalink raw reply
* Re: powerpc/64s: sreset panic if there is no debugger or crash dump handlers
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20180326150116.22990-1-npiggin@gmail.com>
On Mon, 2018-03-26 at 15:01:16 UTC, Nicholas Piggin wrote:
> system_reset_exception does most of its own crash handling now,
> invoking the debugger or crash dumps if they are registered. If not,
> then it goes through to die() to print stack traces, and then is
> supposed to panic (according to comments).
>
> However after die() prints oopses, it does its own handling which
> doesn't allow system_reset_exception to panic (e.g., it may just
> kill the current process). This patch causes sreset exceptions to
> return from die after it prints messages but before acting.
>
> This also stops die from invoking the debugger on 0x100 crashes.
> system_reset_exception similarly calls the debugger. It had been
> thought this was harmless (because if the debugger was disabled,
> neither call would fire, and if it was enabled the first call
> would return). However in some cases like xmon 'X' command, the
> debugger returns 0, which currently causes it to be entered
> again (first in system_reset_exception, then in die), which is
> confusing.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/d40b6768e45bd9213139b2d91d30c7
cheers
^ permalink raw reply
* Re: powerpc/64s: return more carefully from sreset NMI
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20180326150103.22941-1-npiggin@gmail.com>
On Mon, 2018-03-26 at 15:01:03 UTC, Nicholas Piggin wrote:
> System Reset, being an NMI, must return more carefully than other
> interrupts. It has traditionally returned via the nromal return
> from exception path, but that has a number of problems.
>
> - r13 does not get restored if returning to kernel. This is for
> interrupts which may cause a context switch, which sreset will
> never do. Interrupting OPAL (which uses a different r13) is one
> place where this causes breakage.
>
> - It may cause several other problems returning to kernel with
> preempt or TIF_EMULATE_STACK_STORE if it hits at the wrong time.
>
> It's safer just to have a simple restore and return, like machine
> check which is the other NMI.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/15b4dd7981496f51c5f9262a5e0761
cheers
^ permalink raw reply
* Re: powerpc/mm/radix: Fix always false comparison against MMU_NO_CONTEXT
From: Michael Ellerman @ 2018-04-03 16:03 UTC (permalink / raw)
To: Mathieu Malaterre; +Cc: Mathieu Malaterre, linuxppc-dev, Aneesh Kumar K . V
In-Reply-To: <20180322210318.21349-1-malat@debian.org>
On Thu, 2018-03-22 at 21:03:18 UTC, Mathieu Malaterre wrote:
> In commit 9690c1574268 ("powerpc/mm/radix: Fix always false comparison
> against MMU_NO_CONTEXT") an issue was discovered where `mm->context.id` was
> being truncated to an `unsigned int`, while the PID is actually an
> `unsigned long`. Update the earlier patch by fixing one remaining
> occurrence. Discovered during a compilation with W=1:
>
> arch/powerpc/mm/tlb-radix.c:702:19: error: comparison is always false due to limited range of data type [-Werror=type-limits]
>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/19e68b2aec3c0a2bd770d3c358a296
cheers
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox