Re: [PATCH] powerpc: Define and use PPC_ELF_ABI_v2

2016-04-28 Thread Joel Stanley
On Thu, Apr 28, 2016 at 7:08 PM, Michael Ellerman  wrote:
> We're approaching 20 locations where we need to check for ELF ABI v2.
> That's fine, except the logic is a bit awkward, because we have to check
> that _CALL_ELF is defined and then what its value is.
>
> So check it once in asm/types.h and define PPC_ELF_ABI_v2 when ELF ABI
> v2 is detected.
>
> We don't add explicit includes of asm/types.h because it's included
> basically everywhere via compiler.h.

Thank you! I always wondered why we didn't do this.

> Signed-off-by: Michael Ellerman 

Reviewed-by: Joel Stanley 

> ---
>  arch/powerpc/include/asm/code-patching.h | 6 +++---
>  arch/powerpc/include/asm/ftrace.h| 2 +-
>  arch/powerpc/include/asm/kprobes.h   | 4 ++--
>  arch/powerpc/include/asm/linkage.h   | 2 +-
>  arch/powerpc/include/asm/ppc_asm.h   | 4 ++--
>  arch/powerpc/include/asm/ptrace.h| 2 +-
>  arch/powerpc/include/asm/sections.h  | 2 +-
>  arch/powerpc/include/asm/types.h | 4 
>  arch/powerpc/kernel/entry_64.S   | 2 +-
>  arch/powerpc/kernel/head_64.S| 2 +-
>  arch/powerpc/kernel/kprobes.c| 2 +-
>  arch/powerpc/kernel/misc_64.S| 2 +-
>  arch/powerpc/kernel/module_64.c  | 4 ++--
>  arch/powerpc/kvm/book3s_interrupts.S | 2 +-
>  arch/powerpc/kvm/book3s_rmhandlers.S | 2 +-
>  15 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/code-patching.h 
> b/arch/powerpc/include/asm/code-patching.h
> index 994c60a857ce..d325b35315d3 100644
> --- a/arch/powerpc/include/asm/code-patching.h
> +++ b/arch/powerpc/include/asm/code-patching.h
> @@ -50,7 +50,7 @@ void __patch_exception(int exc, unsigned long addr);
>  static inline unsigned long ppc_function_entry(void *func)
>  {
>  #if defined(CONFIG_PPC64)
> -#if defined(_CALL_ELF) && _CALL_ELF == 2
> +#ifdef PPC_ELF_ABI_v2
> u32 *insn = func;
>
> /*
> @@ -90,7 +90,7 @@ static inline unsigned long ppc_function_entry(void *func)
>
>  static inline unsigned long ppc_global_function_entry(void *func)
>  {
> -#if defined(CONFIG_PPC64) && defined(_CALL_ELF) && _CALL_ELF == 2
> +#if defined(CONFIG_PPC64) && defined(PPC_ELF_ABI_v2)

The CONFIG_PPC64 is redundant?

> /* PPC64 ABIv2 the global entry point is at the address */
> return (unsigned long)func;
>  #else
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc: Define and use PPC_ELF_ABI_v2

2016-04-28 Thread Balbir Singh


On 28/04/16 19:38, Michael Ellerman wrote:
> We're approaching 20 locations where we need to check for ELF ABI v2.
> That's fine, except the logic is a bit awkward, because we have to check
> that _CALL_ELF is defined and then what its value is.
> 
> So check it once in asm/types.h and define PPC_ELF_ABI_v2 when ELF ABI
> v2 is detected.
> 
> We don't add explicit includes of asm/types.h because it's included
> basically everywhere via compiler.h.
> 
> Signed-off-by: Michael Ellerman 
> ---

Makes sense

Acked-by: Balbir Singh 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel] powerpc/powernv: Fix debug macro

2016-04-28 Thread Michael Ellerman
On Fri, 2016-04-29 at 14:56 +1000, Alexey Kardashevskiy wrote:

> When cfg_dbg() is enabled (i.e. mapped to printk()), gcc produces
> errors as the __func__ parameter is missing (pnv_pci_cfg_read() has one);
> this adds the missing parameter.

Thanks.

But the whole file should just be converted to use pr_devel(), which is an
existing well known macro and will catch this for you.

cheers

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel] powerpc/powernv: Fix debug macro

2016-04-28 Thread Andrew Donnellan

On 29/04/16 14:56, Alexey Kardashevskiy wrote:

When cfg_dbg() is enabled (i.e. mapped to printk()), gcc produces
errors as the __func__ parameter is missing (pnv_pci_cfg_read() has one);
this adds the missing parameter.

Signed-off-by: Alexey Kardashevskiy 


Reviewed-by: Andrew Donnellan 

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH kernel] powerpc/powernv: Fix debug macro

2016-04-28 Thread Alexey Kardashevskiy
When cfg_dbg() is enabled (i.e. mapped to printk()), gcc produces
errors as the __func__ parameter is missing (pnv_pci_cfg_read() has one);
this adds the missing parameter.

Signed-off-by: Alexey Kardashevskiy 
---
 arch/powerpc/platforms/powernv/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/pci.c 
b/arch/powerpc/platforms/powernv/pci.c
index 73c8dc2..cec1530 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -463,7 +463,7 @@ int pnv_pci_cfg_write(struct pci_dn *pdn,
u32 bdfn = (pdn->busno << 8) | pdn->devfn;
 
cfg_dbg("%s: bus: %x devfn: %x +%x/%x -> %08x\n",
-   pdn->busno, pdn->devfn, where, size, val);
+   __func__, pdn->busno, pdn->devfn, where, size, val);
switch (size) {
case 1:
opal_pci_config_write_byte(phb->opal_id, bdfn, where, val);
-- 
2.5.0.rc3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH kernel] KVM: PPC: Fix debug macros

2016-04-28 Thread Alexey Kardashevskiy
When XICS_DBG is enabled, gcc produces format errors. This fixes
formats to match passed values types.

Signed-off-by: Alexey Kardashevskiy 
---
 arch/powerpc/kvm/book3s_xics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c
index 46871d5..95896d7 100644
--- a/arch/powerpc/kvm/book3s_xics.c
+++ b/arch/powerpc/kvm/book3s_xics.c
@@ -280,7 +280,7 @@ static inline bool icp_try_update(struct kvmppc_icp *icp,
if (!success)
goto bail;
 
-   XICS_DBG("UPD [%04x] - C:%02x M:%02x PP: %02x PI:%06x R:%d O:%d\n",
+   XICS_DBG("UPD [%04lx] - C:%02x M:%02x PP: %02x PI:%06x R:%d O:%d\n",
 icp->server_num,
 old.cppr, old.mfrr, old.pending_pri, old.xisr,
 old.need_resend, old.out_ee);
@@ -336,7 +336,7 @@ static bool icp_try_to_deliver(struct kvmppc_icp *icp, u32 
irq, u8 priority,
union kvmppc_icp_state old_state, new_state;
bool success;
 
-   XICS_DBG("try deliver %#x(P:%#x) to server %#x\n", irq, priority,
+   XICS_DBG("try deliver %#x(P:%#x) to server %#lx\n", irq, priority,
 icp->server_num);
 
do {
-- 
2.5.0.rc3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/mm/radix: Document software bits for radix

2016-04-28 Thread Aneesh Kumar K.V
Add #defines for PowerISA 3.0 software defined bits

Signed-off-by: Aneesh Kumar K.V 
---
 arch/powerpc/include/asm/book3s/64/pgtable.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 9faa511757a1..5e1f3b5a4965 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -20,12 +20,16 @@
 /*
  * Software bits
  */
+#define _RPAGE_SW0 0x2000UL
+#define _RPAGE_SW1 0x00800
+#define _RPAGE_SW2 0x00400
+#define _RPAGE_SW3 0x00200
 #ifdef CONFIG_MEM_SOFT_DIRTY
-#define _PAGE_SOFT_DIRTY   0x00200 /* software: software dirty tracking */
+#define _PAGE_SOFT_DIRTY   _RPAGE_SW3 /* software: software dirty tracking 
*/
 #else
 #define _PAGE_SOFT_DIRTY   0x0
 #endif
-#define _PAGE_SPECIAL  0x00400 /* software: special page */
+#define _PAGE_SPECIAL  _RPAGE_SW2 /* software: special page */
 
 
 #define _PAGE_PTE  (1ul << 62) /* distinguishes PTEs from 
pointers */
-- 
2.7.4

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 1/1] ASoC: fsl_ssi: add CCSR_SSI_SOR to volatile register list

2016-04-28 Thread Nicolin Chen
On Mon, Apr 25, 2016 at 11:36:18AM -0700, Caleb Crome wrote:
> The CCSR_SSI_SOR is a register that clears the TX and/or the RX fifo
> on the i.MX SSI port.  The fsl_ssi_trigger writes this register in
> order to clear the fifo at trigger time.
> 
> However, since the CCSR_SSI_SOR register is not in the volatile list,
> the caching mechanism prevented the register write in the trigger
> function.  This caused the fifo to not be cleared (because the value
> was unchanged from the last time the register was written), and thus
> causes the channels in both TDM or simple I2S mode to slip and be in
> the wrong time slots on SSI restart.
> 
> This has gone unnoticed for so long because with simple stereo mode,
> the consequence is that left and right are swapped, which isn't that
> noticeable.  However, it's catestrophic in some systems that
> require the channels to be in the right slots.
> 
> Signed-off-by: Caleb Crome 
> Suggested-by: Arnaud Mouiche 

Acked-by: Nicolin Chen 

Thanks

> 
> ---
>  sound/soc/fsl/fsl_ssi.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
> index 216e3cb..2f3bf9c 100644
> --- a/sound/soc/fsl/fsl_ssi.c
> +++ b/sound/soc/fsl/fsl_ssi.c
> @@ -151,6 +151,7 @@ static bool fsl_ssi_volatile_reg(struct device *dev, 
> unsigned int reg)
>   case CCSR_SSI_SACDAT:
>   case CCSR_SSI_SATAG:
>   case CCSR_SSI_SACCST:
> + case CCSR_SSI_SOR:
>   return true;
>   default:
>   return false;
> -- 
> 1.9.1
> 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [alsa-devel] [PATCH v2 1/1] ASoC: fsl_ssi: add CCSR_SSI_SOR to volatile register list

2016-04-28 Thread Fabio Estevam
On Mon, Apr 25, 2016 at 3:36 PM, Caleb Crome  wrote:
> The CCSR_SSI_SOR is a register that clears the TX and/or the RX fifo
> on the i.MX SSI port.  The fsl_ssi_trigger writes this register in
> order to clear the fifo at trigger time.
>
> However, since the CCSR_SSI_SOR register is not in the volatile list,
> the caching mechanism prevented the register write in the trigger
> function.  This caused the fifo to not be cleared (because the value
> was unchanged from the last time the register was written), and thus
> causes the channels in both TDM or simple I2S mode to slip and be in
> the wrong time slots on SSI restart.
>
> This has gone unnoticed for so long because with simple stereo mode,
> the consequence is that left and right are swapped, which isn't that
> noticeable.  However, it's catestrophic in some systems that
> require the channels to be in the right slots.
>
> Signed-off-by: Caleb Crome 
> Suggested-by: Arnaud Mouiche 

Reviewed-by: Fabio Estevam 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH resend] powerpc: enable qspinlock and its virtualization support

2016-04-28 Thread Pan Xinhui

On 2016年04月29日 05:07, Waiman Long wrote:
> On 04/28/2016 06:55 AM, Pan Xinhui wrote:
>> From: Pan Xinhui
>>
>> This patch aims to enable qspinlock on PPC. And on pseries platform, it also 
>> support
>> paravirt qspinlock.
>>
>> Signed-off-by: Pan Xinhui
>> ---
>>   arch/powerpc/include/asm/qspinlock.h   | 37 +++
>>   arch/powerpc/include/asm/qspinlock_paravirt.h  | 36 +++
>>   .../powerpc/include/asm/qspinlock_paravirt_types.h | 13 ++
>>   arch/powerpc/include/asm/spinlock.h| 31 -
>>   arch/powerpc/include/asm/spinlock_types.h  |  4 ++
>>   arch/powerpc/kernel/paravirt.c | 52 
>> ++
>>   arch/powerpc/lib/locks.c   | 32 +
>>   arch/powerpc/platforms/pseries/setup.c |  5 +++
>>   8 files changed, 198 insertions(+), 12 deletions(-)
>>   create mode 100644 arch/powerpc/include/asm/qspinlock.h
>>   create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h
>>   create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt_types.h
>>   create mode 100644 arch/powerpc/kernel/paravirt.c
>>
>>
> 
> This is just an enablement patch. You will also need a patch to activate 
> qspinlock for, at lease, some PPC configs. Right?
> 
yep, I want to enable these config and makefile at last.
it just looks like

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 2da380f..ae7c2f1 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
 obj-$(CONFIG_PPC_P7_NAP)   += idle_power7.o
 procfs-y   := proc_powerpc.o
 obj-$(CONFIG_PROC_FS)  += $(procfs-y)
+obj-$(CONFIG_PARAVIRT_SPINLOCKS)   += paravirt.o
 rtaspci-$(CONFIG_PPC64)-$(CONFIG_PCI)  := rtas_pci.o
 obj-$(CONFIG_PPC_RTAS) += rtas.o rtas-rtc.o $(rtaspci-y-y)
 obj-$(CONFIG_PPC_RTAS_DAEMON)  += rtasd.o
diff --git a/arch/powerpc/platforms/pseries/Kconfig 
b/arch/powerpc/platforms/pseries/Kconfig
index bec90fb..46632e4 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -21,6 +21,7 @@ config PPC_PSERIES
select HOTPLUG_CPU if SMP
select ARCH_RANDOM
select PPC_DOORBELL
+   select ARCH_USE_QUEUED_SPINLOCKS
default y
 
 config PPC_SPLPAR
@@ -127,3 +128,11 @@ config HV_PERF_CTRS
  systems. 24x7 is available on Power 8 systems.
 
   If unsure, select Y.
+
+config PARAVIRT_SPINLOCKS
+   bool "Paravirtialization support for qspinlock"
+   depends on PPC_SPLPAR && QUEUED_SPINLOCKS
+   default y
+   help
+ If platform supports virtualization, for example PowerVM, this option
+ can let guest have a better performace.
-- 
2.4.3

> It has dependency on the pv_wait() patch that I sent out extend the parameter 
> list. Some performance data on how PPC system will perform with and without 
> qspinlock will also be helpful data points.
> 
For now, pv_wait defined in ppc is static inline void pv_wait(u8 *ptr, u8 val)
My plan is that waiting your patch goes in kernel tree first, then I send out 
another patch to extend the parameter list.

yes, I need copy some performance data in my patch's comments.

thanks
xinhui
> Cheers,
> Longman
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH resend] powerpc: enable qspinlock and its virtualization support

2016-04-28 Thread Waiman Long

On 04/28/2016 06:55 AM, Pan Xinhui wrote:

From: Pan Xinhui

This patch aims to enable qspinlock on PPC. And on pseries platform, it also 
support
paravirt qspinlock.

Signed-off-by: Pan Xinhui
---
  arch/powerpc/include/asm/qspinlock.h   | 37 +++
  arch/powerpc/include/asm/qspinlock_paravirt.h  | 36 +++
  .../powerpc/include/asm/qspinlock_paravirt_types.h | 13 ++
  arch/powerpc/include/asm/spinlock.h| 31 -
  arch/powerpc/include/asm/spinlock_types.h  |  4 ++
  arch/powerpc/kernel/paravirt.c | 52 ++
  arch/powerpc/lib/locks.c   | 32 +
  arch/powerpc/platforms/pseries/setup.c |  5 +++
  8 files changed, 198 insertions(+), 12 deletions(-)
  create mode 100644 arch/powerpc/include/asm/qspinlock.h
  create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h
  create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt_types.h
  create mode 100644 arch/powerpc/kernel/paravirt.c




This is just an enablement patch. You will also need a patch to activate 
qspinlock for, at lease, some PPC configs. Right?


It has dependency on the pv_wait() patch that I sent out extend the 
parameter list. Some performance data on how PPC system will perform 
with and without qspinlock will also be helpful data points.


Cheers,
Longman
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: VDSO unmap and remap support for additional architectures

2016-04-28 Thread Andy Lutomirski
On 04/28/2016 08:18 AM, Christopher Covington wrote:
> Please take a look at the following prototype of sharing the PowerPC
> VDSO unmap and remap code with other architectures. I've only hooked
> up arm64 to begin with. If folks think this is a reasonable approach I
> can work on 32 bit ARM as well. Not hearing back from an earlier
> request for guidance [1], I simply dove in and started hacking.
> Laurent's test case [2][3] is a compelling illustration of whether VDSO
> remap works or not on a given architecture.

I think there's a much nicer way:

https://lkml.kernel.org/r/1461584223-9418-1-git-send-email-dsafo...@virtuozzo.com

Could arm64 and ppc use this approach?  These arch_xyz hooks are gross.

Also, at some point, possibly quite soon, x86 will want a way for user code to 
ask the kernel to map a specific vdso variant at a specific address.  Could we 
perhaps add a new pair of syscalls:

struct vdso_info {
unsigned long space_needed_before;
unsigned long space_needed_after;
unsigned long alignment;
};

long vdso_get_info(unsigned int vdso_type, struct vdso_info *info);

long vdso_remap(unsigned int vdso_type, unsigned long addr, unsigned int flags);

#define VDSO_X86_I386 0
#define VDSO_X86_64 1
#define VDSO_X86_X32 2
// etc.

vdso_remap will map the vdso of the chosen type such at AT_SYSINFO_EHDR lines 
up with addr.  It will use up to space_needed_before bytes before that address 
and space_needed_after after than address.  It will also unmap the old vdso (or 
maybe only do that if some flag is set).

On x86, mremap is *not* sufficient for everything that's needed, because some 
programs will need to change the vdso type.

--Andy

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 18/18] livepatch: add /proc//patch_state

2016-04-28 Thread Josh Poimboeuf
Expose the per-task patch state value so users can determine which tasks
are holding up completion of a patching operation.

Signed-off-by: Josh Poimboeuf 
---
 Documentation/filesystems/proc.txt | 18 ++
 fs/proc/base.c | 15 +++
 2 files changed, 33 insertions(+)

diff --git a/Documentation/filesystems/proc.txt 
b/Documentation/filesystems/proc.txt
index e8d0075..0b09495 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -44,6 +44,7 @@ Table of Contents
   3.8   /proc//fdinfo/ - Information about opened file
   3.9   /proc//map_files - Information about memory mapped files
   3.10  /proc//timerslack_ns - Task timerslack value
+  3.11 /proc//patch_state - Livepatch patch operation state
 
   4Configuring procfs
   4.1  Mount options
@@ -1880,6 +1881,23 @@ Valid values are from 0 - ULLONG_MAX
 An application setting the value must have PTRACE_MODE_ATTACH_FSCREDS level
 permissions on the task specified to change its timerslack_ns value.
 
+3.11   /proc//patch_state - Livepatch patch operation state
+-
+When CONFIG_LIVEPATCH is enabled, this file displays the value of the
+patch state for the task.
+
+A value of '-1' indicates that no patch is in transition.
+
+A value of '0' indicates that a patch is in transition and the task is
+unpatched.  If the patch is being enabled, then the task hasn't been
+patched yet.  If the patch is being disabled, then the task has already
+been unpatched.
+
+A value of '1' indicates that a patch is in transition and the task is
+patched.  If the patch is being enabled, then the task has already been
+patched.  If the patch is being disabled, then the task hasn't been
+unpatched yet.
+
 
 --
 Configuring procfs
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 2868cdf..c485450 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2801,6 +2801,15 @@ static int proc_pid_personality(struct seq_file *m, 
struct pid_namespace *ns,
return err;
 }
 
+#ifdef CONFIG_LIVEPATCH
+static int proc_pid_patch_state(struct seq_file *m, struct pid_namespace *ns,
+   struct pid *pid, struct task_struct *task)
+{
+   seq_printf(m, "%d\n", task->patch_state);
+   return 0;
+}
+#endif /* CONFIG_LIVEPATCH */
+
 /*
  * Thread groups
  */
@@ -2900,6 +2909,9 @@ static const struct pid_entry tgid_base_stuff[] = {
REG("timers", S_IRUGO, proc_timers_operations),
 #endif
REG("timerslack_ns", S_IRUGO|S_IWUGO, 
proc_pid_set_timerslack_ns_operations),
+#ifdef CONFIG_LIVEPATCH
+   ONE("patch_state",  S_IRUSR, proc_pid_patch_state),
+#endif
 };
 
 static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
@@ -3282,6 +3294,9 @@ static const struct pid_entry tid_base_stuff[] = {
REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
REG("setgroups",  S_IRUGO|S_IWUSR, proc_setgroups_operations),
 #endif
+#ifdef CONFIG_LIVEPATCH
+   ONE("patch_state",  S_IRUSR, proc_pid_patch_state),
+#endif
 };
 
 static int proc_tid_base_readdir(struct file *file, struct dir_context *ctx)
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 17/18] livepatch: change to a per-task consistency model

