Re: [PATCH v2] powerpc/book3s: mce: Move add_taint() later in virtual mode.

2017-04-24 Thread Mahesh Jagannath Salgaonkar
On 04/21/2017 09:37 AM, Michael Ellerman wrote: > Daniel Axtens writes: >>> diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c >>> index a1475e6..b23b323 100644 >>> --- a/arch/powerpc/kernel/mce.c >>> +++ b/arch/powerpc/kernel/mce.c >>> @@ -221,6 +221,8 @@ static void machine_check

Re: [PATCH v3 3/7] kprobes: validate the symbol name length

2017-04-24 Thread Masami Hiramatsu
On Sun, 23 Apr 2017 15:44:32 + "Naveen N. Rao" wrote: > >> >> +bool is_valid_kprobe_symbol_name(const char *name) > >> > > >> > This just check the length of symbol_name buffer, and can contain > >> > some invalid chars. > >> > >> Yes, I kept the function name generic incase we would like t

Re: Powerpc64: Fixup oops when debug programs with CONFIG_RELOCATABLE=y

2017-04-24 Thread Scott Wood
On Tue, Feb 07, 2017 at 10:35:52AM +0800, Liu Hailong wrote: > From: LiuHailong > > Debug interrupts can be taken during regular program or a standard > interrupt, the EA of the instruction causing the interrupt will be > kept in DSRR0. > Kernel will check if this value is between [interrupt_base

Re: [kernel-hardening] Re: [PATCH v2] powerpc/mm: Add support for runtime configuration of ASLR limits

2017-04-24 Thread Balbir Singh
On Tue, 2017-04-25 at 00:29 +1000, Michael Ellerman wrote: > Balbir Singh writes: > > > On Fri, 2017-04-21 at 00:36 +1000, Michael Ellerman wrote: > > > Add powerpc support for mmap_rnd_bits and mmap_rnd_compat_bits, which are > > > two > > > sysctls that allow a user to configure the number of

Re: [PATCH 8/8] selftests: x86: override clean in lib.mk to fix warnings

2017-04-24 Thread Shuah Khan
On 04/24/2017 09:57 AM, David Laight wrote: > From: Linuxppc-dev Michael Ellerman >> Shuah Khan writes: >> >>> Add override for lib.mk clean to fix the following warnings from clean >>> target run. >>> >>> Makefile:44: warning: overriding recipe for target 'clean' >>> ../lib.mk:55: warning: ignori

Re: [PATCH 2/8] selftests: lib.mk: define CLEAN macro to allow Makefiles to override clean

2017-04-24 Thread Shuah Khan
On 04/24/2017 09:45 AM, David Laight wrote: > From: Shuah Khan >> Sent: 22 April 2017 00:15 >> Define CLEAN macro to allow Makefiles to override common clean target >> in lib.mk. This will help fix the following failures: >> >> warning: overriding recipe for target 'clean' >> ../lib.mk:55: warning:

Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions

2017-04-24 Thread Benjamin Herrenschmidt
On Mon, 2017-04-24 at 10:25 -0700, Sukadev Bhattiprolu wrote: > which maybe due to this :-) Should I change to pgprot_noncached() for > the MMIO writes? Just use normal ioremap(). > > requires being mapped cachable. Ask Aneesh for a cleaner way of > > doing it too while at it.

Re: [RFC] arch/powerpc: Turn off irqs in switch_mm()

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 06:38:26 UTC, David Gibson wrote: > There seems to be a mismatch in expectations between the powerpc arch code > and the generic (and x86) code in terms of the irq state when switch_mm() > is called. > > powerpc expects irqs to already be (soft) disabled when switch_mm() is >

Re: powerpc/xmon: Deindent the SLB dumping logic

2017-04-24 Thread Michael Ellerman
On Mon, 2017-04-24 at 00:35:14 UTC, Michael Ellerman wrote: > Currently the code that dumps SLB entries uses a double-nested if. This > means the actual dumping logic is a bit squashed. Deindent it by using > continue. > > Signed-off-by: Michael Ellerman > Reviewed-by: Rashmica Gupta Applied to

