Re: [PATCH v5 3/6] powerpc/mm/slice: Enhance for supporting PPC32
On Thu, 22 Feb 2018 15:27:24 +0100 (CET) Christophe Leroy wrote: > In preparation for the following patch which will fix an issue on > the 8xx by re-using the 'slices', this patch enhances the > 'slices' implementation to support 32 bits CPUs. > > On PPC32, the address space is limited to 4Gbytes, hence only the low > slices will be used. > > The high slices use bitmaps. As bitmap functions are not prepared to > handle bitmaps of size 0, this patch ensures that bitmap functions > are called only when SLICE_NUM_HIGH is not nul. > > Signed-off-by: Christophe Leroy This looks good to me, thank you for taking my feedback into account. Is the patch split and naming good? Yes I guess so, this adds support for ppc32 archs that select PPC_MM_SLICES, and the next one implements it for 8xx. There looks to be some generic arch/powerpc/mm bits in the next patch. I wonder if you would move them over? Then the next patch could be called powerpc/8xx: ? Anyway it's not a big deal. Reviewed-by: Nicholas Piggin
Re: [PATCH v5 2/6] powerpc/mm/slice: create header files dedicated to slices
On Thu, 22 Feb 2018 15:27:22 +0100 (CET) Christophe Leroy wrote: > In preparation for the following patch which will enhance 'slices' > for supporting PPC32 in order to fix an issue on hugepages on 8xx, > this patch takes out of page*.h all bits related to 'slices' and put > them into newly created slice.h header files. > While common parts go into asm/slice.h, subarch specific > parts go into respective books3s/64/slice.c and nohash/64/slice.c > 'slices' > > Signed-off-by: Christophe Leroy I don't see a problem with this. Even by itself it seems like a good cleanup. Reviewed-by: Nicholas Piggin > --- > v5: new - come from a split of patch 2 of v4 > > arch/powerpc/include/asm/book3s/64/slice.h | 27 ++ > arch/powerpc/include/asm/nohash/64/slice.h | 12 ++ > arch/powerpc/include/asm/page.h| 1 + > arch/powerpc/include/asm/page_64.h | 59 > -- > arch/powerpc/include/asm/slice.h | 40 > 5 files changed, 80 insertions(+), 59 deletions(-) > create mode 100644 arch/powerpc/include/asm/book3s/64/slice.h > create mode 100644 arch/powerpc/include/asm/nohash/64/slice.h > create mode 100644 arch/powerpc/include/asm/slice.h > > diff --git a/arch/powerpc/include/asm/book3s/64/slice.h > b/arch/powerpc/include/asm/book3s/64/slice.h > new file mode 100644 > index ..db0dedab65ee > --- /dev/null > +++ b/arch/powerpc/include/asm/book3s/64/slice.h > @@ -0,0 +1,27 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_POWERPC_BOOK3S_64_SLICE_H > +#define _ASM_POWERPC_BOOK3S_64_SLICE_H > + > +#ifdef CONFIG_PPC_MM_SLICES > + > +#define SLICE_LOW_SHIFT 28 > +#define SLICE_LOW_TOP(0x1ul) > +#define SLICE_NUM_LOW(SLICE_LOW_TOP >> SLICE_LOW_SHIFT) > +#define GET_LOW_SLICE_INDEX(addr)((addr) >> SLICE_LOW_SHIFT) > + > +#define SLICE_HIGH_SHIFT 40 > +#define SLICE_NUM_HIGH (H_PGTABLE_RANGE >> SLICE_HIGH_SHIFT) > +#define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT) > + > +#else /* CONFIG_PPC_MM_SLICES */ > + > +#define get_slice_psize(mm, addr)((mm)->context.user_psize) > +#define slice_set_user_psize(mm, psize) \ > +do { \ > + (mm)->context.user_psize = (psize); \ > + (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \ > +} while (0) > + > +#endif /* CONFIG_PPC_MM_SLICES */ > + > +#endif /* _ASM_POWERPC_BOOK3S_64_SLICE_H */ > diff --git a/arch/powerpc/include/asm/nohash/64/slice.h > b/arch/powerpc/include/asm/nohash/64/slice.h > new file mode 100644 > index ..ad0d6e3cc1c5 > --- /dev/null > +++ b/arch/powerpc/include/asm/nohash/64/slice.h > @@ -0,0 +1,12 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_POWERPC_NOHASH_64_SLICE_H > +#define _ASM_POWERPC_NOHASH_64_SLICE_H > + > +#ifdef CONFIG_PPC_64K_PAGES > +#define get_slice_psize(mm, addr)MMU_PAGE_64K > +#else /* CONFIG_PPC_64K_PAGES */ > +#define get_slice_psize(mm, addr)MMU_PAGE_4K > +#endif /* !CONFIG_PPC_64K_PAGES */ > +#define slice_set_user_psize(mm, psize) do { BUG(); } while (0) > + > +#endif /* _ASM_POWERPC_NOHASH_64_SLICE_H */ > diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h > index 8da5d4c1cab2..d5f1c41b7dba 100644 > --- a/arch/powerpc/include/asm/page.h > +++ b/arch/powerpc/include/asm/page.h > @@ -344,5 +344,6 @@ typedef struct page *pgtable_t; > > #include > #endif /* __ASSEMBLY__ */ > +#include > > #endif /* _ASM_POWERPC_PAGE_H */ > diff --git a/arch/powerpc/include/asm/page_64.h > b/arch/powerpc/include/asm/page_64.h > index 56234c6fcd61..af04acdb873f 100644 > --- a/arch/powerpc/include/asm/page_64.h > +++ b/arch/powerpc/include/asm/page_64.h > @@ -86,65 +86,6 @@ extern u64 ppc64_pft_size; > > #endif /* __ASSEMBLY__ */ > > -#ifdef CONFIG_PPC_MM_SLICES > - > -#define SLICE_LOW_SHIFT 28 > -#define SLICE_HIGH_SHIFT 40 > - > -#define SLICE_LOW_TOP(0x1ul) > -#define SLICE_NUM_LOW(SLICE_LOW_TOP >> SLICE_LOW_SHIFT) > -#define SLICE_NUM_HIGH (H_PGTABLE_RANGE >> SLICE_HIGH_SHIFT) > - > -#define GET_LOW_SLICE_INDEX(addr)((addr) >> SLICE_LOW_SHIFT) > -#define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT) > - > -#ifndef __ASSEMBLY__ > -struct mm_struct; > - > -extern unsigned long slice_get_unmapped_area(unsigned long addr, > - unsigned long len, > - unsigned long flags, > - unsigned int psize, > - int topdown); > - > -extern unsigned int get_slice_psize(struct mm_struct *mm, > - unsigned long addr); > - > -extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize); > -extern void slice_set_range_psize(str
[PATCH 3/3] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support
Book3S minimum supported ISA version now requires mtmsrd L=1. This instruction does not require bits other than RI and EE to be supplied, so __hard_irq_enable() and __hard_irq_disable() does not have to read the kernel_msr from paca. Interrupt entry code already relies on L=1 support. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/hw_irq.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index 8004d7887ff6..fbc2d83808aa 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -228,8 +228,8 @@ static inline bool arch_irqs_disabled(void) #define __hard_irq_enable()asm volatile("wrteei 1" : : : "memory") #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory") #else -#define __hard_irq_enable()__mtmsrd(local_paca->kernel_msr | MSR_EE, 1) -#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1) +#define __hard_irq_enable()__mtmsrd(MSR_EE|MSR_RI, 1) +#define __hard_irq_disable() __mtmsrd(MSR_RI, 1) #endif #define hard_irq_disable() do {\ -- 2.16.1
[PATCH 2/3] powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE]
When the masked interrupt handler clears MSR[EE] for an interrupt in the PACA_IRQ_MUST_HARD_MASK set, it does not set PACA_IRQ_HARD_DIS. This makes them get out of synch. With that taken into account, it's only low level irq manipulation (and interrupt entry before reconcile) where they can be out of synch. This makes the code less surprising. It also allows the IRQ replay code to rely on the IRQ_HARD_DIS value and not have to mtmsrd again in this case (e.g., for an external interrupt that has been masked). Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/hw_irq.h| 10 ++ arch/powerpc/kernel/exceptions-64s.S | 5 - arch/powerpc/kernel/irq.c| 14 ++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index 855e17d158b1..8004d7887ff6 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -248,14 +248,16 @@ static inline bool lazy_irq_pending(void) /* * This is called by asynchronous interrupts to conditionally - * re-enable hard interrupts when soft-disabled after having - * cleared the source of the interrupt + * re-enable hard interrupts after having cleared the source + * of the interrupt. They are kept disabled if there is a different + * soft-masked interrupt pending that requires hard masking. */ static inline void may_hard_irq_enable(void) { - get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS; - if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK)) + if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK)) { + get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS; __hard_irq_enable(); + } } static inline bool arch_irq_disabled_regs(struct pt_regs *regs) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 3ac87e53b3da..d1b0b0ef6658 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1446,7 +1446,10 @@ masked_##_H##interrupt: \ mfspr r10,SPRN_##_H##SRR1;\ xorir10,r10,MSR_EE; /* clear MSR_EE */ \ mtspr SPRN_##_H##SRR1,r10;\ -2: mtcrf 0x80,r9;\ + ori r11,r11,PACA_IRQ_HARD_DIS; \ + stb r11,PACAIRQHAPPENED(r13); \ +2: /* done */ \ + mtcrf 0x80,r9;\ ld r9,PACA_EXGEN+EX_R9(r13); \ ld r10,PACA_EXGEN+EX_R10(r13); \ ld r11,PACA_EXGEN+EX_R11(r13); \ diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index f88038847790..1c9ed0a3ba3f 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -256,16 +256,14 @@ notrace void arch_local_irq_restore(unsigned long mask) * __check_irq_replay(). We also need to soft-disable * again to avoid warnings in there due to the use of * per-cpu variables. -* -* We know that if the value in irq_happened is exactly 0x01 -* then we are already hard disabled (there are other less -* common cases that we'll ignore for now), so we skip the -* (expensive) mtmsrd. */ - if (unlikely(irq_happened != PACA_IRQ_HARD_DIS)) + if (!(irq_happened & PACA_IRQ_HARD_DIS)) { +#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG + WARN_ON(!(mfmsr() & MSR_EE)); +#endif __hard_irq_disable(); #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG - else { + } else { /* * We should already be hard disabled here. We had bugs * where that wasn't the case so let's dbl check it and @@ -274,8 +272,8 @@ notrace void arch_local_irq_restore(unsigned long mask) */ if (WARN_ON(mfmsr() & MSR_EE)) __hard_irq_disable(); - } #endif + } irq_soft_mask_set(IRQS_ALL_DISABLED); trace_hardirqs_off(); -- 2.16.1
[PATCH 1/3] powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG
This check does not catch IRQ soft mask bugs, but this option is slightly more suitable than TRACE_IRQFLAGS. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/plpar_wrappers.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h index 55eddf50d149..86f220110890 100644 --- a/arch/powerpc/include/asm/plpar_wrappers.h +++ b/arch/powerpc/include/asm/plpar_wrappers.h @@ -45,10 +45,10 @@ static inline long extended_cede_processor(unsigned long latency_hint) set_cede_latency_hint(latency_hint); rc = cede_processor(); -#ifdef CONFIG_TRACE_IRQFLAGS - /* Ensure that H_CEDE returns with IRQs on */ - if (WARN_ON(!(mfmsr() & MSR_EE))) - __hard_irq_enable(); +#ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG + /* Ensure that H_CEDE returns with IRQs on */ + if (WARN_ON(!(mfmsr() & MSR_EE))) + __hard_irq_enable(); #endif set_cede_latency_hint(old_latency_hint); -- 2.16.1
[PATCH 0/3] a few small irq improvements
Patch 2 is really the main one. Patch 3 assumes we drop POWER4 support as per https://patchwork.ozlabs.org/patch/875852/ Nicholas Piggin (3): powerpc/pseries: put cede MSR[EE] check under IRQ_SOFT_MASK_DEBUG powerpc/64s: make PACA_IRQ_HARD_DIS track MSR[EE] powerpc/64s: micro-optimise __hard_irq_enable() for mtmsrd L=1 support arch/powerpc/include/asm/hw_irq.h | 14 -- arch/powerpc/include/asm/plpar_wrappers.h | 8 arch/powerpc/kernel/exceptions-64s.S | 5 - arch/powerpc/kernel/irq.c | 14 ++ 4 files changed, 22 insertions(+), 19 deletions(-) -- 2.16.1
[GIT PULL] Please pull powerpc/linux.git powerpc-4.16-4 tag
Hi Linus, Please pull some more powerpc fixes for 4.16: The following changes since commit 91ab883eb21325ad80f3473633f794c78ac87f51: Linux 4.16-rc2 (2018-02-18 17:29:42 -0800) are available in the git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-4.16-4 for you to fetch changes up to eb0a2d2620ae431c543963c8c7f08f597366fc60: powerpc/powernv: Support firmware disable of RFI flush (2018-02-23 16:55:42 +1100) powerpc fixes for 4.16 #4 Add handling for a missing instruction in our 32-bit BPF JIT so that it can be used for seccomp filtering. Add a missing NULL pointer check before a function call in new EEH code. Fix an error path in the new ocxl driver to correctly return EFAULT. The support for the new ibm,drc-info device tree property turns out to need several fixes, so for now we just stop advertising to firmware that we support it until the bugs can be ironed out. One fix for the new drmem code which was incorrectly modifying the device tree in place. Finally two fixes for the RFI flush support, so that firmware can advertise to us that it should be disabled entirely so as not to affect performance. Thanks to: Bharata B Rao, Frederic Barrat, Juan J. Alvarez, Mark Lord, Michael Bringmann. Bharata B Rao (1): powerpc/mm/drmem: Fix unexpected flag value in ibm,dynamic-memory-v2 Frederic Barrat (1): ocxl: Fix potential bad errno on irq allocation Juan J. Alvarez (1): powerpc/eeh: Fix crashes in eeh_report_resume() Mark Lord (1): powerpc/bpf/jit: Fix 32-bit JIT for seccomp_data access Michael Bringmann (1): powerpc/pseries: Revert support for ibm,drc-info devtree property Michael Ellerman (3): powerpc/pseries: Fix duplicate firmware feature for DRC_INFO powerpc/pseries: Support firmware disable of RFI flush powerpc/powernv: Support firmware disable of RFI flush arch/powerpc/include/asm/firmware.h| 2 +- arch/powerpc/kernel/eeh_driver.c | 3 ++- arch/powerpc/kernel/prom_init.c| 2 +- arch/powerpc/mm/drmem.c| 6 +++--- arch/powerpc/net/bpf_jit_comp.c| 3 +++ arch/powerpc/platforms/powernv/setup.c | 4 arch/powerpc/platforms/pseries/setup.c | 3 ++- drivers/misc/ocxl/file.c | 6 -- 8 files changed, 20 insertions(+), 9 deletions(-) signature.asc Description: PGP signature
Re: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro conversions
Greg KH writes: > On Fri, Feb 23, 2018 at 11:11:12PM +1100, Michael Ellerman wrote: >> Michael Ellerman writes: >> > Subject: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro >> > conversions >> ^ >>4.9 >> >> Gah, sorry just realised these last two have "v4.4" in the subject, but >> it should be "4.9". > > Ah, good, I was wondering about that :) Sorry for the confusion, I need to automate generation of the patch subjects obviously :) > I'll apply these after lunch... Thanks. cheers
Re: [PATCH v12 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled
On Fri, Feb 23, 2018 at 03:11:45PM +0800, kbuild test robot wrote: > Hi Ram, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on linus/master] > [also build test ERROR on v4.16-rc2 next-20180222] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > chmod +x ~/bin/make.cross ...snip.. > # save the attached .config to linux build tree > make.cross ARCH=powerpc > > Note: the > linux-review/Ram-Pai/mm-x86-powerpc-Enhancements-to-Memory-Protection-Keys/20180223-042743 > HEAD c5692bca45543c242ffca15c811923e4c548ed19 builds fine. > It only hurts bisectibility. oops, it broke git-bisect on powerpc :-( The following change will fix it. This should nail it down. diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h index 0409c80..0b3b669 100644 --- a/arch/powerpc/include/asm/pkeys.h +++ b/arch/powerpc/include/asm/pkeys.h @@ -25,6 +25,7 @@ # define VM_PKEY_BIT1 VM_HIGH_ARCH_1 # define VM_PKEY_BIT2 VM_HIGH_ARCH_2 # define VM_PKEY_BIT3 VM_HIGH_ARCH_3 # define VM_PKEY_BIT4 VM_HIGH_ARCH_4 +#elif !defined(VM_PKEY_BIT4) +# define VM_PKEY_BIT4 VM_HIGH_ARCH_4 #endif
Re: [PATCH 00/38] cxlflash: OpenCXL transport support
On Feb 22, 2018, at 10:13 PM, Andrew Donnellan wrote:On 23/02/18 09:20, Uma Krishnan wrote:This patch series adds OpenCXL support to the cxlflash driver. Withthis support, new devices using the OpenCXL transport will be supportedby the cxlflash driver along with the existing CXL devices. An effort ismade to keep this transport specific function independent of the existingcore driver that communicates with the AFU.It's "OpenCAPI" for the standard, and "ocxl" for the driver - I'd rather not add "OpenCXL" to our already somewhat confusing proliferation of names :)I agree. I will fix it in V2. Thanks for the feedback.I'll try to review as much of the ocxl-specific stuff as I can get to, though I'm a bit busy with the OpenCAPI skiboot work and reviewing the libocxl userspace library at the moment.Andrew-- Andrew Donnellan OzLabs, ADL Canberraandrew.donnel...@au1.ibm.com IBM Australia Limited
[PATCH 3/3] ftrace: Add MODULE_PLTS support
Teach ftrace_make_call() and ftrace_make_nop() about PLTs. Teach PLT code about FTRACE and all its callbacks. Otherwise the following might happen: [ cut here ] WARNING: CPU: 14 PID: 2265 at .../arch/arm/kernel/insn.c:14 __arm_gen_branch+0x83/0x8c() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (__arm_gen_branch+0x83/0x8c) [] (__arm_gen_branch) from [] (ftrace_make_nop+0xf/0x24) [] (ftrace_make_nop) from [] (ftrace_process_locs+0x27b/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcc ]--- [ cut here ] WARNING: CPU: 14 PID: 2265 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1b1/0x234() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (ftrace_bug+0x1b1/0x234) [] (ftrace_bug) from [] (ftrace_process_locs+0x285/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcd ]--- ftrace failed to modify [] 0xe9ef7006 actual: 02:f0:3b:fa ftrace record flags: 0 (0) expected tramp: c0314265 Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/module.h | 1 + arch/arm/kernel/ftrace.c | 70 --- arch/arm/kernel/module-plts.c | 53 3 files changed, 101 insertions(+), 23 deletions(-) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 6996405..e3d7a51 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -30,6 +30,7 @@ struct plt_entries { struct mod_plt_sec { struct elf32_shdr *plt; + struct plt_entries *plt_ent; int plt_count; }; diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index be20adc..0a0da25 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -98,6 +98,19 @@ int ftrace_arch_code_modify_post_process(void) static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) { + s32 offset = addr - pc; + s32 blim = 0xfe08; + s32 flim = 0x0204; + + if (IS_ENABLED(CONFIG_THUMB2_KERNEL)) { + blim = 0xff04; + flim = 0x0102; + } + + if (IS_ENABLED(CONFIG_ARM_MODULE_PLTS) && + (offset < blim || offset > flim)) + return 0; + return arm_gen_branch_link(pc, addr); } @@ -167,10 +180,27 @@ int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, { unsigned long new, old; unsigned long ip = rec->ip; + unsigned long aaddr = adjust_address(rec, addr); old = ftrace_nop_replace(rec); - new = ftrace_call_replace(ip, adjust_address(rec, addr)); + new = ftrace_call_replace(ip, aaddr); + +#ifdef CONFIG_ARM_MODULE_PLTS + if (!new) { + /* +* mod is only supplied during module loading, later we have to +* search for it +*/ + if (!mod) + mod = __module_address(ip); + + if (mod) { + aaddr = get_module_plt(mod, ip, aaddr); + new = ftrace_call_replace(ip, aaddr); + } + } +#endif return ftrace_modify_code(rec->ip, old, new, true); } @@ -200,20 +230,40 @@ int ftrace_make_nop(struct module *mod, unsigned long new; int ret; - old = ftrace_call_replace(ip, adjust_address(rec, addr)); - new = ftrace_nop_replace(rec); - ret = ftrace_modify_code(ip, old, new, true); - -#ifdef CONFIG_OLD_MCOUNT - if (ret == -EINVAL && addr == MCOUNT_ADDR) { - rec->arch.old_mcount = true; + for (;;) { + unsigned long aaddr = adjust_address(rec, addr); + + old = ftrace_call_replace(ip, aaddr); + +#ifdef CONFIG_ARM_MODULE_PLTS + if (!old) { + /* +* mod is only supplied during module loading, later we +* have to search for it +*/ + if (!mod) + mod = __module_address(ip); + + if (mod) { + aaddr = get_module_plt(mod, ip, aaddr); +
[PATCH 2/3] ARM: PLT: Move struct plt_entries definition to header
No functional change, later it will be re-used in several files. Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/module.h | 9 + arch/arm/kernel/module-plts.c | 9 - 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 89ad059..6996405 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -19,6 +19,15 @@ enum { }; #endif +#define PLT_ENT_STRIDE L1_CACHE_BYTES +#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32)) +#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT) + +struct plt_entries { + u32 ldr[PLT_ENT_COUNT]; + u32 lit[PLT_ENT_COUNT]; +}; + struct mod_plt_sec { struct elf32_shdr *plt; int plt_count; diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c index 3d0c2e4..f272711 100644 --- a/arch/arm/kernel/module-plts.c +++ b/arch/arm/kernel/module-plts.c @@ -14,10 +14,6 @@ #include #include -#define PLT_ENT_STRIDE L1_CACHE_BYTES -#define PLT_ENT_COUNT (PLT_ENT_STRIDE / sizeof(u32)) -#define PLT_ENT_SIZE (sizeof(struct plt_entries) / PLT_ENT_COUNT) - #ifdef CONFIG_THUMB2_KERNEL #define PLT_ENT_LDR__opcode_to_mem_thumb32(0xf8dff000 | \ (PLT_ENT_STRIDE - 4)) @@ -26,11 +22,6 @@ (PLT_ENT_STRIDE - 8)) #endif -struct plt_entries { - u32 ldr[PLT_ENT_COUNT]; - u32 lit[PLT_ENT_COUNT]; -}; - static bool in_init(const struct module *mod, unsigned long loc) { return loc - (u32)mod->init_layout.base < mod->init_layout.size; -- 2.4.6
[PATCH 1/3] ftrace: Add module to ftrace_make_call() parameters
ARM support for modules' PLTs will require a module pointer in ftrace_make_call() exactly as ftrace_make_nop() has it. Change the function signature without functional change for now. Signed-off-by: Alexander Sverdlin --- arch/arm/kernel/ftrace.c | 3 ++- arch/arm64/kernel/ftrace.c | 3 ++- arch/blackfin/kernel/ftrace.c | 3 ++- arch/ia64/kernel/ftrace.c | 3 ++- arch/metag/kernel/ftrace.c | 3 ++- arch/microblaze/kernel/ftrace.c| 3 ++- arch/mips/kernel/ftrace.c | 3 ++- arch/powerpc/kernel/trace/ftrace.c | 3 ++- arch/s390/kernel/ftrace.c | 3 ++- arch/sh/kernel/ftrace.c| 3 ++- arch/sparc/kernel/ftrace.c | 3 ++- arch/tile/kernel/ftrace.c | 3 ++- arch/x86/kernel/ftrace.c | 3 ++- include/linux/ftrace.h | 4 +++- kernel/trace/ftrace.c | 6 +++--- 15 files changed, 32 insertions(+), 17 deletions(-) diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 5617932..be20adc 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -162,7 +162,8 @@ int ftrace_update_ftrace_func(ftrace_func_t func) return ret; } -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { unsigned long new, old; unsigned long ip = rec->ip; diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 50986e3..e3a95d3 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -68,7 +68,8 @@ int ftrace_update_ftrace_func(ftrace_func_t func) /* * Turn on the call to ftrace_caller() in instrumented function */ -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { unsigned long pc = rec->ip; u32 old, new; diff --git a/arch/blackfin/kernel/ftrace.c b/arch/blackfin/kernel/ftrace.c index 8dad758..61ffc99 100644 --- a/arch/blackfin/kernel/ftrace.c +++ b/arch/blackfin/kernel/ftrace.c @@ -45,7 +45,8 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, return ftrace_modify_code(rec->ip, mnop, sizeof(mnop)); } -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { /* Restore the mcount call site */ unsigned char call[8]; diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c index cee411e..658a011 100644 --- a/arch/ia64/kernel/ftrace.c +++ b/arch/ia64/kernel/ftrace.c @@ -169,7 +169,8 @@ int ftrace_make_nop(struct module *mod, return ftrace_modify_code(rec->ip, NULL, new, 0); } -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { unsigned long ip = rec->ip; unsigned char *old, *new; diff --git a/arch/metag/kernel/ftrace.c b/arch/metag/kernel/ftrace.c index f7b23d3..635652a 100644 --- a/arch/metag/kernel/ftrace.c +++ b/arch/metag/kernel/ftrace.c @@ -104,7 +104,8 @@ int ftrace_make_nop(struct module *mod, return ftrace_modify_code(ip, old, new); } -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { unsigned char *new, *old; unsigned long ip = rec->ip; diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c index d57563c..01b314a 100644 --- a/arch/microblaze/kernel/ftrace.c +++ b/arch/microblaze/kernel/ftrace.c @@ -161,7 +161,8 @@ int ftrace_make_nop(struct module *mod, } /* I believe that first is called ftrace_make_nop before this function */ -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { int ret; pr_debug("%s: addr:0x%x, rec->ip: 0x%x, imm:0x%x\n", diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c index 7f3dfdb..9dcec19 100644 --- a/arch/mips/kernel/ftrace.c +++ b/arch/mips/kernel/ftrace.c @@ -200,7 +200,8 @@ int ftrace_make_nop(struct module *mod, #endif } -int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) +int ftrace_make_call(struct module *mod, struct dyn_ftrace *rec, +unsigned long addr) { unsigned int new; unsigned long ip = rec->ip; diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 4741fe1..b198433 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -437,7 +437,8 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) #endif /* CONFIG_PPC64 */ #endif /* CONFIG_MODULES
[PATCH 0/3] ARM: Implement MODULE_PLT support in FTRACE
FTRACE's function tracer currently doesn't always work on ARM with MODULE_PLT option enabled. If the module is loaded too far, FTRACE's code modifier cannot cope with introduced veneers and turns the function tracer off globally. ARM64 already has a solution for the problem, refer to the following patches: arm64: ftrace: emit ftrace-mod.o contents through code arm64: module-plts: factor out PLT generation code for ftrace arm64: ftrace: fix !CONFIG_ARM64_MODULE_PLTS kernels arm64: ftrace: fix building without CONFIG_MODULES arm64: ftrace: add support for far branches to dynamic ftrace arm64: ftrace: don't validate branch via PLT in ftrace_make_nop() But the presented ARM variant has just a half of the footprint in terms of the changed LoCs. It also retains the code validation-before-modification instead of switching it off. Alexander Sverdlin (3): ftrace: Add module to ftrace_make_call() parameters ARM: PLT: Move struct plt_entries definition to header ftrace: Add MODULE_PLTS support arch/arm/include/asm/module.h | 10 ++ arch/arm/kernel/ftrace.c | 73 -- arch/arm/kernel/module-plts.c | 58 +++--- arch/arm64/kernel/ftrace.c | 3 +- arch/blackfin/kernel/ftrace.c | 3 +- arch/ia64/kernel/ftrace.c | 3 +- arch/metag/kernel/ftrace.c | 3 +- arch/microblaze/kernel/ftrace.c| 3 +- arch/mips/kernel/ftrace.c | 3 +- arch/powerpc/kernel/trace/ftrace.c | 3 +- arch/s390/kernel/ftrace.c | 3 +- arch/sh/kernel/ftrace.c| 3 +- arch/sparc/kernel/ftrace.c | 3 +- arch/tile/kernel/ftrace.c | 3 +- arch/x86/kernel/ftrace.c | 3 +- include/linux/ftrace.h | 4 ++- kernel/trace/ftrace.c | 6 ++-- 17 files changed, 140 insertions(+), 47 deletions(-) -- 2.4.6
[PATCH] powerpc/boot: Fix random build errors
Once in a while I see build errors similar to the following when building images from a clean tree. Building powerpc:virtex-ml507:44x/virtex5_defconfig ... failed Error log: arch/powerpc/boot/treeboot-akebono.c:37:20: fatal error: libfdt.h: No such file or directory Building powerpc:bamboo:smpdev:44x/bamboo_defconfig ... failed Error log: arch/powerpc/boot/treeboot-akebono.c:37:20: fatal error: libfdt.h: No such file or directory arch/powerpc/boot/treeboot-currituck.c:35:20: fatal error: libfdt.h: No such file or directory Rebuilds will succeed. Turns out that several source files in arch/powerpc/boot/ include libfdt.h, but Makefile dependencies are incomplete. Let's fix that. Signed-off-by: Guenter Roeck --- arch/powerpc/boot/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index ef6549e57157..26d5d2a5b8e9 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -101,7 +101,8 @@ $(addprefix $(obj)/,$(zlib-y)): \ libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c libfdtheader := fdt.h libfdt.h libfdt_internal.h -$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \ +$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \ + treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \ $(addprefix $(obj)/,$(libfdtheader)) src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \ -- 2.7.4
Re: [PATCH] powerpc/powernv: Turn on SCSI_AACRAID in powernv_defconfig
On 02/22/2018 06:16 PM, Stewart Smith wrote: > Michael Ellerman writes: >> Brian King writes: >>> On 09/03/2017 06:19 PM, Stewart Smith wrote: Michael Ellerman writes: >> 2. On a bare metal machine, if you set ipr.fast_reboot=1 on the skiboot >>kernel, then we should also avoid resetting the ipr adapter, so ipr >>init on the kernel being kexec booted from skiboot should be >> extremely fast. > > OK, I didn't know that was an option, so that might help. > >> ... >> If you've got cases where ipr init is taking a long time, I'd be >> interested to know what scenarios are the most annoying to see if there >> is any opportunity to improve. > > Yeah booting bare metal is where I see it (not using ipr.fast_reboot). Hrm... We should probably enable that by default for petitboot then. It'd at least cut some time off booting straight through to OS. >>> >>> Agreed. I'd be interested to hear if that helps address the issue >>> Michael is seeing. >>> >>> You can easily test this by exiting to a petitboot shell: >>> >>> echo 1 > /sys/module/ipr/parameters/fast_reboot >>> >>> Then go back to petitboot and boot the OS. >> >> Just following up on this (!). >> >> This does work, and I've now been running it in my CI for about a month >> (~1000 boots) with no problems. >> >> You can also make it persistent by doing: >> >> $ nvram -p ibm,skiboot --update-config bootargs="ipr.fast_reboot=1" > > Okay, cool. https://github.com/open-power/op-build/pull/1900 will set it > in firmware - we may as well run with this and fix any bugs we find. > > Any reason why it isn't the default behaviour? The primary reason this isn't the default setting is because it would cause undesired behavior on system reboots. On a kexec reboot, since the PCIe slots don't get power cycled or even hit with PERST, we can simply quiesce devices and pick them up at the other side of the kexec. On a real reboot where the firmware or hardware may end up doing a PERST or power cycle, we need to tell the ipr adapters that is coming and let them shutdown gracefully. If we don't, we will likely be OK in the single adapter configuration in most scenarios, but for a dual ipr adapter configuration, we can then end up with undesired adapter failovers occurring due to the unexpected power offs / resets, which can then end up extending the next boot. -Brian -- Brian King Power Linux I/O IBM Linux Technology Center
Re: [PATCH 00/38] cxlflash: OpenCXL transport support
> On Feb 22, 2018, at 10:13 PM, Andrew Donnellan > wrote: > > On 23/02/18 09:20, Uma Krishnan wrote: >> This patch series adds OpenCXL support to the cxlflash driver. With >> this support, new devices using the OpenCXL transport will be supported >> by the cxlflash driver along with the existing CXL devices. An effort is >> made to keep this transport specific function independent of the existing >> core driver that communicates with the AFU. > > It's "OpenCAPI" for the standard, and "ocxl" for the driver - I'd rather not > add "OpenCXL" to our already somewhat confusing proliferation of names :) I agree. :) I will fix it in V2. Thanks for the feedback.
Re: [PATCH 04/38] cxlflash: Introduce OpenCXL backend
> On Feb 22, 2018, at 10:28 PM, Andrew Donnellan > wrote: > > On 23/02/18 09:22, Uma Krishnan wrote: >> Add initial infrastructure to support a new cxlflash transport, OpenCXL. >> Claim a dependency on OpenCXL (OCXL) and add a new file, ocxl_hw.c, which >> will host the backend routines that are specific to OpenCXL. >> Signed-off-by: Uma Krishnan > > Is it necessary to depend on OCXL in all cases? IMHO it should be possible to > build a cxl-only version without ocxl, though I don't feel very strongly on > this. I thought through this and did not feel it is necessary to distinguish right now. I will look at adding this in the future. Thanks Andrew !
Re: [PATCH 2/2] selftests/powerpc: Add core file test for Protection Key registers
On Fri, Feb 23, 2018 at 03:33:44PM -0300, Thiago Jung Bauermann wrote: > This test verifies that the AMR, IAMR and UAMOR are being written to a > process' core file. > Acked-by: Ram Pai Tested-by: Ram Pai > Signed-off-by: Thiago Jung Bauermann > --- > tools/testing/selftests/powerpc/ptrace/Makefile| 5 +- > tools/testing/selftests/powerpc/ptrace/core-pkey.c | 460 > + > 2 files changed, 464 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/powerpc/ptrace/core-pkey.c > .snip... RP
Re: [PATCH 1/2] selftests/powerpc: Add ptrace tests for Protection Key registers
On Fri, Feb 23, 2018 at 03:33:43PM -0300, Thiago Jung Bauermann wrote: > This test exercises read and write access to the AMR, IAMR and UAMOR. > Tested-by: Ram Pai Acked-by: Ram Pai > Signed-off-by: Thiago Jung Bauermann > --- > tools/testing/selftests/powerpc/include/reg.h | 1 + > tools/testing/selftests/powerpc/ptrace/Makefile| 5 +- > tools/testing/selftests/powerpc/ptrace/child.h | 130 > .../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 326 > + > tools/testing/selftests/powerpc/ptrace/ptrace.h| 37 +++ > 5 files changed, 498 insertions(+), 1 deletion(-) > create mode 100644 tools/testing/selftests/powerpc/ptrace/child.h > create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c > > diff --git a/tools/testing/selftests/powerpc/include/reg.h > b/tools/testing/selftests/powerpc/include/reg.h > index 4afdebcce4cd..7f348c059bc2 100644 > --- a/tools/testing/selftests/powerpc/include/reg.h > +++ b/tools/testing/selftests/powerpc/include/reg.h > @@ -54,6 +54,7 @@ > #define SPRN_DSCR_PRIV 0x11 /* Privilege State DSCR */ > #define SPRN_DSCR 0x03 /* Data Stream Control Register */ > #define SPRN_PPR 896 /* Program Priority Register */ > +#define SPRN_AMR 13/* Authority Mask Register - problem state */ > > /* TEXASR register bits */ > #define TEXASR_FC0xFE00 > diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile > b/tools/testing/selftests/powerpc/ptrace/Makefile > index 480305266504..707ba734faf2 100644 > --- a/tools/testing/selftests/powerpc/ptrace/Makefile > +++ b/tools/testing/selftests/powerpc/ptrace/Makefile > @@ -1,7 +1,7 @@ > # SPDX-License-Identifier: GPL-2.0 > TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ >ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx > ptrace-tm-vsx \ > - ptrace-tm-spd-vsx ptrace-tm-spr > + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey > > include ../../lib.mk > > @@ -9,6 +9,9 @@ all: $(TEST_PROGS) > > CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie > > +ptrace-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h > ptrace-pkey.c > + $(LINK.c) $^ $(LDLIBS) -pthread -o $@ > + > $(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h > > clean: > diff --git a/tools/testing/selftests/powerpc/ptrace/child.h > b/tools/testing/selftests/powerpc/ptrace/child.h > new file mode 100644 > index ..40c1a6d92111 > --- /dev/null > +++ b/tools/testing/selftests/powerpc/ptrace/child.h > @@ -0,0 +1,130 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Helper functions to sync execution between parent and child processes. > + * > + * Copyright 2018, Thiago Jung Bauermann, IBM Corporation. > + */ > +#include > +#include > +#include > + > +/* > + * Information in a shared memory location for synchronization between child > and > + * parent. > + */ > +struct child_sync { > + /* The parent waits on this semaphore. */ > + sem_t sem_parent; > + > + /* If true, the child should give up as well. */ > + bool parent_gave_up; > + > + /* The child waits on this semaphore. */ > + sem_t sem_child; > + > + /* If true, the parent should give up as well. */ > + bool child_gave_up; > +}; > + > +#define CHILD_FAIL_IF(x, sync) > \ > + do {\ > + if (x) {\ > + fprintf(stderr, \ > + "[FAIL] Test FAILED on line %d\n", __LINE__); \ > + (sync)->child_gave_up = true; \ > + prod_parent(sync); \ > + return 1; \ > + } \ > + } while (0) > + > +#define PARENT_FAIL_IF(x, sync) > \ > + do {\ > + if (x) {\ > + fprintf(stderr, \ > + "[FAIL] Test FAILED on line %d\n", __LINE__); \ > + (sync)->parent_gave_up = true; \ > + prod_child(sync); \ > + return 1; \ > + } \ > + } while (0) > + > +int init_child_sync(struct child_sync *sync) > +{ > + int ret; > + > + ret = sem_init(&sync->sem_parent, 1, 0); > + if (ret) { > + perror("Semaphore initialization failed"); > + return 1; > + } > + > + ret
[PATCH 2/2] selftests/powerpc: Add core file test for Protection Key registers
This test verifies that the AMR, IAMR and UAMOR are being written to a process' core file. Signed-off-by: Thiago Jung Bauermann --- tools/testing/selftests/powerpc/ptrace/Makefile| 5 +- tools/testing/selftests/powerpc/ptrace/core-pkey.c | 460 + 2 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/core-pkey.c diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 707ba734faf2..a10916c3f3e1 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ - ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey core-pkey include ../../lib.mk @@ -12,6 +12,9 @@ CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie ptrace-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h ptrace-pkey.c $(LINK.c) $^ $(LDLIBS) -pthread -o $@ +core-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h core-pkey.c + $(LINK.c) $^ $(LDLIBS) -pthread -o $@ + $(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h clean: diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c b/tools/testing/selftests/powerpc/ptrace/core-pkey.c new file mode 100644 index ..ddbe0f2caf70 --- /dev/null +++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c @@ -0,0 +1,460 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Ptrace test for Memory Protection Key registers + * + * Copyright (C) 2015 Anshuman Khandual, IBM Corporation. + * Copyright (C) 2018 IBM Corporation. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ptrace.h" +#include "child.h" + +#ifndef __NR_pkey_alloc +#define __NR_pkey_alloc384 +#endif + +#ifndef __NR_pkey_free +#define __NR_pkey_free 385 +#endif + +#ifndef NT_PPC_PKEY +#define NT_PPC_PKEY0x110 +#endif + +#ifndef PKEY_DISABLE_EXECUTE +#define PKEY_DISABLE_EXECUTE 0x4 +#endif + +#define AMR_BITS_PER_PKEY 2 +#define PKEY_REG_BITS (sizeof(u64) * 8) +#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) + +#define CORE_FILE_LIMIT(5 * 1024 * 1024) /* 5 MB should be enough */ + +static const char core_pattern_file[] = "/proc/sys/kernel/core_pattern"; + +static const char user_write[] = "[User Write (Running)]"; +static const char core_read_running[] = "[Core Read (Running)]"; + +/* Information shared between the parent and the child. */ +struct shared_info { + struct child_sync child_sync; + + /* AMR value the parent expects to read in the core file. */ + unsigned long amr; + + /* IAMR value the parent expects to read in the core file. */ + unsigned long iamr; + + /* UAMOR value the parent expects to read in the core file. */ + unsigned long uamor; + + /* When the child crashed. */ + time_t core_time; +}; + +static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights) +{ + return syscall(__NR_pkey_alloc, flags, init_access_rights); +} + +static int sys_pkey_free(int pkey) +{ + return syscall(__NR_pkey_free, pkey); +} + +static int increase_core_file_limit(void) +{ + struct rlimit rlim; + int ret; + + ret = getrlimit(RLIMIT_CORE, &rlim); + FAIL_IF(ret); + + if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < CORE_FILE_LIMIT) { + rlim.rlim_cur = CORE_FILE_LIMIT; + + if (rlim.rlim_max != RLIM_INFINITY && + rlim.rlim_max < CORE_FILE_LIMIT) + rlim.rlim_max = CORE_FILE_LIMIT; + + ret = setrlimit(RLIMIT_CORE, &rlim); + FAIL_IF(ret); + } + + ret = getrlimit(RLIMIT_FSIZE, &rlim); + FAIL_IF(ret); + + if (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < CORE_FILE_LIMIT) { + rlim.rlim_cur = CORE_FILE_LIMIT; + + if (rlim.rlim_max != RLIM_INFINITY && + rlim.rlim_max < CORE_FILE_LIMIT) + rlim.rlim_max = CORE_FILE_LIMIT; + + ret = setrlimit(RLIMIT_FSIZE, &rlim); + FAIL_IF(ret); + } + + return TEST_PASS; +} + +static int child(struct shared_info *info) +{ + bool disable_execute = true; + int pkey1, pkey2, pkey3; + int *ptr, ret; + + /* Wait until parent fills out the initial register values. */ + ret = wait_parent(&info->child_sync); + if (ret) + return ret; + + ret = increase_core_file_limit(); + FAIL_IF(ret); + + /* Get some pkeys so that we can change their bits in the AMR. */
[PATCH 1/2] selftests/powerpc: Add ptrace tests for Protection Key registers
This test exercises read and write access to the AMR, IAMR and UAMOR. Signed-off-by: Thiago Jung Bauermann --- tools/testing/selftests/powerpc/include/reg.h | 1 + tools/testing/selftests/powerpc/ptrace/Makefile| 5 +- tools/testing/selftests/powerpc/ptrace/child.h | 130 .../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 326 + tools/testing/selftests/powerpc/ptrace/ptrace.h| 37 +++ 5 files changed, 498 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/child.h create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c diff --git a/tools/testing/selftests/powerpc/include/reg.h b/tools/testing/selftests/powerpc/include/reg.h index 4afdebcce4cd..7f348c059bc2 100644 --- a/tools/testing/selftests/powerpc/include/reg.h +++ b/tools/testing/selftests/powerpc/include/reg.h @@ -54,6 +54,7 @@ #define SPRN_DSCR_PRIV 0x11/* Privilege State DSCR */ #define SPRN_DSCR 0x03/* Data Stream Control Register */ #define SPRN_PPR 896 /* Program Priority Register */ +#define SPRN_AMR 13 /* Authority Mask Register - problem state */ /* TEXASR register bits */ #define TEXASR_FC 0xFE00 diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 480305266504..707ba734faf2 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ - ptrace-tm-spd-vsx ptrace-tm-spr + ptrace-tm-spd-vsx ptrace-tm-spr ptrace-pkey include ../../lib.mk @@ -9,6 +9,9 @@ all: $(TEST_PROGS) CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie +ptrace-pkey: ../harness.c ../utils.c ../lib/reg.S ptrace.h child.h ptrace-pkey.c + $(LINK.c) $^ $(LDLIBS) -pthread -o $@ + $(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h clean: diff --git a/tools/testing/selftests/powerpc/ptrace/child.h b/tools/testing/selftests/powerpc/ptrace/child.h new file mode 100644 index ..40c1a6d92111 --- /dev/null +++ b/tools/testing/selftests/powerpc/ptrace/child.h @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Helper functions to sync execution between parent and child processes. + * + * Copyright 2018, Thiago Jung Bauermann, IBM Corporation. + */ +#include +#include +#include + +/* + * Information in a shared memory location for synchronization between child and + * parent. + */ +struct child_sync { + /* The parent waits on this semaphore. */ + sem_t sem_parent; + + /* If true, the child should give up as well. */ + bool parent_gave_up; + + /* The child waits on this semaphore. */ + sem_t sem_child; + + /* If true, the parent should give up as well. */ + bool child_gave_up; +}; + +#define CHILD_FAIL_IF(x, sync) \ + do {\ + if (x) {\ + fprintf(stderr, \ + "[FAIL] Test FAILED on line %d\n", __LINE__); \ + (sync)->child_gave_up = true; \ + prod_parent(sync); \ + return 1; \ + } \ + } while (0) + +#define PARENT_FAIL_IF(x, sync) \ + do {\ + if (x) {\ + fprintf(stderr, \ + "[FAIL] Test FAILED on line %d\n", __LINE__); \ + (sync)->parent_gave_up = true; \ + prod_child(sync); \ + return 1; \ + } \ + } while (0) + +int init_child_sync(struct child_sync *sync) +{ + int ret; + + ret = sem_init(&sync->sem_parent, 1, 0); + if (ret) { + perror("Semaphore initialization failed"); + return 1; + } + + ret = sem_init(&sync->sem_child, 1, 0); + if (ret) { + perror("Semaphore initialization failed"); + return 1; + } + + return 0; +} + +void destroy_child_sync(struct child_sync *sync) +{ + sem_destroy(&sync->sem_parent); + sem_de
Re: [PATCH] PCI/AER: Move pci_uevent_ers() out of pci.h
On 2/22/18 10:10 PM, Michael Ellerman wrote: > Bjorn Helgaas writes: > >> On Thu, Feb 08, 2018 at 09:05:45AM -0600, Bryant G. Ly wrote: >>> On 2/8/18 6:20 AM, Michael Ellerman wrote: >>> There's no reason pci_uevent_ers() needs to be inline in pci.h, so move it out to a C file. Given it's used by AER the obvious location would be somewhere in drivers/pci/pcie/aer, but because it's also used by powerpc EEH code unfortunately that doesn't work in the case where EEH is enabled but PCIEPORTBUS is not. So for now put it in pci-driver.c, next to pci_uevent(), with an appropriate #ifdef so it's not built if AER and EEH are both disabled. While we're moving it also fix up the kernel doc comment for @pdev to be accurate. Reported-by: Linus Torvalds Signed-off-by: Michael Ellerman --- drivers/pci/pci-driver.c | 36 include/linux/pci.h | 38 +++--- 2 files changed, 39 insertions(+), 35 deletions(-) >>> Looks good, thanks for fixing it! >>> >>> Signed-off-by: Bryant G. Ly >> This would normally be a "Reviewed-by" unless you actually >> participated in developing the patch, and in that case, your >> "Signed-off-by" would normally be included in the original posting. >> >> What do you intend? I'll be glad to add either. > I wrote the patch, so Bryant meant Reviewed-by or maybe Acked-by. > > cheers > Yes, I mean't, Reviewed-by: Bryant G. Ly Thanks, Bryant
Re: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro conversions
On Fri, Feb 23, 2018 at 11:11:12PM +1100, Michael Ellerman wrote: > Michael Ellerman writes: > > Subject: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro conversions > ^ >4.9 > > Gah, sorry just realised these last two have "v4.4" in the subject, but > it should be "4.9". Ah, good, I was wondering about that :) I'll apply these after lunch... greg k-h
Re: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro conversions
Michael Ellerman writes: > Subject: [PATCH v4.4 backport 2/3] powerpc/64s: Simple RFI macro conversions ^ 4.9 Gah, sorry just realised these last two have "v4.4" in the subject, but it should be "4.9". cheers
Hotplug + Reboot is crashing HPT guest with HPT resizing enabled
Hi, Rebooting a hash guest after hotplugging memory to it is crashing the guest. This is seen only when HPT resizing is enabled. I see guest crashing at multiple places, but this location is fairly commonly seen: kernel BUG at mm/slub.c:3912! Testing with latest guest kernel and ppc-for-2.12 branch of QEMU. A bit of debugging shows me that when memory is added, the guest kernel tries to resize HPT to a htab_shift value lesser than the value with which the guest has booted. For eg. a 8GB guest boots with htab_shift of 26. When 1G is hot-added, arch/powerpc/mm/hash_utils_64.c:resize_hpt_for_hotplug() ends up assigning 24 to target_hpt_shift. This looks suspicious as we are increasing the memory, but kernel is asking for shrinking the HPT size. HPT resizing requests fail though, but next reboot crashes the guest. Regards, Bharata. -- http://raobharata.wordpress.com/
Re: samples/seccomp/ broken when cross compiling s390, ppc allyesconfig
On Thu 22-02-18 09:30:35, Kees Cook wrote: > On Thu, Feb 22, 2018 at 5:07 AM, Michal Hocko wrote: > > On Wed 14-02-18 09:14:47, Kees Cook wrote: > > [...] > >> I can send it through my seccomp tree via James Morris. > > > > Could you please do it? > > Hi! Yes, sorry, this fell through the cracks. Now applied. Thanks! -- Michal Hocko SUSE Labs
Re: [PATCH v12 1/3] mm, powerpc, x86: define VM_PKEY_BITx bits if CONFIG_ARCH_HAS_PKEYS is enabled
Hi Ram, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc2 next-20180223] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Ram-Pai/mm-x86-powerpc-Enhancements-to-Memory-Protection-Keys/20180223-042743 config: powerpc-skiroot_defconfig (attached as .config) compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc Note: the linux-review/Ram-Pai/mm-x86-powerpc-Enhancements-to-Memory-Protection-Keys/20180223-042743 HEAD c5692bca45543c242ffca15c811923e4c548ed19 builds fine. It only hurts bisectibility. All errors (new ones prefixed by >>): In file included from include/linux/pkeys.h:9:0, from arch/powerpc/include/asm/mman.h:16, from include/uapi/linux/mman.h:5, from include/linux/mman.h:9, from arch/powerpc/kernel/asm-offsets.c:22: arch/powerpc/include/asm/pkeys.h: In function 'pkey_to_vmflag_bits': >> arch/powerpc/include/asm/pkeys.h:32:23: error: 'VM_PKEY_BIT4' undeclared >> (first use in this function); did you mean 'VM_PKEY_BIT3'? VM_PKEY_BIT3 | VM_PKEY_BIT4) ^ arch/powerpc/include/asm/pkeys.h:42:41: note: in expansion of macro 'ARCH_VM_PKEY_FLAGS' return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS); ^~ arch/powerpc/include/asm/pkeys.h:32:23: note: each undeclared identifier is reported only once for each function it appears in VM_PKEY_BIT3 | VM_PKEY_BIT4) ^ arch/powerpc/include/asm/pkeys.h:42:41: note: in expansion of macro 'ARCH_VM_PKEY_FLAGS' return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS); ^~ arch/powerpc/include/asm/pkeys.h: In function 'vmflag_to_pte_pkey_bits': arch/powerpc/include/asm/pkeys.h:54:16: error: 'VM_PKEY_BIT4' undeclared (first use in this function); did you mean 'VM_PKEY_BIT3'? ((vm_flags & VM_PKEY_BIT4) ? H_PTE_PKEY_BIT0 : 0x0UL)); ^~~~ VM_PKEY_BIT3 arch/powerpc/include/asm/pkeys.h: In function 'vma_pkey': >> arch/powerpc/include/asm/pkeys.h:32:23: error: 'VM_PKEY_BIT4' undeclared >> (first use in this function); did you mean 'VM_PKEY_BIT3'? VM_PKEY_BIT3 | VM_PKEY_BIT4) ^ arch/powerpc/include/asm/pkeys.h:61:26: note: in expansion of macro 'ARCH_VM_PKEY_FLAGS' return (vma->vm_flags & ARCH_VM_PKEY_FLAGS) >> VM_PKEY_SHIFT; ^~ make[2]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [prepare0] Error 2 make[1]: Target 'prepare' not remade because of errors. make: *** [sub-make] Error 2 vim +32 arch/powerpc/include/asm/pkeys.h 4fb158f6 Ram Pai 2018-01-18 30 4fb158f6 Ram Pai 2018-01-18 31 #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \ 4fb158f6 Ram Pai 2018-01-18 @32 VM_PKEY_BIT3 | VM_PKEY_BIT4) 4fb158f6 Ram Pai 2018-01-18 33 :: The code at line 32 was first introduced by commit :: 4fb158f65ac5556b9b4a6f63f38272853ed99b22 powerpc: track allocation status of all pkeys :: TO: Ram Pai :: CC: Michael Ellerman --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 0/5] PPC32/ioremap: Use memblock API to check for RAM
Le 22/02/2018 à 13:15, Jonathan Neuschäfer a écrit : This patchset solves the same problem as my previous one[1] but follows a rather different approach. Instead of implementing DISCONTIGMEM for PowerPC32, I simply switched the "is this RAM" check in __ioremap_caller to the existing page_is_ram function, and unified page_is_ram to search memblock.memory on PPC64 and PPC32. The intended result is, as before, that my Wii can allocate the MMIO range of its GPIO controller, which was previously not possible, because the reserved memory hack (__allow_ioremap_reserved) didn't affect the API in kernel/resource.c. Thanks to Christophe Leroy for reviewing the previous patchset. I tested your new serie, it doesn't break my 8xx so it is OK for me. Christophe [1]: https://www.spinics.net/lists/kernel/msg2726786.html Jonathan Neuschäfer (5): powerpc: mm: Simplify page_is_ram by using memblock_is_memory powerpc: mm: Use memblock API for PPC32 page_is_ram powerpc/mm/32: Use page_is_ram to check for RAM powerpc: wii: Don't rely on the reserved memory hack powerpc/mm/32: Remove the reserved memory hack arch/powerpc/mm/init_32.c| 5 - arch/powerpc/mm/mem.c| 12 +--- arch/powerpc/mm/mmu_decl.h | 1 - arch/powerpc/mm/pgtable_32.c | 4 +--- arch/powerpc/platforms/embedded6xx/wii.c | 14 +- 5 files changed, 3 insertions(+), 33 deletions(-)