2016-04-28 Thread Josh Poimboeuf
Change livepatch to use a basic per-task consistency model.  This is the
foundation which will eventually enable us to patch those ~10% of
security patches which change function or data semantics.  This is the
biggest remaining piece needed to make livepatch more generally useful.

This code stems from the design proposal made by Vojtech [1] in November
2014.  It's a hybrid of kGraft and kpatch: it uses kGraft's per-task
consistency and syscall barrier switching combined with kpatch's stack
trace switching.  There are also a number of fallback options which make
it quite flexible.

Patches are applied on a per-task basis, when the task is deemed safe to
switch over.  When a patch is enabled, livepatch enters into a
transition state where tasks are converging to the patched state.
Usually this transition state can complete in a few seconds.  The same
sequence occurs when a patch is disabled, except the tasks converge from
the patched state to the unpatched state.

An interrupt handler inherits the patched state of the task it
interrupts.  The same is true for forked tasks: the child inherits the
patched state of the parent.

Livepatch uses several complementary approaches to determine when it's
safe to patch tasks:

1. The first and most effective approach is stack checking of sleeping
   tasks.  If no affected functions are on the stack of a given task,
   the task is patched.  In most cases this will patch most or all of
   the tasks on the first try.  Otherwise it'll keep trying
   periodically.  This option is only available if the architecture has
   reliable stacks (CONFIG_RELIABLE_STACKTRACE and
   CONFIG_STACK_VALIDATION).

2. The second approach, if needed, is kernel exit switching.  A
   task is switched when it returns to user space from a system call, a
   user space IRQ, or a signal.  It's useful in the following cases:

   a) Patching I/O-bound user tasks which are sleeping on an affected
  function.  In this case you have to send SIGSTOP and SIGCONT to
  force it to exit the kernel and be patched.
   b) Patching CPU-bound user tasks.  If the task is highly CPU-bound
  then it will get patched the next time it gets interrupted by an
  IRQ.
   c) Applying patches for architectures which don't yet have
  CONFIG_RELIABLE_STACKTRACE.  In this case you'll have to signal
  most of the tasks on the system.  However this isn't a complete
  solution, because there's currently no way to patch kthreads
  without CONFIG_RELIABLE_STACKTRACE.

   Note: since idle "swapper" tasks don't ever exit the kernel, they
   instead have a kpatch_patch_task() call in the idle loop which allows
   them to patched before the CPU enters the idle state.

3. A third approach (not yet implemented) is planned for the case where
   a kthread is sleeping on an affected function.  In that case we could
   kick the kthread with a signal and then try to patch the task from
   the to-be-patched function's livepatch ftrace handler when it
   re-enters the function.  This will require
   CONFIG_RELIABLE_STACKTRACE.

All the above approaches may be skipped by setting the 'immediate' flag
in the 'klp_patch' struct, which will patch all tasks immediately.  This
can be useful if the patch doesn't change any function or data
semantics.  Note that, even with this flag set, it's possible that some
tasks may still be running with an old version of the function, until
that function returns.

There's also an 'immediate' flag in the 'klp_func' struct which allows
you to specify that certain functions in the patch can be applied
without per-task consistency.  This might be useful if you want to patch
a common function like schedule(), and the function change doesn't need
consistency but the rest of the patch does.

For architectures which don't have CONFIG_RELIABLE_STACKTRACE, there
are two options:

a) the user can set the patch->immediate flag which causes all tasks to
   be patched immediately.  This option should be used with care, only
   when the patch doesn't change any function or data semantics; or

b) use the kernel exit switching approach (this is the default).
   Note the patching will never complete because there's no currently no
   way to patch kthreads without CONFIG_RELIABLE_STACKTRACE.

The /sys/kernel/livepatch//transition file shows whether a patch
is in transition.  Only a single patch (the topmost patch on the stack)
can be in transition at a given time.  A patch can remain in transition
indefinitely, if any of the tasks are stuck in the initial patch state.

A transition can be reversed and effectively canceled by writing the
opposite value to the /sys/kernel/livepatch//enabled file while
the transition is in progress.  Then all the tasks will attempt to
converge back to the original patch state.

[1] https://lkml.kernel.org/r/20141107140458.ga21...@suse.cz

Signed-off-by: Josh Poimboeuf 
---
 Documentation/ABI/testing/sysfs-kernel-livepatch |   8 +
 Documentation/livepatch/livepatch.txt   

[RFC PATCH v2 16/18] livepatch: store function sizes

2016-04-28 Thread Josh Poimboeuf
For the consistency model we'll need to know the sizes of the old and
new functions to determine if they're on the stacks of any tasks.

Signed-off-by: Josh Poimboeuf 
---
 include/linux/livepatch.h |  3 +++
 kernel/livepatch/core.c   | 16 
 2 files changed, 19 insertions(+)

diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 9ba26c5..c38c694 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -37,6 +37,8 @@
  * @old_addr:  the address of the function being patched
  * @kobj:  kobject for sysfs resources
  * @stack_node:list node for klp_ops func_stack list
+ * @old_size:  size of the old function
+ * @new_size:  size of the new function
  * @patched:   the func has been added to the klp_ops list
  */
 struct klp_func {
@@ -56,6 +58,7 @@ struct klp_func {
unsigned long old_addr;
struct kobject kobj;
struct list_head stack_node;
+   unsigned long old_size, new_size;
bool patched;
 };
 
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index f28504d..aa3dbdf 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -577,6 +577,22 @@ static int klp_init_object_loaded(struct klp_patch *patch,
 &func->old_addr);
if (ret)
return ret;
+
+   ret = kallsyms_lookup_size_offset(func->old_addr,
+ &func->old_size, NULL);
+   if (!ret) {
+   pr_err("kallsyms size lookup failed for '%s'\n",
+  func->old_name);
+   return -ENOENT;
+   }
+
+   ret = kallsyms_lookup_size_offset((unsigned long)func->new_func,
+ &func->new_size, NULL);
+   if (!ret) {
+   pr_err("kallsyms size lookup failed for '%s' 
replacement\n",
+  func->old_name);
+   return -ENOENT;
+   }
}
 
return 0;
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 15/18] livepatch: move patching functions into patch.c

2016-04-28 Thread Josh Poimboeuf
Move functions related to the actual patching of functions and objects
into a new patch.c file.

Signed-off-by: Josh Poimboeuf 
---
 kernel/livepatch/Makefile |   2 +-
 kernel/livepatch/core.c   | 202 +--
 kernel/livepatch/patch.c  | 213 ++
 kernel/livepatch/patch.h  |  32 +++
 4 files changed, 247 insertions(+), 202 deletions(-)
 create mode 100644 kernel/livepatch/patch.c
 create mode 100644 kernel/livepatch/patch.h

diff --git a/kernel/livepatch/Makefile b/kernel/livepatch/Makefile
index e8780c0..e136dad 100644
--- a/kernel/livepatch/Makefile
+++ b/kernel/livepatch/Makefile
@@ -1,3 +1,3 @@
 obj-$(CONFIG_LIVEPATCH) += livepatch.o
 
-livepatch-objs := core.o
+livepatch-objs := core.o patch.o
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 2ad7892..f28504d 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -24,32 +24,13 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-
-/**
- * struct klp_ops - structure for tracking registered ftrace ops structs
- *
- * A single ftrace_ops is shared between all enabled replacement functions
- * (klp_func structs) which have the same old_addr.  This allows the switch
- * between function versions to happen instantaneously by updating the klp_ops
- * struct's func_stack list.  The winner is the klp_func at the top of the
- * func_stack (front of the list).
- *
- * @node:  node for the global klp_ops list
- * @func_stack:list head for the stack of klp_func's (active func is 
on top)
- * @fops:  registered ftrace ops struct
- */
-struct klp_ops {
-   struct list_head node;
-   struct list_head func_stack;
-   struct ftrace_ops fops;
-};
+#include "patch.h"
 
 /*
  * The klp_mutex protects the global lists and state transitions of any
@@ -60,28 +41,12 @@ struct klp_ops {
 static DEFINE_MUTEX(klp_mutex);
 
 static LIST_HEAD(klp_patches);
-static LIST_HEAD(klp_ops);
 
 static struct kobject *klp_root_kobj;
 
 /* TODO: temporary stub */
 void klp_patch_task(struct task_struct *task) {}
 
-static struct klp_ops *klp_find_ops(unsigned long old_addr)
-{
-   struct klp_ops *ops;
-   struct klp_func *func;
-
-   list_for_each_entry(ops, &klp_ops, node) {
-   func = list_first_entry(&ops->func_stack, struct klp_func,
-   stack_node);
-   if (func->old_addr == old_addr)
-   return ops;
-   }
-
-   return NULL;
-}
-
 static bool klp_is_module(struct klp_object *obj)
 {
return obj->name;
@@ -316,171 +281,6 @@ static int klp_write_object_relocations(struct module 
*pmod,
return ret;
 }
 
-static void notrace klp_ftrace_handler(unsigned long ip,
-  unsigned long parent_ip,
-  struct ftrace_ops *fops,
-  struct pt_regs *regs)
-{
-   struct klp_ops *ops;
-   struct klp_func *func;
-
-   ops = container_of(fops, struct klp_ops, fops);
-
-   rcu_read_lock();
-   func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
- stack_node);
-   if (WARN_ON_ONCE(!func))
-   goto unlock;
-
-   klp_arch_set_pc(regs, (unsigned long)func->new_func);
-unlock:
-   rcu_read_unlock();
-}
-
-/*
- * Convert a function address into the appropriate ftrace location.
- *
- * Usually this is just the address of the function, but on some architectures
- * it's more complicated so allow them to provide a custom behaviour.
- */
-#ifndef klp_get_ftrace_location
-static unsigned long klp_get_ftrace_location(unsigned long faddr)
-{
-   return faddr;
-}
-#endif
-
-static void klp_unpatch_func(struct klp_func *func)
-{
-   struct klp_ops *ops;
-
-   if (WARN_ON(!func->patched))
-   return;
-   if (WARN_ON(!func->old_addr))
-   return;
-
-   ops = klp_find_ops(func->old_addr);
-   if (WARN_ON(!ops))
-   return;
-
-   if (list_is_singular(&ops->func_stack)) {
-   unsigned long ftrace_loc;
-
-   ftrace_loc = klp_get_ftrace_location(func->old_addr);
-   if (WARN_ON(!ftrace_loc))
-   return;
-
-   WARN_ON(unregister_ftrace_function(&ops->fops));
-   WARN_ON(ftrace_set_filter_ip(&ops->fops, ftrace_loc, 1, 0));
-
-   list_del_rcu(&func->stack_node);
-   list_del(&ops->node);
-   kfree(ops);
-   } else {
-   list_del_rcu(&func->stack_node);
-   }
-
-   func->patched = false;
-}
-
-static int klp_patch_func(struct klp_func *func)
-{
-   struct klp_ops *ops;
-   int ret;
-
-   if (WARN_ON(!func->old_addr))
-   return -EINVAL;
-
-   if (WARN_ON(func->patched))
-   return -EI

[RFC PATCH v2 14/18] livepatch: remove unnecessary object loaded check

2016-04-28 Thread Josh Poimboeuf
klp_patch_object()'s callers already ensure that the object is loaded,
so its call to klp_is_object_loaded() is unnecessary.

This will also make it possible to move the patching code into a
separate file.

Signed-off-by: Josh Poimboeuf 
---
 kernel/livepatch/core.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 2b59230..2ad7892 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -469,9 +469,6 @@ static int klp_patch_object(struct klp_object *obj)
if (WARN_ON(obj->patched))
return -EINVAL;
 
-   if (WARN_ON(!klp_is_object_loaded(obj)))
-   return -EINVAL;
-
klp_for_each_func(obj, func) {
ret = klp_patch_func(func);
if (ret) {
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 13/18] livepatch: separate enabled and patched states

2016-04-28 Thread Josh Poimboeuf
Once we have a consistency model, patches and their objects will be
enabled and disabled at different times.  For example, when a patch is
disabled, its loaded objects' funcs can remain registered with ftrace
indefinitely until the unpatching operation is complete and they're no
longer in use.

It's less confusing if we give them different names: patches can be
enabled or disabled; objects (and their funcs) can be patched or
unpatched:

- Enabled means that a patch is logically enabled (but not necessarily
  fully applied).

- Patched means that an object's funcs are registered with ftrace and
  added to the klp_ops func stack.

Also, since these states are binary, represent them with booleans
instead of ints.

Signed-off-by: Josh Poimboeuf 
---
 include/linux/livepatch.h | 17 ---
 kernel/livepatch/core.c   | 72 +++
 2 files changed, 42 insertions(+), 47 deletions(-)

diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index a8c6c9c..9ba26c5 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -28,11 +28,6 @@
 
 #include 
 
-enum klp_state {
-   KLP_DISABLED,
-   KLP_ENABLED
-};
-
 /**
  * struct klp_func - function structure for live patching
  * @old_name:  name of the function to be patched
@@ -41,8 +36,8 @@ enum klp_state {
  * can be found (optional)
  * @old_addr:  the address of the function being patched
  * @kobj:  kobject for sysfs resources
- * @state: tracks function-level patch application state
  * @stack_node:list node for klp_ops func_stack list
+ * @patched:   the func has been added to the klp_ops list
  */
 struct klp_func {
/* external */
@@ -60,8 +55,8 @@ struct klp_func {
/* internal */
unsigned long old_addr;
struct kobject kobj;
-   enum klp_state state;
struct list_head stack_node;
+   bool patched;
 };
 
 /**
@@ -71,7 +66,7 @@ struct klp_func {
  * @kobj:  kobject for sysfs resources
  * @mod:   kernel module associated with the patched object
  * (NULL for vmlinux)
- * @state: tracks object-level patch application state
+ * @patched:   the object's funcs have been added to the klp_ops list
  */
 struct klp_object {
/* external */
@@ -81,7 +76,7 @@ struct klp_object {
/* internal */
struct kobject kobj;
struct module *mod;
-   enum klp_state state;
+   bool patched;
 };
 
 /**
@@ -90,7 +85,7 @@ struct klp_object {
  * @objs:  object entries for kernel objects to be patched
  * @list:  list node for global list of registered patches
  * @kobj:  kobject for sysfs resources
- * @state: tracks patch-level application state
+ * @enabled:   the patch is enabled (but operation may be incomplete)
  */
 struct klp_patch {
/* external */
@@ -100,7 +95,7 @@ struct klp_patch {
/* internal */
struct list_head list;
struct kobject kobj;
-   enum klp_state state;
+   bool enabled;
 };
 
 #define klp_for_each_object(patch, obj) \
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 6ea6880..2b59230 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -350,11 +350,11 @@ static unsigned long klp_get_ftrace_location(unsigned 
long faddr)
 }
 #endif
 
-static void klp_disable_func(struct klp_func *func)
+static void klp_unpatch_func(struct klp_func *func)
 {
struct klp_ops *ops;
 
-   if (WARN_ON(func->state != KLP_ENABLED))
+   if (WARN_ON(!func->patched))
return;
if (WARN_ON(!func->old_addr))
return;
@@ -380,10 +380,10 @@ static void klp_disable_func(struct klp_func *func)
list_del_rcu(&func->stack_node);
}
 
-   func->state = KLP_DISABLED;
+   func->patched = false;
 }
 
-static int klp_enable_func(struct klp_func *func)
+static int klp_patch_func(struct klp_func *func)
 {
struct klp_ops *ops;
int ret;
@@ -391,7 +391,7 @@ static int klp_enable_func(struct klp_func *func)
if (WARN_ON(!func->old_addr))
return -EINVAL;
 
-   if (WARN_ON(func->state != KLP_DISABLED))
+   if (WARN_ON(func->patched))
return -EINVAL;
 
ops = klp_find_ops(func->old_addr);
@@ -439,7 +439,7 @@ static int klp_enable_func(struct klp_func *func)
list_add_rcu(&func->stack_node, &ops->func_stack);
}
 
-   func->state = KLP_ENABLED;
+   func->patched = true;
 
return 0;
 
@@ -450,36 +450,36 @@ err:
return ret;
 }
 
-static void klp_disable_object(struct klp_object *obj)
+static void klp_unpatch_object(struct klp_object *obj)
 {
struct klp_func *func;
 
klp_for_each_func(obj, func)
-   if (func->state == KLP_ENABLED)
-   klp_disable_func(func);
+   if (func->patched)
+   klp_unpatch_func(func);
 
-   obj->state = KLP_DISABLED

[RFC PATCH v2 12/18] livepatch/s390: add TIF_PATCH_PENDING thread flag

2016-04-28 Thread Josh Poimboeuf
From: Miroslav Benes 

Update a task's patch state when returning from a system call or user
space interrupt, or after handling a signal.

This greatly increases the chances of a patch operation succeeding.  If
a task is I/O bound, it can be patched when returning from a system
call.  If a task is CPU bound, it can be patched when returning from an
interrupt.  If a task is sleeping on a to-be-patched function, the user
can send SIGSTOP and SIGCONT to force it to switch.

Since there are two ways the syscall can be restarted on return from a
signal handling process, it is important to clear the flag before
do_signal() is called. Otherwise we could miss the migration if we used
SIGSTOP/SIGCONT procedure or fake signal to migrate patching blocking
tasks. If we place our hook to sysc_work label in entry before
TIF_SIGPENDING is evaluated we kill two birds with one stone. The task
is correctly migrated in all return paths from a syscall.

Signed-off-by: Miroslav Benes 
Signed-off-by: Josh Poimboeuf 
---
 arch/s390/include/asm/thread_info.h |  2 ++
 arch/s390/kernel/entry.S| 31 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/s390/include/asm/thread_info.h 
b/arch/s390/include/asm/thread_info.h
index 8642c1d..b69d538 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -75,6 +75,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define TIF_SIGPENDING 1   /* signal pending */
 #define TIF_NEED_RESCHED   2   /* rescheduling necessary */
 #define TIF_UPROBE 3   /* breakpointed or single-stepping */
+#define TIF_PATCH_PENDING  4   /* pending live patching update */
 
 #define TIF_31BIT  16  /* 32bit process */
 #define TIF_MEMDIE 17  /* is terminating due to OOM killer */
@@ -93,6 +94,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define _TIF_SIGPENDING_BITUL(TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED  _BITUL(TIF_NEED_RESCHED)
 #define _TIF_UPROBE_BITUL(TIF_UPROBE)
+#define _TIF_PATCH_PENDING _BITUL(TIF_PATCH_PENDING)
 
 #define _TIF_31BIT _BITUL(TIF_31BIT)
 #define _TIF_SINGLE_STEP   _BITUL(TIF_SINGLE_STEP)
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 2d47f9c..5db5959 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -46,7 +46,7 @@ STACK_SIZE  = 1 << STACK_SHIFT
 STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
 
 _TIF_WORK  = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
-  _TIF_UPROBE)
+  _TIF_UPROBE | _TIF_PATCH_PENDING)
 _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
   _TIF_SYSCALL_TRACEPOINT)
 _CIF_WORK  = (_CIF_MCCK_PENDING | _CIF_ASCE | _CIF_FPU)
@@ -329,6 +329,11 @@ ENTRY(system_call)
 #endif
TSTMSK  __PT_FLAGS(%r11),_PIF_PER_TRAP
jo  .Lsysc_singlestep
+#ifdef CONFIG_LIVEPATCH
+   TSTMSK  __TI_flags(%r12),_TIF_PATCH_PENDING
+   jo  .Lsysc_patch_pending# handle live patching just before
+   # signals and possible syscall restart
+#endif
TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
jo  .Lsysc_sigpending
TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
@@ -404,6 +409,16 @@ ENTRY(system_call)
 #endif
 
 #
+# _TIF_PATCH_PENDING is set, call klp_patch_task
+#
+#ifdef CONFIG_LIVEPATCH
+.Lsysc_patch_pending:
+   lg  %r2,__TI_task(%r12)
+   larl%r14,.Lsysc_return
+   jg  klp_patch_task
+#endif
+
+#
 # _PIF_PER_TRAP is set, call do_per_trap
 #
 .Lsysc_singlestep:
@@ -652,6 +667,10 @@ ENTRY(io_int_handler)
jo  .Lio_mcck_pending
TSTMSK  __TI_flags(%r12),_TIF_NEED_RESCHED
jo  .Lio_reschedule
+#ifdef CONFIG_LIVEPATCH
+   TSTMSK  __TI_flags(%r12),_TIF_PATCH_PENDING
+   jo  .Lio_patch_pending
+#endif
TSTMSK  __TI_flags(%r12),_TIF_SIGPENDING
jo  .Lio_sigpending
TSTMSK  __TI_flags(%r12),_TIF_NOTIFY_RESUME
@@ -698,6 +717,16 @@ ENTRY(io_int_handler)
j   .Lio_return
 
 #
+# _TIF_PATCH_PENDING is set, call klp_patch_task
+#
+#ifdef CONFIG_LIVEPATCH
+.Lio_patch_pending:
+   lg  %r2,__TI_task(%r12)
+   larl%r14,.Lio_return
+   jg  klp_patch_task
+#endif
+
+#
 # _TIF_SIGPENDING or is set, call do_signal
 #
 .Lio_sigpending:
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 11/18] livepatch/s390: reorganize TIF thread flag bits