Re: [v4, 3/6] kprobes: Skip preparing optprobe if the probe is ftrace-based

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:52:25 UTC, "Naveen N. Rao" wrote: > From: Masami Hiramatsu > > Skip preparing optprobe if the probe is ftrace-based, since anyway, it > must not be optimized (or already optimized by ftrace). > > Tested-by: Naveen N. Rao > Signed-off-by: Masami Hiramatsu Applied to po

Re: [v4, 6/6] powerpc: kprobes: prefer ftrace when probing function entry

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:52:28 UTC, "Naveen N. Rao" wrote: > KPROBES_ON_FTRACE avoids much of the overhead with regular kprobes as it > eliminates the need for a trap, as well as the need to emulate or > single-step instructions. > > Though OPTPROBES provides us with similar performance, we have l

Re: [v4, 5/6] powerpc: introduce a new helper to obtain function entry points

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:52:27 UTC, "Naveen N. Rao" wrote: > kprobe_lookup_name() is specific to the kprobe subsystem and may not > always return the function entry point (in a subsequent patch for > KPROBES_ON_FTRACE). For looking up function entry points, introduce a > separate helper and use the

Re: [v4,4/6] powerpc: kprobes: add support for KPROBES_ON_FTRACE

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:52:26 UTC, "Naveen N. Rao" wrote: > Allow kprobes to be placed on ftrace _mcount() call sites. This > optimization avoids the use of a trap, by riding on ftrace > infrastructure. > > This depends on HAVE_DYNAMIC_FTRACE_WITH_REGS which depends on > MPROFILE_KERNEL, which is

Re: [v4,2/6] powerpc: ftrace: restore LR from pt_regs

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:52:24 UTC, "Naveen N. Rao" wrote: > Pass the real LR to the ftrace handler. This is needed for > KPROBES_ON_FTRACE for the pre handlers. > > Also, with KPROBES_ON_FTRACE, the link register may be updated by the > pre handlers or by a registed kretprobe. Honor updated LR by

Re: [v3, 6/7] powerpc: kprobes: emulate instructions on kprobe handler re-entry

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:51:05 UTC, "Naveen N. Rao" wrote: > On kprobe handler re-entry, try to emulate the instruction rather than > single stepping always. > > Acked-by: Ananth N Mavinakayanahalli > Signed-off-by: Naveen N. Rao Applied to powerpc next, thanks. https://git.kernel.org/powerpc/

Re: [v3, 5/7] powerpc: kprobes: factor out code to emulate instruction into a helper

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:51:04 UTC, "Naveen N. Rao" wrote: > No functional changes. > > Acked-by: Ananth N Mavinakayanahalli > Signed-off-by: Naveen N. Rao Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/1cabd2f8f720a0ed612139547acb65 cheers

Re: [v3,1/7] kprobes: convert kprobe_lookup_name() to a function

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:51:00 UTC, "Naveen N. Rao" wrote: > The macro is now pretty long and ugly on powerpc. In the light of > further changes needed here, convert it to a __weak variant to be > over-ridden with a nicer looking function. > > Suggested-by: Masami Hiramatsu > Acked-by: Masami Hir

Re: [v3, 2/7] powerpc: kprobes: fix handling of function offsets on ABIv2

2017-04-24 Thread Michael Ellerman
On Wed, 2017-04-19 at 12:51:01 UTC, "Naveen N. Rao" wrote: > commit 239aeba76409 ("perf powerpc: Fix kprobe and kretprobe handling > with kallsyms on ppc64le") changed how we use the offset field in struct > kprobe on ABIv2. perf now offsets from the GEP (Global entry point) if an > offset is speci

Re: [2/2] powerpc/sysfs: fix reference leak of cpu device_nodes present at boot

2017-04-24 Thread Michael Ellerman
On Tue, 2017-04-18 at 00:24:39 UTC, Tyrel Datwyler wrote: > For cpus present at boot each logical cpu acquires a reference to the > associated device node of the core. This happens in register_cpu() which > is called by topology_init(). The result of this is that we end up with > a reference held b

Re: [1/2] powerpc/pseries: fix of_node_put() underflow during dlpar remove