2016-04-28 Thread Josh Poimboeuf
From: Jiri Slaby 

Group the TIF thread flag bits by their inclusion in the _TIF_WORK and
_TIF_TRACE macros.

Signed-off-by: Jiri Slaby 
Signed-off-by: Josh Poimboeuf 
---
 arch/s390/include/asm/thread_info.h | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/thread_info.h 
b/arch/s390/include/asm/thread_info.h
index 2fffc2c..8642c1d 100644
--- a/arch/s390/include/asm/thread_info.h
+++ b/arch/s390/include/asm/thread_info.h
@@ -70,14 +70,12 @@ void arch_release_task_struct(struct task_struct *tsk);
 /*
  * thread information flags bit numbers
  */
+/* _TIF_WORK bits */
 #define TIF_NOTIFY_RESUME  0   /* callback before returning to user */
 #define TIF_SIGPENDING 1   /* signal pending */
 #define TIF_NEED_RESCHED   2   /* rescheduling necessary */
-#define TIF_SYSCALL_TRACE  3   /* syscall trace active */
-#define TIF_SYSCALL_AUDIT  4   /* syscall auditing active */
-#define TIF_SECCOMP5   /* secure computing */
-#define TIF_SYSCALL_TRACEPOINT 6   /* syscall tracepoint instrumentation */
-#define TIF_UPROBE 7   /* breakpointed or single-stepping */
+#define TIF_UPROBE 3   /* breakpointed or single-stepping */
+
 #define TIF_31BIT  16  /* 32bit process */
 #define TIF_MEMDIE 17  /* is terminating due to OOM killer */
 #define TIF_RESTORE_SIGMASK18  /* restore signal mask in do_signal() */
@@ -85,15 +83,23 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define TIF_BLOCK_STEP 20  /* This task is block stepped */
 #define TIF_UPROBE_SINGLESTEP  21  /* This task is uprobe single stepped */
 
+/* _TIF_TRACE bits */
+#define TIF_SYSCALL_TRACE  24  /* syscall trace active */
+#define TIF_SYSCALL_AUDIT  25  /* syscall auditing active */
+#define TIF_SECCOMP26  /* secure computing */
+#define TIF_SYSCALL_TRACEPOINT 27  /* syscall tracepoint instrumentation */
+
 #define _TIF_NOTIFY_RESUME _BITUL(TIF_NOTIFY_RESUME)
 #define _TIF_SIGPENDING_BITUL(TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED  _BITUL(TIF_NEED_RESCHED)
+#define _TIF_UPROBE_BITUL(TIF_UPROBE)
+
+#define _TIF_31BIT _BITUL(TIF_31BIT)
+#define _TIF_SINGLE_STEP   _BITUL(TIF_SINGLE_STEP)
+
 #define _TIF_SYSCALL_TRACE _BITUL(TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT _BITUL(TIF_SYSCALL_AUDIT)
 #define _TIF_SECCOMP   _BITUL(TIF_SECCOMP)
 #define _TIF_SYSCALL_TRACEPOINT_BITUL(TIF_SYSCALL_TRACEPOINT)
-#define _TIF_UPROBE_BITUL(TIF_UPROBE)
-#define _TIF_31BIT _BITUL(TIF_31BIT)
-#define _TIF_SINGLE_STEP   _BITUL(TIF_SINGLE_STEP)
 
 #endif /* _ASM_THREAD_INFO_H */
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 10/18] livepatch/powerpc: add TIF_PATCH_PENDING thread flag

2016-04-28 Thread Josh Poimboeuf
Add the TIF_PATCH_PENDING thread flag to enable the new livepatch
per-task consistency model for powerpc.  The bit getting set indicates
the thread has a pending patch which needs to be applied when the thread
exits the kernel.

The bit is included in the _TIF_USER_WORK_MASK macro so that
do_notify_resume() and klp_patch_task() get called when the bit is set.

Signed-off-by: Josh Poimboeuf 
---
 arch/powerpc/include/asm/thread_info.h | 4 +++-
 arch/powerpc/kernel/signal.c   | 4 
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index 8febc3f..df262ca 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -88,6 +88,7 @@ static inline struct thread_info *current_thread_info(void)
   TIF_NEED_RESCHED */
 #define TIF_32BIT  4   /* 32 bit binary */
 #define TIF_RESTORE_TM 5   /* need to restore TM FP/VEC/VSX */
+#define TIF_PATCH_PENDING  6   /* pending live patching update */
 #define TIF_SYSCALL_AUDIT  7   /* syscall auditing active */
 #define TIF_SINGLESTEP 8   /* singlestepping active */
 #define TIF_NOHZ   9   /* in adaptive nohz mode */
@@ -111,6 +112,7 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_POLLING_NRFLAG(1<
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -159,6 +160,9 @@ void do_notify_resume(struct pt_regs *regs, unsigned long 
thread_info_flags)
tracehook_notify_resume(regs);
}
 
+   if (thread_info_flags & _TIF_PATCH_PENDING)
+   klp_patch_task(current);
+
user_enter();
 }
 
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 09/18] livepatch/x86: add TIF_PATCH_PENDING thread flag

2016-04-28 Thread Josh Poimboeuf
Add the TIF_PATCH_PENDING thread flag to enable the new livepatch
per-task consistency model for x86_64.  The bit getting set indicates
the thread has a pending patch which needs to be applied when the thread
exits the kernel.

The bit is placed in the least-significant word of the thread_info flags
so that it gets automatically included in the _TIF_ALLWORK_MASK macro.
This results in exit_to_usermode_loop() and klp_patch_task() getting
called when the bit is set.

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/entry/common.c| 9 ++---
 arch/x86/include/asm/thread_info.h | 2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index ec138e5..0eaa1d9 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -202,14 +203,13 @@ long syscall_trace_enter(struct pt_regs *regs)
 
 #define EXIT_TO_USERMODE_LOOP_FLAGS\
(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE |   \
-_TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY)
+_TIF_NEED_RESCHED | _TIF_USER_RETURN_NOTIFY | _TIF_PATCH_PENDING)
 
 static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags)
 {
/*
 * In order to return to user mode, we need to have IRQs off with
-* none of _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_USER_RETURN_NOTIFY,
-* _TIF_UPROBE, or _TIF_NEED_RESCHED set.  Several of these flags
+* none of EXIT_TO_USERMODE_LOOP_FLAGS set.  Several of these flags
 * can be set at any time on preemptable kernels if we have IRQs on,
 * so we need to loop.  Disabling preemption wouldn't help: doing the
 * work to clear some of the flags can sleep.
@@ -236,6 +236,9 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 
cached_flags)
if (cached_flags & _TIF_USER_RETURN_NOTIFY)
fire_user_return_notifiers();
 
+   if (cached_flags & _TIF_PATCH_PENDING)
+   klp_patch_task(current);
+
/* Disable IRQs and retry */
local_irq_disable();
 
diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 30c133a..4e4f50e 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -97,6 +97,7 @@ struct thread_info {
 #define TIF_SECCOMP8   /* secure computing */
 #define TIF_USER_RETURN_NOTIFY 11  /* notify kernel of userspace return */
 #define TIF_UPROBE 12  /* breakpointed or singlestepping */
+#define TIF_PATCH_PENDING  13  /* pending live patching update */
 #define TIF_NOTSC  16  /* TSC is not accessible in userland */
 #define TIF_IA32   17  /* IA32 compatibility process */
 #define TIF_FORK   18  /* ret_from_fork */
@@ -121,6 +122,7 @@ struct thread_info {
 #define _TIF_SECCOMP   (1 << TIF_SECCOMP)
 #define _TIF_USER_RETURN_NOTIFY(1 << TIF_USER_RETURN_NOTIFY)
 #define _TIF_UPROBE(1 << TIF_UPROBE)
+#define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING)
 #define _TIF_NOTSC (1 << TIF_NOTSC)
 #define _TIF_IA32  (1 << TIF_IA32)
 #define _TIF_FORK  (1 << TIF_FORK)
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 08/18] livepatch: temporary stubs for klp_patch_pending() and klp_patch_task()

2016-04-28 Thread Josh Poimboeuf
Create temporary stubs for klp_patch_pending() and klp_patch_task() so
we can add TIF_PATCH_PENDING to different architectures in separate
patches without breaking build bisectability.

Signed-off-by: Josh Poimboeuf 
---
 include/linux/livepatch.h | 7 ++-
 kernel/livepatch/core.c   | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 0933ca4..a8c6c9c 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -118,10 +118,15 @@ int klp_disable_patch(struct klp_patch *);
 int klp_module_coming(struct module *mod);
 void klp_module_going(struct module *mod);
 
+static inline bool klp_patch_pending(struct task_struct *task) { return false; 
}
+void klp_patch_task(struct task_struct *task);
+
 #else /* !CONFIG_LIVEPATCH */
 
 static inline int klp_module_coming(struct module *mod) { return 0; }
-static inline void klp_module_going(struct module *mod) { }
+static inline void klp_module_going(struct module *mod) {}
+static inline bool klp_patch_pending(struct task_struct *task) { return false; 
}
+static inline void klp_patch_task(struct task_struct *task) {}
 
 #endif /* CONFIG_LIVEPATCH */
 
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index a19f195..6ea6880 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -64,6 +64,9 @@ static LIST_HEAD(klp_ops);
 
 static struct kobject *klp_root_kobj;
 
+/* TODO: temporary stub */
+void klp_patch_task(struct task_struct *task) {}
+
 static struct klp_ops *klp_find_ops(unsigned long old_addr)
 {
struct klp_ops *ops;
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 07/18] stacktrace/x86: function for detecting reliable stack traces

2016-04-28 Thread Josh Poimboeuf
For live patching and possibly other use cases, a stack trace is only
useful if it can be assured that it's completely reliable.  Add a new
save_stack_trace_tsk_reliable() function to achieve that.

Scenarios which indicate that a stack trace may be unreliable:

- running tasks
- interrupt stacks
- preemption
- corrupted stack data
- the stack grows the wrong way
- the stack walk doesn't reach the bottom
- the user didn't provide a large enough entries array

Also add a config option so arch-independent code can determine at build
time whether the function is implemented.

Signed-off-by: Josh Poimboeuf 
---
 arch/Kconfig |  6 
 arch/x86/Kconfig |  1 +
 arch/x86/kernel/dumpstack.c  | 77 
 arch/x86/kernel/stacktrace.c | 24 ++
 include/linux/kernel.h   |  1 +
 include/linux/stacktrace.h   | 20 +---
 kernel/extable.c |  2 +-
 kernel/stacktrace.c  |  4 +--
 lib/Kconfig.debug|  6 
 9 files changed, 134 insertions(+), 7 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8f84fd2..ec4d480 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -598,6 +598,12 @@ config HAVE_STACK_VALIDATION
  Architecture supports the 'objtool check' host tool command, which
  performs compile-time stack metadata validation.
 
+config HAVE_RELIABLE_STACKTRACE
+   bool
+   help
+ Architecture has a save_stack_trace_tsk_reliable() function which
+ only returns a stack trace if it can guarantee the trace is reliable.
+
 #
 # ABI hall of shame
 #
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0b128b4..78c4e00 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -140,6 +140,7 @@ config X86
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
+   select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_UID16   if X86_32 || IA32_EMULATION
select HAVE_UNSTABLE_SCHED_CLOCK
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 13d240c..70d0013 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -145,6 +145,83 @@ int print_context_stack_bp(struct thread_info *tinfo,
 }
 EXPORT_SYMBOL_GPL(print_context_stack_bp);
 
+#ifdef CONFIG_RELIABLE_STACKTRACE
+/*
+ * Only succeeds if the stack trace is deemed reliable.  This relies on the
+ * fact that frame pointers are reliable thanks to CONFIG_STACK_VALIDATION.
+ *
+ * The caller must ensure that the task is either sleeping or is the current
+ * task.
+ */
+int print_context_stack_reliable(struct thread_info *tinfo,
+unsigned long *stack, unsigned long *bp,
+const struct stacktrace_ops *ops,
+void *data, unsigned long *end, int *graph)
+{
+   struct stack_frame *frame = (struct stack_frame *)*bp;
+   struct stack_frame *last_frame = NULL;
+   unsigned long *ret_addr = &frame->return_address;
+
+   /*
+* If the kernel was preempted by an IRQ, we can't trust the stack
+* because the preempted function might not have gotten the chance to
+* save the frame pointer on the stack before it was interrupted.
+*/
+   if (tinfo->task->flags & PF_PREEMPT_IRQ)
+   return -EINVAL;
+
+   /*
+* A freshly forked task has an empty stack trace.  We can consider
+* that to be reliable.
+*/
+   if (test_ti_thread_flag(tinfo, TIF_FORK))
+   return 0;
+
+   while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
+   unsigned long addr = *ret_addr;
+
+   /*
+* Make sure the stack only grows down.
+*/
+   if (frame <= last_frame)
+   return -EINVAL;
+
+   /*
+* Make sure the frame refers to a valid kernel function.
+*/
+   if (!core_kernel_text(addr) && !init_kernel_text(addr) &&
+   !is_module_text_address(addr))
+   return -EINVAL;
+
+   /*
+* Save the kernel text address and make sure the entries array
+* isn't full.
+*/
+   if (ops->address(data, addr, 1))
+   return -EINVAL;
+
+   /*
+* If the function graph tracer is in effect, save the real
+* function address.
+*/
+   print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
+
+   last_frame = frame;
+   frame = frame->next_frame;
+   ret_addr = &frame->return_address;
+   }
+
+   /*
+* Make sure we reached the bottom of the stack.
+*/
+   if (last_frame + 1 

[RFC PATCH v2 06/18] x86: dump_trace() error handling

2016-04-28 Thread Josh Poimboeuf
In preparation for being able to determine whether a given stack trace
is reliable, allow the stacktrace_ops functions to propagate errors to
dump_trace().

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/include/asm/stacktrace.h | 36 +++---
 arch/x86/kernel/dumpstack.c   | 31 +++
 arch/x86/kernel/dumpstack_32.c| 22 ++--
 arch/x86/kernel/dumpstack_64.c| 53 ++-
 4 files changed, 87 insertions(+), 55 deletions(-)

diff --git a/arch/x86/include/asm/stacktrace.h 
b/arch/x86/include/asm/stacktrace.h
index 7c247e7..a64523f3 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -14,26 +14,32 @@ extern int kstack_depth_to_print;
 struct thread_info;
 struct stacktrace_ops;
 
-typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
- unsigned long *stack,
- unsigned long bp,
- const struct stacktrace_ops *ops,
- void *data,
- unsigned long *end,
- int *graph);
-
-extern unsigned long
+typedef int (*walk_stack_t)(struct thread_info *tinfo,
+   unsigned long *stack,
+   unsigned long *bp,
+   const struct stacktrace_ops *ops,
+   void *data,
+   unsigned long *end,
+   int *graph);
+
+extern int
 print_context_stack(struct thread_info *tinfo,
-   unsigned long *stack, unsigned long bp,
+   unsigned long *stack, unsigned long *bp,
const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph);
 
-extern unsigned long
+extern int
 print_context_stack_bp(struct thread_info *tinfo,
-  unsigned long *stack, unsigned long bp,
+  unsigned long *stack, unsigned long *bp,
   const struct stacktrace_ops *ops, void *data,
   unsigned long *end, int *graph);
 
+extern int
+print_context_stack_reliable(struct thread_info *tinfo,
+unsigned long *stack, unsigned long *bp,
+const struct stacktrace_ops *ops, void *data,
+unsigned long *end, int *graph);
+
 /* Generic stack tracer with callbacks */
 
 struct stacktrace_ops {
@@ -43,9 +49,9 @@ struct stacktrace_ops {
walk_stack_twalk_stack;
 };
 
-void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
-   unsigned long *stack, unsigned long bp,
-   const struct stacktrace_ops *ops, void *data);
+int dump_trace(struct task_struct *tsk, struct pt_regs *regs,
+  unsigned long *stack, unsigned long bp,
+  const struct stacktrace_ops *ops, void *data);
 
 #ifdef CONFIG_X86_32
 #define STACKSLOTS_PER_LINE 8
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 2bb25c3..13d240c 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -92,23 +92,22 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
return p > t && p < t + THREAD_SIZE - size;
 }
 
-unsigned long
-print_context_stack(struct thread_info *tinfo,
-   unsigned long *stack, unsigned long bp,
-   const struct stacktrace_ops *ops, void *data,
-   unsigned long *end, int *graph)
+int print_context_stack(struct thread_info *tinfo,
+   unsigned long *stack, unsigned long *bp,
+   const struct stacktrace_ops *ops, void *data,
+   unsigned long *end, int *graph)
 {
-   struct stack_frame *frame = (struct stack_frame *)bp;
+   struct stack_frame *frame = (struct stack_frame *)*bp;
 
while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
unsigned long addr;
 
addr = *stack;
if (__kernel_text_address(addr)) {
-   if ((unsigned long) stack == bp + sizeof(long)) {
+   if ((unsigned long) stack == *bp + sizeof(long)) {
ops->address(data, addr, 1);
frame = frame->next_frame;
-   bp = (unsigned long) frame;
+   *bp = (unsigned long) frame;
} else {
ops->address(data, addr, 0);
}
@@ -116,17 +115,16 @@ print_context_stack(struct thread_info *tinfo,
}
stack++;
}
-   return bp;
+   return 0;
 }
 EXPORT_SYMBOL_GPL(print_context_stack);
 
-unsigned long
-print_context_stack_bp(struct thread_info *tinfo,
-  unsigned long 

[RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking

2016-04-28 Thread Josh Poimboeuf
A preempted function might not have had a chance to save the frame
pointer to the stack yet, which can result in its caller getting skipped
on a stack trace.

Add a flag to indicate when the task has been preempted so that stack
dump code can determine whether the stack trace is reliable.

Signed-off-by: Josh Poimboeuf 
---
 include/linux/sched.h | 1 +
 kernel/fork.c | 2 +-
 kernel/sched/core.c   | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3d31572..fb364a0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2137,6 +2137,7 @@ extern void thread_group_cputime_adjusted(struct 
task_struct *p, cputime_t *ut,
 #define PF_SWAPWRITE   0x0080  /* Allowed to write to swap */
 #define PF_NO_SETAFFINITY 0x0400   /* Userland is not allowed to meddle 
with cpus_allowed */
 #define PF_MCE_EARLY0x0800  /* Early kill for mce process policy */
+#define PF_PREEMPT_IRQ 0x1000  /* Thread is preempted by an irq */
 #define PF_MUTEX_TESTER0x2000  /* Thread belongs to the rt 
mutex tester */
 #define PF_FREEZER_SKIP0x4000  /* Freezer should not count it 
as freezable */
 #define PF_SUSPEND_TASK 0x8000  /* this thread called freeze_processes 
and should not be frozen */
diff --git a/kernel/fork.c b/kernel/fork.c
index b73a539..d2fe04a 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1373,7 +1373,7 @@ static struct task_struct *copy_process(unsigned long 
clone_flags,
goto bad_fork_cleanup_count;
 
delayacct_tsk_init(p);  /* Must remain after dup_task_struct() */
-   p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER);
+   p->flags &= ~(PF_SUPERPRIV | PF_WQ_WORKER | PF_PREEMPT_IRQ);
p->flags |= PF_FORKNOEXEC;
INIT_LIST_HEAD(&p->children);
INIT_LIST_HEAD(&p->sibling);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9d84d60..7594267 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3422,6 +3422,8 @@ asmlinkage __visible void __sched 
preempt_schedule_irq(void)
 
prev_state = exception_enter();
 
+   current->flags |= PF_PREEMPT_IRQ;
+
do {
preempt_disable();
local_irq_enable();
@@ -3430,6 +3432,8 @@ asmlinkage __visible void __sched 
preempt_schedule_irq(void)
sched_preempt_enable_no_resched();
} while (need_resched());
 
+   current->flags &= ~PF_PREEMPT_IRQ;
+
exception_exit(prev_state);
 }
 
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 04/18] x86: move _stext marker before head code

2016-04-28 Thread Josh Poimboeuf
When core_kernel_text() is used to determine whether an address on a
task's stack trace is a kernel text address, it incorrectly returns
false for early text addresses for the head code between the _text and
_stext markers.

Head code is text code too, so mark it as such.  This seems to match the
intent of other users of the _stext symbol, and it also seems consistent
with what other architectures are already doing.

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 4c941f8..79e15ef 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -91,10 +91,10 @@ SECTIONS
/* Text and read-only data */
.text :  AT(ADDR(.text) - LOAD_OFFSET) {
_text = .;
+   _stext = .;
/* bootstrapping code */
HEAD_TEXT
. = ALIGN(8);
-   _stext = .;
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 03/18] x86/asm/head: standardize the bottom of the stack for idle tasks

2016-04-28 Thread Josh Poimboeuf
Thanks to all the recent x86 entry code refactoring, most tasks' kernel
stacks start at the same offset right above their saved pt_regs,
regardless of which syscall was used to enter the kernel.  That creates
a nice convention which makes it straightforward to identify the
"bottom" of the stack, which can be useful for stack walking code which
needs to verify the stack is sane.

However there are still a few types of tasks which don't yet follow that
convention:

1) CPU idle tasks, aka the "swapper" tasks

2) freshly forked TIF_FORK tasks which don't have a stack at all

Make the idle tasks conform to the new stack bottom convention by
starting their stack at a sizeof(pt_regs) offset from the end of the
stack page.

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/kernel/head_64.S | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 6dbd2c0..0b12311 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -296,8 +296,9 @@ ENTRY(start_cpu)
 *  REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
 *  address given in m16:64.
 */
-   movqinitial_code(%rip),%rax
-   pushq   $0  # fake return address to stop unwinder
+   call1f  # put return address on stack for unwinder
+1: xorq%rbp, %rbp  # clear frame pointer
+   movqinitial_code(%rip), %rax
pushq   $__KERNEL_CS# set correct cs
pushq   %rax# target address in negative space
lretq
@@ -325,7 +326,7 @@ ENDPROC(start_cpu0)
GLOBAL(initial_gs)
.quad   INIT_PER_CPU_VAR(irq_stack_union)
GLOBAL(initial_stack)
-   .quad  init_thread_union+THREAD_SIZE-8
+   .quad  init_thread_union + THREAD_SIZE - SIZEOF_PTREGS
__FINITDATA
 
 bad_address:
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 02/18] x86/asm/head: use a common function for starting CPUs

2016-04-28 Thread Josh Poimboeuf
There are two different pieces of code for starting a CPU: start_cpu0()
and the end of secondary_startup_64().  They're identical except for the
stack setup.  Combine the common parts into a shared start_cpu()
function.

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/kernel/head_64.S | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 792c3bb..6dbd2c0 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -264,13 +264,15 @@ ENTRY(secondary_startup_64)
movl$MSR_GS_BASE,%ecx
movlinitial_gs(%rip),%eax
movlinitial_gs+4(%rip),%edx
-   wrmsr   
+   wrmsr
 
/* rsi is pointer to real mode structure with interesting info.
   pass it to C */
movq%rsi, %rdi
-   
-   /* Finally jump to run C code and to be on real kernel address
+
+ENTRY(start_cpu)
+   /*
+* Jump to run C code and to be on a real kernel address.
 * Since we are running on identity-mapped space we have to jump
 * to the full 64bit address, this is only possible as indirect
 * jump.  In addition we need to ensure %cs is set so we make this
@@ -299,6 +301,7 @@ ENTRY(secondary_startup_64)
pushq   $__KERNEL_CS# set correct cs
pushq   %rax# target address in negative space
lretq
+ENDPROC(start_cpu)
 
 #include "verify_cpu.S"
 
@@ -306,15 +309,11 @@ ENTRY(secondary_startup_64)
 /*
  * Boot CPU0 entry point. It's called from play_dead(). Everything has been set
  * up already except stack. We just set up stack here. Then call
- * start_secondary().
+ * start_secondary() via start_cpu().
  */
 ENTRY(start_cpu0)
-   movq initial_stack(%rip),%rsp
-   movqinitial_code(%rip),%rax
-   pushq   $0  # fake return address to stop unwinder
-   pushq   $__KERNEL_CS# set correct cs
-   pushq   %rax# target address in negative space
-   lretq
+   movqinitial_stack(%rip), %rsp
+   jmp start_cpu
 ENDPROC(start_cpu0)
 #endif
 
-- 
2.4.11

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC PATCH v2 01/18] x86/asm/head: clean up initial stack variable

2016-04-28 Thread Josh Poimboeuf
The stack_start variable is similar in usage to initial_code and
initial_gs: they're all stored in head_64.S and they're all updated by
SMP and suspend/resume before starting a CPU.

Rename stack_start to initial_stack to be more consistent with the
others.

Also do a few other related cleanups:

- Remove the unused init_rsp variable declaration.

- Remove the ".word 0" statement after the initial_stack definition
  because it has no apparent function.

Signed-off-by: Josh Poimboeuf 
---
 arch/x86/include/asm/realmode.h |  2 +-
 arch/x86/include/asm/smp.h  |  3 ---
 arch/x86/kernel/acpi/sleep.c|  2 +-
 arch/x86/kernel/head_32.S   |  8 
 arch/x86/kernel/head_64.S   | 10 --
 arch/x86/kernel/smpboot.c   |  2 +-
 6 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
index 9c6b890..677a671 100644
--- a/arch/x86/include/asm/realmode.h
+++ b/arch/x86/include/asm/realmode.h
@@ -44,9 +44,9 @@ struct trampoline_header {
 extern struct real_mode_header *real_mode_header;
 extern unsigned char real_mode_blob_end[];
 
-extern unsigned long init_rsp;
 extern unsigned long initial_code;
 extern unsigned long initial_gs;
+extern unsigned long initial_stack;
 
 extern unsigned char real_mode_blob[];
 extern unsigned char real_mode_relocs[];
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 66b0573..a9ac31b 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -38,9 +38,6 @@ DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid);
 DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid);
 #endif
 
-/* Static state in head.S used to set up a CPU */
-extern unsigned long stack_start; /* Initial stack pointer address */
-
 struct task_struct;
 
 struct smp_ops {
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index adb3eaf..4858733 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -99,7 +99,7 @@ int x86_acpi_suspend_lowlevel(void)
saved_magic = 0x12345678;
 #else /* CONFIG_64BIT */
 #ifdef CONFIG_SMP
-   stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
+   initial_stack = (unsigned long)temp_stack + sizeof(temp_stack);
early_gdt_descr.address =
(unsigned long)get_cpu_gdt_table(smp_processor_id());
initial_gs = per_cpu_offset(smp_processor_id());
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 6770865..da840be 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -94,7 +94,7 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
  */
 __HEAD
 ENTRY(startup_32)
-   movl pa(stack_start),%ecx
+   movl pa(initial_stack),%ecx

/* test KEEP_SEGMENTS flag to see if the bootloader is asking
us to not reload segments */
@@ -286,7 +286,7 @@ num_subarch_entries = (. - subarch_entries) / 4
  * start_secondary().
  */
 ENTRY(start_cpu0)
-   movl stack_start, %ecx
+   movl initial_stack, %ecx
movl %ecx, %esp
jmp  *(initial_code)
 ENDPROC(start_cpu0)
@@ -307,7 +307,7 @@ ENTRY(startup_32_smp)
movl %eax,%es
movl %eax,%fs
movl %eax,%gs
-   movl pa(stack_start),%ecx
+   movl pa(initial_stack),%ecx
movl %eax,%ss
leal -__PAGE_OFFSET(%ecx),%esp
 
@@ -709,7 +709,7 @@ ENTRY(initial_page_table)
 
 .data
 .balign 4
-ENTRY(stack_start)
+ENTRY(initial_stack)
.long init_thread_union+THREAD_SIZE
 
 __INITRODATA
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 5df831e..792c3bb 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -226,7 +226,7 @@ ENTRY(secondary_startup_64)
movq%rax, %cr0
 
/* Setup a boot time stack */
-   movq stack_start(%rip), %rsp
+   movq initial_stack(%rip), %rsp
 
/* zero EFLAGS after setting rsp */
pushq $0
@@ -309,7 +309,7 @@ ENTRY(secondary_startup_64)
  * start_secondary().
  */
 ENTRY(start_cpu0)
-   movq stack_start(%rip),%rsp
+   movq initial_stack(%rip),%rsp
movqinitial_code(%rip),%rax
pushq   $0  # fake return address to stop unwinder
pushq   $__KERNEL_CS# set correct cs
@@ -318,17 +318,15 @@ ENTRY(start_cpu0)
 ENDPROC(start_cpu0)
 #endif
 
-   /* SMP bootup changes these two */
+   /* SMP bootup changes these variables */
__REFDATA
.balign 8
GLOBAL(initial_code)
.quad   x86_64_start_kernel
GLOBAL(initial_gs)
.quad   INIT_PER_CPU_VAR(irq_stack_union)
-
-   GLOBAL(stack_start)
+   GLOBAL(initial_stack)
.quad  init_thread_union+THREAD_SIZE-8
-   .word  0
__FINITDATA
 
 bad_address:
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 1fe4130..503682a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -950,7 +950,7 @@ static

[RFC PATCH v2 00/18] livepatch: hybrid consistency model

2016-04-28 Thread Josh Poimboeuf
This is v2 of the livepatch hybrid consistency model, based on
linux-next/master.

v1 of this patch set was posted over a year ago:

  https://lkml.kernel.org/r/cover.1423499826.git.jpoim...@redhat.com

The biggest complaint at that time was that stack traces are unreliable.
Since CONFIG_STACK_VALIDATION was merged, that issue has been addressed.
I've also tried to address all other outstanding complaints and issues.

Ingo and Peter, note that I'm using task_rq_lock() in patch 17/18 to
make sure a task stays asleep while its stack gets checked.  I'm not
sure if there's a better way to achieve that goal -- any suggestions
there would be greatly appreciated.

Patches 1-7 create a mechanism for detecting whether a given stack trace
can be deemed reliable.

Patches 8-18 add the consistency model.  See patch 17/18 for more
details about the consistency model itself.

Remaining TODOs:
- how to patch kthreads without RELIABLE_STACKTRACE?
- safe patch module removal
- fake signal facility
- allow user to force a task to the patched state
- enable the patching of kthreads which are sleeping on affected
  functions, via the livepatch ftrace handler
- WARN on certain stack error conditions

v2:
- "universe" -> "patch state"
- rename klp_update_task_universe() -> klp_patch_task()
- add preempt IRQ tracking (TF_PREEMPT_IRQ)
- fix print_context_stack_reliable() bug
- improve print_context_stack_reliable() comments
- klp_ftrace_handler comment fixes
- add "patch_state" proc file to tid_base_stuff
- schedule work even for !RELIABLE_STACKTRACE
- forked child inherits patch state from parent
- add detailed comment to livepatch.h klp_func definition about the
  klp_func patched/transition state transitions
- update exit_to_usermode_loop() comment
- clear all TIF_KLP_NEED_UPDATE flags in klp_complete_transition()
- remove unnecessary function externs
- add livepatch documentation, sysfs documentation, /proc documentation
- /proc/pid/patch_state: -1 means no patch is currently being applied/reverted
- "TIF_KLP_NEED_UPDATE" -> "TIF_PATCH_PENDING"
- support for s390 and powerpc-le
- don't assume stacks with dynamic ftrace trampolines are reliable
- add _TIF_ALLWORK_MASK info to commit log

v1.9:
- revive from the dead and rebased
- reliable stacks!
- add support for immediate consistency model
- add a ton of comments
- fix up memory barriers
- remove "allow patch modules to be removed" patch for now, it still 
  needs more discussion and thought - it can be done with something
- "proc/pid/universe" -> "proc/pid/patch_status"
- remove WARN_ON_ONCE from !func condition in ftrace handler -- can
  happen because of RCU
- keep klp_mutex private by putting the work_fn in core.c
- convert states from int to boolean
- remove obsolete '@state' comments
- several header file and include improvements suggested by Jiri S
- change kallsyms_lookup_size_offset() errors from EINVAL -> ENOENT
- change proc file permissions S_IRUGO -> USR
- use klp_for_each_object/func helpers


Jiri Slaby (1):
  livepatch/s390: reorganize TIF thread flag bits

Josh Poimboeuf (16):
  x86/asm/head: clean up initial stack variable
  x86/asm/head: use a common function for starting CPUs
  x86/asm/head: standardize the bottom of the stack for idle tasks
  x86: move _stext marker before head code
  sched: add task flag for preempt IRQ tracking
  x86: dump_trace() error handling
  stacktrace/x86: function for detecting reliable stack traces
  livepatch: temporary stubs for klp_patch_pending() and
klp_patch_task()
  livepatch/x86: add TIF_PATCH_PENDING thread flag
  livepatch/powerpc: add TIF_PATCH_PENDING thread flag
  livepatch: separate enabled and patched states
  livepatch: remove unnecessary object loaded check
  livepatch: move patching functions into patch.c
  livepatch: store function sizes
  livepatch: change to a per-task consistency model
  livepatch: add /proc//patch_state

Miroslav Benes (1):
  livepatch/s390: add TIF_PATCH_PENDING thread flag

 Documentation/ABI/testing/sysfs-kernel-livepatch |   8 +
 Documentation/filesystems/proc.txt   |  18 +
 Documentation/livepatch/livepatch.txt| 132 ++-
 arch/Kconfig |   6 +
 arch/powerpc/include/asm/thread_info.h   |   4 +-
 arch/powerpc/kernel/signal.c |   4 +
 arch/s390/include/asm/thread_info.h  |  24 +-
 arch/s390/kernel/entry.S |  31 +-
 arch/x86/Kconfig |   1 +
 arch/x86/entry/common.c  |   9 +-
 arch/x86/include/asm/realmode.h  |   2 +-
 arch/x86/include/asm/smp.h   |   3 -
 arch/x86/include/asm/stacktrace.h|  36 +-
 arch/x86/include/asm/thread_info.h   |   2 +
 arch/x86/kernel/acpi/sleep.c |   2 +-
 arch/x86/kernel/dumpstack.c  | 108 +-
 arch/x86/kernel/dumpstack_32.c   |  22 +-
 arch/x86/kernel/dumps

Re: [PATCH kernel] vfio_iommu_spapr_tce: Remove unneeded iommu_group_get_iommudata

2016-04-28 Thread Alex Williamson
On Fri,  8 Apr 2016 14:54:41 +1000
Alexey Kardashevskiy  wrote:

> This removes iommu_group_get_iommudata() as the result is never used.
> As this is a minor cleanup, no change in behavior is expected.
> 
> Signed-off-by: Alexey Kardashevskiy 
> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
> b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 0582b72..6419566 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -331,14 +331,12 @@ static void tce_iommu_free_table(struct iommu_table 
> *tbl);
>  static void tce_iommu_release(void *iommu_data)
>  {
>   struct tce_container *container = iommu_data;
> - struct iommu_table_group *table_group;
>   struct tce_iommu_group *tcegrp;
>   long i;
>  
>   while (tce_groups_attached(container)) {
>   tcegrp = list_first_entry(&container->group_list,
>   struct tce_iommu_group, next);
> - table_group = iommu_group_get_iommudata(tcegrp->grp);
>   tce_iommu_detach_group(iommu_data, tcegrp->grp);
>   }
>  

Applied to next with David's R-b for v4.7.  Thanks,

Alex
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 0/3] Add support for perf user stack dump in powerpc

2016-04-28 Thread Arnaldo Carvalho de Melo
Em Thu, Apr 28, 2016 at 09:44:29PM +0530, Naveen N. Rao escreveu:
> On 2016/04/28 12:29PM, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
> > > On 2016/04/28 03:01PM, Chandan Kumar wrote:
> > > > This patch set enables perf user stack dump on powerpc
> > > 
> > > For this patch-set:
> > > Reviewed-by: Naveen N. Rao 
> > > 
> > > I suppose that implies my testing, but nonetheless:
> > > Tested-by: Naveen N. Rao 
> > > 
> > > > 
> > > > Example with "ls" command as user program
> > > > ./perf record --call-graph=dwarf,8192 ls
> > > > 
> > > > ./perf script
> > > > -8< -
> > > > ..
> > > > ...
> > > > perf 12549 75938.934539:   1771 cycles:ppp: 
> > > >   210d90 .perf_event_exec (/boot/vmlinux)
> > > >   34b914 .load_elf_binary (/boot/vmlinux)
> > > >   2dcabc .search_binary_handler (/boot/vmlinux)
> > > >   2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
> > > >   2ddcd8 .sys_execve (/boot/vmlinux)
> > > >19258 system_call (/boot/vmlinux)
> > > 
> > > To expand on this, with upstream libunwind 
> > > (git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:
> > > 
> > > # ./perf record -e cycles -g --call-graph dwarf -- find . -iname
> > > '*linux*'
> > >  ./tests/vmlinux-kallsyms.c
> > > ./tests/vmlinux-kallsyms.o
> > > ./tests/.vmlinux-kallsyms.o.cmd
> > > ./util/include/linux
> > > [ perf record: Woken up 2 times to write data ]
> > > [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ]
> > > # ./perf script
> > > 
> > > find 23858 167788.657182: 881967 cycles: 
> > >   8e758c _cond_resched 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >   3f83bc selinux_inode_getattr 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >   3ee254 security_inode_getattr 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >   3063a4 vfs_getattr 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >   306530 vfs_fstatat 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >   306c60 sys_newfstatat 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > >19210 system_call 
> > > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > > 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so)
> > > 10025ac8 fts_stat.isra.2 (/usr/bin/find)
> > > 10027c04 fts_read (/usr/bin/find)
> > > 10003e18 find (/usr/bin/find)
> > > 100035ec main (/usr/bin/find)
> > > 3fffa30a4580 generic_start_main.isra.0 
> > > (/usr/lib64/libc-2.17.so)
> > > 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)
> > > 
> > > 
> > > 
> > > 
> > > Arnaldo, Michael,
> > > Can we take this through powerpc/next as well since this pretty much 
> > > rides on the recent perf regs work?
> > 
> > I haven't tested with the bits that touch the common code, have you? But
> > I think it should be harmless and overall this patchset looks fine, so,
> > if you, just in case, have tested this on a x86_64 machine and all seems
> > well, i.e. perf test, perf record/report with a perf-probe generated
> > event, to exercise this stuff, then:
> 
> Yes, I processed a perf.data file that had the user stackdump unwound 
> with libunwind with/without patch 3 and the output matches. And:
> 
> # ./perf test 46
> 46: Test dwarf unwind: Ok