2017-04-24 Thread Michael Ellerman
On Tue, 2017-04-18 at 00:21:40 UTC, Tyrel Datwyler wrote: > Historically device_node references were tracked using a kref embedded > as a struct field. Commit 75b57ecf9 refactored device_nodes to be > kobjects such that the device tree could by more simply exposed to > userspace using sysfs. Commit

Re: [v5, 2/5] powerpc: kretprobes: override default function entry offset

2017-04-24 Thread Michael Ellerman
On Wed, 2017-03-08 at 08:26:07 UTC, "Naveen N. Rao" wrote: > With ABIv2, we offset 8 bytes into a function to get at the local entry > point. > > Acked-by: Ananth N Mavinakayanahalli > Acked-by: Michael Ellerman > Signed-off-by: Naveen N. Rao > Acked-by: Michael Ellerman Applied to powerpc ne

Re: [kernel-hardening] Re: [PATCH v2] powerpc/mm: Add support for runtime configuration of ASLR limits

2017-04-24 Thread Michael Ellerman
Kees Cook writes: > On Mon, Apr 24, 2017 at 7:29 AM, Michael Ellerman wrote: >> Balbir Singh writes: diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index a5d9ef59debe..6141cfff634e 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -59,13 +

Re: [PATCH v4 04/11] VAS: Define vas_init() and vas_exit()

2017-04-24 Thread Tyrel Datwyler
On 03/30/2017 10:13 PM, Sukadev Bhattiprolu wrote: > Implement vas_init() and vas_exit() functions for a new VAS module. > This VAS module is essentially a library for other device drivers > and kernel users of the NX coprocessors like NX-842 and NX-GZIP. > In the future this will be extended to ad

Re: [kernel-hardening] Re: [PATCH v2] powerpc/mm: Add support for runtime configuration of ASLR limits

2017-04-24 Thread Kees Cook
On Mon, Apr 24, 2017 at 7:29 AM, Michael Ellerman wrote: > Balbir Singh writes: > >> On Fri, 2017-04-21 at 00:36 +1000, Michael Ellerman wrote: >>> Add powerpc support for mmap_rnd_bits and mmap_rnd_compat_bits, which are >>> two >>> sysctls that allow a user to configure the number of bits of r

Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions

2017-04-24 Thread Sukadev Bhattiprolu
Benjamin Herrenschmidt [b...@kernel.crashing.org] wrote: > On Thu, 2017-03-30 at 22:13 -0700, Sukadev Bhattiprolu wrote: > > +static void *map_mmio_region(char *name, uint64_t start, int len) > > +{ > > +   void *map; > > + > > +   if (!request_mem_region(start, len, name)) { > > + 

RE: [PATCH 8/8] selftests: x86: override clean in lib.mk to fix warnings

2017-04-24 Thread David Laight
From: Linuxppc-dev Michael Ellerman > Shuah Khan writes: > > > Add override for lib.mk clean to fix the following warnings from clean > > target run. > > > > Makefile:44: warning: overriding recipe for target 'clean' > > ../lib.mk:55: warning: ignoring old recipe for target 'clean' > > > > Signed

RE: [PATCH 2/8] selftests: lib.mk: define CLEAN macro to allow Makefiles to override clean

2017-04-24 Thread David Laight
From: Shuah Khan > Sent: 22 April 2017 00:15 > Define CLEAN macro to allow Makefiles to override common clean target > in lib.mk. This will help fix the following failures: > > warning: overriding recipe for target 'clean' > ../lib.mk:55: warning: ignoring old recipe for target 'clean' > > Signed

Re: [PATCH v2 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32

2017-04-24 Thread Christophe LEROY
Le 23/04/2017 à 12:26, Michael Ellerman a écrit : christophe leroy writes: Le 22/04/2017 à 08:08, Michael Ellerman a écrit : "Naveen N. Rao" writes: Excerpts from Christophe Leroy's message of April 21, 2017 18:32: diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c

Re: [kernel-hardening] Re: [PATCH v2] powerpc/mm: Add support for runtime configuration of ASLR limits

2017-04-24 Thread Michael Ellerman
Balbir Singh writes: > On Fri, 2017-04-21 at 00:36 +1000, Michael Ellerman wrote: >> Add powerpc support for mmap_rnd_bits and mmap_rnd_compat_bits, which are two >> sysctls that allow a user to configure the number of bits of randomness used >> for >> ASLR. ... > > Could we please suggest that

[PATCH v3 2/3] powerpc/mm: Fix kernel RAM protection after freeing unused memory on PPC32

2017-04-24 Thread Christophe Leroy
As seen below, allthough the init sections have been freed, the associated memory area is still marked as executable in the page tables. ~ dmesg [5.860093] Freeing unused kernel memory: 592K (c057 - c0604000) ~ cat /sys/kernel/debug/kernel_page_tables ---[ Start of kernel VM ]--- 0xc0

[PATCH v3 3/3] powerpc/mm: Implement CONFIG_DEBUG_RODATA on PPC32

2017-04-24 Thread Christophe Leroy
This patch implements CONFIG_DEBUG_RODATA on PPC32. As for CONFIG_DEBUG_PAGEALLOC, it deactivates BAT and LTLB mappings in order to allow page protection setup at the level of each page. As BAT/LTLB mappings are deactivated, their might be performance impact. For this reason, we keep it OFF by de

[PATCH v3 1/3] powerpc/mm: Ensure change_page_attr() doesn't invalidate pinned TLBs

2017-04-24 Thread Christophe Leroy
__change_page_attr() uses flush_tlb_page(). flush_tlb_page() uses tlbie instruction, which also invalidates pinned TLBs, which is not what we expect. This patch modifies the implementation to use flush_tlb_kernel_range() instead. This will make use of tlbia which will preserve pinned TLBs. Signed

[PATCH v3 0/3] powerpc/mm: Fix kernel protection and implement CONFIG_DEBUG_RODATA on PPC32

2017-04-24 Thread Christophe Leroy
This patch set implements CONFIG_DEBUG_RODATA on Powerpc32 after fixing a few issues related to kernel code page protection. Changes in v2: Instead of making the entire kernel RW to patch code in ftrace, we now only change the rights on the page to be modified Changes in v3: Changing the ri

[PATCH v2] powerpc/mm: Ensure IRQs are off in switch_mm()

2017-04-24 Thread Michael Ellerman
From: David Gibson powerpc expects IRQs to already be (soft) disabled when switch_mm() is called, as made clear in the commit message of 9c1e105238c4 ("powerpc: Allow perf_counters to access user memory at interrupt time"). Aside from any race conditions that might exist between switch_mm() and

Re: [PATCH v2 1/2] fadump: reduce memory consumption for capture kernel

2017-04-24 Thread Michal Suchánek
On Mon, 24 Apr 2017 18:26:37 +0530 Hari Bathini wrote: > Hi Michal. > > On Monday 24 April 2017 03:54 PM, Michal Suchánek wrote: > > On Fri, 21 Apr 2017 00:19:55 +0530 > > Hari Bathini wrote: > > > >> On Wednesday 19 April 2017 07:38 PM, Michal Suchánek wrote: > >>> On Wed, 19 Apr 2017 14:1

Re: [PATCH v2 1/2] fadump: reduce memory consumption for capture kernel

2017-04-24 Thread Hari Bathini
Hi Michal. On Monday 24 April 2017 03:54 PM, Michal Suchánek wrote: On Fri, 21 Apr 2017 00:19:55 +0530 Hari Bathini wrote: On Wednesday 19 April 2017 07:38 PM, Michal Suchánek wrote: On Wed, 19 Apr 2017 14:19:47 +1000 Michael Ellerman wrote: Michal Suchánek writes: On Mon, 17 Apr 2017

[PATCH] powerpc/sysfs: Move #ifdef CONFIG_HOTPLUG_CPU out of the function body

2017-04-24 Thread Michael Ellerman
The entire body of unregister_cpu_online() is inside an #ifdef CONFIG_HOTPLUG_CPU block. This is ugly and means we create an empty function when hotplug is disabled for no reason. Instead move the #ifdef out of the function body and define the function to be NULL in the else case. This means we'll

Re: [PATCH v2 1/2] fadump: reduce memory consumption for capture kernel

2017-04-24 Thread Michal Suchánek
On Fri, 21 Apr 2017 00:19:55 +0530 Hari Bathini wrote: > On Wednesday 19 April 2017 07:38 PM, Michal Suchánek wrote: > > On Wed, 19 Apr 2017 14:19:47 +1000 > > Michael Ellerman wrote: > > > >> Michal Suchánek writes: > >>> On Mon, 17 Apr 2017 20:43:02 +0530 > >>> Hari Bathini wrote: > >>

Re: [PATCH] powerpc/mm: Only read faulting instruction when necessary in do_page_fault()

2017-04-24 Thread Christophe LEROY
Le 24/04/2017 à 11:15, Michael Ellerman a écrit : Christophe Leroy writes: diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index 400f2d0d42f8..3d506589236c 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -356,8 +348,22 @@ int do_page_fault(struct pt_regs

Re: [PATCH] powerpc/64s: use ibm, tlbiel-congruence-classes-(hash|radix) dt property

2017-04-24 Thread Aneesh Kumar K.V
On Monday 24 April 2017 02:47 PM, Michael Ellerman wrote: "Aneesh Kumar K.V" writes: Nicholas Piggin writes: tlbiel instruction with IS!=0 on POWER7 and later Book3s CPUs invalidate TLBs belonging to a specified congruence class. In order to operate on the entire TLB, all congruence classes

Re: [PATCH] powerpc/64s: use ibm, tlbiel-congruence-classes-(hash|radix) dt property

2017-04-24 Thread Michael Ellerman
"Aneesh Kumar K.V" writes: > Nicholas Piggin writes: >> tlbiel instruction with IS!=0 on POWER7 and later Book3s CPUs invalidate >> TLBs belonging to a specified congruence class. In order to operate on >> the entire TLB, all congruence classes must be specified, requiring a >> software loop. ...

Re: [PATCH] powerpc/mm: Only read faulting instruction when necessary in do_page_fault()

2017-04-24 Thread Michael Ellerman
Christophe Leroy writes: > diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c > index 400f2d0d42f8..3d506589236c 100644 > --- a/arch/powerpc/mm/fault.c > +++ b/arch/powerpc/mm/fault.c > @@ -356,8 +348,22 @@ int do_page_fault(struct pt_regs *regs, unsigned long > address, >

Re: [PATCH 4/5] powerpc/mm: Evaluate user_mode(regs) only once in do_page_fault()

2017-04-24 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Analysis of the assembly code shows that when using user_mode(regs), > at least the 'andi.' is redone all the time, and also > the 'lwz ,132(r31)' most of the time. With the new form, the 'is_user' > is mapped to cr4, then all further use of is_user results in just > th

Re: [PATCH 2/5] powerpc/mm: split store_updates_sp() in two parts in do_page_fault()

2017-04-24 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Only the get_user() in store_updates_sp() has to be done outside > the mm semaphore. All the comparison can be done within the semaphore, > so only when really needed. > > As we got a DSI exception, the address pointed by regs->nip is > obviously valid, otherwise we wou

Re: [PATCH 1/5] powerpc/mm: only call store_updates_sp() on stores in do_page_fault()

2017-04-24 Thread Aneesh Kumar K.V
Christophe Leroy writes: > Function store_updates_sp() checks whether the faulting > instruction is a store updating r1. Therefore we can limit its calls > to stores exceptions. > > This patch is an improvement of commit a7a9dcd882a67 ("powerpc: Avoid > taking a data miss on every userspace instr

[PATCH] powerpc/mm: Only read faulting instruction when necessary in do_page_fault()

2017-04-24 Thread Christophe Leroy
Commit a7a9dcd882a67 ("powerpc: Avoid taking a data miss on every userspace instruction miss") has shown that limiting the read of faulting instruction to likely cases improves performance. This patch goes further into this direction by limiting the read of the faulting instruction to the only cas

Re: [PATCH] powerpc/64s: use ibm, tlbiel-congruence-classes-(hash|radix) dt property

2017-04-24 Thread Aneesh Kumar K.V
Nicholas Piggin writes: > tlbiel instruction with IS!=0 on POWER7 and later Book3s CPUs invalidate > TLBs belonging to a specified congruence class. In order to operate on > the entire TLB, all congruence classes must be specified, requiring a > software loop. > > This dt property specifies the n