Ok then,
 
Acked-by: Arnaldo Carvalho de Melo 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 0/3] Add support for perf user stack dump in powerpc

2016-04-28 Thread Naveen N. Rao
On 2016/04/28 12:29PM, Arnaldo Carvalho de Melo wrote:
> Em Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
> > On 2016/04/28 03:01PM, Chandan Kumar wrote:
> > > This patch set enables perf user stack dump on powerpc
> > 
> > For this patch-set:
> > Reviewed-by: Naveen N. Rao 
> > 
> > I suppose that implies my testing, but nonetheless:
> > Tested-by: Naveen N. Rao 
> > 
> > > 
> > > Example with "ls" command as user program
> > > ./perf record --call-graph=dwarf,8192 ls
> > > 
> > > ./perf script
> > > -8< -
> > > ..
> > > ...
> > > perf 12549 75938.934539:   1771 cycles:ppp: 
> > >   210d90 .perf_event_exec (/boot/vmlinux)
> > >   34b914 .load_elf_binary (/boot/vmlinux)
> > >   2dcabc .search_binary_handler (/boot/vmlinux)
> > >   2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
> > >   2ddcd8 .sys_execve (/boot/vmlinux)
> > >19258 system_call (/boot/vmlinux)
> > 
> > To expand on this, with upstream libunwind 
> > (git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:
> > 
> > # ./perf record -e cycles -g --call-graph dwarf -- find . -iname
> > '*linux*'
> >  ./tests/vmlinux-kallsyms.c
> > ./tests/vmlinux-kallsyms.o
> > ./tests/.vmlinux-kallsyms.o.cmd
> > ./util/include/linux
> > [ perf record: Woken up 2 times to write data ]
> > [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ]
> > # ./perf script
> > 
> > find 23858 167788.657182: 881967 cycles: 
> >   8e758c _cond_resched 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >   3f83bc selinux_inode_getattr 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >   3ee254 security_inode_getattr 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >   3063a4 vfs_getattr 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >   306530 vfs_fstatat 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >   306c60 sys_newfstatat 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> >19210 system_call 
> > (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> > 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so)
> > 10025ac8 fts_stat.isra.2 (/usr/bin/find)
> > 10027c04 fts_read (/usr/bin/find)
> > 10003e18 find (/usr/bin/find)
> > 100035ec main (/usr/bin/find)
> > 3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so)
> > 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)
> > 
> > 
> > 
> > 
> > Arnaldo, Michael,
> > Can we take this through powerpc/next as well since this pretty much 
> > rides on the recent perf regs work?
> 
> I haven't tested with the bits that touch the common code, have you? But
> I think it should be harmless and overall this patchset looks fine, so,
> if you, just in case, have tested this on a x86_64 machine and all seems
> well, i.e. perf test, perf record/report with a perf-probe generated
> event, to exercise this stuff, then:

Yes, I processed a perf.data file that had the user stackdump unwound 
with libunwind with/without patch 3 and the output matches. And:

# ./perf test 46
46: Test dwarf unwind: Ok

> 
> Acked-by: Arnaldo Carvalho de Melo 
> 

Thanks.
- Naveen

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 0/3] Add support for perf user stack dump in powerpc

2016-04-28 Thread Arnaldo Carvalho de Melo
Em Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
> On 2016/04/28 03:01PM, Chandan Kumar wrote:
> > This patch set enables perf user stack dump on powerpc
> 
> For this patch-set:
> Reviewed-by: Naveen N. Rao 
> 
> I suppose that implies my testing, but nonetheless:
> Tested-by: Naveen N. Rao 
> 
> > 
> > Example with "ls" command as user program
> > ./perf record --call-graph=dwarf,8192 ls
> > 
> > ./perf script
> > -8< -
> > ..
> > ...
> > perf 12549 75938.934539:   1771 cycles:ppp: 
> >   210d90 .perf_event_exec (/boot/vmlinux)
> >   34b914 .load_elf_binary (/boot/vmlinux)
> >   2dcabc .search_binary_handler (/boot/vmlinux)
> >   2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
> >   2ddcd8 .sys_execve (/boot/vmlinux)
> >19258 system_call (/boot/vmlinux)
> 
> To expand on this, with upstream libunwind 
> (git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:
> 
> # ./perf record -e cycles -g --call-graph dwarf -- find . -iname
> '*linux*'
>  ./tests/vmlinux-kallsyms.c
> ./tests/vmlinux-kallsyms.o
> ./tests/.vmlinux-kallsyms.o.cmd
> ./util/include/linux
> [ perf record: Woken up 2 times to write data ]
> [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ]
> # ./perf script
> 
> find 23858 167788.657182: 881967 cycles: 
>   8e758c _cond_resched 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>   3f83bc selinux_inode_getattr 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>   3ee254 security_inode_getattr 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>   3063a4 vfs_getattr 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>   306530 vfs_fstatat 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>   306c60 sys_newfstatat 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
>19210 system_call 
> (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
> 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so)
> 10025ac8 fts_stat.isra.2 (/usr/bin/find)
> 10027c04 fts_read (/usr/bin/find)
> 10003e18 find (/usr/bin/find)
> 100035ec main (/usr/bin/find)
> 3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so)
> 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)
> 
> 
> 
> 
> Arnaldo, Michael,
> Can we take this through powerpc/next as well since this pretty much 
> rides on the recent perf regs work?

I haven't tested with the bits that touch the common code, have you? But
I think it should be harmless and overall this patchset looks fine, so,
if you, just in case, have tested this on a x86_64 machine and all seems
well, i.e. perf test, perf record/report with a perf-probe generated
event, to exercise this stuff, then:

Acked-by: Arnaldo Carvalho de Melo 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC 5/5] arm64: Gain VDSO unmap and remap powers

2016-04-28 Thread Christopher Covington
Checkpoint/Restore In Userspace (CRIU) must be able to remap and unmap the
Virtual Dynamic Shared Object (VDSO) to be able to handle the changing
addresses that result from address space layout randomization. Now that the
support for this originally written for PowerPC has been moved to a generic
location and arm64 has adopted unsigned long for the type of mm->context.vdso,
simply opt-in to VDSO unmap and remap support.

Signed-off-by: Christopher Covington 
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4f43622..cbdce39 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -14,6 +14,7 @@ config ARM64
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
select ARCH_WANT_FRAME_POINTERS
+   select ARCH_WANT_VDSO_MAP
select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARM_AMBA
select ARM_ARCH_TIMER
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC 4/5] arm64: Use unsigned long for vdso

2016-04-28 Thread Christopher Covington
In order to get AArch64 remap and unmap support for the VDSO, like PowerPC
and x86 have, without duplicating the code, we need a common name and type
for the address of the VDSO. An informal survey of the architectures
indicates unsigned long vdso is popular. Change the type in arm64 to be
unsigned long, which has the added benefit of dropping a few typecasts.

Signed-off-by: Christopher Covington 
---
 arch/arm64/include/asm/mmu.h | 2 +-
 arch/arm64/kernel/vdso.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index 990124a..a67352f 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -18,7 +18,7 @@
 
 typedef struct {
atomic64_t  id;
-   void*vdso;
+   unsigned long   vdso;
 } mm_context_t;
 
 /*
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 97bc68f..e742b1d 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -96,7 +96,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int 
uses_interp)
void *ret;
 
down_write(&mm->mmap_sem);
-   current->mm->context.vdso = (void *)addr;
+   current->mm->context.vdso = addr;
 
/* Map vectors page at the high address. */
ret = _install_special_mapping(mm, addr, PAGE_SIZE,
@@ -176,7 +176,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
goto up_fail;
 
vdso_base += PAGE_SIZE;
-   mm->context.vdso = (void *)vdso_base;
+   mm->context.vdso = vdso_base;
ret = _install_special_mapping(mm, vdso_base, vdso_text_len,
   VM_READ|VM_EXEC|
   VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
@@ -189,7 +189,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
return 0;
 
 up_fail:
-   mm->context.vdso = NULL;
+   mm->context.vdso = 0;
up_write(&mm->mmap_sem);
return PTR_ERR(ret);
 }
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC 3/5] mm/powerpc: Make VDSO remap generic

2016-04-28 Thread Christopher Covington
In order to support remapping the VDSO on additional architectures without
duplicating code, move the remap code out from arch/powerpc. Architectures
that wish to use the generic logic must have an unsigned long vdso in
mm->context and can opt in by selecting CONFIG_ARCH_WANT_VDSO_MAP. This
allows PowerPC to use mm-arch-hooks.h from include/asm-generic.

Signed-off-by: Christopher Covington 
---
 arch/powerpc/include/asm/Kbuild  |  1 +
 arch/powerpc/include/asm/mm-arch-hooks.h | 28 
 mm/mremap.c  | 10 --
 3 files changed, 9 insertions(+), 30 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/mm-arch-hooks.h

diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild
index ab9f4e0..9dbb372 100644
--- a/arch/powerpc/include/asm/Kbuild
+++ b/arch/powerpc/include/asm/Kbuild
@@ -7,3 +7,4 @@ generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += rwsem.h
 generic-y += vtime.h
+generic-y += mm-arch-hooks.h
diff --git a/arch/powerpc/include/asm/mm-arch-hooks.h 
b/arch/powerpc/include/asm/mm-arch-hooks.h
deleted file mode 100644
index ea6da89..000
--- a/arch/powerpc/include/asm/mm-arch-hooks.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Architecture specific mm hooks
- *
- * Copyright (C) 2015, IBM Corporation
- * Author: Laurent Dufour 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _ASM_POWERPC_MM_ARCH_HOOKS_H
-#define _ASM_POWERPC_MM_ARCH_HOOKS_H
-
-static inline void arch_remap(struct mm_struct *mm,
- unsigned long old_start, unsigned long old_end,
- unsigned long new_start, unsigned long new_end)
-{
-   /*
-* mremap() doesn't allow moving multiple vmas so we can limit the
-* check to old_start == vdso.
-*/
-   if (old_start == mm->context.vdso)
-   mm->context.vdso = new_start;
-}
-#define arch_remap arch_remap
-
-#endif /* _ASM_POWERPC_MM_ARCH_HOOKS_H */
diff --git a/mm/mremap.c b/mm/mremap.c
index 3fa0a467..59032b7 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -293,8 +293,14 @@ static unsigned long move_vma(struct vm_area_struct *vma,
old_addr = new_addr;
new_addr = err;
} else {
-   arch_remap(mm, old_addr, old_addr + old_len,
-  new_addr, new_addr + new_len);
+#ifdef CONFIG_ARCH_WANT_VDSO_MAP
+   /*
+* mremap() doesn't allow moving multiple vmas so we can limit 
the
+* check to old_addr == vdso.
+*/
+   if (old_addr == mm->context.vdso)
+   mm->context.vdso = new_addr;
+#endif  /* CONFIG_ARCH_WANT_VDSO_MAP */
}
 
/* Conceal VM_ACCOUNT so old reservation is not undone */
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC 2/5] mm/powerpc: Make VDSO unmap generic

2016-04-28 Thread Christopher Covington
In order to support unmapping the VDSO on additional architectures, move the
unmap code out from arch/powerpc. Architectures that wish to use the generic
logic must have an unsigned long vdso in mm->context and can opt in by
selecting CONFIG_ARCH_WANT_VDSO_MAP. This allows PowerPC to go back to using
the generic MM hooks, instead of carrying its own.

Signed-off-by: Christopher Covington 
---
 arch/powerpc/Kconfig   |  1 +
 arch/powerpc/include/asm/mmu_context.h | 35 +-
 include/asm-generic/mm_hooks.h |  4 
 3 files changed, 6 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7cd32c0..f74320e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -160,6 +160,7 @@ config PPC
select HAVE_ARCH_SECCOMP_FILTER
select ARCH_HAS_UBSAN_SANITIZE_ALL
select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT
+   select ARCH_WANT_VDSO_MAP
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/mmu_context.h 
b/arch/powerpc/include/asm/mmu_context.h
index 508b842..3e51842 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -8,6 +8,7 @@
 #include 
 #include
 #include 
+#include 
 #include 
 
 /*
@@ -126,39 +127,5 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,
 #endif
 }
 
-static inline void arch_dup_mmap(struct mm_struct *oldmm,
-struct mm_struct *mm)
-{
-}
-
-static inline void arch_exit_mmap(struct mm_struct *mm)
-{
-}
-
-static inline void arch_unmap(struct mm_struct *mm,
- struct vm_area_struct *vma,
- unsigned long start, unsigned long end)
-{
-   if (start <= mm->context.vdso && mm->context.vdso < end)
-   mm->context.vdso = 0;
-}
-
-static inline void arch_bprm_mm_init(struct mm_struct *mm,
-struct vm_area_struct *vma)
-{
-}
-
-static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
-   bool write, bool execute, bool foreign)
-{
-   /* by default, allow everything */
-   return true;
-}
-
-static inline bool arch_pte_access_permitted(pte_t pte, bool write)
-{
-   /* by default, allow everything */
-   return true;
-}
 #endif /* __KERNEL__ */
 #endif /* __ASM_POWERPC_MMU_CONTEXT_H */
diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
index cc5d9a14..6645116 100644
--- a/include/asm-generic/mm_hooks.h
+++ b/include/asm-generic/mm_hooks.h
@@ -19,6 +19,10 @@ static inline void arch_unmap(struct mm_struct *mm,
struct vm_area_struct *vma,
unsigned long start, unsigned long end)
 {
+#ifdef CONFIG_ARCH_WANT_VDSO_MAP
+   if (start <= mm->context.vdso && mm->context.vdso < end)
+   mm->context.vdso = 0;
+#endif  /* CONFIG_ARCH_WANT_VDSO_MAP */
 }
 
 static inline void arch_bprm_mm_init(struct mm_struct *mm,
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[RFC 1/5] powerpc: Rename context.vdso_base to context.vdso

2016-04-28 Thread Christopher Covington
In order to share remap and unmap support for the VDSO with other
architectures without duplicating the code, we need a common name and type
for the address of the VDSO. An informal survey of the architectures
indicates unsigned long vdso is popular. Change the variable name in
powerpc from mm->context.vdso_base to simply mm->context.vdso.

Signed-off-by: Christopher Covington 
---
 arch/powerpc/include/asm/book3s/32/mmu-hash.h |  2 +-
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |  2 +-
 arch/powerpc/include/asm/mm-arch-hooks.h  |  6 +++---
 arch/powerpc/include/asm/mmu-40x.h|  2 +-
 arch/powerpc/include/asm/mmu-44x.h|  2 +-
 arch/powerpc/include/asm/mmu-8xx.h|  2 +-
 arch/powerpc/include/asm/mmu-book3e.h |  2 +-
 arch/powerpc/include/asm/mmu_context.h|  4 ++--
 arch/powerpc/include/asm/vdso.h   |  2 +-
 arch/powerpc/include/uapi/asm/elf.h   |  2 +-
 arch/powerpc/kernel/signal_32.c   |  8 
 arch/powerpc/kernel/signal_64.c   |  4 ++--
 arch/powerpc/kernel/vdso.c|  8 
 arch/powerpc/perf/callchain.c | 12 ++--
 14 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/mmu-hash.h 
b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
index 16f513e..9d8de53 100644
--- a/arch/powerpc/include/asm/book3s/32/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/32/mmu-hash.h
@@ -79,7 +79,7 @@ struct hash_pte {
 
 typedef struct {
unsigned long id;
-   unsigned long vdso_base;
+   unsigned long vdso;
 } mm_context_t;
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index 0cea480..99df600 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -525,7 +525,7 @@ typedef struct {
 #else
u16 sllp;   /* SLB page size encoding */
 #endif
-   unsigned long vdso_base;
+   unsigned long vdso;
 #ifdef CONFIG_PPC_SUBPAGE_PROT
struct subpage_prot_table spt;
 #endif /* CONFIG_PPC_SUBPAGE_PROT */
diff --git a/arch/powerpc/include/asm/mm-arch-hooks.h 
b/arch/powerpc/include/asm/mm-arch-hooks.h
index f2a2da8..ea6da89 100644
--- a/arch/powerpc/include/asm/mm-arch-hooks.h
+++ b/arch/powerpc/include/asm/mm-arch-hooks.h
@@ -18,10 +18,10 @@ static inline void arch_remap(struct mm_struct *mm,
 {
/*
 * mremap() doesn't allow moving multiple vmas so we can limit the
-* check to old_start == vdso_base.
+* check to old_start == vdso.
 */
-   if (old_start == mm->context.vdso_base)
-   mm->context.vdso_base = new_start;
+   if (old_start == mm->context.vdso)
+   mm->context.vdso = new_start;
 }
 #define arch_remap arch_remap
 
diff --git a/arch/powerpc/include/asm/mmu-40x.h 
b/arch/powerpc/include/asm/mmu-40x.h
index 3491686..e8e57b7 100644
--- a/arch/powerpc/include/asm/mmu-40x.h
+++ b/arch/powerpc/include/asm/mmu-40x.h
@@ -56,7 +56,7 @@
 typedef struct {
unsigned intid;
unsigned intactive;
-   unsigned long   vdso_base;
+   unsigned long   vdso;
 } mm_context_t;
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/mmu-44x.h 
b/arch/powerpc/include/asm/mmu-44x.h
index bf52d70..471891c 100644
--- a/arch/powerpc/include/asm/mmu-44x.h
+++ b/arch/powerpc/include/asm/mmu-44x.h
@@ -107,7 +107,7 @@ extern unsigned int tlb_44x_index;
 typedef struct {
unsigned intid;
unsigned intactive;
-   unsigned long   vdso_base;
+   unsigned long   vdso;
 } mm_context_t;
 
 #endif /* !__ASSEMBLY__ */
diff --git a/arch/powerpc/include/asm/mmu-8xx.h 
b/arch/powerpc/include/asm/mmu-8xx.h
index 0a566f1..9d1f160 100644
--- a/arch/powerpc/include/asm/mmu-8xx.h
+++ b/arch/powerpc/include/asm/mmu-8xx.h
@@ -167,7 +167,7 @@
 typedef struct {
unsigned int id;
unsigned int active;
-   unsigned long vdso_base;
+   unsigned long vdso;
 } mm_context_t;
 #endif /* !__ASSEMBLY__ */
 
diff --git a/arch/powerpc/include/asm/mmu-book3e.h 
b/arch/powerpc/include/asm/mmu-book3e.h
index cd4f04a..0cf1d11 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -228,7 +228,7 @@ extern unsigned int tlbcam_index;
 typedef struct {
unsigned intid;
unsigned intactive;
-   unsigned long   vdso_base;
+   unsigned long   vdso;
 #ifdef CONFIG_PPC_MM_SLICES
u64 low_slices_psize;   /* SLB page size encodings */
u64 high_slices_psize;  /* 4 bits per slice for now */
diff --git a/arch/powerpc/include/asm/mmu_context.h 
b/arch/powerpc/include/asm/mmu_context.h
index 4eaab40..508b842 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -139,8 +139,8 @@ static inline void arch_unmap(struct mm_struct *mm,
   

VDSO unmap and remap support for additional architectures

2016-04-28 Thread Christopher Covington
Please take a look at the following prototype of sharing the PowerPC
VDSO unmap and remap code with other architectures. I've only hooked
up arm64 to begin with. If folks think this is a reasonable approach I
can work on 32 bit ARM as well. Not hearing back from an earlier
request for guidance [1], I simply dove in and started hacking.
Laurent's test case [2][3] is a compelling illustration of whether VDSO
remap works or not on a given architecture.

1. https://lkml.org/lkml/2016/3/2/225
2. https://lists.openvz.org/pipermail/criu/2015-March/019161.html
3. 
http://lists.openvz.org/pipermail/criu/attachments/20150318/f02ed9ea/attachment.bin

Thanks,
Christopher Covington

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [PATCH] powerpc: Add support for userspace P9 copy paste

2016-04-28 Thread David Laight
From: Chris Smart
> Sent: 28 April 2016 00:52
...
> >In that case what actually completes the copy?
> >I think you'd need to be inside a 'restartable atomic sequence'
> >in which case the cp_abort need only be done when the/a RAS
> >block is detected.
> >
> >Or have I missed something??
> 
> It's up to the userspace process that's doing the copy paste to check
> the CR field after the paste to see whether it has succeeded. If it has
> not succeeded, then the process can choose to re-do the copy and paste.
>
> Hope that makes sense.

Yes, thanks.

David

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 0/3] Add support for perf user stack dump in powerpc

2016-04-28 Thread Naveen N. Rao
On 2016/04/28 03:01PM, Chandan Kumar wrote:
> This patch set enables perf user stack dump on powerpc

For this patch-set:
Reviewed-by: Naveen N. Rao 

I suppose that implies my testing, but nonetheless:
Tested-by: Naveen N. Rao 

> 
> Example with "ls" command as user program
> ./perf record --call-graph=dwarf,8192 ls
> 
> ./perf script
> -8< -
> ..
> ...
> perf 12549 75938.934539:   1771 cycles:ppp: 
>   210d90 .perf_event_exec (/boot/vmlinux)
>   34b914 .load_elf_binary (/boot/vmlinux)
>   2dcabc .search_binary_handler (/boot/vmlinux)
>   2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
>   2ddcd8 .sys_execve (/boot/vmlinux)
>19258 system_call (/boot/vmlinux)

To expand on this, with upstream libunwind 
(git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:

# ./perf record -e cycles -g --call-graph dwarf -- find . -iname
'*linux*'
 ./tests/vmlinux-kallsyms.c
./tests/vmlinux-kallsyms.o
./tests/.vmlinux-kallsyms.o.cmd
./util/include/linux
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ]
# ./perf script

find 23858 167788.657182: 881967 cycles: 
  8e758c _cond_resched 
(/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
  3f83bc selinux_inode_getattr 
(/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
  3ee254 security_inode_getattr 
(/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
  3063a4 vfs_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
  306530 vfs_fstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
  306c60 sys_newfstatat 
(/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
   19210 system_call (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so)
10025ac8 fts_stat.isra.2 (/usr/bin/find)
10027c04 fts_read (/usr/bin/find)
10003e18 find (/usr/bin/find)
100035ec main (/usr/bin/find)
3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so)
3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)




Arnaldo, Michael,
Can we take this through powerpc/next as well since this pretty much 
rides on the recent perf regs work?

- Naveen

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [V2] powerpc/cxl: Use REGION_ID instead of opencoding

2016-04-28 Thread Michael Ellerman
On Wed, 2016-20-04 at 07:59:47 UTC, "Aneesh Kumar K.V" wrote:
> Also the wrong `~` operation resulted in wrong access check as explained
> below.
>
...
> Reviewed-by: Andrew Donnellan 
> Acked-by: Ian Munsie 
> Signed-off-by: Aneesh Kumar K.V 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3b1dbfa14f97188ec33fdfc7ac

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v2] powerpc/perf: Replace raw event hex values with #def

2016-04-28 Thread Michael Ellerman
On Thu, 2016-21-04 at 10:16:34 UTC, Madhavan Srinivasan wrote:
> Minor cleanup patch to replace the raw event hex values in
> power8-pmu.c with #def.
> 
> Signed-off-by: Madhavan Srinivasan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/5bcca743cb6e3ab97ff400ef92

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: powerpc: Add support for userspace P9 copy paste

2016-04-28 Thread Michael Ellerman
On Tue, 2016-26-04 at 00:28:50 UTC, Chris Smart wrote:
> The copy paste facility introduced in POWER9 provides an optimised
> mechanism for a userspace application to copy a cacheline. This is
> provided by a pair of instructions, copy and paste, while a third,
> cp_abort (copy paste abort), provides a clean up of the state in case of
> a failure.
...
> Signed-off-by: Chris Smart 
> Reviewed-by: Cyril Bur 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8a649045e75a4b9091ea9d041f

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: powerpc/mpic: handle subsys_system_register() failure

2016-04-28 Thread Michael Ellerman
On Tue, 2016-26-04 at 07:55:04 UTC, Andrew Donnellan wrote:
> mpic_init_sys() currently doesn't check whether
> subsys_system_register() succeeded or not. Check the return code of
> subsys_system_register() and clean up if there's an error.
> 
> Signed-off-by: Andrew Donnellan 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/4ad5e8831e1cb663f17112e444

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v2] ftrace: Match dot symbols when searching functions on ppc64

2016-04-28 Thread Michael Ellerman
On Mon, 2016-25-04 at 21:56:14 UTC, Thiago Jung Bauermann wrote:
> In the ppc64 big endian ABI, function symbols point to function
> descriptors. The symbols which point to the function entry points
> have a dot in front of the function name. Consequently, when the
> ftrace filter mechanism searches for the symbol corresponding to
> an entry point address, it gets the dot symbol.
...
> 
> Signed-off-by: Thiago Jung Bauermann 
> Acked-by: Steven Rostedt 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/7132e2d669bd42c3783327f301

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: powerpc/eeh: fix misleading indentation

2016-04-28 Thread Michael Ellerman
On Tue, 2016-26-04 at 05:02:50 UTC, Andrew Donnellan wrote:
> Found by smatch.
> 
> Signed-off-by: Andrew Donnellan 
> Acked-by: Russell Currey 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2d5217840ff1d0cf0f88201a92

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v2,1/6] powerpc: rework sparse for lib/xor_vmx.c

2016-04-28 Thread Michael Ellerman
On Tue, 2016-26-04 at 13:49:09 UTC, Daniel Axtens wrote:
> Sparse doesn't seem to be passing -maltivec around properly, leading
> to lots of errors:
...
> Only include the altivec.h header for non-__CHECKER__ builds.
> For builds with __CHECKER__, make up some stubs instead, as
> suggested by Balbir. (The vector size of 16 is arbitrary.)
> 
> Suggested-by: Balbir Singh 
> Signed-off-by: Daniel Axtens 
> Tested-by: Balbir Singh 

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/8fe088850f13eabf8197df5b0b

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [V2,67/68] powerpc/mm/radix: Cputable update for radix

2016-04-28 Thread Michael Ellerman
On Sat, 2016-09-04 at 06:14:03 UTC, "Aneesh Kumar K.V" wrote:
> With P9 Radix we need to do
> 
> * set UPRT = 1
> * set different TLB set count
> 
> In this patch we delay the UPRT=1 to early mmu init. This help us to
> keep the cpu table setup and restore cpu callback the same across
> different MMU model.
> 
> This also implies that a cpu_restore cur_cpu_spec callback won't set
> UPRT=1. We currently use that for secondary cpu init and on primary
> after we did an opal reinit for endian switch. In both the case
> we call early_mmu_init after the above operations. This set UPRT
> to correct value.

This probably needs a new subject and updated change log as it is mainly adding
the setup code.

> diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
> index 6c662b8de90d..e009722d5914 100644
> --- a/arch/powerpc/kernel/cputable.c
> +++ b/arch/powerpc/kernel/cputable.c
> @@ -514,7 +514,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
>   .cpu_features   = CPU_FTRS_POWER9,
>   .cpu_user_features  = COMMON_USER_POWER9,
>   .cpu_user_features2 = COMMON_USER2_POWER9,
> - .mmu_features   = MMU_FTRS_POWER9,
> + .mmu_features   = MMU_FTRS_POWER9 | MMU_FTR_RADIX,

I think we discussed this before, but I want to drop this.

That will mean the only way MMU_FTR_RADIX is enabled is via ibm,pa-features (in
the next patch).

cheers
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH resend] powerpc: enable qspinlock and its virtualization support

2016-04-28 Thread Pan Xinhui
From: Pan Xinhui 

This patch aims to enable qspinlock on PPC. And on pseries platform, it also 
support
paravirt qspinlock.

Signed-off-by: Pan Xinhui 
---
 arch/powerpc/include/asm/qspinlock.h   | 37 +++
 arch/powerpc/include/asm/qspinlock_paravirt.h  | 36 +++
 .../powerpc/include/asm/qspinlock_paravirt_types.h | 13 ++
 arch/powerpc/include/asm/spinlock.h| 31 -
 arch/powerpc/include/asm/spinlock_types.h  |  4 ++
 arch/powerpc/kernel/paravirt.c | 52 ++
 arch/powerpc/lib/locks.c   | 32 +
 arch/powerpc/platforms/pseries/setup.c |  5 +++
 8 files changed, 198 insertions(+), 12 deletions(-)
 create mode 100644 arch/powerpc/include/asm/qspinlock.h
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt_types.h
 create mode 100644 arch/powerpc/kernel/paravirt.c

diff --git a/arch/powerpc/include/asm/qspinlock.h 
b/arch/powerpc/include/asm/qspinlock.h
new file mode 100644
index 000..d4e4dc3
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock.h
@@ -0,0 +1,37 @@
+#ifndef _ASM_POWERPC_QSPINLOCK_H
+#define _ASM_POWERPC_QSPINLOCK_H
+
+#include 
+
+#define SPIN_THRESHOLD (1 << 15)
+#definequeued_spin_unlock queued_spin_unlock
+
+static inline void native_queued_spin_unlock(struct qspinlock *lock)
+{
+   /* no load/store can be across the unlock()*/
+   smp_store_release((u8 *)lock, 0);
+}
+
+#ifdef CONFIG_PARAVIRT_SPINLOCKS
+
+#include 
+
+static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
+{
+   pv_queued_spin_lock(lock, val);
+}
+
+static inline void queued_spin_unlock(struct qspinlock *lock)
+{
+   pv_queued_spin_unlock(lock);
+}
+#else
+static inline void queued_spin_unlock(struct qspinlock *lock)
+{
+   native_queued_spin_unlock(lock);
+}
+#endif
+
+#include 
+
+#endif /* _ASM_POWERPC_QSPINLOCK_H */
diff --git a/arch/powerpc/include/asm/qspinlock_paravirt.h 
b/arch/powerpc/include/asm/qspinlock_paravirt.h
new file mode 100644
index 000..86e81c3
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock_paravirt.h
@@ -0,0 +1,36 @@
+#ifndef CONFIG_PARAVIRT_SPINLOCKS
+#error "do not include this file"
+#endif
+
+#ifndef _ASM_QSPINLOCK_PARAVIRT_H
+#define _ASM_QSPINLOCK_PARAVIRT_H
+
+#include  
+
+extern void pv_lock_init(void);
+extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_init_lock_hash(void);
+extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_queued_spin_unlock(struct qspinlock *lock);
+
+static inline void pv_queued_spin_lock(struct qspinlock *lock, u32 val)
+{
+   pv_lock_op.lock(lock, val);
+}
+
+static inline void pv_queued_spin_unlock(struct qspinlock *lock)
+{
+   pv_lock_op.unlock(lock);
+}
+
+static inline void pv_wait(u8 *ptr, u8 val)
+{
+   pv_lock_op.wait(ptr, val, -1);
+}
+
+static inline void pv_kick(int cpu)
+{
+   pv_lock_op.kick(cpu);
+}
+
+#endif
diff --git a/arch/powerpc/include/asm/qspinlock_paravirt_types.h 
b/arch/powerpc/include/asm/qspinlock_paravirt_types.h
new file mode 100644
index 000..e1fdeb0
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock_paravirt_types.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_QSPINLOCK_PARAVIRT_TYPES_H
+#define _ASM_QSPINLOCK_PARAVIRT_TYPES_H
+
+struct pv_lock_ops {
+   void (*lock)(struct qspinlock *lock, u32 val);
+   void (*unlock)(struct qspinlock *lock);
+   void (*wait)(u8 *ptr, u8 val, int cpu);
+   void (*kick)(int cpu);
+};
+
+extern struct pv_lock_ops pv_lock_op;
+
+#endif
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 523673d..3b65372 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -52,6 +52,24 @@
 #define SYNC_IO
 #endif
 
+#if defined(CONFIG_PPC_SPLPAR)
+/* We only yield to the hypervisor if we are in shared processor mode */
+#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
+extern void __spin_yield(arch_spinlock_t *lock);
+extern void __spin_yield_cpu(int cpu);
+extern void __spin_wake_cpu(int cpu);
+extern void __rw_yield(arch_rwlock_t *lock);
+#else /* SPLPAR */
+#define __spin_yield(x)barrier()
+#define __spin_yield_cpu(x) barrier()
+#define __spin_wake_cpu(x) barrier()
+#define __rw_yield(x)  barrier()
+#define SHARED_PROCESSOR   0
+#endif
+
+#ifdef CONFIG_QUEUED_SPINLOCKS
+#include 
+#else
 static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
 {
return lock.slock == 0;
@@ -106,18 +124,6 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
  * held.  Conveniently, we have a word in the paca that holds this
  * value.
  */
-
-#if defined(CONFIG_PPC_SPLPAR)
-/* We only yield to the hypervisor if we are in shared processor mode */
-#define SHARED_PROCESSOR (lppaca

Re: [PATCH] powerpc: Define and use PPC_ELF_ABI_v2

2016-04-28 Thread Naveen N. Rao
On 2016/04/28 07:38PM, Michael Ellerman wrote:
> We're approaching 20 locations where we need to check for ELF ABI v2.
> That's fine, except the logic is a bit awkward, because we have to check
> that _CALL_ELF is defined and then what its value is.
> 
> So check it once in asm/types.h and define PPC_ELF_ABI_v2 when ELF ABI
> v2 is detected.
> 
> We don't add explicit includes of asm/types.h because it's included
> basically everywhere via compiler.h.
> 
> Signed-off-by: Michael Ellerman 

Thanks for doing this!

Does it make sense to call this PPC64_ELF_ABI_V2 since this is 64-bit 
only, and include check for CONFIG_PPC64 as well?

Apart from that:
Acked-by: Naveen N. Rao 

- Naveen

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc: enable qspinlock and its virtualization support

2016-04-28 Thread Pan Xinhui
From: Pan Xinhui 

This path aims to enable qspinlock on PPC. And on pseries platform, it also 
support
paravirt qspinlock.

Signed-off-by: Pan Xinhui 
---
 arch/powerpc/include/asm/qspinlock.h   | 37 +++
 arch/powerpc/include/asm/qspinlock_paravirt.h  | 36 +++
 .../powerpc/include/asm/qspinlock_paravirt_types.h | 13 ++
 arch/powerpc/include/asm/spinlock.h| 31 -
 arch/powerpc/include/asm/spinlock_types.h  |  4 ++
 arch/powerpc/kernel/paravirt.c | 52 ++
 arch/powerpc/lib/locks.c   | 32 +
 arch/powerpc/platforms/pseries/setup.c |  5 +++
 8 files changed, 198 insertions(+), 12 deletions(-)
 create mode 100644 arch/powerpc/include/asm/qspinlock.h
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt.h
 create mode 100644 arch/powerpc/include/asm/qspinlock_paravirt_types.h
 create mode 100644 arch/powerpc/kernel/paravirt.c

diff --git a/arch/powerpc/include/asm/qspinlock.h 
b/arch/powerpc/include/asm/qspinlock.h
new file mode 100644
index 000..d4e4dc3
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock.h
@@ -0,0 +1,37 @@
+#ifndef _ASM_POWERPC_QSPINLOCK_H
+#define _ASM_POWERPC_QSPINLOCK_H
+
+#include 
+
+#define SPIN_THRESHOLD (1 << 15)
+#definequeued_spin_unlock queued_spin_unlock
+
+static inline void native_queued_spin_unlock(struct qspinlock *lock)
+{
+   /* no load/store can be across the unlock()*/
+   smp_store_release((u8 *)lock, 0);
+}
+
+#ifdef CONFIG_PARAVIRT_SPINLOCKS
+
+#include 
+
+static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
+{
+   pv_queued_spin_lock(lock, val);
+}
+
+static inline void queued_spin_unlock(struct qspinlock *lock)
+{
+   pv_queued_spin_unlock(lock);
+}
+#else
+static inline void queued_spin_unlock(struct qspinlock *lock)
+{
+   native_queued_spin_unlock(lock);
+}
+#endif
+
+#include 
+
+#endif /* _ASM_POWERPC_QSPINLOCK_H */
diff --git a/arch/powerpc/include/asm/qspinlock_paravirt.h 
b/arch/powerpc/include/asm/qspinlock_paravirt.h
new file mode 100644
index 000..86e81c3
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock_paravirt.h
@@ -0,0 +1,36 @@
+#ifndef CONFIG_PARAVIRT_SPINLOCKS
+#error "do not include this file"
+#endif
+
+#ifndef _ASM_QSPINLOCK_PARAVIRT_H
+#define _ASM_QSPINLOCK_PARAVIRT_H
+
+#include  
+
+extern void pv_lock_init(void);
+extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_init_lock_hash(void);
+extern void __pv_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
+extern void __pv_queued_spin_unlock(struct qspinlock *lock);
+
+static inline void pv_queued_spin_lock(struct qspinlock *lock, u32 val)
+{
+   pv_lock_op.lock(lock, val);
+}
+
+static inline void pv_queued_spin_unlock(struct qspinlock *lock)
+{
+   pv_lock_op.unlock(lock);
+}
+
+static inline void pv_wait(u8 *ptr, u8 val)
+{
+   pv_lock_op.wait(ptr, val, -1);
+}
+
+static inline void pv_kick(int cpu)
+{
+   pv_lock_op.kick(cpu);
+}
+
+#endif
diff --git a/arch/powerpc/include/asm/qspinlock_paravirt_types.h 
b/arch/powerpc/include/asm/qspinlock_paravirt_types.h
new file mode 100644
index 000..e1fdeb0
--- /dev/null
+++ b/arch/powerpc/include/asm/qspinlock_paravirt_types.h
@@ -0,0 +1,13 @@
+#ifndef _ASM_QSPINLOCK_PARAVIRT_TYPES_H
+#define _ASM_QSPINLOCK_PARAVIRT_TYPES_H
+
+struct pv_lock_ops {
+   void (*lock)(struct qspinlock *lock, u32 val);
+   void (*unlock)(struct qspinlock *lock);
+   void (*wait)(u8 *ptr, u8 val, int cpu);
+   void (*kick)(int cpu);
+};
+
+extern struct pv_lock_ops pv_lock_op;
+
+#endif
diff --git a/arch/powerpc/include/asm/spinlock.h 
b/arch/powerpc/include/asm/spinlock.h
index 523673d..3b65372 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -52,6 +52,24 @@
 #define SYNC_IO
 #endif
 
+#if defined(CONFIG_PPC_SPLPAR)
+/* We only yield to the hypervisor if we are in shared processor mode */
+#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
+extern void __spin_yield(arch_spinlock_t *lock);
+extern void __spin_yield_cpu(int cpu);
+extern void __spin_wake_cpu(int cpu);
+extern void __rw_yield(arch_rwlock_t *lock);
+#else /* SPLPAR */
+#define __spin_yield(x)barrier()
+#define __spin_yield_cpu(x) barrier()
+#define __spin_wake_cpu(x) barrier()
+#define __rw_yield(x)  barrier()
+#define SHARED_PROCESSOR   0
+#endif
+
+#ifdef CONFIG_QUEUED_SPINLOCKS
+#include 
+#else
 static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
 {
return lock.slock == 0;
@@ -106,18 +124,6 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
  * held.  Conveniently, we have a word in the paca that holds this
  * value.
  */
-
-#if defined(CONFIG_PPC_SPLPAR)
-/* We only yield to the hypervisor if we are in shared processor mode */
-#define SHARED_PROCESSOR (lppaca_

Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16

2016-04-28 Thread Pan Xinhui


On 2016年04月28日 15:59, Peter Zijlstra wrote:
> On Wed, Apr 27, 2016 at 05:16:45PM +0800, Pan Xinhui wrote:
>> From: Pan Xinhui 
>>
>> Implement xchg{u8,u16}{local,relaxed}, and
>> cmpxchg{u8,u16}{,local,acquire,relaxed}.
>>
>> It works on all ppc.
>>
>> remove volatile of first parameter in __cmpxchg_local and __cmpxchg
>>
>> Suggested-by: Peter Zijlstra (Intel) 
>> Signed-off-by: Pan Xinhui 
> 
> Generally has the right shape; and I trust others to double check the
> ppc-asm minutia.
> 
> Acked-by: Peter Zijlstra (Intel) 
> 
> 
thanks!

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2] livepatch: Add some basic LivePatch documentation

2016-04-28 Thread Chris J Arges
On Wed, Apr 27, 2016 at 10:08:08PM +0200, Jiri Kosina wrote:
> On Tue, 26 Apr 2016, Chris J Arges wrote:
> 
> [ ... snip ... ]
> > > +  + Kretprobes using the ftrace framework conflict with the patched
> > 
> >  +  + Kretprobes using the ftrace framework conflicts with the patched
> 
> Chris,
> 
> I've incorporated all your feedback except for this one; are you really 
> sure about it? 'kretprobes' is plural form in this sentence, so what's the 
> rationale for your proposed change?
> 
> Thanks,
> 
> -- 
> Jiri Kosina
> SUSE Labs
>

You are correct here; the subject and verb need to agree. Thanks!
--chris
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16

2016-04-28 Thread Pan Xinhui


On 2016年04月27日 22:59, Boqun Feng wrote:
> On Wed, Apr 27, 2016 at 10:50:34PM +0800, Boqun Feng wrote:
>>
>> Sorry, my bad, we can't implement cmpxchg like this.. please ignore
>> this, I should really go to bed soon...
>>
>> But still, we can save the "tmp" for xchg() I think.
>>
> 
> No.. we can't. Sorry for all the noise.
> 
> This patch looks good to me.
> 
> FWIW, you can add
> 
> Acked-by: Boqun Feng 
> 
thanks!

> Regards,
> Boqun
> 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/3] powerpc: Add HAVE_PERF_USER_STACK_DUMP support

2016-04-28 Thread Chandan Kumar
With perf regs support enabled for powerpc, the support for obtaining
perf user stack dump is already enabled.
This patch declares the support for same and also updates documentation
to mark the support for perf-regs and perf-stackdump.

Signed-off-by: Chandan Kumar 
---
 Documentation/features/perf/perf-regs/arch-support.txt  | 2 +-
 Documentation/features/perf/perf-stackdump/arch-support.txt | 2 +-
 arch/powerpc/Kconfig| 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/features/perf/perf-regs/arch-support.txt 
b/Documentation/features/perf/perf-regs/arch-support.txt
index e2b4a78..f179b1f 100644
--- a/Documentation/features/perf/perf-regs/arch-support.txt
+++ b/Documentation/features/perf/perf-regs/arch-support.txt
@@ -27,7 +27,7 @@
 |   nios2: | TODO |
 |openrisc: | TODO |
 |  parisc: | TODO |
-| powerpc: | TODO |
+| powerpc: |  ok  |
 |s390: | TODO |
 |   score: | TODO |
 |  sh: | TODO |
diff --git a/Documentation/features/perf/perf-stackdump/arch-support.txt 
b/Documentation/features/perf/perf-stackdump/arch-support.txt
index 3dc24b0..85777c5 100644
--- a/Documentation/features/perf/perf-stackdump/arch-support.txt
+++ b/Documentation/features/perf/perf-stackdump/arch-support.txt
@@ -27,7 +27,7 @@
 |   nios2: | TODO |
 |openrisc: | TODO |
 |  parisc: | TODO |
-| powerpc: | TODO |
+| powerpc: |  ok  |
 |s390: | TODO |
 |   score: | TODO |
 |  sh: | TODO |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b14966d..a630ac2 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -117,6 +117,7 @@ config PPC
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
+   select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64
select ARCH_WANT_IPC_PARSE_VERSION
-- 
1.9.3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/3] powerpc/perf: Add support for unwinding perf-stackdump

2016-04-28 Thread Chandan Kumar
Adds support for unwinding user stack dump by linking with libunwind.

Signed-off-by: Chandan Kumar 
---
 tools/perf/arch/powerpc/util/Build  |  1 +
 tools/perf/arch/powerpc/util/unwind-libunwind.c | 96 +
 tools/perf/config/Makefile  |  1 +
 3 files changed, 98 insertions(+)
 create mode 100644 tools/perf/arch/powerpc/util/unwind-libunwind.c

diff --git a/tools/perf/arch/powerpc/util/Build 
b/tools/perf/arch/powerpc/util/Build
index 9ee3350..90ad64b 100644
--- a/tools/perf/arch/powerpc/util/Build
+++ b/tools/perf/arch/powerpc/util/Build
@@ -5,3 +5,4 @@ libperf-y += perf_regs.o
 
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
+libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
diff --git a/tools/perf/arch/powerpc/util/unwind-libunwind.c 
b/tools/perf/arch/powerpc/util/unwind-libunwind.c
new file mode 100644
index 000..9e15f92
--- /dev/null
+++ b/tools/perf/arch/powerpc/util/unwind-libunwind.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2016 Chandan Kumar, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include "../../util/unwind.h"
+#include "../../util/debug.h"
+
+int libunwind__arch_reg_id(int regnum)
+{
+   switch (regnum) {
+   case UNW_PPC64_R0:
+   return PERF_REG_POWERPC_R0;
+   case UNW_PPC64_R1:
+   return PERF_REG_POWERPC_R1;
+   case UNW_PPC64_R2:
+   return PERF_REG_POWERPC_R2;
+   case UNW_PPC64_R3:
+   return PERF_REG_POWERPC_R3;
+   case UNW_PPC64_R4:
+   return PERF_REG_POWERPC_R4;
+   case UNW_PPC64_R5:
+   return PERF_REG_POWERPC_R5;
+   case UNW_PPC64_R6:
+   return PERF_REG_POWERPC_R6;
+   case UNW_PPC64_R7:
+   return PERF_REG_POWERPC_R7;
+   case UNW_PPC64_R8:
+   return PERF_REG_POWERPC_R8;
+   case UNW_PPC64_R9:
+   return PERF_REG_POWERPC_R9;
+   case UNW_PPC64_R10:
+   return PERF_REG_POWERPC_R10;
+   case UNW_PPC64_R11:
+   return PERF_REG_POWERPC_R11;
+   case UNW_PPC64_R12:
+   return PERF_REG_POWERPC_R12;
+   case UNW_PPC64_R13:
+   return PERF_REG_POWERPC_R13;
+   case UNW_PPC64_R14:
+   return PERF_REG_POWERPC_R14;
+   case UNW_PPC64_R15:
+   return PERF_REG_POWERPC_R15;
+   case UNW_PPC64_R16:
+   return PERF_REG_POWERPC_R16;
+   case UNW_PPC64_R17:
+   return PERF_REG_POWERPC_R17;
+   case UNW_PPC64_R18:
+   return PERF_REG_POWERPC_R18;
+   case UNW_PPC64_R19:
+   return PERF_REG_POWERPC_R19;
+   case UNW_PPC64_R20:
+   return PERF_REG_POWERPC_R20;
+   case UNW_PPC64_R21:
+   return PERF_REG_POWERPC_R21;
+   case UNW_PPC64_R22:
+   return PERF_REG_POWERPC_R22;
+   case UNW_PPC64_R23:
+   return PERF_REG_POWERPC_R23;
+   case UNW_PPC64_R24:
+   return PERF_REG_POWERPC_R24;
+   case UNW_PPC64_R25:
+   return PERF_REG_POWERPC_R25;
+   case UNW_PPC64_R26:
+   return PERF_REG_POWERPC_R26;
+   case UNW_PPC64_R27:
+   return PERF_REG_POWERPC_R27;
+   case UNW_PPC64_R28:
+   return PERF_REG_POWERPC_R28;
+   case UNW_PPC64_R29:
+   return PERF_REG_POWERPC_R29;
+   case UNW_PPC64_R30:
+   return PERF_REG_POWERPC_R30;
+   case UNW_PPC64_R31:
+   return PERF_REG_POWERPC_R31;
+   case UNW_PPC64_LR:
+   return PERF_REG_POWERPC_LINK;
+   case UNW_PPC64_CTR:
+   return PERF_REG_POWERPC_CTR;
+   case UNW_PPC64_XER:
+   return PERF_REG_POWERPC_XER;
+   case UNW_PPC64_NIP:
+   return PERF_REG_POWERPC_NIP;
+   default:
+   pr_err("unwind: invalid reg id %d\n", regnum);
+   return -EINVAL;
+   }
+   return -EINVAL;
+}
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index eda1cfb..220536c 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -26,6 +26,7 @@ NO_PERF_REGS := 1
 # Additional ARCH settings for ppc
 ifeq ($(ARCH),powerpc)
   NO_PERF_REGS := 0
+  LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
 endif
 
 # Additional ARCH settings for x86
-- 
1.9.3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 3/3] perf tools: Fix perf regs mask generation

2016-04-28 Thread Chandan Kumar
From: "Naveen N. Rao" 

On some architectures (powerpc in particular), the number of registers
exceeds what can be represented in an integer bitmask. Ensure we
generate the proper bitmask on such platforms.

Fixes: 71ad0f5e4 ("perf tools: Support for DWARF CFI unwinding on post
processing")

Signed-off-by: Naveen N. Rao 
---
 tools/perf/util/perf_regs.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
index 6b8eb13..c4023f2 100644
--- a/tools/perf/util/perf_regs.c
+++ b/tools/perf/util/perf_regs.c
@@ -12,18 +12,18 @@ int perf_reg_value(u64 *valp, struct regs_dump *regs, int 
id)
int i, idx = 0;
u64 mask = regs->mask;
 
-   if (regs->cache_mask & (1 << id))
+   if (regs->cache_mask & (1ULL << id))
goto out;
 
-   if (!(mask & (1 << id)))
+   if (!(mask & (1ULL << id)))
return -EINVAL;
 
for (i = 0; i < id; i++) {
-   if (mask & (1 << i))
+   if (mask & (1ULL << i))
idx++;
}
 
-   regs->cache_mask |= (1 << id);
+   regs->cache_mask |= (1ULL << id);
regs->cache_regs[id] = regs->regs[idx];
 
 out:
-- 
1.9.3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 0/3] Add support for perf user stack dump in powerpc

2016-04-28 Thread Chandan Kumar
This patch set enables perf user stack dump on powerpc

Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls

./perf script
-8< -
..
...
perf 12549 75938.934539:   1771 cycles:ppp: 
  210d90 .perf_event_exec (/boot/vmlinux)
  34b914 .load_elf_binary (/boot/vmlinux)
  2dcabc .search_binary_handler (/boot/vmlinux)
  2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
  2ddcd8 .sys_execve (/boot/vmlinux)
   19258 system_call (/boot/vmlinux)

perf 12549 75938.934549:   8415 cycles:ppp: 
  207a88 .perf_event_aux_ctx (/boot/vmlinux)
   0 [unknown] ([unknown])
  214ab8 .perf_event_comm (/boot/vmlinux)
  2dcfb8 .__set_task_comm (/boot/vmlinux)
  2ddb44 .setup_new_exec (/boot/vmlinux)
  34b914 .load_elf_binary (/boot/vmlinux)
  2dcabc .search_binary_handler (/boot/vmlinux)
  2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
  2ddcd8 .sys_execve (/boot/vmlinux)
   19258 system_call (/boot/vmlinux)

ls 12549 75938.934562:  33745 cycles:ppp: 
   ee570 .task_work_add (/boot/vmlinux)
   0 [unknown] ([unknown])
  2ce380 .filp_close (/boot/vmlinux)
  2fc464 .do_close_on_exec (/boot/vmlinux)
  2ddbd8 .setup_new_exec (/boot/vmlinux)
  34b914 .load_elf_binary (/boot/vmlinux)
  2dcabc .search_binary_handler (/boot/vmlinux)
  2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
  2ddcd8 .sys_execve (/boot/vmlinux)
   19258 system_call (/boot/vmlinux)

ls 12549 75938.934587: 116078 cycles:ppp: 
   6ff94 .__clear_user (/boot/vmlinux)
  944400 .padzero ([kernel.vmlinux].text.unlikely)
  34bd28 .load_elf_binary (/boot/vmlinux)
  2dcabc .search_binary_handler (/boot/vmlinux)
  2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
  2ddcd8 .sys_execve (/boot/vmlinux)
   19258 system_call (/boot/vmlinux)
...
..
- 8< -

Chandan Kumar (2):
  powerpc: Add HAVE_PERF_USER_STACK_DUMP support
  powerpc/perf: Add support for unwinding perf-stackdump

Naveen N. Rao (1):
  perf tools: Fix perf regs mask generation

 .../features/perf/perf-regs/arch-support.txt   |  2 +-
 .../features/perf/perf-stackdump/arch-support.txt  |  2 +-
 arch/powerpc/Kconfig   |  1 +
 tools/perf/arch/powerpc/util/Build |  1 +
 tools/perf/arch/powerpc/util/unwind-libunwind.c| 96 ++
 tools/perf/config/Makefile |  1 +
 tools/perf/util/perf_regs.c|  8 +-
 7 files changed, 105 insertions(+), 6 deletions(-)
 create mode 100644 tools/perf/arch/powerpc/util/unwind-libunwind.c

-- 
1.9.3

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 13/16] char/genrtc: remove powerpc support

2016-04-28 Thread Arnd Bergmann
On Thursday 28 April 2016 09:25:25 Geert Uytterhoeven wrote:
> On Thu, Apr 28, 2016 at 12:34 AM, Arnd Bergmann  wrote:
> > --- a/arch/powerpc/platforms/Kconfig
> > +++ b/arch/powerpc/platforms/Kconfig
> > @@ -321,6 +321,17 @@ config OF_RTC
> >   Uses information from the OF or flattened device tree to 
> > instantiate
> >   platform devices for direct mapped RTC chips like the DS1742 or 
> > DS1743.
> >
> > +config GEN_RTC
> > +   bool "Use the platform RTC operations from user space"
> > +   select RTC_CLASS
> > +   select RTC_DRV_GENERIC
> > +   help
> > + This option provides backwards compatibility with the old 
> > gen_rtc.ko
> > + module that was traditionally used for old PowerPC machines.
> > + Platforms should migrate to enabling the RTC_DRV_GENERIC by hand
> > + replacing changing their get_rtc_time/set_rtc_time callbacks with
> 
> Drop "changing".
> 
> 

done, thanks!

Arnd
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 04/16] rtc: sh: provide rtc_class_ops directly

2016-04-28 Thread Arnd Bergmann
On Thursday 28 April 2016 11:08:41 Arnd Bergmann wrote:
> I only see two of them anyway (dreamcast and sh03), so that should
> be easy enough to do. For instance in arch/sh/boards/mach-sh03/rtc.c,
> the sh03_time_init() function should register a platform driver,
> whose probe function calls devm_rtc_device_register() to register
> with the rtc subsystem. Then you move the entire file to drivers/rtc/
> and change the callers of sh03_time_init() to create the device
> manually (for the classic board file) or drop it (for DT).

Just FYI:

Another look at the sh03_rtc_settimeofday function shows that it's
always been wrong: unlike the set_mmss() function it calls, it should
set all the time fields, not just minutes and seconds.

Arnd
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc: Define and use PPC_ELF_ABI_v2

2016-04-28 Thread Michael Ellerman
We're approaching 20 locations where we need to check for ELF ABI v2.
That's fine, except the logic is a bit awkward, because we have to check
that _CALL_ELF is defined and then what its value is.

So check it once in asm/types.h and define PPC_ELF_ABI_v2 when ELF ABI
v2 is detected.

We don't add explicit includes of asm/types.h because it's included
basically everywhere via compiler.h.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/code-patching.h | 6 +++---
 arch/powerpc/include/asm/ftrace.h| 2 +-
 arch/powerpc/include/asm/kprobes.h   | 4 ++--
 arch/powerpc/include/asm/linkage.h   | 2 +-
 arch/powerpc/include/asm/ppc_asm.h   | 4 ++--
 arch/powerpc/include/asm/ptrace.h| 2 +-
 arch/powerpc/include/asm/sections.h  | 2 +-
 arch/powerpc/include/asm/types.h | 4 
 arch/powerpc/kernel/entry_64.S   | 2 +-
 arch/powerpc/kernel/head_64.S| 2 +-
 arch/powerpc/kernel/kprobes.c| 2 +-
 arch/powerpc/kernel/misc_64.S| 2 +-
 arch/powerpc/kernel/module_64.c  | 4 ++--
 arch/powerpc/kvm/book3s_interrupts.S | 2 +-
 arch/powerpc/kvm/book3s_rmhandlers.S | 2 +-
 15 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/include/asm/code-patching.h 
b/arch/powerpc/include/asm/code-patching.h
index 994c60a857ce..d325b35315d3 100644
--- a/arch/powerpc/include/asm/code-patching.h
+++ b/arch/powerpc/include/asm/code-patching.h
@@ -50,7 +50,7 @@ void __patch_exception(int exc, unsigned long addr);
 static inline unsigned long ppc_function_entry(void *func)
 {
 #if defined(CONFIG_PPC64)
-#if defined(_CALL_ELF) && _CALL_ELF == 2
+#ifdef PPC_ELF_ABI_v2
u32 *insn = func;
 
/*
@@ -90,7 +90,7 @@ static inline unsigned long ppc_function_entry(void *func)
 
 static inline unsigned long ppc_global_function_entry(void *func)
 {
-#if defined(CONFIG_PPC64) && defined(_CALL_ELF) && _CALL_ELF == 2
+#if defined(CONFIG_PPC64) && defined(PPC_ELF_ABI_v2)
/* PPC64 ABIv2 the global entry point is at the address */
return (unsigned long)func;
 #else
@@ -106,7 +106,7 @@ static inline unsigned long ppc_global_function_entry(void 
*func)
  */
 
 /* This must match the definition of STK_GOT in  */
-#if defined(_CALL_ELF) && _CALL_ELF == 2
+#ifdef PPC_ELF_ABI_v2
 #define R2_STACK_OFFSET 24
 #else
 #define R2_STACK_OFFSET 40
diff --git a/arch/powerpc/include/asm/ftrace.h 
b/arch/powerpc/include/asm/ftrace.h
index 50ca7585abe2..0b0bfcaa587a 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -66,7 +66,7 @@ struct dyn_arch_ftrace {
 #endif
 
 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && 
!defined(__ASSEMBLY__)
-#if !defined(_CALL_ELF) || _CALL_ELF != 2
+#ifdef PPC_ELF_ABI_v2
 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
 static inline bool arch_syscall_match_sym_name(const char *sym, const char 
*name)
 {
diff --git a/arch/powerpc/include/asm/kprobes.h 
b/arch/powerpc/include/asm/kprobes.h
index 039b583db029..f905c908533f 100644
--- a/arch/powerpc/include/asm/kprobes.h
+++ b/arch/powerpc/include/asm/kprobes.h
@@ -41,7 +41,7 @@ typedef ppc_opcode_t kprobe_opcode_t;
 #define MAX_INSN_SIZE 1
 
 #ifdef CONFIG_PPC64
-#if defined(_CALL_ELF) && _CALL_ELF == 2
+#ifdef PPC_ELF_ABI_v2
 /* PPC64 ABIv2 needs local entry point */
 #define kprobe_lookup_name(name, addr) \
 {  \
@@ -92,7 +92,7 @@ typedef ppc_opcode_t kprobe_opcode_t;
addr = (kprobe_opcode_t *)kallsyms_lookup_name(name);   \
}   \
 }
-#endif /* defined(_CALL_ELF) && _CALL_ELF == 2 */
+#endif /* PPC_ELF_ABI_v2 */
 #endif /* CONFIG_PPC64 */
 
 #define flush_insn_slot(p) do { } while (0)
diff --git a/arch/powerpc/include/asm/linkage.h 
b/arch/powerpc/include/asm/linkage.h
index e3ad5c72724a..4f04b6c400cf 100644
--- a/arch/powerpc/include/asm/linkage.h
+++ b/arch/powerpc/include/asm/linkage.h
@@ -2,7 +2,7 @@
 #define _ASM_POWERPC_LINKAGE_H
 
 #ifdef CONFIG_PPC64
-#if !defined(_CALL_ELF) || _CALL_ELF != 2
+#ifndef PPC_ELF_ABI_v2
 #define cond_syscall(x) \
asm ("\t.weak " #x "\n\t.set " #x ", sys_ni_syscall\n"  \
 "\t.weak ." #x "\n\t.set ." #x ", .sys_ni_syscall\n")
diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index 499d9f89435a..e179780ee47a 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -189,7 +189,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 #define __STK_REG(i)   (112 + ((i)-14)*8)
 #define STK_REG(i) __STK_REG(__REG_##i)
 
-#if defined(_CALL_ELF) && _CALL_ELF == 2
+#ifdef PPC_ELF_ABI_v2
 #define STK_GOT24
 #define __STK_PARAM(i) (32 + ((i)-3)*8)
 #else
@@ -198,7 +198,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 #endif
 #define STK_PARAM(i)   __STK_PA

Re: [PATCH v3 04/16] rtc: sh: provide rtc_class_ops directly

2016-04-28 Thread Arnd Bergmann
On Wednesday 27 April 2016 19:21:22 Rich Felker wrote:
> On Thu, Apr 28, 2016 at 12:34:18AM +0200, Arnd Bergmann wrote:
> > The rtc-generic driver provides an architecture specific
> > wrapper on top of the generic rtc_class_ops abstraction,
> > and on sh, that goes through another indirection using
> > the rtc_sh_get_time/rtc_sh_set_time functions.
> > 
> > This changes the sh rtc-generic device to provide its
> > rtc_class_ops directly, skipping one of the abstraction
> > levels.
> > 
> > Signed-off-by: Arnd Bergmann 
> 
> Looks ok in principle. Have you tested that it builds? 

I think I build tested version 1, but not the current version.

> > diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
> > index d6d0a986c6e9..92cd676970d9 100644
> > --- a/arch/sh/kernel/time.c
> > +++ b/arch/sh/kernel/time.c
> > @@ -50,27 +50,30 @@ int update_persistent_clock(struct timespec now)
> >  }
> >  #endif
> >  
> > -unsigned int get_rtc_time(struct rtc_time *tm)
> > +static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
> >  {
> > -   if (rtc_sh_get_time != null_rtc_get_time) {
> 
> This seems like a functional change -- whereas previously the
> null_rtc_get_time case left *tm unchanged, now the function gets
> called and junk gets filled in. Is that desired?

I dropped the check because it duplicates the check in rtc_generic_init()
below it: the old genrtc driver needed the check in get_rtc_time()
because it would call that function unconditionally, but with the
rtc-generic driver, we know that we only ever call this after
registering the device successfully.

> > -   struct timespec tv;
> > +   struct timespec tv;
> >  
> > -   rtc_sh_get_time(&tv);
> > -   rtc_time_to_tm(tv.tv_sec, tm);
> > -   }
> > -
> > -   return RTC_24H;
> > +   rtc_sh_get_time(&tv);
> > +   rtc_time_to_tm(tv.tv_sec, tm);
> > +   return 0;
> 
> Also the return value is changed. Is this correct?

Yes: again, the genrtc driver had obscure calling conventions requiring
RTC_24H to be returned on success, while the rtc-generic driver uses
the normal kernel coding style of using 0 for success.

Previously, this function was used to convert from get_rtc_time()
calling conventions (without a device) to the normal rtc_class_ops:

static int generic_get_time(struct device *dev, struct rtc_time *tm)
{
   unsigned int ret = get_rtc_time(tm);

   if (ret & RTC_BATT_BAD)
   return -EOPNOTSUPP;

   return rtc_valid_tm(tm);
}

> >  }
> > -EXPORT_SYMBOL(get_rtc_time);
> >  
> > -int set_rtc_time(struct rtc_time *tm)
> > +static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
> >  {
> > unsigned long secs;
> >  
> > rtc_tm_to_time(tm, &secs);
> > -   return rtc_sh_set_time(secs);
> > +   if (!rtc_sh_set_time || rtc_sh_set_time(secs) < 0)
> > +   return -EOPNOTSUPP;
> > +
> > +   return 0;
> >  }
> > -EXPORT_SYMBOL(set_rtc_time);
> 
> Why checking rtc_sh_set_time for a null pointer? null_rtc_set_time is
> not a null pointer but a dummy function that's always safe to call, I
> think.

You are right, it should check for null_rtc_set_time instead, I probably
copied it from powerpc, which does this a bit differently.

Actually calling null_rtc_set_time however would be (slightly) wrong here,
because we want to return an error to user space if we try to set a
read-only rtc.

> > +static const struct rtc_class_ops rtc_generic_ops = {
> > +   .read_time = rtc_generic_get_time,
> > +   .set_time = rtc_generic_set_time,
> > +};
> >  
> >  static int __init rtc_generic_init(void)
> >  {
> > @@ -79,7 +82,10 @@ static int __init rtc_generic_init(void)
> > if (rtc_sh_get_time == null_rtc_get_time)
> > return -ENODEV;
> >  
> > -   pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
> > +   pdev = platform_device_register_data(NULL, "rtc-generic", -1,
> > +&rtc_generic_ops,
> > +sizeof(rtc_generic_ops));
> > +
> 
> Not a complaint about your patch, but I'd like to get rid of this
> platform device and abstraction layer completely since it doesn't seem
> like something that can be modeled correctly in device tree. When
> you're done cleaning this up, will it be possible to just have rtc
> drivers that use whatever generic framework is left, where the right
> driver is automatically attached to compatible DT nodes? I'm trying to
> move all of arch/sh over to device tree and remove hard-coded platform
> devices.

Yes, I think that would be great. When an rtc driver is registered, you
don't actually need the read_persistent_clock/update_persistent_clock
functions (there are __weak versions of them that do nothing and cause
a fallback to calling into the rtc subsystem), so you can replace
the rtc_sh_get_time/rtc_sh_set_time with proper drivers one at a time.

I only see two of them anyway (dreamcast and sh03), so that should
be easy enough to do. For instance in a

Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16

2016-04-28 Thread Peter Zijlstra
On Wed, Apr 27, 2016 at 05:16:45PM +0800, Pan Xinhui wrote:
> From: Pan Xinhui 
> 
> Implement xchg{u8,u16}{local,relaxed}, and
> cmpxchg{u8,u16}{,local,acquire,relaxed}.
> 
> It works on all ppc.
> 
> remove volatile of first parameter in __cmpxchg_local and __cmpxchg
> 
> Suggested-by: Peter Zijlstra (Intel) 
> Signed-off-by: Pan Xinhui 

Generally has the right shape; and I trust others to double check the
ppc-asm minutia.

Acked-by: Peter Zijlstra (Intel) 


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc: Add out of bounds check to crash_shutdown_unregister()

2016-04-28 Thread Balbir Singh
> 
> Thanks for taking a look Balbir, the size of crash_shutdown_handles is
> actually CRASH_HANDLER_MAX+1.
> 

Acked-by: Balbir Singh 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: error while trying to compile linux kernel with powerpc arch

2016-04-28 Thread Joel Stanley
Hello,

On Thu, Apr 28, 2016 at 2:13 AM, Marwa Hamza  wrote:
> hello
> every time i try to compile the linux kernel with arch=powerpc i got this
> error
>
> WRAP arch / powerpc / boot / zImage.pseries
> powerpc-linux-gnu-ld: unrecognized emulation mode: -T
> Emulations supported: elf32ppclinux elf32ppc elf32ppcsim elf64ppc elf32_spu
> make [1]: *** [arch / powerpc / boot / zImage.pseries] Error 1
> make: *** [zImage] Error 2
>
> im using powerpc-linux-gnu ( sudo apt-get install powerpc-linux-gnu)  and
> linux-4.4.1
> make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  pseries_defconfig
> make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
> ubuntu 14.04
> any suggestion ?

You need a 64 bit compiler, as the pseries configuration is for a 64
bit machine.

$ head -n1 arch/powerpc/configs/pseries_defconfig
CONFIG_PPC64=y

'apt-get install gcc-powerpc64-linux-gnu' should do the trick. Set
CROSS_COMPILE=powerpc64-linux-gnu- and you will be good to go.

Cheers,

Joel
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 00/16] genrtc removal

2016-04-28 Thread Geert Uytterhoeven
On Thu, Apr 28, 2016 at 12:34 AM, Arnd Bergmann  wrote:
> I ended up stuffing the two patch series into one, as they are now
> more dependent on one another. This now thoroughly removes the
> genrtc driver including the asm/rtc.h headers it uses. For all
> architectures that still have a meaningful asm/rtc.h, this goes
> through two stages:
>
> 1) make the rtc-generic implementation independent of asm/rtc.h
> 2) remove the asm/rtc.h header and disallow the gen_rtc driver
>
> As the last step, the driver itself gets removed.

In general, after fixing the minor nit:
Acked-by: Geert Uytterhoeven 

For the m68k bits:
Tested-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 13/16] char/genrtc: remove powerpc support

2016-04-28 Thread Geert Uytterhoeven
On Thu, Apr 28, 2016 at 12:34 AM, Arnd Bergmann  wrote:
> --- a/arch/powerpc/platforms/Kconfig
> +++ b/arch/powerpc/platforms/Kconfig
> @@ -321,6 +321,17 @@ config OF_RTC
>   Uses information from the OF or flattened device tree to instantiate
>   platform devices for direct mapped RTC chips like the DS1742 or 
> DS1743.
>
> +config GEN_RTC
> +   bool "Use the platform RTC operations from user space"
> +   select RTC_CLASS
> +   select RTC_DRV_GENERIC
> +   help
> + This option provides backwards compatibility with the old gen_rtc.ko
> + module that was traditionally used for old PowerPC machines.
> + Platforms should migrate to enabling the RTC_DRV_GENERIC by hand
> + replacing changing their get_rtc_time/set_rtc_time callbacks with

Drop "changing".

> + a proper RTC device driver.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 04/16] rtc: sh: provide rtc_class_ops directly

2016-04-28 Thread Geert Uytterhoeven
Hi Rich,

On Thu, Apr 28, 2016 at 1:21 AM, Rich Felker  wrote:
> Not a complaint about your patch, but I'd like to get rid of this
> platform device and abstraction layer completely since it doesn't seem
> like something that can be modeled correctly in device tree. When
> you're done cleaning this up, will it be possible to just have rtc
> drivers that use whatever generic framework is left, where the right
> driver is automatically attached to compatible DT nodes? I'm trying to
> move all of arch/sh over to device tree and remove hard-coded platform
> devices.

If you describe the RTC in DT, it can bound to a hardware-specific driver
in drivers/rtc/rtc-*.c.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc: Add out of bounds check to crash_shutdown_unregister()

2016-04-28 Thread Suraj Jitindar Singh
On Thu, 28 Apr 2016 16:55:13 +1000
Balbir Singh  wrote:

> On 28/04/16 16:17, Suraj Jitindar Singh wrote:
> > When unregistering a crash_shutdown_handle in the function
> > crash_shutdown_unregister() the other handles are shifted down in
> > the array to replace the unregistered handle. The for loop assumes
> > that the last element in the array is null and uses this as the
> > stop condition, however in the case that the last element is not
> > null there is no check to ensure that an out of bounds access is
> > not performed.
> > 
> > Add a check to terminate the shift operation when CRASH_HANDLER_MAX
> > is reached in order to protect against out of bounds accesses.
> > 
> > Signed-off-by: Suraj Jitindar Singh 
> > ---
> >  arch/powerpc/kernel/crash.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/kernel/crash.c
> > b/arch/powerpc/kernel/crash.c index 2bb252c..6b267af 100644
> > --- a/arch/powerpc/kernel/crash.c
> > +++ b/arch/powerpc/kernel/crash.c
> > @@ -288,7 +288,7 @@ int crash_shutdown_unregister(crash_shutdown_t
> > handler) rc = 1;
> > } else {
> > /* Shift handles down */
> > -   for (; crash_shutdown_handles[i]; i++)
> > +   for (; crash_shutdown_handles[i] && i <
> > CRASH_HANDLER_MAX; i++) crash_shutdown_handles[i] =
> > crash_shutdown_handles[i+1];
> > rc = 0;
> >   
> 
> with i = CRASH_HANDLER_MAX-1 we could end up with
> crash_shutdown_handles[i+1] already out of bounds I think you need to
> check that i+1 does not overflow
> 
> Balbir

Thanks for taking a look Balbir, the size of crash_shutdown_handles is
actually CRASH_HANDLER_MAX+1.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH V3 2/2] powerpc/drivers: Add driver for operator panel on FSP machines

2016-04-28 Thread Suraj Jitindar Singh
Implement new character device driver to allow access from user space
to the 2x16 character operator panel display present on IBM Power Systems
machines with FSPs.

This will allow status information to be presented on the display which
is visible to a user.

The driver implements a 32 character buffer which a user can read/write
by accessing the device (/dev/oppanel). This buffer is then displayed on
the operator panel display. Any attempt to write past the 32nd position
will have no effect and attempts to write more than 32 characters will be
truncated. The device may only be accessed by a single process at a time.

Signed-off-by: Suraj Jitindar Singh 
Reviewed-by: Andrew Donnellan 

---

Change Log:

V1 -> V2:
- Replace "IBM pSeries machines" with "IBM Power Systems machines
with FSPs" for improved clarity
- Basic wording/grammar fixes
V2 -> V3:
- Nothing
---
 MAINTAINERS|   6 +
 arch/powerpc/configs/powernv_defconfig |   1 +
 arch/powerpc/include/asm/opal.h|   2 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 arch/powerpc/platforms/powernv/opal.c  |   5 +
 drivers/char/Kconfig   |  14 ++
 drivers/char/Makefile  |   1 +
 drivers/char/op-panel-powernv.c| 247 +
 8 files changed, 277 insertions(+)
 create mode 100644 drivers/char/op-panel-powernv.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 40eb1db..dbacb12 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8817,6 +8817,12 @@ F:   drivers/firmware/psci.c
 F: include/linux/psci.h
 F: include/uapi/linux/psci.h
 
+POWERNV OPERATOR PANEL LCD DISPLAY DRIVER
+M: Suraj Jitindar Singh 
+L: linuxppc-dev@lists.ozlabs.org
+S: Maintained
+F: drivers/char/op-panel-powernv.c
+
 PNP SUPPORT
 M: "Rafael J. Wysocki" 
 S: Maintained
diff --git a/arch/powerpc/configs/powernv_defconfig 
b/arch/powerpc/configs/powernv_defconfig
index 0450310..8f9f4ce 100644
--- a/arch/powerpc/configs/powernv_defconfig
+++ b/arch/powerpc/configs/powernv_defconfig
@@ -181,6 +181,7 @@ CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_JSM=m
 CONFIG_VIRTIO_CONSOLE=m
+CONFIG_IBM_OP_PANEL=m
 CONFIG_IPMI_HANDLER=y
 CONFIG_IPMI_DEVICE_INTERFACE=y
 CONFIG_IPMI_POWERNV=y
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 9d86c66..b33e349 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -178,6 +178,8 @@ int64_t opal_dump_ack(uint32_t dump_id);
 int64_t opal_dump_resend_notification(void);
 
 int64_t opal_get_msg(uint64_t buffer, uint64_t size);
+int64_t opal_write_oppanel_async(uint64_t token, oppanel_line_t *lines,
+   uint64_t num_lines);
 int64_t opal_check_completion(uint64_t buffer, uint64_t size, uint64_t token);
 int64_t opal_sync_host_reboot(void);
 int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer,
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index e45b88a..ddba8bf 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -278,6 +278,7 @@ OPAL_CALL(opal_dump_info2,  
OPAL_DUMP_INFO2);
 OPAL_CALL(opal_dump_read,  OPAL_DUMP_READ);
 OPAL_CALL(opal_dump_ack,   OPAL_DUMP_ACK);
 OPAL_CALL(opal_get_msg,OPAL_GET_MSG);
+OPAL_CALL(opal_write_oppanel_async,OPAL_WRITE_OPPANEL_ASYNC);
 OPAL_CALL(opal_check_completion,   OPAL_CHECK_ASYNC_COMPLETION);
 OPAL_CALL(opal_dump_resend_notification,   OPAL_DUMP_RESEND);
 OPAL_CALL(opal_sync_host_reboot,   OPAL_SYNC_HOST_REBOOT);
diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index 0256d07..228751a 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -751,6 +751,9 @@ static int __init opal_init(void)
opal_pdev_init(opal_node, "ibm,opal-flash");
opal_pdev_init(opal_node, "ibm,opal-prd");
 
+   /* Initialise platform device: oppanel interface */
+   opal_pdev_init(opal_node, "ibm,opal-oppanel");
+
/* Initialise OPAL kmsg dumper for flushing console on panic */
opal_kmsg_init();
 
@@ -885,3 +888,5 @@ EXPORT_SYMBOL_GPL(opal_i2c_request);
 /* Export these symbols for PowerNV LED class driver */
 EXPORT_SYMBOL_GPL(opal_leds_get_ind);
 EXPORT_SYMBOL_GPL(opal_leds_set_ind);
+/* Export this symbol for PowerNV Operator Panel class driver */
+EXPORT_SYMBOL_GPL(opal_write_oppanel_async);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 3ec0766..c1d354d 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -178,6 +178,20 @@ config IBM_BSR
  of threads across a large system which avoids bouncing a cachel

[PATCH V3 1/2] devicetree/bindings: Add binding for operator panel on FSP machines

2016-04-28 Thread Suraj Jitindar Singh
Add a binding to Documentation/devicetree/bindings/powerpc/opal
(oppanel-opal.txt) for the operator panel which is present on IBM
Power Systems machines with FSPs.

Signed-off-by: Suraj Jitindar Singh 
Acked-by: Rob Herring 
Acked-by: Stewart Smith 

---

Change Log:

V1 -> V2:
- Nothing
V2 -> V3:
- Change "IBM pseries machines" to "IBM Power Systems machines"
in the commit message for improved clarity.
---
 .../devicetree/bindings/powerpc/opal/oppanel-opal.txt  | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/powerpc/opal/oppanel-opal.txt

diff --git a/Documentation/devicetree/bindings/powerpc/opal/oppanel-opal.txt 
b/Documentation/devicetree/bindings/powerpc/opal/oppanel-opal.txt
new file mode 100644
index 000..dffb791
--- /dev/null
+++ b/Documentation/devicetree/bindings/powerpc/opal/oppanel-opal.txt
@@ -0,0 +1,14 @@
+IBM OPAL Operator Panel Binding
+---
+
+Required properties:
+- compatible : Should be "ibm,opal-oppanel".
+- #lines : Number of lines on the operator panel e.g. <0x2>.
+- #length: Number of characters per line of the operator panel e.g. <0x10>.
+
+Example:
+   oppanel {
+   compatible = "ibm,opal-oppanel";
+   #lines = <0x2>;
+   #length = <0x10>;
+   };
-- 
2.5.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev