Re: [PATCH 1/3] powerpc/pseries: Simplify check for suspendability during suspend/migration

2015-03-04 Thread Nathan Fontenot
On 03/03/2015 02:16 PM, Tyrel Datwyler wrote:
 On 03/02/2015 10:15 PM, Michael Ellerman wrote:
 On Mon, 2015-03-02 at 13:30 -0800, Tyrel Datwyler wrote:
 On 03/01/2015 08:19 PM, Cyril Bur wrote:
 On Fri, 2015-02-27 at 18:24 -0800, Tyrel Datwyler wrote:
 During suspend/migration operation we must wait for the VASI state 
 reported
 by the hypervisor to become Suspending prior to making the ibm,suspend-me
 RTAS call. Calling routines to rtas_ibm_supend_me() pass a vasi_state 
 variable
 that exposes the VASI state to the caller. This is unnecessary as the 
 caller
 only really cares about the following three conditions; if there is an 
 error
 we should bailout, success indicating we have suspended and woken back up 
 so
 proceed to device tree updated, or we are not suspendable yet so try 
 calling
 rtas_ibm_suspend_me again shortly.

 This patch removes the extraneous vasi_state variable and simply uses the
 return code to communicate how to proceed. We either succeed, fail, or get
 -EAGAIN in which case we sleep for a second before trying to call
 rtas_ibm_suspend_me again.

   u64 handle = ((u64)be32_to_cpu(args.args[0])  32)
 | be32_to_cpu(args.args[1]);
 - rc = rtas_ibm_suspend_me(handle, vasi_rc);
 - args.rets[0] = cpu_to_be32(vasi_rc);
 - if (rc)
 + rc = rtas_ibm_suspend_me(handle);
 + if (rc == -EAGAIN)
 + args.rets[0] = cpu_to_be32(RTAS_NOT_SUSPENDABLE);

 (continuing on...) so perhaps here have
rc = 0;
 else if (rc == -EIO)
args.rets[0] = cpu_to_be32(-1);
rc = 0;
 Which should keep the original behaviour, the last thing we want to do
 is break BE.

 The biggest problem here is we are making what basically equates to a
 fake rtas call from drmgr which we intercept in ppc_rtas(). From there
 we make this special call to rtas_ibm_suspend_me() to check VASI state
 and do a bunch of other specialized work that needs to be setup prior to
 making the actual ibm,suspend-me rtas call. Since, we are cheating PAPR
 here I guess we can really handle it however we want. I chose to simply
 fail the rtas call in the case where rtas_ibm_suspend_me() fails with
 something other than -EAGAIN. In user space librtas will log errno for
 the failure and return RTAS_IO_ASSERT to drmgr which in turn will log
 that error and fail.

 We don't want to change the return values of the syscall unless we absolutely
 have to. And I don't think that's the case here.
 
 I'd like to argue that the one case I changed makes sense, but its just
 as easy to keep the original behavior.
 

 Sure we think drmgr is the only thing that uses this crap, but we don't know
 for sure.
 
 I can't imagine how anybody else could possibly use this hack without a
 streamid from the hmc/hypervisor, but I've been wrong in the past more
 times than I can count. :)

Correct, this will fail if called with a random streamid. The streamid has
to match what is handed to us from the HMC when a migration request is
initiated.

-Nathan
 
 
 -Tyrel
 

 cheers


 

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

Re: [PATCH V3] powerpc/85xx: workaround for chips with MSI hardware errata

2015-03-04 Thread Scott Wood
On Wed, 2015-03-04 at 00:44 -0600, Jia Hongtao-B38951 wrote:
 Hi Scott,
 
 I sent V3 of this patch a few days ago.
 Comments are welcome.

Patience is welcome. :-)

-Scott


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

[Patch v2] powerpc/pseries: Little endian fixes for post mobility device tree update

2015-03-04 Thread Tyrel Datwyler
We currently use the device tree update code in the kernel after resuming
from a suspend operation to re-sync the kernels view of the device tree with
that of the hypervisor. The code as it stands is not endian safe as it relies
on parsing buffers returned by RTAS calls that thusly contains data in big
endian format.

This patch annotates variables and structure members with __be types as well
as performing necessary byte swaps to cpu endian for data that needs to be
parsed.

Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com
Cc: Nathan Fontenot nf...@linux.vnet.ibm.com
Cc: Cyril Bur cyril...@gmail.com
Cc: sta...@vger.kernel.org
---

Changes in v2:
- Addresed Cyril's comments as follows:
- Added __be32 annotation to phandle parameter of delete_dt_node()
- Byte swapped phandle to cpu endian for of_find_node_by_phandle()

 arch/powerpc/platforms/pseries/mobility.c | 44 ---
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/mobility.c 
b/arch/powerpc/platforms/pseries/mobility.c
index 90cf3dc..8f35d52 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -25,10 +25,10 @@
 static struct kobject *mobility_kobj;
 
 struct update_props_workarea {
-   u32 phandle;
-   u32 state;
-   u64 reserved;
-   u32 nprops;
+   __be32 phandle;
+   __be32 state;
+   __be64 reserved;
+   __be32 nprops;
 } __packed;
 
 #define NODE_ACTION_MASK   0xff00
@@ -54,11 +54,11 @@ static int mobility_rtas_call(int token, char *buf, s32 
scope)
return rc;
 }
 
-static int delete_dt_node(u32 phandle)
+static int delete_dt_node(__be32 phandle)
 {
struct device_node *dn;
 
-   dn = of_find_node_by_phandle(phandle);
+   dn = of_find_node_by_phandle(be32_to_cpu(phandle));
if (!dn)
return -ENOENT;
 
@@ -127,7 +127,7 @@ static int update_dt_property(struct device_node *dn, 
struct property **prop,
return 0;
 }
 
-static int update_dt_node(u32 phandle, s32 scope)
+static int update_dt_node(__be32 phandle, s32 scope)
 {
struct update_props_workarea *upwa;
struct device_node *dn;
@@ -136,6 +136,7 @@ static int update_dt_node(u32 phandle, s32 scope)
char *prop_data;
char *rtas_buf;
int update_properties_token;
+   u32 nprops;
u32 vd;
 
update_properties_token = rtas_token(ibm,update-properties);
@@ -146,7 +147,7 @@ static int update_dt_node(u32 phandle, s32 scope)
if (!rtas_buf)
return -ENOMEM;
 
-   dn = of_find_node_by_phandle(phandle);
+   dn = of_find_node_by_phandle(be32_to_cpu(phandle));
if (!dn) {
kfree(rtas_buf);
return -ENOENT;
@@ -162,6 +163,7 @@ static int update_dt_node(u32 phandle, s32 scope)
break;
 
prop_data = rtas_buf + sizeof(*upwa);
+   nprops = be32_to_cpu(upwa-nprops);
 
/* On the first call to ibm,update-properties for a node the
 * the first property value descriptor contains an empty
@@ -170,17 +172,17 @@ static int update_dt_node(u32 phandle, s32 scope)
 */
if (*prop_data == 0) {
prop_data++;
-   vd = *(u32 *)prop_data;
+   vd = be32_to_cpu(*(__be32 *)prop_data);
prop_data += vd + sizeof(vd);
-   upwa-nprops--;
+   nprops--;
}
 
-   for (i = 0; i  upwa-nprops; i++) {
+   for (i = 0; i  nprops; i++) {
char *prop_name;
 
prop_name = prop_data;
prop_data += strlen(prop_name) + 1;
-   vd = *(u32 *)prop_data;
+   vd = be32_to_cpu(*(__be32 *)prop_data);
prop_data += sizeof(vd);
 
switch (vd) {
@@ -212,13 +214,13 @@ static int update_dt_node(u32 phandle, s32 scope)
return 0;
 }
 
-static int add_dt_node(u32 parent_phandle, u32 drc_index)
+static int add_dt_node(__be32 parent_phandle, __be32 drc_index)
 {
struct device_node *dn;
struct device_node *parent_dn;
int rc;
 
-   parent_dn = of_find_node_by_phandle(parent_phandle);
+   parent_dn = of_find_node_by_phandle(be32_to_cpu(parent_phandle));
if (!parent_dn)
return -ENOENT;
 
@@ -237,7 +239,7 @@ static int add_dt_node(u32 parent_phandle, u32 drc_index)
 int pseries_devicetree_update(s32 scope)
 {
char *rtas_buf;
-   u32 *data;
+   __be32 *data;
int update_nodes_token;
int rc;
 
@@ -254,17 +256,17 @@ int pseries_devicetree_update(s32 scope)
if (rc  rc != 1)
break;
 
-   data = (u32 *)rtas_buf + 4;
-   while (*data  NODE_ACTION_MASK) {
+   

[PATCH v4 06/10] s390: standardize mmap_rnd() usage

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, this refactors the use of
mmap_rnd() to be used similarly to arm and x86, and extracts the checking
of PF_RANDOMIZE.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/s390/mm/mmap.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 179a2c20b01f..db57078075c5 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -62,20 +62,18 @@ static inline int mmap_is_legacy(void)
 
 static unsigned long mmap_rnd(void)
 {
-   if (!(current-flags  PF_RANDOMIZE))
-   return 0;
if (is_32bit_task())
return (get_random_int()  0x7ff)  PAGE_SHIFT;
else
return (get_random_int()  mmap_rnd_mask)  PAGE_SHIFT;
 }
 
-static unsigned long mmap_base_legacy(void)
+static unsigned long mmap_base_legacy(unsigned long rnd)
 {
-   return TASK_UNMAPPED_BASE + mmap_rnd();
+   return TASK_UNMAPPED_BASE + rnd;
 }
 
-static inline unsigned long mmap_base(void)
+static inline unsigned long mmap_base(unsigned long rnd)
 {
unsigned long gap = rlimit(RLIMIT_STACK);
 
@@ -84,7 +82,7 @@ static inline unsigned long mmap_base(void)
else if (gap  MAX_GAP)
gap = MAX_GAP;
gap = PAGE_MASK;
-   return STACK_TOP - stack_maxrandom_size() - mmap_rnd() - gap;
+   return STACK_TOP - stack_maxrandom_size() - rnd - gap;
 }
 
 unsigned long
@@ -187,7 +185,11 @@ unsigned long randomize_et_dyn(void)
if (!is_32bit_task())
/* Align to 4GB */
base = ~((1UL  32) - 1);
-   return base + mmap_rnd();
+
+   if (current-flags  PF_RANDOMIZE)
+   base += mmap_rnd();
+
+   return base;
 }
 
 #ifndef CONFIG_64BIT
@@ -198,15 +200,20 @@ unsigned long randomize_et_dyn(void)
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+   unsigned long random_factor = 0UL;
+
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
+
/*
 * Fall back to the standard layout if the personality
 * bit is set, or if the expected stack growth is unlimited:
 */
if (mmap_is_legacy()) {
-   mm-mmap_base = mmap_base_legacy();
+   mm-mmap_base = mmap_base_legacy(random_factor);
mm-get_unmapped_area = arch_get_unmapped_area;
} else {
-   mm-mmap_base = mmap_base();
+   mm-mmap_base = mmap_base(random_factor);
mm-get_unmapped_area = arch_get_unmapped_area_topdown;
}
 }
@@ -273,15 +280,20 @@ s390_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr,
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+   unsigned long random_factor = 0UL;
+
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
+
/*
 * Fall back to the standard layout if the personality
 * bit is set, or if the expected stack growth is unlimited:
 */
if (mmap_is_legacy()) {
-   mm-mmap_base = mmap_base_legacy();
+   mm-mmap_base = mmap_base_legacy(random_factor);
mm-get_unmapped_area = s390_get_unmapped_area;
} else {
-   mm-mmap_base = mmap_base();
+   mm-mmap_base = mmap_base(random_factor);
mm-get_unmapped_area = s390_get_unmapped_area_topdown;
}
 }
-- 
1.9.1

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

[PATCH v4 02/10] x86: standardize mmap_rnd() usage

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, this refactors the use of
mmap_rnd() to be used similarly to arm, and extracts the checking of
PF_RANDOMIZE.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/x86/mm/mmap.c | 36 
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index df4552bd239e..ebfa52030d5c 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -67,22 +67,21 @@ static int mmap_is_legacy(void)
 
 static unsigned long mmap_rnd(void)
 {
-   unsigned long rnd = 0;
+   unsigned long rnd;
 
/*
-   *  8 bits of randomness in 32bit mmaps, 20 address space bits
-   * 28 bits of randomness in 64bit mmaps, 40 address space bits
-   */
-   if (current-flags  PF_RANDOMIZE) {
-   if (mmap_is_ia32())
-   rnd = get_random_int() % (18);
-   else
-   rnd = get_random_int() % (128);
-   }
+*  8 bits of randomness in 32bit mmaps, 20 address space bits
+* 28 bits of randomness in 64bit mmaps, 40 address space bits
+*/
+   if (mmap_is_ia32())
+   rnd = (unsigned long)get_random_int() % (18);
+   else
+   rnd = (unsigned long)get_random_int() % (128);
+
return rnd  PAGE_SHIFT;
 }
 
-static unsigned long mmap_base(void)
+static unsigned long mmap_base(unsigned long rnd)
 {
unsigned long gap = rlimit(RLIMIT_STACK);
 
@@ -91,19 +90,19 @@ static unsigned long mmap_base(void)
else if (gap  MAX_GAP)
gap = MAX_GAP;
 
-   return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
+   return PAGE_ALIGN(TASK_SIZE - gap - rnd);
 }
 
 /*
  * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
  * does, but not when emulating X86_32
  */
-static unsigned long mmap_legacy_base(void)
+static unsigned long mmap_legacy_base(unsigned long rnd)
 {
if (mmap_is_ia32())
return TASK_UNMAPPED_BASE;
else
-   return TASK_UNMAPPED_BASE + mmap_rnd();
+   return TASK_UNMAPPED_BASE + rnd;
 }
 
 /*
@@ -112,13 +111,18 @@ static unsigned long mmap_legacy_base(void)
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
-   mm-mmap_legacy_base = mmap_legacy_base();
-   mm-mmap_base = mmap_base();
+   unsigned long random_factor = 0UL;
+
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
+
+   mm-mmap_legacy_base = mmap_legacy_base(random_factor);
 
if (mmap_is_legacy()) {
mm-mmap_base = mm-mmap_legacy_base;
mm-get_unmapped_area = arch_get_unmapped_area;
} else {
+   mm-mmap_base = mmap_base(random_factor);
mm-get_unmapped_area = arch_get_unmapped_area_topdown;
}
 }
-- 
1.9.1

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

[PATCH v4 10/10] mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE

2015-03-04 Thread Kees Cook
The arch_randomize_brk() function is used on several architectures,
even those that don't support ET_DYN ASLR. To avoid bulky extern/#define
tricks, consolidate the support under CONFIG_ARCH_HAS_ELF_RANDOMIZE for
the architectures that support it, while still handling CONFIG_COMPAT_BRK.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/Kconfig   |  1 +
 arch/arm/include/asm/elf.h |  4 
 arch/arm64/include/asm/elf.h   |  4 
 arch/mips/include/asm/elf.h|  4 
 arch/powerpc/include/asm/elf.h |  4 
 arch/s390/include/asm/elf.h|  3 ---
 arch/x86/include/asm/elf.h |  3 ---
 fs/binfmt_elf.c|  4 +---
 include/linux/elf-randomize.h  | 12 
 9 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 9ff5aa8fa2c1..d4f270a54fe6 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -490,6 +490,7 @@ config ARCH_HAS_ELF_RANDOMIZE
  An architecture supports choosing randomized locations for
  stack, mmap, brk, and ET_DYN. Defined functions:
  - arch_mmap_rnd()
+ - arch_randomize_brk()
 
 #
 # ABI hall of shame
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index afb9cafd3786..c1ff8ab12914 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -125,10 +125,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t 
*elfregs);
 extern void elf_set_personality(const struct elf32_hdr *);
 #define SET_PERSONALITY(ex)elf_set_personality((ex))
 
-struct mm_struct;
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
 #ifdef CONFIG_MMU
 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
 struct linux_binprm;
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index f724db00b235..faad6df49e5b 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -156,10 +156,6 @@ extern int arch_setup_additional_pages(struct linux_binprm 
*bprm,
 #define STACK_RND_MASK (0x3  (PAGE_SHIFT - 12))
 #endif
 
-struct mm_struct;
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
 #ifdef CONFIG_COMPAT
 
 #ifdef __AARCH64EB__
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 535f196ffe02..31d747d46a23 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -410,10 +410,6 @@ struct linux_binprm;
 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
   int uses_interp);
 
-struct mm_struct;
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
 struct arch_elf_state {
int fp_abi;
int interp_fp_abi;
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index 57d289acb803..ee46ffef608e 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -128,10 +128,6 @@ extern int arch_setup_additional_pages(struct linux_binprm 
*bprm,
(0x7ff  (PAGE_SHIFT - 12)) : \
(0x3  (PAGE_SHIFT - 12)))
 
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
-
 #ifdef CONFIG_SPU_BASE
 /* Notes used in ET_CORE. Note name is SPU/fd/filename. */
 #define NT_SPU 1
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index d0db9d944b6d..fdda72e56404 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -226,9 +226,6 @@ struct linux_binprm;
 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
 int arch_setup_additional_pages(struct linux_binprm *, int);
 
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa, __vector128 *vxrs);
 
 #endif
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index ca3347a9dab5..bbdace22daf8 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -338,9 +338,6 @@ extern int compat_arch_setup_additional_pages(struct 
linux_binprm *bprm,
  int uses_interp);
 #define compat_arch_setup_additional_pages compat_arch_setup_additional_pages
 
-extern unsigned long arch_randomize_brk(struct mm_struct *mm);
-#define arch_randomize_brk arch_randomize_brk
-
 /*
  * True on X86_32 or when emulating IA32 on X86_64
  */
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 6f08f5fa99dc..a115da230ce0 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1043,15 +1043,13 @@ static int load_elf_binary(struct linux_binprm *bprm)
current-mm-end_data = end_data;
current-mm-start_stack = bprm-p;
 
-#ifdef arch_randomize_brk
if ((current-flags  PF_RANDOMIZE)  (randomize_va_space  1)) {
current-mm-brk = current-mm-start_brk =
 

[PATCH v4 07/10] mm: expose arch_mmap_rnd when available

2015-03-04 Thread Kees Cook
When an architecture fully supports randomizing the ELF load location,
a per-arch mmap_rnd() function is used to find a randomized mmap base.
In preparation for randomizing the location of ET_DYN binaries
separately from mmap, this renames and exports these functions as
arch_mmap_rnd(). Additionally introduces CONFIG_ARCH_HAS_ELF_RANDOMIZE
for describing this feature on architectures that support it
(which is a superset of ARCH_BINFMT_ELF_RANDOMIZE_PIE, since s390
already supports a separated ET_DYN ASLR from mmap ASLR without the
ARCH_BINFMT_ELF_RANDOMIZE_PIE logic).

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/Kconfig  |  7 +++
 arch/arm/Kconfig  |  1 +
 arch/arm/mm/mmap.c|  4 ++--
 arch/arm64/Kconfig|  1 +
 arch/arm64/mm/mmap.c  |  4 ++--
 arch/mips/Kconfig |  1 +
 arch/mips/mm/mmap.c   |  4 ++--
 arch/powerpc/Kconfig  |  1 +
 arch/powerpc/mm/mmap.c|  4 ++--
 arch/s390/Kconfig |  1 +
 arch/s390/mm/mmap.c   |  8 
 arch/x86/Kconfig  |  1 +
 arch/x86/mm/mmap.c|  4 ++--
 include/linux/elf-randomize.h | 10 ++
 14 files changed, 37 insertions(+), 14 deletions(-)
 create mode 100644 include/linux/elf-randomize.h

diff --git a/arch/Kconfig b/arch/Kconfig
index 05d7a8a458d5..9ff5aa8fa2c1 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -484,6 +484,13 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK
  This spares a stack switch and improves cache usage on softirq
  processing.
 
+config ARCH_HAS_ELF_RANDOMIZE
+   bool
+   help
+ An architecture supports choosing randomized locations for
+ stack, mmap, brk, and ET_DYN. Defined functions:
+ - arch_mmap_rnd()
+
 #
 # ABI hall of shame
 #
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9f1f09a2bc9b..248d99cabaa8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -3,6 +3,7 @@ config ARM
default y
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
+   select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 15a8160096b3..407dc786583a 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -169,7 +169,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
return addr;
 }
 
-static unsigned long mmap_rnd(void)
+unsigned long arch_mmap_rnd(void)
 {
unsigned long rnd;
 
@@ -184,7 +184,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
unsigned long random_factor = 0UL;
 
if (current-flags  PF_RANDOMIZE)
-   random_factor = mmap_rnd();
+   random_factor = arch_mmap_rnd();
 
if (mmap_is_legacy()) {
mm-mmap_base = TASK_UNMAPPED_BASE + random_factor;
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b8e97331ffb..5f469095e0e2 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2,6 +2,7 @@ config ARM64
def_bool y
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
+   select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_HAS_SG_CHAIN
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c
index ba776c01b552..ed177475dd8c 100644
--- a/arch/arm64/mm/mmap.c
+++ b/arch/arm64/mm/mmap.c
@@ -47,7 +47,7 @@ static int mmap_is_legacy(void)
return sysctl_legacy_va_layout;
 }
 
-static unsigned long mmap_rnd(void)
+unsigned long arch_mmap_rnd(void)
 {
unsigned long rnd;
 
@@ -77,7 +77,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
unsigned long random_factor = 0UL;
 
if (current-flags  PF_RANDOMIZE)
-   random_factor = mmap_rnd();
+   random_factor = arch_mmap_rnd();
 
/*
 * Fall back to the standard layout if the personality bit is set, or
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index c7a16904cd03..72ce5cece768 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -24,6 +24,7 @@ config MIPS
select HAVE_DEBUG_KMEMLEAK
select HAVE_SYSCALL_TRACEPOINTS
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
+   select ARCH_HAS_ELF_RANDOMIZE
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES  64BIT
select RTC_LIB if !MACH_LOONGSON
select GENERIC_ATOMIC64 if !64BIT
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index 9a4f1f5c1f0e..5c81fdd032c3 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -142,7 +142,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file 
*filp,
addr0, len, pgoff, flags, DOWN);
 }
 
-static unsigned long mmap_rnd(void)
+unsigned long 

[PATCH v2] powerpc/pseries: Simplify check for suspendability during suspend/migration

2015-03-04 Thread Tyrel Datwyler
During suspend/migration operation we must wait for the VASI state reported
by the hypervisor to become Suspending prior to making the ibm,suspend-me
RTAS call. Calling routines to rtas_ibm_supend_me() pass a vasi_state variable
that exposes the VASI state to the caller. This is unnecessary as the caller
only really cares about the following three conditions; if there is an error
we should bailout, success indicating we have suspended and woken back up so
proceed to device tree updated, or we are not suspendable yet so try calling
rtas_ibm_suspend_me again shortly.

This patch removes the extraneous vasi_state variable and simply uses the
return code to communicate how to proceed. We either succeed, fail, or get
-EAGAIN in which case we sleep for a second before trying to call
rtas_ibm_suspend_me again.

Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com
Cc: Nathan Fontenot nf...@linux.vnet.ibm.com
Cc: Cyril Bur cyril...@gmail.com
---

Changes in v2:
- Addressed Cyril's comments as follow:
- Removed unused vasi_rc variable
- Kept return behavior of ppc_rtas the same in the case of VASI error
- Updated rtas_ibm_suspend_me function definition for !CONFIG_PPC_PSERIES

 arch/powerpc/include/asm/rtas.h   |  2 +-
 arch/powerpc/kernel/rtas.c| 26 +-
 arch/powerpc/platforms/pseries/mobility.c |  9 +++--
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 2e23e92..fc85eb0 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -327,7 +327,7 @@ extern int rtas_suspend_cpu(struct rtas_suspend_me_data 
*data);
 extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
 extern int rtas_online_cpus_mask(cpumask_var_t cpus);
 extern int rtas_offline_cpus_mask(cpumask_var_t cpus);
-extern int rtas_ibm_suspend_me(u64 handle, int *vasi_return);
+extern int rtas_ibm_suspend_me(u64 handle);
 
 struct rtc_time;
 extern unsigned long rtas_get_boot_time(void);
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 21c45a2..b9a7b89 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -897,7 +897,7 @@ int rtas_offline_cpus_mask(cpumask_var_t cpus)
 }
 EXPORT_SYMBOL(rtas_offline_cpus_mask);
 
-int rtas_ibm_suspend_me(u64 handle, int *vasi_return)
+int rtas_ibm_suspend_me(u64 handle)
 {
long state;
long rc;
@@ -919,13 +919,11 @@ int rtas_ibm_suspend_me(u64 handle, int *vasi_return)
printk(KERN_ERR rtas_ibm_suspend_me: vasi_state returned 
%ld\n,rc);
return rc;
} else if (state == H_VASI_ENABLED) {
-   *vasi_return = RTAS_NOT_SUSPENDABLE;
-   return 0;
+   return -EAGAIN;
} else if (state != H_VASI_SUSPENDING) {
printk(KERN_ERR rtas_ibm_suspend_me: vasi_state returned state 
%ld\n,
   state);
-   *vasi_return = -1;
-   return 0;
+   return -EIO;
}
 
if (!alloc_cpumask_var(offline_mask, GFP_TEMPORARY))
@@ -972,7 +970,7 @@ out:
return atomic_read(data.error);
 }
 #else /* CONFIG_PPC_PSERIES */
-int rtas_ibm_suspend_me(u64 handle, int *vasi_return)
+int rtas_ibm_suspend_me(u64 handle)
 {
return -ENOSYS;
 }
@@ -1022,7 +1020,6 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
unsigned long flags;
char *buff_copy, *errbuf = NULL;
int nargs, nret, token;
-   int rc;
 
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -1054,15 +1051,18 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
if (token == ibm_suspend_me_token) {
 
/*
-* rtas_ibm_suspend_me assumes args are in cpu endian, or at 
least the
-* hcall within it requires it.
+* rtas_ibm_suspend_me assumes the streamid handle is in cpu
+* endian, or at least the hcall within it requires it.
 */
-   int vasi_rc = 0;
+   int rc = 0;
u64 handle = ((u64)be32_to_cpu(args.args[0])  32)
  | be32_to_cpu(args.args[1]);
-   rc = rtas_ibm_suspend_me(handle, vasi_rc);
-   args.rets[0] = cpu_to_be32(vasi_rc);
-   if (rc)
+   rc = rtas_ibm_suspend_me(handle);
+   if (rc == -EAGAIN)
+   args.rets[0] = cpu_to_be32(RTAS_NOT_SUSPENDABLE);
+   else if (rc == -EIO)
+   args.rets[0] = cpu_to_be32(-1);
+   else if (rc)
return rc;
goto copy_return;
}
diff --git a/arch/powerpc/platforms/pseries/mobility.c 
b/arch/powerpc/platforms/pseries/mobility.c
index 90cf3dc..c489701 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -318,22 

[PATCH v4 03/10] arm64: standardize mmap_rnd() usage

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, this refactors the use of
mmap_rnd() to be used similarly to arm and x86. This additionally enables
mmap ASLR on legacy mmap layouts, which appeared to be missing on arm64,
and was already supported on arm. Additionally removes a copy/pasted
declaration of an unused function.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/arm64/include/asm/elf.h |  1 -
 arch/arm64/mm/mmap.c | 18 +++---
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 1f65be393139..f724db00b235 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -125,7 +125,6 @@ typedef struct user_fpsimd_state elf_fpregset_t;
  * the loader.  We need to make sure that it is out of the way of the program
  * that it will exec, and that there is sufficient room for the brk.
  */
-extern unsigned long randomize_et_dyn(unsigned long base);
 #define ELF_ET_DYN_BASE(2 * TASK_SIZE_64 / 3)
 
 /*
diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c
index 54922d1275b8..ba776c01b552 100644
--- a/arch/arm64/mm/mmap.c
+++ b/arch/arm64/mm/mmap.c
@@ -49,15 +49,14 @@ static int mmap_is_legacy(void)
 
 static unsigned long mmap_rnd(void)
 {
-   unsigned long rnd = 0;
+   unsigned long rnd;
 
-   if (current-flags  PF_RANDOMIZE)
-   rnd = (long)get_random_int()  STACK_RND_MASK;
+   rnd = (unsigned long)get_random_int()  STACK_RND_MASK;
 
return rnd  PAGE_SHIFT;
 }
 
-static unsigned long mmap_base(void)
+static unsigned long mmap_base(unsigned long rnd)
 {
unsigned long gap = rlimit(RLIMIT_STACK);
 
@@ -66,7 +65,7 @@ static unsigned long mmap_base(void)
else if (gap  MAX_GAP)
gap = MAX_GAP;
 
-   return PAGE_ALIGN(STACK_TOP - gap - mmap_rnd());
+   return PAGE_ALIGN(STACK_TOP - gap - rnd);
 }
 
 /*
@@ -75,15 +74,20 @@ static unsigned long mmap_base(void)
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+   unsigned long random_factor = 0UL;
+
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
+
/*
 * Fall back to the standard layout if the personality bit is set, or
 * if the expected stack growth is unlimited:
 */
if (mmap_is_legacy()) {
-   mm-mmap_base = TASK_UNMAPPED_BASE;
+   mm-mmap_base = TASK_UNMAPPED_BASE + random_factor;
mm-get_unmapped_area = arch_get_unmapped_area;
} else {
-   mm-mmap_base = mmap_base();
+   mm-mmap_base = mmap_base(random_factor);
mm-get_unmapped_area = arch_get_unmapped_area_topdown;
}
 }
-- 
1.9.1

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

[PATCH v4 04/10] mips: extract logic for mmap_rnd()

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, extract the mmap ASLR
selection into a separate function.

Signed-off-by: Kees Cook keesc...@chromium.org
---
It seems the entropy gets smaller as the PAGE_SIZE increases. Is this
intentional?
---
 arch/mips/mm/mmap.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index f1baadd56e82..9a4f1f5c1f0e 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -142,18 +142,26 @@ unsigned long arch_get_unmapped_area_topdown(struct file 
*filp,
addr0, len, pgoff, flags, DOWN);
 }
 
+static unsigned long mmap_rnd(void)
+{
+   unsigned long rnd;
+
+   rnd = (unsigned long)get_random_int();
+   rnd = PAGE_SHIFT;
+   if (TASK_IS_32BIT_ADDR)
+   rnd = 0xfful;
+   else
+   rnd = 0xffful;
+
+   return rnd;
+}
+
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
unsigned long random_factor = 0UL;
 
-   if (current-flags  PF_RANDOMIZE) {
-   random_factor = get_random_int();
-   random_factor = random_factor  PAGE_SHIFT;
-   if (TASK_IS_32BIT_ADDR)
-   random_factor = 0xfful;
-   else
-   random_factor = 0xffful;
-   }
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
 
if (mmap_is_legacy()) {
mm-mmap_base = TASK_UNMAPPED_BASE + random_factor;
-- 
1.9.1

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

Re: [PATCH 4/5] mm: split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Kees Cook
On Tue, Mar 3, 2015 at 8:16 PM, Michael Ellerman m...@ellerman.id.au wrote:
 On Mon, 2015-03-02 at 16:19 -0800, Kees Cook wrote:
 This fixes the offset2lib weakness in ASLR for arm, arm64, mips,
 powerpc, and x86. The problem is that if there is a leak of ASLR from
 the executable (ET_DYN), it means a leak of shared library offset as
 well (mmap), and vice versa. Further details and a PoC of this attack
 are available here:
 http://cybersecurity.upv.es/attacks/offset2lib/offset2lib.html

 With this patch, a PIE linked executable (ET_DYN) has its own ASLR region:

 $ ./show_mmaps_pie
 54859ccd6000-54859ccd7000 r-xp  ...  /tmp/show_mmaps_pie
 54859ced6000-54859ced7000 r--p  ...  /tmp/show_mmaps_pie
 54859ced7000-54859ced8000 rw-p  ...  /tmp/show_mmaps_pie

 Just to be clear, it's the fact that the above vmas are in a different
 address range to those below that shows the patch is working, right?

That's correct, yes. I've called this out explicitly now in the 9/10
patch in v4.


 7f75be764000-7f75be91f000 r-xp  ...  /lib/x86_64-linux-gnu/libc.so.6
 7f75be91f000-7f75beb1f000 ---p  ...  /lib/x86_64-linux-gnu/libc.so.6


 On powerpc I'm seeing:

 # /bin/dash
 # cat /proc/$$/maps
 524e-5251 r-xp  08:03 129814 
 /bin/dash
 5251-5252 rw-p 0002 08:03 129814 
 /bin/dash
 10034f2-10034f5 rw-p  00:00 0
 [heap]
 3fffaeaf-3fffaeca r-xp  08:03 13529  
 /lib/powerpc64le-linux-gnu/libc-2.19.so
 3fffaeca-3fffaecb rw-p 001a 08:03 13529  
 /lib/powerpc64le-linux-gnu/libc-2.19.so
 3fffaecc-3fffaecd rw-p  00:00 0
 3fffaecd-3fffaecf r-xp  00:00 0  
 [vdso]
 3fffaecf-3fffaed2 r-xp  08:03 13539  
 /lib/powerpc64le-linux-gnu/ld-2.19.so
 3fffaed2-3fffaed3 rw-p 0002 08:03 13539  
 /lib/powerpc64le-linux-gnu/ld-2.19.so
 3fffc707-3fffc70a rw-p  00:00 0  
 [stack]


 Whereas previously the /bin/dash vmas were up at 3fff..

Fantastic! Thanks very much for testing!


 So looks good to me for powerpc.

 Acked-by: Michael Ellerman m...@ellerman.id.au

I had a question in the powerpc-specific change that may have gone unnoticed:

Can mmap ASLR be safely enabled in the legacy mmap case here? Other archs
use mm-mmap_base = TASK_UNMAPPED_BASE + random_factor.

Separate from this series, do you happen to know if this improvement
can be made, or if the legacy mmap on powerpc can't handle this?

Thanks!

-Kees

-- 
Kees Cook
Chrome OS Security
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v4 05/10] powerpc: standardize mmap_rnd() usage

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, this refactors the use of
mmap_rnd() to be used similarly to arm and x86.

Signed-off-by: Kees Cook keesc...@chromium.org
Acked-by: Michael Ellerman m...@ellerman.id.au
---
Can mmap ASLR be safely enabled in the legacy mmap case here? Other archs
use mm-mmap_base = TASK_UNMAPPED_BASE + random_factor.
---
 arch/powerpc/mm/mmap.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
index cb8bdbe4972f..1ad2299d795d 100644
--- a/arch/powerpc/mm/mmap.c
+++ b/arch/powerpc/mm/mmap.c
@@ -55,19 +55,18 @@ static inline int mmap_is_legacy(void)
 
 static unsigned long mmap_rnd(void)
 {
-   unsigned long rnd = 0;
+   unsigned long rnd;
+
+   /* 8MB for 32bit, 1GB for 64bit */
+   if (is_32bit_task())
+   rnd = (unsigned long)get_random_int() % (1(23-PAGE_SHIFT));
+   else
+   rnd = (unsigned long)get_random_int() % (1(30-PAGE_SHIFT));
 
-   if (current-flags  PF_RANDOMIZE) {
-   /* 8MB for 32bit, 1GB for 64bit */
-   if (is_32bit_task())
-   rnd = (long)(get_random_int() % (1(23-PAGE_SHIFT)));
-   else
-   rnd = (long)(get_random_int() % (1(30-PAGE_SHIFT)));
-   }
return rnd  PAGE_SHIFT;
 }
 
-static inline unsigned long mmap_base(void)
+static inline unsigned long mmap_base(unsigned long rnd)
 {
unsigned long gap = rlimit(RLIMIT_STACK);
 
@@ -76,7 +75,7 @@ static inline unsigned long mmap_base(void)
else if (gap  MAX_GAP)
gap = MAX_GAP;
 
-   return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
+   return PAGE_ALIGN(TASK_SIZE - gap - rnd);
 }
 
 /*
@@ -85,6 +84,11 @@ static inline unsigned long mmap_base(void)
  */
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
+   unsigned long random_factor = 0UL;
+
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
+
/*
 * Fall back to the standard layout if the personality
 * bit is set, or if the expected stack growth is unlimited:
@@ -93,7 +97,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
mm-mmap_base = TASK_UNMAPPED_BASE;
mm-get_unmapped_area = arch_get_unmapped_area;
} else {
-   mm-mmap_base = mmap_base();
+   mm-mmap_base = mmap_base(random_factor);
mm-get_unmapped_area = arch_get_unmapped_area_topdown;
}
 }
-- 
1.9.1

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

[PATCH v4 01/10] arm: factor out mmap ASLR into mmap_rnd

2015-03-04 Thread Kees Cook
In preparation for splitting out ET_DYN ASLR, this moves the ASLR calculations
for mmap on ARM into a separate routine, similar to x86. This also removes
the redundant check of personality (PF_RANDOMIZE is already set before calling
arch_pick_mmap_layout).

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/arm/mm/mmap.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..15a8160096b3 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -169,14 +169,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
return addr;
 }
 
+static unsigned long mmap_rnd(void)
+{
+   unsigned long rnd;
+
+   /* 8 bits of randomness in 20 address space bits */
+   rnd = (unsigned long)get_random_int() % (1  8);
+
+   return rnd  PAGE_SHIFT;
+}
+
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
unsigned long random_factor = 0UL;
 
-   /* 8 bits of randomness in 20 address space bits */
-   if ((current-flags  PF_RANDOMIZE) 
-   !(current-personality  ADDR_NO_RANDOMIZE))
-   random_factor = (get_random_int() % (1  8))  PAGE_SHIFT;
+   if (current-flags  PF_RANDOMIZE)
+   random_factor = mmap_rnd();
 
if (mmap_is_legacy()) {
mm-mmap_base = TASK_UNMAPPED_BASE + random_factor;
-- 
1.9.1

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

[PATCH v4 0/10] split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Kees Cook
To address the offset2lib ASLR weakness[1], this separates ET_DYN
ASLR from mmap ASLR, as already done on s390. The architectures
that are already randomizing mmap (arm, arm64, mips, powerpc, s390,
and x86), have their various forms of arch_mmap_rnd() made available
via the new CONFIG_ARCH_HAS_ELF_RANDOMIZE. For these architectures,
arch_randomize_brk() is collapsed as well.

This is an alternative to the solutions in:
https://lkml.org/lkml/2015/2/23/442

I've been able to test x86 and arm, and the buildbot (so far) seems
happy with building the rest.

Thanks!

-Kees

[1] http://cybersecurity.upv.es/attacks/offset2lib/offset2lib.html

v4:
- added Ack on powerpc (mpe)
- fixed mmap_base argument convention to be the same on all archs
- corrected paste-o in mips variable names (buildbot)
- clarified ET_DYN vs mmap ASLR regions in 9/10 (mpe)
v3:
- split change on a per-arch basis for easier review
- moved PF_RANDOMIZE check out of per-arch code (ingo)
v2:
- verbosified the commit logs, especially 4/5 (akpm)

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

Re: [PATCH v4 0/10] split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Ingo Molnar

* Kees Cook keesc...@chromium.org wrote:

 To address the offset2lib ASLR weakness[1], this separates ET_DYN
 ASLR from mmap ASLR, as already done on s390. The architectures
 that are already randomizing mmap (arm, arm64, mips, powerpc, s390,
 and x86), have their various forms of arch_mmap_rnd() made available
 via the new CONFIG_ARCH_HAS_ELF_RANDOMIZE. For these architectures,
 arch_randomize_brk() is collapsed as well.
 
 This is an alternative to the solutions in:
 https://lkml.org/lkml/2015/2/23/442
 
 I've been able to test x86 and arm, and the buildbot (so far) seems
 happy with building the rest.

Ok, this looks really good - for all patches:

   Reviewed-by: Ingo Molnar mi...@kernel.org

Thanks,

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

Re: [PATCH v4 0/10] split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Kees Cook
On Wed, Mar 4, 2015 at 1:54 PM, Ingo Molnar mi...@kernel.org wrote:

 * Kees Cook keesc...@chromium.org wrote:

 To address the offset2lib ASLR weakness[1], this separates ET_DYN
 ASLR from mmap ASLR, as already done on s390. The architectures
 that are already randomizing mmap (arm, arm64, mips, powerpc, s390,
 and x86), have their various forms of arch_mmap_rnd() made available
 via the new CONFIG_ARCH_HAS_ELF_RANDOMIZE. For these architectures,
 arch_randomize_brk() is collapsed as well.

 This is an alternative to the solutions in:
 https://lkml.org/lkml/2015/2/23/442

 I've been able to test x86 and arm, and the buildbot (so far) seems
 happy with building the rest.

 Ok, this looks really good - for all patches:

Reviewed-by: Ingo Molnar mi...@kernel.org

Great! Thanks for the suggestions and reviews. :)

-Kees

-- 
Kees Cook
Chrome OS Security
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v4 09/10] mm: split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Kees Cook
This fixes the offset2lib weakness in ASLR for arm, arm64, mips,
powerpc, and x86. The problem is that if there is a leak of ASLR from
the executable (ET_DYN), it means a leak of shared library offset as
well (mmap), and vice versa. Further details and a PoC of this attack
is available here:
http://cybersecurity.upv.es/attacks/offset2lib/offset2lib.html

With this patch, a PIE linked executable (ET_DYN) has its own ASLR region
(e.g. 0x5... instead of 0x7f... on x86_64):

$ ./show_mmaps_pie
54859ccd6000-54859ccd7000 r-xp  ...  /tmp/show_mmaps_pie
54859ced6000-54859ced7000 r--p  ...  /tmp/show_mmaps_pie
54859ced7000-54859ced8000 rw-p  ...  /tmp/show_mmaps_pie
7f75be764000-7f75be91f000 r-xp  ...  /lib/x86_64-linux-gnu/libc.so.6
7f75be91f000-7f75beb1f000 ---p  ...  /lib/x86_64-linux-gnu/libc.so.6
7f75beb1f000-7f75beb23000 r--p  ...  /lib/x86_64-linux-gnu/libc.so.6
7f75beb23000-7f75beb25000 rw-p  ...  /lib/x86_64-linux-gnu/libc.so.6
7f75beb25000-7f75beb2a000 rw-p  ...
7f75beb2a000-7f75beb4d000 r-xp  ...  /lib64/ld-linux-x86-64.so.2
7f75bed45000-7f75bed46000 rw-p  ...
7f75bed46000-7f75bed47000 r-xp  ...
7f75bed47000-7f75bed4c000 rw-p  ...
7f75bed4c000-7f75bed4d000 r--p  ...  /lib64/ld-linux-x86-64.so.2
7f75bed4d000-7f75bed4e000 rw-p  ...  /lib64/ld-linux-x86-64.so.2
7f75bed4e000-7f75bed4f000 rw-p  ...
7fffb3741000-7fffb3762000 rw-p  ...  [stack]
7fffb377b000-7fffb377d000 r--p  ...  [vvar]
7fffb377d000-7fffb377f000 r-xp  ...  [vdso]

The change is to add a call the newly created arch_mmap_rnd() into the
ELF loader for handling ET_DYN ASLR in a separate region from mmap ASLR,
as was already done on s390. Removes CONFIG_BINFMT_ELF_RANDOMIZE_PIE,
which is no longer needed.

Reported-by: Hector Marco-Gisbert hecma...@upv.es
Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/arm/Kconfig|  1 -
 arch/arm64/Kconfig  |  1 -
 arch/mips/Kconfig   |  1 -
 arch/powerpc/Kconfig|  1 -
 arch/s390/include/asm/elf.h |  5 ++---
 arch/s390/mm/mmap.c |  8 
 arch/x86/Kconfig|  1 -
 fs/Kconfig.binfmt   |  3 ---
 fs/binfmt_elf.c | 18 --
 9 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 248d99cabaa8..e2f0ef9c6ee3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,7 +1,6 @@
 config ARM
bool
default y
-   select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 5f469095e0e2..07e0fc7adc88 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,6 +1,5 @@
 config ARM64
def_bool y
-   select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 72ce5cece768..557c5f1772c1 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -23,7 +23,6 @@ config MIPS
select HAVE_KRETPROBES
select HAVE_DEBUG_KMEMLEAK
select HAVE_SYSCALL_TRACEPOINTS
-   select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ELF_RANDOMIZE
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES  64BIT
select RTC_LIB if !MACH_LOONGSON
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 14fe1c411489..910fa4f9ad1e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -88,7 +88,6 @@ config PPC
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_MIGHT_HAVE_PC_SERIO
select BINFMT_ELF
-   select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ELF_RANDOMIZE
select OF
select OF_EARLY_FLATTREE
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index 2e63de8aac7c..d0db9d944b6d 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -163,10 +163,9 @@ extern unsigned int vdso_enabled;
the loader.  We need to make sure that it is out of the way of the program
that it will exec, and that there is sufficient room for the brk. 64-bit
tasks are aligned to 4GB. */
-extern unsigned long randomize_et_dyn(void);
-#define ELF_ET_DYN_BASE (randomize_et_dyn() + (is_32bit_task() ? \
+#define ELF_ET_DYN_BASE (is_32bit_task() ? \
(STACK_TOP / 3 * 2) : \
-   (STACK_TOP / 3 * 2)  ~((1UL  32) - 1)))
+   (STACK_TOP / 3 * 2)  ~((1UL  32) - 1))
 
 /* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. */
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 8c11536f972d..bb3367c5cb0b 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -177,14 +177,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long 

[PATCH v4 08/10] s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE

2015-03-04 Thread Kees Cook
In preparation for moving ET_DYN randomization into the ELF loader (which
requires a static ELF_ET_DYN_BASE), this redefines s390's existing ET_DYN
randomization in a call to arch_mmap_rnd(). This refactoring results in
the same ET_DYN randomization on s390.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/s390/include/asm/elf.h |  8 +---
 arch/s390/mm/mmap.c | 11 ++-
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index c9df40b5c0ac..2e63de8aac7c 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -161,10 +161,12 @@ extern unsigned int vdso_enabled;
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
use of this is to invoke ./ld.so someprog to test out a new version of
the loader.  We need to make sure that it is out of the way of the program
-   that it will exec, and that there is sufficient room for the brk.  */
-
+   that it will exec, and that there is sufficient room for the brk. 64-bit
+   tasks are aligned to 4GB. */
 extern unsigned long randomize_et_dyn(void);
-#define ELF_ET_DYN_BASErandomize_et_dyn()
+#define ELF_ET_DYN_BASE (randomize_et_dyn() + (is_32bit_task() ? \
+   (STACK_TOP / 3 * 2) : \
+   (STACK_TOP / 3 * 2)  ~((1UL  32) - 1)))
 
 /* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. */
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index a94504d99c47..8c11536f972d 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -179,17 +179,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
 
 unsigned long randomize_et_dyn(void)
 {
-   unsigned long base;
-
-   base = STACK_TOP / 3 * 2;
-   if (!is_32bit_task())
-   /* Align to 4GB */
-   base = ~((1UL  32) - 1);
-
if (current-flags  PF_RANDOMIZE)
-   base += arch_mmap_rnd();
+   return arch_mmap_rnd();
 
-   return base;
+   return 0UL;
 }
 
 #ifndef CONFIG_64BIT
-- 
1.9.1

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

[PATCH v3 8/8] x86: switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. The obsolete sigreturn syscall override
is retained in 32-bit mode, and the ia32 syscall overrides are used in
the compat case. Remaining definitions were identical.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/x86/include/asm/seccomp.h| 21 ++---
 arch/x86/include/asm/seccomp_32.h | 11 ---
 arch/x86/include/asm/seccomp_64.h | 17 -
 3 files changed, 18 insertions(+), 31 deletions(-)
 delete mode 100644 arch/x86/include/asm/seccomp_32.h
 delete mode 100644 arch/x86/include/asm/seccomp_64.h

diff --git a/arch/x86/include/asm/seccomp.h b/arch/x86/include/asm/seccomp.h
index 0f3d7f099224..0c8c7c8861b4 100644
--- a/arch/x86/include/asm/seccomp.h
+++ b/arch/x86/include/asm/seccomp.h
@@ -1,5 +1,20 @@
+#ifndef _ASM_X86_SECCOMP_H
+#define _ASM_X86_SECCOMP_H
+
+#include asm/unistd.h
+
 #ifdef CONFIG_X86_32
-# include asm/seccomp_32.h
-#else
-# include asm/seccomp_64.h
+#define __NR_seccomp_sigreturn __NR_sigreturn
 #endif
+
+#ifdef CONFIG_COMPAT
+#include asm/ia32_unistd.h
+#define __NR_seccomp_read_32   __NR_ia32_read
+#define __NR_seccomp_write_32  __NR_ia32_write
+#define __NR_seccomp_exit_32   __NR_ia32_exit
+#define __NR_seccomp_sigreturn_32  __NR_ia32_sigreturn
+#endif
+
+#include asm-generic/seccomp.h
+
+#endif /* _ASM_X86_SECCOMP_H */
diff --git a/arch/x86/include/asm/seccomp_32.h 
b/arch/x86/include/asm/seccomp_32.h
deleted file mode 100644
index b811d6f5780c..
--- a/arch/x86/include/asm/seccomp_32.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _ASM_X86_SECCOMP_32_H
-#define _ASM_X86_SECCOMP_32_H
-
-#include linux/unistd.h
-
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_sigreturn
-
-#endif /* _ASM_X86_SECCOMP_32_H */
diff --git a/arch/x86/include/asm/seccomp_64.h 
b/arch/x86/include/asm/seccomp_64.h
deleted file mode 100644
index 84ec1bd161a5..
--- a/arch/x86/include/asm/seccomp_64.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _ASM_X86_SECCOMP_64_H
-#define _ASM_X86_SECCOMP_64_H
-
-#include linux/unistd.h
-#include asm/ia32_unistd.h
-
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
-#define __NR_seccomp_read_32 __NR_ia32_read
-#define __NR_seccomp_write_32 __NR_ia32_write
-#define __NR_seccomp_exit_32 __NR_ia32_exit
-#define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn
-
-#endif /* _ASM_X86_SECCOMP_64_H */
-- 
1.9.1

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

[PATCH v3 0/8] switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Most architectures don't need to do much special for the strict-mode
seccomp syscall entries. Remove the redundant headers and reduce the
others.

Signed-off-by: Kees Cook keesc...@chromium.org
---
v3:
- split patch series by architecture
- fix up architectures that need sigreturn overrides (ingo)
v2:
- use Kbuild generic-y instead of explicit #include lines (sfr)

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

[PATCH v3 6/8] powerpc: switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. The obsolete sigreturn in COMPAT mode
is retained as an override. Remaining definitions are identical, though
they incorrectly appeared in uapi, which has been corrected.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/powerpc/include/asm/seccomp.h  | 10 ++
 arch/powerpc/include/uapi/asm/Kbuild|  1 -
 arch/powerpc/include/uapi/asm/seccomp.h | 16 
 3 files changed, 10 insertions(+), 17 deletions(-)
 create mode 100644 arch/powerpc/include/asm/seccomp.h
 delete mode 100644 arch/powerpc/include/uapi/asm/seccomp.h

diff --git a/arch/powerpc/include/asm/seccomp.h 
b/arch/powerpc/include/asm/seccomp.h
new file mode 100644
index ..c1818e35cf02
--- /dev/null
+++ b/arch/powerpc/include/asm/seccomp.h
@@ -0,0 +1,10 @@
+#ifndef _ASM_POWERPC_SECCOMP_H
+#define _ASM_POWERPC_SECCOMP_H
+
+#include linux/unistd.h
+
+#define __NR_seccomp_sigreturn_32 __NR_sigreturn
+
+#include asm-generic/seccomp.h
+
+#endif /* _ASM_POWERPC_SECCOMP_H */
diff --git a/arch/powerpc/include/uapi/asm/Kbuild 
b/arch/powerpc/include/uapi/asm/Kbuild
index 7a3f795ac218..79c4068be278 100644
--- a/arch/powerpc/include/uapi/asm/Kbuild
+++ b/arch/powerpc/include/uapi/asm/Kbuild
@@ -25,7 +25,6 @@ header-y += posix_types.h
 header-y += ps3fb.h
 header-y += ptrace.h
 header-y += resource.h
-header-y += seccomp.h
 header-y += sembuf.h
 header-y += setup.h
 header-y += shmbuf.h
diff --git a/arch/powerpc/include/uapi/asm/seccomp.h 
b/arch/powerpc/include/uapi/asm/seccomp.h
deleted file mode 100644
index 00c1d9133cfe..
--- a/arch/powerpc/include/uapi/asm/seccomp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _ASM_POWERPC_SECCOMP_H
-#define _ASM_POWERPC_SECCOMP_H
-
-#include linux/unistd.h
-
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
-#define __NR_seccomp_read_32 __NR_read
-#define __NR_seccomp_write_32 __NR_write
-#define __NR_seccomp_exit_32 __NR_exit
-#define __NR_seccomp_sigreturn_32 __NR_sigreturn
-
-#endif /* _ASM_POWERPC_SECCOMP_H */
-- 
1.9.1

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

[PATCH v3 1/8] seccomp: allow COMPAT sigreturn overrides

2015-03-04 Thread Kees Cook
Some architectures may need to override the compat sigreturn definition,
as is already possible in the non-compat case.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 include/asm-generic/seccomp.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/asm-generic/seccomp.h b/include/asm-generic/seccomp.h
index 9fa1f653ed3b..c9ccafa0d99a 100644
--- a/include/asm-generic/seccomp.h
+++ b/include/asm-generic/seccomp.h
@@ -17,7 +17,9 @@
 #define __NR_seccomp_read_32   __NR_read
 #define __NR_seccomp_write_32  __NR_write
 #define __NR_seccomp_exit_32   __NR_exit
+#ifndef __NR_seccomp_sigreturn_32
 #define __NR_seccomp_sigreturn_32  __NR_rt_sigreturn
+#endif
 #endif /* CONFIG_COMPAT  ! already defined */
 
 #define __NR_seccomp_read  __NR_read
-- 
1.9.1

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

[PATCH v3 3/8] microblaze: use asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. Since microblaze is 32-bit, the COMPAT
seccomp defines are unused and can be dropped. The obsolete sigreturn
for seccomp strict mode is retained as an override. Remaining definitions
are identical.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/microblaze/include/asm/seccomp.h | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/microblaze/include/asm/seccomp.h 
b/arch/microblaze/include/asm/seccomp.h
index 0d912758a0d7..204618a2ce84 100644
--- a/arch/microblaze/include/asm/seccomp.h
+++ b/arch/microblaze/include/asm/seccomp.h
@@ -3,14 +3,8 @@
 
 #include linux/unistd.h
 
-#define __NR_seccomp_read  __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit  __NR_exit
 #define __NR_seccomp_sigreturn __NR_sigreturn
 
-#define __NR_seccomp_read_32   __NR_read
-#define __NR_seccomp_write_32  __NR_write
-#define __NR_seccomp_exit_32   __NR_exit
-#define __NR_seccomp_sigreturn_32  __NR_sigreturn
+#include asm-generic/seccomp.h
 
 #endif /* _ASM_MICROBLAZE_SECCOMP_H */
-- 
1.9.1

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

Re: [PATCH 4/5] mm: split ET_DYN ASLR from mmap ASLR

2015-03-04 Thread Michael Ellerman
On Wed, 2015-03-04 at 13:13 -0800, Kees Cook wrote:
 
 I had a question in the powerpc-specific change that may have gone unnoticed:
 
 Can mmap ASLR be safely enabled in the legacy mmap case here? Other archs
 use mm-mmap_base = TASK_UNMAPPED_BASE + random_factor.
 
 Separate from this series, do you happen to know if this improvement
 can be made, or if the legacy mmap on powerpc can't handle this?

Yeah I saw that. The short answer is I'm not sure.

I assume we have that distinction for some good reason, but whether we still
need it I don't know. I'll dig a bit and see if anyone can remember the details.

cheers


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

[PATCH v3 5/8] parisc: switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. Definitions were identical.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/parisc/include/asm/Kbuild|  1 +
 arch/parisc/include/asm/seccomp.h | 16 
 2 files changed, 1 insertion(+), 16 deletions(-)
 delete mode 100644 arch/parisc/include/asm/seccomp.h

diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild
index 8686237a3c3c..12b341d04f88 100644
--- a/arch/parisc/include/asm/Kbuild
+++ b/arch/parisc/include/asm/Kbuild
@@ -20,6 +20,7 @@ generic-y += param.h
 generic-y += percpu.h
 generic-y += poll.h
 generic-y += preempt.h
+generic-y += seccomp.h
 generic-y += segment.h
 generic-y += topology.h
 generic-y += trace_clock.h
diff --git a/arch/parisc/include/asm/seccomp.h 
b/arch/parisc/include/asm/seccomp.h
deleted file mode 100644
index 015f7887aa29..
--- a/arch/parisc/include/asm/seccomp.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _ASM_PARISC_SECCOMP_H
-#define _ASM_PARISC_SECCOMP_H
-
-#include linux/unistd.h
-
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
-#define __NR_seccomp_read_32 __NR_read
-#define __NR_seccomp_write_32 __NR_write
-#define __NR_seccomp_exit_32 __NR_exit
-#define __NR_seccomp_sigreturn_32 __NR_rt_sigreturn
-
-#endif /* _ASM_PARISC_SECCOMP_H */
-- 
1.9.1

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

Re: Problems with Kernels 3.17-rc1 and onwards on Acube Sam460 AMCC 460ex board

2015-03-04 Thread Michael Ellerman
On Wed, 2015-03-04 at 07:46 -0400, Julian Margetson wrote:
 Still stuck.
 Problem still exist with 4.0.0-rc2 and I cant finish the bisect.
 Triggered when using HDMI. No problem when using DVI.

 [   33.535692] Unable to handle kernel paging request for data at address 
 0x0008
 [   33.566786] Faulting instruction address: 0xc049db84
 [   33.574188] Vector: 300 (Data Access) at [eeb13c20]
 [   33.579086] pc: c049db84: radeon_audio_enable+0x4/0x18
 [   33.584630] lr: c049e2f4: radeon_audio_detect+0x288/0x290
 [   33.590429] sp: eeb13cd0
 [   33.593310]msr: 29000
 [   33.595931]dar: 8
 [   33.598207]  dsisr: 0
 [   33.600480]   current = 0xeea93ac0
 [   33.603885] pid   = 2311, comm = Xorg
 [   33.607922] enter ? for help
 [   33.610806] [link register   ] c049e2f4 radeon_audio_detect+0x288/0x290
 [   33.617469] [eeb13cd0] c049e254 radeon_audio_detect+0x1e8/0x290 
 (unreliable)
 [   33.624571] [eeb13d00] c03dfe7c radeon_dvi_detect+0x388/0x3ac
 [   33.630369] [eeb13d30] c038b9d4 
 drm_helper_probe_single_connector_modes_merge_bits+0xf4/0x434
 [   33.638954] [eeb13d70] c03a7670 drm_mode_getconnector+0xf4/0x334
 [   33.645022] [eeb13e10] c039a8c0 drm_ioctl+0x348/0x464
 [   33.650135] [eeb13ed0] c00d0ca0 do_vfs_ioctl+0x52c/0x6e8
 [   33.655507] [eeb13f20] c00d0e9c SyS_ioctl+0x40/0x68
 [   33.660438] [eeb13f40] c000ab04 ret_from_syscall+0x0/0x3c
 [   33.665896] --- Exception: c01 (System Call) at 6fb1b8dc
 [   33.671253] SP (bfa56d20) is in userspace
 [   33.675263] mon  no input ...

This just looks like a missing NULL check in the radeon code. Probably here:

void radeon_audio_detect(struct drm_connector *connector,
enum drm_connector_status status)
{
struct radeon_device *rdev;
struct radeon_encoder *radeon_encoder;
struct radeon_encoder_atom_dig *dig;

if (!connector || !connector-encoder)
return;

rdev = connector-encoder-dev-dev_private;
   ^

So you could try adding !connector-encoder-dev to the if there.

cheers


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

[PATCH v3 2/8] arm: use asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. Definitions were identical.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/arm/include/asm/Kbuild|  1 +
 arch/arm/include/asm/seccomp.h | 11 ---
 2 files changed, 1 insertion(+), 11 deletions(-)
 delete mode 100644 arch/arm/include/asm/seccomp.h

diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild
index fe74c0d1e485..d7be5a9fd171 100644
--- a/arch/arm/include/asm/Kbuild
+++ b/arch/arm/include/asm/Kbuild
@@ -22,6 +22,7 @@ generic-y += preempt.h
 generic-y += resource.h
 generic-y += rwsem.h
 generic-y += scatterlist.h
+generic-y += seccomp.h
 generic-y += sections.h
 generic-y += segment.h
 generic-y += sembuf.h
diff --git a/arch/arm/include/asm/seccomp.h b/arch/arm/include/asm/seccomp.h
deleted file mode 100644
index 52b156b341f5..
--- a/arch/arm/include/asm/seccomp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _ASM_ARM_SECCOMP_H
-#define _ASM_ARM_SECCOMP_H
-
-#include linux/unistd.h
-
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
-#endif /* _ASM_ARM_SECCOMP_H */
-- 
1.9.1

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

Re: [PATCH] clk: ppc-corenet: Add support for the FMD clock

2015-03-04 Thread Scott Wood
On Fri, 2015-02-27 at 10:02 -0600, Kumar Gala wrote:
 On Jan 20, 2015, at 6:03 AM, Igal.Liberman igal.liber...@freescale.com 
 wrote:
  +   guts_regs = of_iomap(guts, 0);
  +   of_node_put(guts);
  +   if (!guts_regs) {
  +   pr_err(ioremap of GUTS node failed\n);
  +   return -EINVAL;
  +   }
 
 Have you guys looked at using drivers/mfd/syscon.c for GUTS access.

Given the lack of documentation, could you explain what that file
offers?  Other than a requirement to modify existing device trees to do
something other than describe the hardware (that file won't touch
anything that isn't compatible with syscon).

-Scott


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

[PATCH v3 7/8] sparc: switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. The obsolete sigreturn in COMPAT mode
is retained as an override. Remaining definitions are identical. Also
corrected missing #define for header reinclusion protection.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/sparc/include/asm/seccomp.h | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/sparc/include/asm/seccomp.h b/arch/sparc/include/asm/seccomp.h
index adca1bce41d4..5ef8826d44f8 100644
--- a/arch/sparc/include/asm/seccomp.h
+++ b/arch/sparc/include/asm/seccomp.h
@@ -1,15 +1,10 @@
 #ifndef _ASM_SECCOMP_H
+#define _ASM_SECCOMP_H
 
 #include linux/unistd.h
 
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
-#define __NR_seccomp_read_32 __NR_read
-#define __NR_seccomp_write_32 __NR_write
-#define __NR_seccomp_exit_32 __NR_exit
 #define __NR_seccomp_sigreturn_32 __NR_sigreturn
 
+#include asm-generic/seccomp.h
+
 #endif /* _ASM_SECCOMP_H */
-- 
1.9.1

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

[PATCH] powerpc/pseries: Introduce api_version to migration sysfs interface

2015-03-04 Thread Tyrel Datwyler
The /sys/kernel/mobility/migration interface was added all the way back
in 2.6.37. However, the drmgr userspace tool was never augmented to use
this interface to perfrom migrations. Instead it has continued using a
faux rtas call coupled with performing the device tree update processing
in userspace and communicating it back to the kernel via the ugly
/proc/ppc64/ofdt interface.

Up until 3.12 the device tree update code in the kernel was badly broken
and bit rotting. This code was fixed in 3.12 and is now utilized by the
kernel suspend code as of 3.15. The kernel is now better suited to
handle the post-mobility fixup of the device tree and drmgr should be
transitioned to using the sysfs migration interface.

This patch introduces the api_version sysfs file to /sys/kernel/mobility
as a means for drmgr to query the current implementation level of the
kernel migration code. This initial versioning indicates it is capable
of perfroming all current PAPR requirements for migration including the
post-mobility firmware activation and device tree update.

Signed-off-by: Tyrel Datwyler tyr...@linux.vnet.ibm.com
Cc: Nathan Fontenot nf...@linux.vnet.ibm.com
Cc: Cyril Bur cyril...@gmail.com
---
 arch/powerpc/platforms/pseries/mobility.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/mobility.c 
b/arch/powerpc/platforms/pseries/mobility.c
index bdf62c1..ceb18d3 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -338,7 +338,16 @@ static ssize_t migrate_store(struct class *class, struct 
class_attribute *attr,
return count;
 }
 
+/*
+ * Used by drmgr to determine the kernel behavior of the migration interface.
+ *
+ * Version 1: Performs all PAPR requirements for migration including
+ * firmware activation and device tree update.
+ */
+#define MIGRATION_API_VERSION  1
+
 static CLASS_ATTR(migration, S_IWUSR, NULL, migrate_store);
+static CLASS_ATTR_STRING(api_version, S_IRUGO, 
__stringify(MIGRATION_API_VERSION));
 
 static int __init mobility_sysfs_init(void)
 {
@@ -349,7 +358,13 @@ static int __init mobility_sysfs_init(void)
return -ENOMEM;
 
rc = sysfs_create_file(mobility_kobj, class_attr_migration.attr);
+   if (rc)
+   pr_err(mobility: unable to create migration sysfs file 
(%d)\n, rc);
 
-   return rc;
+   rc = sysfs_create_file(mobility_kobj, 
class_attr_api_version.attr.attr);
+   if (rc)
+   pr_err(mobility: unable to create api_version sysfs file 
(%d)\n, rc);
+
+   return 0;
 }
 machine_device_initcall(pseries, mobility_sysfs_init);
-- 
1.7.12.2

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

[PATCH 7/7] soc/fman: Add the FMan SP FLIB

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/fsl/fman/Makefile |   1 +
 drivers/soc/fsl/fman/sp/Makefile  |  13 +++
 drivers/soc/fsl/fman/sp/fman_sp.c | 204 ++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/soc/fsl/fman/sp/Makefile
 create mode 100644 drivers/soc/fsl/fman/sp/fman_sp.c

diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index f415188..4a854b3 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -14,5 +14,6 @@ obj-$(CONFIG_FSL_FMAN_PORT)   += port/
 obj-$(CONFIG_FSL_FMAN_MAC) += mac/
 obj-$(CONFIG_FSL_FMAN_PCD) += pcd/
 obj-$(CONFIG_FSL_FMAN_RTC) += rtc/
+obj-$(CONFIG_FSL_FMAN) += sp/
 
 endif
diff --git a/drivers/soc/fsl/fman/sp/Makefile b/drivers/soc/fsl/fman/sp/Makefile
new file mode 100644
index 000..4655c11
--- /dev/null
+++ b/drivers/soc/fsl/fman/sp/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN) += fsl_fman_sp.o
+
+fsl_fman_sp-objs   := fman_sp.o
+
+endif
diff --git a/drivers/soc/fsl/fman/sp/fman_sp.c 
b/drivers/soc/fsl/fman/sp/fman_sp.c
new file mode 100644
index 000..e11413d
--- /dev/null
+++ b/drivers/soc/fsl/fman/sp/fman_sp.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_sp.h
+
+uint32_t fman_vsp_get_statistics(struct fm_pcd_storage_profile_regs *regs,
+uint16_t index)
+{
+   struct fm_pcd_storage_profile_regs *sp_regs;
+
+   sp_regs = regs[index];
+   return ioread32be(sp_regs-fm_sp_acnt);
+}
+
+void fman_vsp_set_statistics(struct fm_pcd_storage_profile_regs *regs,
+uint16_t index, uint32_t value)
+{
+   struct fm_pcd_storage_profile_regs *sp_regs;
+
+   sp_regs = regs[index];
+   iowrite32be(value, sp_regs-fm_sp_acnt);
+}
+
+void fman_vsp_defconfig(struct fm_storage_profile_params *cfg)
+{
+   cfg-dma_swap_data = DEFAULT_FMAN_SP_DMA_SWAP_DATA;
+   cfg-int_context_cache_attr =
+   DEFAULT_FMAN_SP_DMA_INT_CONTEXT_CACHE_ATTR;
+   cfg-header_cache_attr = DEFAULT_FMAN_SP_DMA_HEADER_CACHE_ATTR;
+   cfg-scatter_gather_cache_attr =
+   DEFAULT_FMAN_SP_DMA_SCATTER_GATHER_CACHE_ATTR;
+   cfg-dma_write_optimize = DEFAULT_FMAN_SP_DMA_WRITE_OPTIMIZE;
+   cfg-no_scather_gather = DEFAULT_FMAN_SP_NO_SCATTER_GATHER;
+}
+
+static inline uint32_t calc_vec_dep(int max_pools, bool *pools,
+   struct fman_ext_pools *ext_buf_pools,
+   uint32_t mask)
+{
+   int i, j;
+   uint32_t vector = 0;
+
+   for (i = 0; i  max_pools; i++)
+   if (pools[i])
+   for (j = 0; j  ext_buf_pools-num_pools_used; j++)
+   if (i == ext_buf_pools-ext_buf_pool[j].id) {
+   vector |= mask  j;
+   break;
+   }
+   return 

Re: [PATCH v3 8/8] x86: switch to using asm-generic for seccomp.h

2015-03-04 Thread Ingo Molnar

* Kees Cook keesc...@chromium.org wrote:

 Switch to using the newly created asm-generic/seccomp.h for the 
 seccomp strict mode syscall definitions. The obsolete sigreturn 
 syscall override is retained in 32-bit mode, and the ia32 syscall 
 overrides are used in the compat case. Remaining definitions were 
 identical.
 
 Signed-off-by: Kees Cook keesc...@chromium.org

Acked-by: Ingo Molnar mi...@kernel.org

Thanks,

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

[PATCH] ASoC: fsl_ssi: Don't try to round-up for PM divisor calculation

2015-03-04 Thread Nicolin Chen
According to i.MX6 Series Reference Manual, the formula to calculate
the sys clock is

sysclk rate = bclk rate * (div2 + 1) * (7 * psr + 1) * (pm + 1) * 2

Commit aafa85e71a75 (ASoC: fsl_ssi: Add DAI master mode support for
SSI on i.MX series) added the divisor calculation which relies on
the clk_round_rate(). However, at that time, clk_round_rate() didn't
provide closest clock rates for some cases because it might not use
a correct rounding policy. So using the original formula (pm + 1) for
PM divisor was not able to give us a desired clock rate. And then we
used (pm + 2) to do the trick.

However, the clk-divider driver has been refined a lot since commit
b11d282dbea2 (clk: divider: fix rate calculation for fractional rates)
Now using (pm + 2) trick would result an incorrect clock rate.

So this patch fixes the problem by removing the useless trick.

Reported-by: Stephane Cerveau scerv...@voxtok.com
Signed-off-by: Nicolin Chen nicoleots...@gmail.com
---
 sound/soc/fsl/fsl_ssi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 05575f4..6b0c8f7 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -603,7 +603,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream 
*substream,
factor = (div2 + 1) * (7 * psr + 1) * 2;
 
for (i = 0; i  255; i++) {
-   tmprate = freq * factor * (i + 2);
+   tmprate = freq * factor * (i + 1);
 
if (baudclk_is_used)
clkrate = clk_get_rate(ssi_private-baudclk);
-- 
1.9.1

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

[PATCH 2/7] soc/fman: Add the FMan FLIB

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/Kconfig   |1 +
 drivers/soc/Makefile  |1 +
 drivers/soc/fsl/Kconfig   |1 +
 drivers/soc/fsl/Makefile  |1 +
 drivers/soc/fsl/fman/Kconfig  |7 +
 drivers/soc/fsl/fman/Makefile |   13 +
 drivers/soc/fsl/fman/fman.c   | 1396 +
 7 files changed, 1420 insertions(+)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/Makefile
 create mode 100644 drivers/soc/fsl/fman/Kconfig
 create mode 100644 drivers/soc/fsl/fman/Makefile
 create mode 100644 drivers/soc/fsl/fman/fman.c

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 76d6bd4..674a6e6 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,5 +1,6 @@
 menu SOC (System On Chip) specific Drivers
 
+source drivers/soc/fsl/Kconfig
 source drivers/soc/qcom/Kconfig
 source drivers/soc/ti/Kconfig
 source drivers/soc/versatile/Kconfig
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 063113d..42836ee 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -2,6 +2,7 @@
 # Makefile for the Linux Kernel SOC specific device drivers.
 #
 
+obj-$(CONFIG_FSL_SOC)  += fsl/
 obj-$(CONFIG_ARCH_QCOM)+= qcom/
 obj-$(CONFIG_ARCH_TEGRA)   += tegra/
 obj-$(CONFIG_SOC_TI)   += ti/
diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
new file mode 100644
index 000..38c08ae
--- /dev/null
+++ b/drivers/soc/fsl/Kconfig
@@ -0,0 +1 @@
+source drivers/soc/fsl/fman/Kconfig
diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile
new file mode 100644
index 000..97d715c
--- /dev/null
+++ b/drivers/soc/fsl/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_FSL_FMAN)   += fman/
diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
new file mode 100644
index 000..e5009a9
--- /dev/null
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -0,0 +1,7 @@
+menuconfig FSL_FMAN
+   tristate Freescale DPAA Frame Manager
+   depends on FSL_SOC || COMPILE_TEST
+   default n
+   help
+   Freescale Data-Path Acceleration Architecture Frame Manager
+   (FMan) support
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
new file mode 100644
index 000..d7fbecb
--- /dev/null
+++ b/drivers/soc/fsl/fman/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
+
+fsl_fman-objs  := fman.o
+
+endif
diff --git a/drivers/soc/fsl/fman/fman.c b/drivers/soc/fsl/fman/fman.c
new file mode 100644
index 000..dbf2cd3
--- /dev/null
+++ b/drivers/soc/fsl/fman/fman.c
@@ -0,0 +1,1396 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman.h
+
+uint32_t fman_get_bmi_err_event(struct fman_bmi_regs __iomem *bmi_rg)
+{
+   uint32_t event, mask, force;
+
+   event = ioread32be(bmi_rg-fmbm_ievr);
+   mask = ioread32be(bmi_rg-fmbm_ier);
+   event = mask;
+   /* clear the forced events */
+   force = 

[PATCH 3/7] soc/fman: Add the FMan port FLIB

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/fsl/fman/Kconfig  |   10 +
 drivers/soc/fsl/fman/Makefile |2 +
 drivers/soc/fsl/fman/port/Makefile|   13 +
 drivers/soc/fsl/fman/port/fman_port.c | 1536 +
 4 files changed, 1561 insertions(+)
 create mode 100644 drivers/soc/fsl/fman/port/Makefile
 create mode 100644 drivers/soc/fsl/fman/port/fman_port.c

diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
index e5009a9..a5f981f 100644
--- a/drivers/soc/fsl/fman/Kconfig
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -5,3 +5,13 @@ menuconfig FSL_FMAN
help
Freescale Data-Path Acceleration Architecture Frame Manager
(FMan) support
+
+if FSL_FMAN
+
+config FSL_FMAN_PORT
+   bool FMan port
+   default n
+   help
+   Freescale DPAA FMan port support
+
+endif  # FSL_FMAN
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index d7fbecb..a0132cc 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -10,4 +10,6 @@ obj-$(CONFIG_FSL_FMAN)+= fsl_fman.o
 
 fsl_fman-objs  := fman.o
 
+obj-$(CONFIG_FSL_FMAN_PORT) += port/
+
 endif
diff --git a/drivers/soc/fsl/fman/port/Makefile 
b/drivers/soc/fsl/fman/port/Makefile
new file mode 100644
index 000..3e79c3f
--- /dev/null
+++ b/drivers/soc/fsl/fman/port/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN_PORT),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN_PORT)+= fsl_fman_port.o
+
+fsl_fman_port-objs := fman_port.o
+
+endif
diff --git a/drivers/soc/fsl/fman/port/fman_port.c 
b/drivers/soc/fsl/fman/port/fman_port.c
new file mode 100644
index 000..cc9ebb0
--- /dev/null
+++ b/drivers/soc/fsl/fman/port/fman_port.c
@@ -0,0 +1,1536 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include common/general.h
+
+#include fman_common.h
+#include fsl_fman_port.h
+
+/* problem Eyal: the following should not be here*/
+#define NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME0x0028
+
+static uint32_t get_no_pcd_nia_bmi_ac_enc_frame(struct fman_port_cfg *cfg)
+{
+   if (cfg-errata_A006675)
+   return NIA_ENG_FM_CTL |
+   NIA_FM_CTL_AC_NO_IPACC_PRE_BMI_ENQ_FRAME;
+   else
+   return NIA_ENG_BMI | NIA_BMI_AC_ENQ_FRAME;
+}
+
+static int init_bmi_rx(struct fman_port *port,
+  struct fman_port_cfg *cfg,
+  struct fman_port_params *params)
+{
+   struct fman_port_rx_bmi_regs __iomem *regs = port-bmi_regs-rx;
+   uint32_t tmp;
+
+   /* Rx Configuration register */
+   tmp = 0;
+   if (cfg-discard_override)
+   tmp |= BMI_PORT_CFG_FDOVR;
+   iowrite32be(tmp, regs-fmbm_rcfg);
+
+   /* DMA attributes */
+   tmp = (uint32_t)cfg-dma_swap_data  BMI_DMA_ATTR_SWP_SHIFT;
+   if (cfg-dma_ic_stash_on)
+   tmp |= BMI_DMA_ATTR_IC_STASH_ON;
+   if (cfg-dma_header_stash_on)
+   tmp |= BMI_DMA_ATTR_HDR_STASH_ON;
+  

[PATCH 5/7] soc/fman: Add the FMan parser and KeyGen FLIB(s)

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/fsl/fman/Kconfig|   6 +
 drivers/soc/fsl/fman/Makefile   |   1 +
 drivers/soc/fsl/fman/pcd/Makefile   |  13 +
 drivers/soc/fsl/fman/pcd/fman_kg.c  | 850 
 drivers/soc/fsl/fman/pcd/fman_prs.c | 127 ++
 5 files changed, 997 insertions(+)
 create mode 100644 drivers/soc/fsl/fman/pcd/Makefile
 create mode 100644 drivers/soc/fsl/fman/pcd/fman_kg.c
 create mode 100644 drivers/soc/fsl/fman/pcd/fman_prs.c

diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
index c1c258c..2559ee9 100644
--- a/drivers/soc/fsl/fman/Kconfig
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -20,4 +20,10 @@ config FSL_FMAN_MAC
help
Freescale DPAA FMan MAC support
 
+config FSL_FMAN_PCD
+   bool FMan PCD
+   default n
+   help
+   Freescale DPAA FMan Parse, Classify and Distribute support
+
 endif  # FSL_FMAN
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index ffaabd9..dc37f35 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -12,5 +12,6 @@ fsl_fman-objs := fman.o
 
 obj-$(CONFIG_FSL_FMAN_PORT)+= port/
 obj-$(CONFIG_FSL_FMAN_MAC) += mac/
+obj-$(CONFIG_FSL_FMAN_PCD) += pcd/
 
 endif
diff --git a/drivers/soc/fsl/fman/pcd/Makefile 
b/drivers/soc/fsl/fman/pcd/Makefile
new file mode 100644
index 000..fa40367
--- /dev/null
+++ b/drivers/soc/fsl/fman/pcd/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN_PCD),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN_PCD) += fsl_fman_pcd.o
+
+fsl_fman_pcd-objs  := fman_kg.o fman_prs.o
+
+endif
diff --git a/drivers/soc/fsl/fman/pcd/fman_kg.c 
b/drivers/soc/fsl/fman/pcd/fman_kg.c
new file mode 100644
index 000..f420db6
--- /dev/null
+++ b/drivers/soc/fsl/fman/pcd/fman_kg.c
@@ -0,0 +1,850 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_kg.h
+
+/* static functions */
+
+static uint32_t build_ar_bind_scheme(uint8_t hwport_id, bool write)
+{
+   uint32_t rw;
+
+   rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
+
+   return (uint32_t)(FM_KG_KGAR_GO | rw | FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hwport_id | FM_PCD_KG_KGAR_SEL_PORT_WSEL_SP);
+}
+
+static void clear_pe_all_scheme(struct fman_kg_regs __iomem *regs,
+   uint8_t hwport_id)
+{
+   uint32_t ar;
+
+   fman_kg_write_sp(regs, 0x, 0);
+
+   ar = build_ar_bind_scheme(hwport_id, true);
+   fman_kg_write_ar_wait(regs, ar);
+}
+
+static uint32_t build_ar_bind_cls_plan(uint8_t hwport_id, bool write)
+{
+   uint32_t rw;
+
+   rw = write ? (uint32_t)FM_KG_KGAR_WRITE : (uint32_t)FM_KG_KGAR_READ;
+
+   return (uint32_t)(FM_KG_KGAR_GO | rw | FM_PCD_KG_KGAR_SEL_PORT_ENTRY |
+ hwport_id | FM_PCD_KG_KGAR_SEL_PORT_WSEL_CPP);
+}
+
+static void clear_pe_all_cls_plan(struct fman_kg_regs __iomem *regs,
+ 

[PATCH 6/7] soc/fman: Add the FMan RTC FLIB

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/fsl/fman/Kconfig|   6 +
 drivers/soc/fsl/fman/Makefile   |   1 +
 drivers/soc/fsl/fman/rtc/Makefile   |  13 ++
 drivers/soc/fsl/fman/rtc/fman_rtc.c | 354 
 4 files changed, 374 insertions(+)
 create mode 100644 drivers/soc/fsl/fman/rtc/Makefile
 create mode 100644 drivers/soc/fsl/fman/rtc/fman_rtc.c

diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
index 2559ee9..a144eb5 100644
--- a/drivers/soc/fsl/fman/Kconfig
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -26,4 +26,10 @@ config FSL_FMAN_PCD
help
Freescale DPAA FMan Parse, Classify and Distribute support
 
+config FSL_FMAN_RTC
+   bool FMan RTC
+   default n
+   help
+   Freescale DPAA FMan Real Time Clock (PTP) support
+
 endif  # FSL_FMAN
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index dc37f35..f415188 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -13,5 +13,6 @@ fsl_fman-objs := fman.o
 obj-$(CONFIG_FSL_FMAN_PORT)+= port/
 obj-$(CONFIG_FSL_FMAN_MAC) += mac/
 obj-$(CONFIG_FSL_FMAN_PCD) += pcd/
+obj-$(CONFIG_FSL_FMAN_RTC) += rtc/
 
 endif
diff --git a/drivers/soc/fsl/fman/rtc/Makefile 
b/drivers/soc/fsl/fman/rtc/Makefile
new file mode 100644
index 000..69a92fb
--- /dev/null
+++ b/drivers/soc/fsl/fman/rtc/Makefile
@@ -0,0 +1,13 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN_RTC),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN_RTC) += fsl_fman_rtc.o
+
+fsl_fman_rtc-objs  := fman_rtc.o
+
+endif
diff --git a/drivers/soc/fsl/fman/rtc/fman_rtc.c 
b/drivers/soc/fsl/fman/rtc/fman_rtc.c
new file mode 100644
index 000..e6d6dae
--- /dev/null
+++ b/drivers/soc/fsl/fman/rtc/fman_rtc.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_rtc.h
+
+void fman_rtc_defconfig(struct rtc_cfg *cfg)
+{
+   int i;
+
+   cfg-src_clk = DEFAULT_SRC_CLOCK;
+   cfg-invert_input_clk_phase = DEFAULT_INVERT_INPUT_CLK_PHASE;
+   cfg-invert_output_clk_phase = DEFAULT_INVERT_OUTPUT_CLK_PHASE;
+   cfg-pulse_realign = DEFAULT_PULSE_REALIGN;
+   for (i = 0; i  FMAN_RTC_MAX_NUM_OF_ALARMS; i++)
+   cfg-alarm_polarity[i] = DEFAULT_ALARM_POLARITY;
+   for (i = 0; i  FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS; i++)
+   cfg-trigger_polarity[i] = DEFAULT_TRIGGER_POLARITY;
+}
+
+uint32_t fman_rtc_get_events(struct rtc_regs __iomem *regs)
+{
+   return ioread32be(regs-tmr_tevent);
+}
+
+uint32_t fman_rtc_get_event(struct rtc_regs __iomem *regs, uint32_t ev_mask)
+{
+   return ioread32be(regs-tmr_tevent)  ev_mask;
+}
+
+uint32_t fman_rtc_get_interrupt_mask(struct rtc_regs __iomem *regs)
+{
+   return ioread32be(regs-tmr_temask);
+}
+
+void fman_rtc_set_interrupt_mask(struct rtc_regs __iomem *regs, uint32_t mask)
+{
+   iowrite32be(mask, regs-tmr_temask);
+}
+
+void fman_rtc_ack_event(struct rtc_regs __iomem *regs, uint32_t events)
+{
+   

[PATCH v3 4/8] mips: switch to using asm-generic for seccomp.h

2015-03-04 Thread Kees Cook
Switch to using the newly created asm-generic/seccomp.h for the seccomp
strict mode syscall definitions. COMPAT definitions retain their overrides
and the remaining definitions were identical.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/mips/include/asm/seccomp.h | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/seccomp.h b/arch/mips/include/asm/seccomp.h
index f29c75cf83c6..1d8a2e2c75c1 100644
--- a/arch/mips/include/asm/seccomp.h
+++ b/arch/mips/include/asm/seccomp.h
@@ -2,11 +2,6 @@
 
 #include linux/unistd.h
 
-#define __NR_seccomp_read __NR_read
-#define __NR_seccomp_write __NR_write
-#define __NR_seccomp_exit __NR_exit
-#define __NR_seccomp_sigreturn __NR_rt_sigreturn
-
 /*
  * Kludge alert:
  *
@@ -29,4 +24,6 @@
 
 #endif /* CONFIG_MIPS32_O32 */
 
+#include asm-generic/seccomp.h
+
 #endif /* __ASM_SECCOMP_H */
-- 
1.9.1

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

[PATCH 4/7] soc/fman: Add the FMan MAC FLIB

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/soc/fsl/fman/Kconfig  |   6 +
 drivers/soc/fsl/fman/Makefile |   7 +-
 drivers/soc/fsl/fman/mac/Makefile |  15 +
 drivers/soc/fsl/fman/mac/fman_crc32.c | 117 
 drivers/soc/fsl/fman/mac/fman_crc32.h |  40 ++
 drivers/soc/fsl/fman/mac/fman_dtsec.c | 844 ++
 drivers/soc/fsl/fman/mac/fman_dtsec_mii_acc.c | 169 ++
 drivers/soc/fsl/fman/mac/fman_memac.c | 504 +++
 drivers/soc/fsl/fman/mac/fman_memac_mii_acc.c | 218 +++
 drivers/soc/fsl/fman/mac/fman_tgec.c  | 372 
 10 files changed, 2289 insertions(+), 3 deletions(-)
 create mode 100644 drivers/soc/fsl/fman/mac/Makefile
 create mode 100644 drivers/soc/fsl/fman/mac/fman_crc32.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_crc32.h
 create mode 100644 drivers/soc/fsl/fman/mac/fman_dtsec.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_dtsec_mii_acc.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_memac.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_memac_mii_acc.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_tgec.c

diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
index a5f981f..c1c258c 100644
--- a/drivers/soc/fsl/fman/Kconfig
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -14,4 +14,10 @@ config FSL_FMAN_PORT
help
Freescale DPAA FMan port support
 
+config FSL_FMAN_MAC
+   bool FMan MAC
+   default n
+   help
+   Freescale DPAA FMan MAC support
+
 endif  # FSL_FMAN
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index a0132cc..ffaabd9 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -6,10 +6,11 @@ FMAN = $(srctree)/drivers/soc/fsl/fman
 
 ccflags-y += -I$(FMAN)/flib
 
-obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
+obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
 
-fsl_fman-objs  := fman.o
+fsl_fman-objs  := fman.o
 
-obj-$(CONFIG_FSL_FMAN_PORT) += port/
+obj-$(CONFIG_FSL_FMAN_PORT)+= port/
+obj-$(CONFIG_FSL_FMAN_MAC) += mac/
 
 endif
diff --git a/drivers/soc/fsl/fman/mac/Makefile 
b/drivers/soc/fsl/fman/mac/Makefile
new file mode 100644
index 000..3188c46
--- /dev/null
+++ b/drivers/soc/fsl/fman/mac/Makefile
@@ -0,0 +1,15 @@
+ccflags-y += -DVERSION=\\
+
+ifeq ($(CONFIG_FSL_FMAN_MAC),y)
+
+FMAN = $(srctree)/drivers/soc/fsl/fman
+
+ccflags-y += -I$(FMAN)/flib
+
+obj-$(CONFIG_FSL_FMAN_MAC) += fsl_fman_mac.o
+
+fsl_fman_mac-objs  := fman_dtsec.o fman_dtsec_mii_acc.o\
+  fman_memac.o fman_tgec.o \
+  fman_crc32.o fman_memac_mii_acc.o
+
+endif
diff --git a/drivers/soc/fsl/fman/mac/fman_crc32.c 
b/drivers/soc/fsl/fman/mac/fman_crc32.c
new file mode 100644
index 000..2c85178
--- /dev/null
+++ b/drivers/soc/fsl/fman/mac/fman_crc32.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *   names of its contributors may be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fman_crc32.h
+#include common/general.h
+
+/* precomputed CRC values for address hashing 

[PATCH 0/7] Freescale DPAA FMan FLIB(s)

2015-03-04 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

The Freescale Data Path Acceleration Architecture (DPAA) is a set of
hardware components on specific QorIQ P and T series multicore processors.
This architecture provides the infrastructure to support simplified
sharing of networking interfaces and accelerators by multiple CPU cores,
and the accelerators themselves.

One of the DPAA accelerators is the Frame Manager (FMan), which
combines the Ethernet network interfaces with packet distribution
logic to provide intelligent distribution and queuing decisions for
incoming traffic at line rate.

This patch presents the FMan Foundation Libraries (FLIB) headers.
The FMan FLIB suite adds basic support for the DPAA FMan hardware register 
access.
The FMan FLIB suite is used in Freescale's SDK Releases.

Igal Liberman (7):
  soc/fman: Add the FMan FLIB headers
  soc/fman: Add the FMan FLIB
  soc/fman: Add the FMan port FLIB
  soc/fman: Add the FMan MAC FLIB
  soc/fman: Add the FMan parser and KeyGen FLIB(s)
  soc/fman: Add the FMan RTC FLIB
  soc/fman: Add the FMan SP FLIB

 drivers/soc/Kconfig|1 +
 drivers/soc/Makefile   |1 +
 drivers/soc/fsl/Kconfig|1 +
 drivers/soc/fsl/Makefile   |1 +
 drivers/soc/fsl/fman/Kconfig   |   35 +
 drivers/soc/fsl/fman/Makefile  |   19 +
 drivers/soc/fsl/fman/flib/common/general.h |   45 +
 drivers/soc/fsl/fman/flib/fman_common.h|   74 +
 drivers/soc/fsl/fman/flib/fsl_enet.h   |  276 
 drivers/soc/fsl/fman/flib/fsl_fman.h   |  801 ++
 drivers/soc/fsl/fman/flib/fsl_fman_dtsec.h | 1017 +
 drivers/soc/fsl/fman/flib/fsl_fman_dtsec_mii_acc.h |  104 ++
 drivers/soc/fsl/fman/flib/fsl_fman_kg.h|  506 +++
 drivers/soc/fsl/fman/flib/fsl_fman_memac.h |  492 +++
 drivers/soc/fsl/fman/flib/fsl_fman_memac_mii_acc.h |   77 +
 drivers/soc/fsl/fman/flib/fsl_fman_port.h  |  602 
 drivers/soc/fsl/fman/flib/fsl_fman_prs.h   |  106 ++
 drivers/soc/fsl/fman/flib/fsl_fman_rtc.h   |  415 ++
 drivers/soc/fsl/fman/flib/fsl_fman_sp.h|  133 ++
 drivers/soc/fsl/fman/flib/fsl_fman_tgec.h  |  484 ++
 drivers/soc/fsl/fman/fman.c| 1396 ++
 drivers/soc/fsl/fman/mac/Makefile  |   15 +
 drivers/soc/fsl/fman/mac/fman_crc32.c  |  117 ++
 drivers/soc/fsl/fman/mac/fman_crc32.h  |   40 +
 drivers/soc/fsl/fman/mac/fman_dtsec.c  |  844 +++
 drivers/soc/fsl/fman/mac/fman_dtsec_mii_acc.c  |  169 +++
 drivers/soc/fsl/fman/mac/fman_memac.c  |  504 +++
 drivers/soc/fsl/fman/mac/fman_memac_mii_acc.c  |  218 +++
 drivers/soc/fsl/fman/mac/fman_tgec.c   |  372 +
 drivers/soc/fsl/fman/pcd/Makefile  |   13 +
 drivers/soc/fsl/fman/pcd/fman_kg.c |  850 +++
 drivers/soc/fsl/fman/pcd/fman_prs.c|  127 ++
 drivers/soc/fsl/fman/port/Makefile |   13 +
 drivers/soc/fsl/fman/port/fman_port.c  | 1536 
 drivers/soc/fsl/fman/rtc/Makefile  |   13 +
 drivers/soc/fsl/fman/rtc/fman_rtc.c|  354 +
 drivers/soc/fsl/fman/sp/Makefile   |   13 +
 drivers/soc/fsl/fman/sp/fman_sp.c  |  204 +++
 38 files changed, 11988 insertions(+)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/Makefile
 create mode 100644 drivers/soc/fsl/fman/Kconfig
 create mode 100644 drivers/soc/fsl/fman/Makefile
 create mode 100644 drivers/soc/fsl/fman/flib/common/general.h
 create mode 100644 drivers/soc/fsl/fman/flib/fman_common.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_enet.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_dtsec.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_dtsec_mii_acc.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_kg.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_memac.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_memac_mii_acc.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_port.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_prs.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_rtc.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_sp.h
 create mode 100644 drivers/soc/fsl/fman/flib/fsl_fman_tgec.h
 create mode 100644 drivers/soc/fsl/fman/fman.c
 create mode 100644 drivers/soc/fsl/fman/mac/Makefile
 create mode 100644 drivers/soc/fsl/fman/mac/fman_crc32.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_crc32.h
 create mode 100644 drivers/soc/fsl/fman/mac/fman_dtsec.c
 create mode 100644 drivers/soc/fsl/fman/mac/fman_dtsec_mii_acc.c
 create mode 100644 

Re: [PATCH] spi: fsl-spi: use of_iomap() to map parameter ram on CPM1

2015-03-04 Thread leroy christophe

Le 03/03/2015 19:44, Mark Brown a écrit :

On Thu, Feb 26, 2015 at 05:11:42PM +0100, Christophe Leroy wrote:

On CPM2, the SPI parameter RAM is dynamically allocated in the dualport RAM
whereas in CPM1, it is statically allocated to a default address with
capability to relocate it somewhere else via the use of CPM micropatch.
The address of the parameter RAM is given by the boot loader and expected
to be mapped via of_iomap()

Why are we using of_iomap() rather than a generic I/O mapping function
here?

Euh ...

because all drivers for powerpc seems to be using of_iomap(), as on 
powerpc the HW is described by the bootloader in a OF device tree.
Today, of_iomap() is at least used in FSL SPI, FSL UART, SPI mpc52xx, 
UART mpc52xx, i2c-mpc, i2c-cpm, freescale ethernet drivers, etc 


Is it not correct ?

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

Re: [PATCH v5 2/4] pstore: Add pstore type id for PPC64 opal nvram partition

2015-03-04 Thread Hari Bathini

On 02/06/2015 01:06 AM, Hari Bathini wrote:

This patch adds a new PPC64 partition type to be used for opal
specific nvram partition. A new partition type is needed as none
of the existing type matches this partition type.

Signed-off-by: Hari Bathini hbath...@linux.vnet.ibm.com


This patch series is reviewed by Kees.
Reference link: https://lkml.org/lkml/2015/2/5/651

Reviewed-by: Kees Cook keesc...@chromium.org

Thanks
Hari


---
  fs/pstore/inode.c  |3 +++
  include/linux/pstore.h |1 +
  2 files changed, 4 insertions(+)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 5041660..8e0c009 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -359,6 +359,9 @@ int pstore_mkfile(enum pstore_type_id type, char *psname, 
u64 id, int count,
case PSTORE_TYPE_PPC_COMMON:
sprintf(name, powerpc-common-%s-%lld, psname, id);
break;
+   case PSTORE_TYPE_PPC_OPAL:
+   sprintf(name, powerpc-opal-%s-%lld, psname, id);
+   break;
case PSTORE_TYPE_UNKNOWN:
sprintf(name, unknown-%s-%lld, psname, id);
break;
diff --git a/include/linux/pstore.h b/include/linux/pstore.h
index ece0c6b..af44980 100644
--- a/include/linux/pstore.h
+++ b/include/linux/pstore.h
@@ -39,6 +39,7 @@ enum pstore_type_id {
PSTORE_TYPE_PPC_RTAS= 4,
PSTORE_TYPE_PPC_OF  = 5,
PSTORE_TYPE_PPC_COMMON  = 6,
+   PSTORE_TYPE_PPC_OPAL= 7,
PSTORE_TYPE_UNKNOWN = 255
  };
  


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


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

[PATCH 2/4] perf: Split perf_event_read() and perf_event_count()

2015-03-04 Thread Sukadev Bhattiprolu
perf_event_read() does two things:

- call the PMU to read/update the counter value
- and compute the total count of the event and its children

perf_event_reset() needs the first piece but doesn't need the second.

Similarly, when we implement the ability to read a group of events
using the transaction interface, we would sometimes need one but
not both.

Break up perf_event_read() and have it just read/update the counter
and have the callers compute the total count if necessary.

Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
 kernel/events/core.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index dbc12bf..11c4154 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3223,7 +3223,7 @@ static inline u64 perf_event_count(struct perf_event 
*event)
return local64_read(event-count) + atomic64_read(event-child_count);
 }
 
-static u64 perf_event_read(struct perf_event *event)
+static void perf_event_read(struct perf_event *event)
 {
/*
 * If event is enabled and currently active on a CPU, update the
@@ -3249,8 +3249,6 @@ static u64 perf_event_read(struct perf_event *event)
update_event_times(event);
raw_spin_unlock_irqrestore(ctx-lock, flags);
}
-
-   return perf_event_count(event);
 }
 
 /*
@@ -3654,14 +3652,18 @@ u64 perf_event_read_value(struct perf_event *event, u64 
*enabled, u64 *running)
*running = 0;
 
mutex_lock(event-child_mutex);
-   total += perf_event_read(event);
+
+   perf_event_read(event);
+   total += perf_event_count(event);
+
*enabled += event-total_time_enabled +
atomic64_read(event-child_total_time_enabled);
*running += event-total_time_running +
atomic64_read(event-child_total_time_running);
 
list_for_each_entry(child, event-child_list, child_list) {
-   total += perf_event_read(child);
+   perf_event_read(child);
+   total += perf_event_count(child);
*enabled += child-total_time_enabled;
*running += child-total_time_running;
}
@@ -3821,7 +3823,7 @@ static unsigned int perf_poll(struct file *file, 
poll_table *wait)
 
 static void _perf_event_reset(struct perf_event *event)
 {
-   (void)perf_event_read(event);
+   perf_event_read(event);
local64_set(event-count, 0);
perf_event_update_userpage(event);
 }
-- 
1.8.3.1

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

[PATCH 1/4] perf: Add 'flags' parameter to pmu txn interfaces

2015-03-04 Thread Sukadev Bhattiprolu
In addition to using the transaction interface to schedule events
on a PMU, we will use it to also read a group of counters at once.
Accordingly, add a flags parameter to the transaction interfaces.
The flags indicate wheether the transaction is to add events to
the PMU (PERF_PMU_TXN_ADD) or to read the events PERF_PMU_TXN_READ.

Based on input from Peter Zijlstra.

Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
 arch/powerpc/perf/core-book3s.c  | 15 ---
 arch/x86/kernel/cpu/perf_event.c | 15 ---
 include/linux/perf_event.h   | 14 +++---
 kernel/events/core.c | 26 +++---
 4 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 7c4f669..3d3739a 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1573,10 +1573,13 @@ static void power_pmu_stop(struct perf_event *event, 
int ef_flags)
  * Set the flag to make pmu::enable() not perform the
  * schedulability test, it will be performed at commit time
  */
-static void power_pmu_start_txn(struct pmu *pmu)
+static void power_pmu_start_txn(struct pmu *pmu, int flags)
 {
struct cpu_hw_events *cpuhw = this_cpu_ptr(cpu_hw_events);
 
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return;
+
perf_pmu_disable(pmu);
cpuhw-group_flag |= PERF_EVENT_TXN;
cpuhw-n_txn_start = cpuhw-n_events;
@@ -1587,10 +1590,13 @@ static void power_pmu_start_txn(struct pmu *pmu)
  * Clear the flag and pmu::enable() will perform the
  * schedulability test.
  */
-static void power_pmu_cancel_txn(struct pmu *pmu)
+static void power_pmu_cancel_txn(struct pmu *pmu, int flags)
 {
struct cpu_hw_events *cpuhw = this_cpu_ptr(cpu_hw_events);
 
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return;
+
cpuhw-group_flag = ~PERF_EVENT_TXN;
perf_pmu_enable(pmu);
 }
@@ -1600,11 +1606,14 @@ static void power_pmu_cancel_txn(struct pmu *pmu)
  * Perform the group schedulability test as a whole
  * Return 0 if success
  */
-static int power_pmu_commit_txn(struct pmu *pmu)
+static int power_pmu_commit_txn(struct pmu *pmu, int flags)
 {
struct cpu_hw_events *cpuhw;
long i, n;
 
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return -EINVAL;
+
if (!ppmu)
return -EAGAIN;
cpuhw = this_cpu_ptr(cpu_hw_events);
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index b71a7f8..b2c9e3b 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1607,8 +1607,11 @@ static inline void x86_pmu_read(struct perf_event *event)
  * Set the flag to make pmu::enable() not perform the
  * schedulability test, it will be performed at commit time
  */
-static void x86_pmu_start_txn(struct pmu *pmu)
+static void x86_pmu_start_txn(struct pmu *pmu, int flags)
 {
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return;
+
perf_pmu_disable(pmu);
__this_cpu_or(cpu_hw_events.group_flag, PERF_EVENT_TXN);
__this_cpu_write(cpu_hw_events.n_txn, 0);
@@ -1619,8 +1622,11 @@ static void x86_pmu_start_txn(struct pmu *pmu)
  * Clear the flag and pmu::enable() will perform the
  * schedulability test.
  */
-static void x86_pmu_cancel_txn(struct pmu *pmu)
+static void x86_pmu_cancel_txn(struct pmu *pmu, int flags)
 {
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return;
+
__this_cpu_and(cpu_hw_events.group_flag, ~PERF_EVENT_TXN);
/*
 * Truncate collected array by the number of events added in this
@@ -1638,12 +1644,15 @@ static void x86_pmu_cancel_txn(struct pmu *pmu)
  *
  * Does not cancel the transaction on failure; expects the caller to do this.
  */
-static int x86_pmu_commit_txn(struct pmu *pmu)
+static int x86_pmu_commit_txn(struct pmu *pmu, int flags)
 {
struct cpu_hw_events *cpuc = this_cpu_ptr(cpu_hw_events);
int assign[X86_PMC_IDX_MAX];
int n, ret;
 
+   if (flags  ~PERF_PMU_TXN_ADD)
+   return -EINVAL;
+
n = cpuc-n_events;
 
if (!x86_pmu_initialized())
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2b62198..c8fe60e 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -225,6 +225,8 @@ struct pmu {
 * should stop the counter when perf_event_overflow() returns
 * !0. -start() will be used to continue.
 */
+#definePERF_PMU_TXN_ADD1
+#definePERF_PMU_TXN_READ   2
void (*start)   (struct perf_event *event, int flags);
void (*stop)(struct perf_event *event, int flags);
 
@@ -240,20 +242,26 @@ struct pmu {
 *
 * Start the transaction, after this -add() doesn't need to
 * do schedulability tests.
+*
+* Optional.
 */
-   void (*start_txn)   

[PATCH 3/4] perf: Add 'update' parameter to perf_event_read_value()

2015-03-04 Thread Sukadev Bhattiprolu
perf_event_read_value() reads the counter from the PMC and computes the
total count (including child events). Add an 'update' parameter and have
it read the PMC only if 'update' parameter is TRUE (which it always is
for now). When we add support for reading multiple events using the
transaction interface, we could optimize consulting the PMU, when we know
that the counts are already upto date.

Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
 arch/x86/kvm/pmu.c |  2 +-
 include/linux/perf_event.h |  2 +-
 kernel/events/core.c   | 20 ++--
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 8e6b7d8..ed91009 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -146,7 +146,7 @@ static u64 read_pmc(struct kvm_pmc *pmc)
 
if (pmc-perf_event)
counter += perf_event_read_value(pmc-perf_event,
-enabled, running);
+enabled, running, 1);
 
/* FIXME: Scaling needed? */
 
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index c8fe60e..8c571fb 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -580,7 +580,7 @@ perf_event_create_kernel_counter(struct perf_event_attr 
*attr,
 extern void perf_pmu_migrate_context(struct pmu *pmu,
int src_cpu, int dst_cpu);
 extern u64 perf_event_read_value(struct perf_event *event,
-u64 *enabled, u64 *running);
+u64 *enabled, u64 *running, int update);
 
 
 struct perf_sample_data {
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 11c4154..77ce4f3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3643,7 +3643,8 @@ static void orphans_remove_work(struct work_struct *work)
put_ctx(ctx);
 }
 
-u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
+u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running,
+   int update)
 {
struct perf_event *child;
u64 total = 0;
@@ -3653,7 +3654,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 
*enabled, u64 *running)
 
mutex_lock(event-child_mutex);
 
-   perf_event_read(event);
+   if (update)
+   perf_event_read(event);
+
total += perf_event_count(event);
 
*enabled += event-total_time_enabled +
@@ -3662,7 +3665,8 @@ u64 perf_event_read_value(struct perf_event *event, u64 
*enabled, u64 *running)
atomic64_read(event-child_total_time_running);
 
list_for_each_entry(child, event-child_list, child_list) {
-   perf_event_read(child);
+   if (update)
+   perf_event_read(child);
total += perf_event_count(child);
*enabled += child-total_time_enabled;
*running += child-total_time_running;
@@ -3681,10 +3685,13 @@ static int perf_event_read_group(struct perf_event 
*event,
int n = 0, size = 0, ret;
u64 count, enabled, running;
u64 values[5];
+   int update;
+   
 
lockdep_assert_held(ctx-mutex);
 
-   count = perf_event_read_value(leader, enabled, running);
+   update = 1;
+   count = perf_event_read_value(leader, enabled, running, update);
 
values[n++] = 1 + leader-nr_siblings;
if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED)
@@ -3705,7 +3712,8 @@ static int perf_event_read_group(struct perf_event *event,
list_for_each_entry(sub, leader-sibling_list, group_entry) {
n = 0;
 
-   values[n++] = perf_event_read_value(sub, enabled, running);
+   values[n++] = perf_event_read_value(sub, enabled, running,
+   update);
if (read_format  PERF_FORMAT_ID)
values[n++] = primary_event_id(sub);
 
@@ -3728,7 +3736,7 @@ static int perf_event_read_one(struct perf_event *event,
u64 values[4];
int n = 0;
 
-   values[n++] = perf_event_read_value(event, enabled, running);
+   values[n++] = perf_event_read_value(event, enabled, running, 1);
if (read_format  PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format  PERF_FORMAT_TOTAL_TIME_RUNNING)
-- 
1.8.3.1

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

Re: [v1,1/3] crypto: powerpc/md5 - assembler

2015-03-04 Thread Herbert Xu
On Sun, Mar 01, 2015 at 07:30:35PM +0100, Markus Stockhausen wrote:
 This is the assembler code for the MD5 implementation.
 Handling of algorithm constants has been slightly
 changed to reduce register usage and make better use
 of cores with multiple ALUs. Thus they are stored as
 delta values.
 
 Signed-off-by: Markus Stockhausen stockhau...@collogia.de

All applied.  Thanks!
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 4/4] perf/powerpc: Implement group_read() txn interface for 24x7 counters

2015-03-04 Thread Sukadev Bhattiprolu
The 24x7 counters in Powerpc allow monitoring a large number of counters
simultaneously. They also allow reading several counters in a single
HCALL so we can get a more consistent snapshot of the system.

Use the PMU's transaction interface to monitor and read several event
counters at once. The idea is that users can group several 24x7 events
into a single group of events. We use the following logic to submit
the group of events to the PMU and read the values:

pmu-start_txn()// Intialize before first event

for each event in group
pmu-read(event);   // queue the event to be read

pmu-commit_txn()   // Read/update all queued counters

The -commit_txn() also updates the event counts in the respective
perf_event objects.  The perf subsystem can then directly get the
event counts from the perf_event and can avoid submitting a new
-read() request to the PMU.

Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
 arch/powerpc/perf/hv-24x7.c | 171 
 include/linux/perf_event.h  |   1 +
 kernel/events/core.c|  37 ++
 3 files changed, 209 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8c571fb..a144d67 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -166,6 +166,7 @@ struct perf_event;
  * pmu::capabilities flags
  */
 #define PERF_PMU_CAP_NO_INTERRUPT  0x01
+#define PERF_PMU_CAP_GROUP_READ0x02
 
 /**
  * struct pmu - generic performance monitoring unit
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 77ce4f3..ff62ea5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3677,11 +3677,34 @@ u64 perf_event_read_value(struct perf_event *event, u64 
*enabled, u64 *running,
 }
 EXPORT_SYMBOL_GPL(perf_event_read_value);
 
+static int do_pmu_group_read(struct perf_event *leader)
+{
+   int ret;
+   struct pmu *pmu;
+   struct perf_event *sub;
+
+   pmu = leader-pmu;
+   pmu-start_txn(pmu, PERF_PMU_TXN_READ);
+
+   pmu-read(leader);
+   list_for_each_entry(sub, leader-sibling_list, group_entry)
+   pmu-read(sub);
+
+   /*
+* Commit_txn submits the transaction to read all the counters
+* in the group _and_ updates the event count.
+*/
+   ret = pmu-commit_txn(pmu, PERF_PMU_TXN_READ);
+
+   return ret;
+}
+
 static int perf_event_read_group(struct perf_event *event,
   u64 read_format, char __user *buf)
 {
struct perf_event *leader = event-group_leader, *sub;
struct perf_event_context *ctx = leader-ctx;
+   struct pmu *pmu;
int n = 0, size = 0, ret;
u64 count, enabled, running;
u64 values[5];
@@ -3690,7 +3713,21 @@ static int perf_event_read_group(struct perf_event 
*event,
 
lockdep_assert_held(ctx-mutex);
 
+   pmu = event-pmu;
update = 1;
+
+   if ((read_format  PERF_FORMAT_GROUP) 
+   (pmu-capabilities  PERF_PMU_CAP_GROUP_READ)) {
+   ret = do_pmu_group_read(event);
+   if (ret)
+   return ret;
+   /*
+* -commit_txn() would have updated the event count,
+* so we don't have to consult the PMU again.
+*/
+   update = 0;
+   }
+
count = perf_event_read_value(leader, enabled, running, update);
 
values[n++] = 1 + leader-nr_siblings;
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 66fa6c8..08c69c1 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -142,6 +142,13 @@ static struct attribute_group event_long_desc_group = {
 
 static struct kmem_cache *hv_page_cache;
 
+struct h_24x7_hw {
+   int flags;
+   int in_txn;
+   int txn_err;
+   struct perf_event *events[255];
+};
+
 /*
  * request_buffer and result_buffer are not required to be 4k aligned,
  * but are not allowed to cross any 4k boundary. Aligning them to 4k is
@@ -150,6 +157,7 @@ static struct kmem_cache *hv_page_cache;
 #define H24x7_DATA_BUFFER_SIZE 4096
 DEFINE_PER_CPU(char, hv_24x7_reqb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
 DEFINE_PER_CPU(char, hv_24x7_resb[H24x7_DATA_BUFFER_SIZE]) __aligned(4096);
+DEFINE_PER_CPU(struct h_24x7_hw, h_24x7_hw);
 
 static char *event_name(struct hv_24x7_event_data *ev, int *len)
 {
@@ -1210,10 +1218,46 @@ static void update_event_count(struct perf_event 
*event, u64 now)
 
 static void h_24x7_event_read(struct perf_event *event)
 {
+   int ret;
u64 now;
 
+   struct h_24x7_hw *h24x7hw;
+   struct hv_24x7_request_buffer *request_buffer;
+
+   /*
+* If in a READ transaction, add this counter to the list of
+* counters to read during the next HCALL (i.e commit_txn()).
+* If not in a READ transaction, go ahead and 

[PATCH 0/4] perf: Implement event group read using txn interface

2015-03-04 Thread Sukadev Bhattiprolu
Unlike normal hardware PMCs, the 24x7 counters[1] in Power8 are stored in
memory and accessed via a hypervisor call (HCALL).  A major aspect of the
HCALL is that it allows retireving _SEVERAL_ counters at once (unlike
regular PMCs, which are read one at a time). By reading several counters
at once, we can get a more consistent snapshot of the system.

This patchset explores the possibility of using the transaction interface
to accomplish submitting several events to the PMU and have the PMU read
them all at once. User is expected to submit the set of events they want
to read as an event group.

In the kernel, we submit each event to the PMU using the following logic
(from Peter Zijlstra).

pmu-start_txn(pmu, PMU_TXN_READ);

leader-read();
for_each_sibling()
sibling-read();
pmu-commit_txn();

where:
- the -read()s queue events to be submitted to the hypervisor, and,
- the -commit_txn() issues the HCALL, retrieves the result and
  updates the event count.

Since the -commit_txn() updates the event count, perf subsystem can use
the event count directly and skip the a -read() call immediately after
the transaction.

TODO: 
- Lightly tested on Powerpc; Needs more testing on Power and x86.
- Need to review/update txn and perf_event_read_value() interfaces
  for other architectures.

Thanks to Peter Zijlstra for his input.

Sukadev Bhattiprolu (4):
  perf: Add 'flags' parameter to pmu txn interfaces
  perf: Split perf_event_read() and perf_event_count()
  perf: Add 'update' parameter to perf_event_read_value()
  perf/powerpc: Implement group_read() txn interface for 24x7 counters

 arch/powerpc/perf/core-book3s.c  |  15 +++-
 arch/powerpc/perf/hv-24x7.c  | 171 +++
 arch/x86/kernel/cpu/perf_event.c |  15 +++-
 arch/x86/kvm/pmu.c   |   2 +-
 include/linux/perf_event.h   |  17 +++-
 kernel/events/core.c |  93 -
 6 files changed, 281 insertions(+), 32 deletions(-)

-- 
1.8.3.1

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

[PATCH v2] cpufreq: ppc: Add missing #include asm/smp.h

2015-03-04 Thread Geert Uytterhoeven
If CONFIG_SMP=n, linux/smp.h does not include asm/smp.h, causing:

drivers/cpufreq/ppc-corenet-cpufreq.c: In function 'corenet_cpufreq_cpu_init':
drivers/cpufreq/ppc-corenet-cpufreq.c:173:3: error: implicit declaration of 
function 'get_hard_smp_processor_id' [-Werror=implicit-function-declaration]

Signed-off-by: Geert Uytterhoeven geert+rene...@glider.be
---
Seen with e.g. corenet64_smp_defconfig + CONFIG_CPU_FREQ=y,
CONFIG_PPC_CORENET_CPUFREQ=y, CONFIG_SMP=n

v2:
  - Add comment for #include directive, as requested by Viresh
---
 drivers/cpufreq/ppc-corenet-cpufreq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c 
b/drivers/cpufreq/ppc-corenet-cpufreq.c
index bee5df7794d33d10..7cb4b766cf948d3f 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -22,6 +22,8 @@
 #include linux/smp.h
 #include sysdev/fsl_soc.h
 
+#include asm/smp.h   /* for get_hard_smp_processor_id() in UP configs */
+
 /**
  * struct cpu_data - per CPU data struct
  * @parent: the parent node of cpu clock
-- 
1.9.1

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

Re: [PATCH v2 3/5] crypto: talitos: Fix off-by-one and use all hardware slots

2015-03-04 Thread Martin Hicks
Ok, I'm fine dropping this patch.  I'm sure it doesn't affect
performance in a measurable way.

mh

On Tue, Mar 3, 2015 at 7:35 PM, Kim Phillips kim.phill...@freescale.com wrote:
 On Tue,  3 Mar 2015 08:21:35 -0500
 Martin Hicks m...@bork.org wrote:

 The submission count was off by one.

 Signed-off-by: Martin Hicks m...@bork.org
 ---
 sadly, this directly contradicts:

 commit 4b24ea971a93f5d0bec34bf7bfd0939f70cfaae6
 Author: Vishnu Suresh vis...@freescale.com
 Date:   Mon Oct 20 21:06:18 2008 +0800

 crypto: talitos - Preempt overflow interrupts off-by-one fix

 My guess is your request submission pattern differs from that of
 Vishnu's (probably IPSec and/or tcrypt), or later h/w versions have
 gotten better about dealing with channel near-overflow conditions.
 Either way, I'd prefer we not do this: it might break others, and
 I'm guessing doesn't improve performance _that_ much?

 If it does, we could risk it and restrict it to SEC versions 3.3 and
 above maybe?  Not sure what to do here exactly, barring digging up
 and old 2.x SEC and testing.

 Kim

 p.s. I checked, Vishnu isn't with Freescale anymore, so I can't
 cc him.



-- 
Martin Hicks P.Eng.  | m...@bork.org
Bork Consulting Inc. |   +1 (613) 266-2296
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: Problems with Kernels 3.17-rc1 and onwards on Acube Sam460 AMCC 460ex board

2015-03-04 Thread Julian Margetson

Still stuck.
Problem still exist with 4.0.0-rc2 and I cant finish the bisect.
Triggered when using HDMI. No problem when using DVI.

[   33.535692] Unable to handle kernel paging request for data at address 
0x0008
[   33.566786] Faulting instruction address: 0xc049db84
[   33.574188] Vector: 300 (Data Access) at [eeb13c20]
[   33.579086] pc: c049db84: radeon_audio_enable+0x4/0x18
[   33.584630] lr: c049e2f4: radeon_audio_detect+0x288/0x290
[   33.590429] sp: eeb13cd0
[   33.593310]msr: 29000
[   33.595931]dar: 8
[   33.598207]  dsisr: 0
[   33.600480]   current = 0xeea93ac0
[   33.603885] pid   = 2311, comm = Xorg
[   33.607922] enter ? for help
[   33.610806] [link register   ] c049e2f4 radeon_audio_detect+0x288/0x290
[   33.617469] [eeb13cd0] c049e254 radeon_audio_detect+0x1e8/0x290 (unreliable)
[   33.624571] [eeb13d00] c03dfe7c radeon_dvi_detect+0x388/0x3ac
[   33.630369] [eeb13d30] c038b9d4 
drm_helper_probe_single_connector_modes_merge_bits+0xf4/0x434
[   33.638954] [eeb13d70] c03a7670 drm_mode_getconnector+0xf4/0x334
[   33.645022] [eeb13e10] c039a8c0 drm_ioctl+0x348/0x464
[   33.650135] [eeb13ed0] c00d0ca0 do_vfs_ioctl+0x52c/0x6e8
[   33.655507] [eeb13f20] c00d0e9c SyS_ioctl+0x40/0x68
[   33.660438] [eeb13f40] c000ab04 ret_from_syscall+0x0/0x3c
[   33.665896] --- Exception: c01 (System Call) at 6fb1b8dc
[   33.671253] SP (bfa56d20) is in userspace
[   33.675263] mon  no input ...
[   35.703835] Oops: Kernel access of bad area, sig: 11 [#1]
[   35.709554] PREEMPT Canyonlands
[   35.712876] Modules linked in: cfg80211 snd_ice1724 snd_hda_codec_hdmi 
snd_ak4113 snd_pt2258 snd_ak4114 snd_i2c snd_ice17xx_ak4xxx snd_ak4xxx_adda 
snd_ac97_codec snd_hda_intel ac97_bus snd_hda_controller snd_rawmidi 
snd_hda_codec snd_seq_device snd_pcm snd_timer snd
[   35.738047] CPU: 0 PID: 2311 Comm: Xorg Not tainted 4.0.0-rc1-Sam460ex #1
[   35.745189] task: eea93ac0 ti: eeb12000 task.ti: eeb12000
[   35.750872] NIP: c049db84 LR: c049e2f4 CTR: 
[   35.756098] REGS: eeb13c20 TRAP: 0300   Not tainted  (4.0.0-rc1-Sam460ex)
[   35.763241] MSR: 00029000 CE,EE,ME  CR: 24004422  XER: 2000
[   35.769778] DEAR: 0008 ESR: 
GPR00: c049e254 eeb13cd0 eea93ac0 eaa84000  000f ee0532c0 000190d6
GPR08: eab6da00   eeb13cb0 28004422 b7a11ff4 b7a87a98 b7a87988
GPR16:    eeb13e18 eaa08194 eaa08178 0001 4000
GPR24: 4000 c071cd28 fff2  eab6c000 eaa84000 eab6da00 eab80400
[   35.804302] NIP [c049db84] radeon_audio_enable+0x4/0x18
[   35.809799] LR [c049e2f4] radeon_audio_detect+0x288/0x290
[   35.815480] Call Trace:
[   35.818053] [eeb13cd0] [c049e254] radeon_audio_detect+0x1e8/0x290 
(unreliable)
[   35.825694] [eeb13d00] [c03dfe7c] radeon_dvi_detect+0x388/0x3ac
[   35.831956] [eeb13d30] [c038b9d4] 
drm_helper_probe_single_connector_modes_merge_bits+0xf4/0x434
[   35.841137] [eeb13d70] [c03a7670] drm_mode_getconnector+0xf4/0x334
[   35.847663] [eeb13e10] [c039a8c0] drm_ioctl+0x348/0x464
[   35.853183] [eeb13ed0] [c00d0ca0] do_vfs_ioctl+0x52c/0x6e8
[   35.858974] [eeb13f20] [c00d0e9c] SyS_ioctl+0x40/0x68
[   35.864307] [eeb13f40] [c000ab04] ret_from_syscall+0x0/0x3c
[   35.870196] --- interrupt: c01 at 0x6fb1b8dc
[   35.870196] LR = 0x6fb1b800
[   35.877971] Instruction dump:
[   35.881106] 8129012c 806a0018 2f89 419e0018 81290004 2f89 419e000c 
7d2903a6




On 2/24/2015 4:26 PM, Julian Margetson wrote:

Thanks

after skipping several times :

git bisect skip

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
b486e0e6d599b9ca8667fb9a7d49b7383ee963c7
eab3bbeffd152125ae0f90863b8e9bc8eef49423
960cd9d4fef6dd9e235c0e5c0d4ed027f8a48025
f02ad907cd9e7fe3a6405d2d005840912f1ed258
6a425c2a9b37ca3d2c37e3c1cdf973dba53eaa79
ee0a89cf3c2c550e6d877dda21dd2947afb90cb6
92890583627ee2a0518e55b063fcff86826fef96
95d6eb3b134e1826ed04cc92b224d93de13e281f
9469244d869623e8b54d9f3d4d00737e377af273
We cannot bisect more!



On 2/24/2015 3:14 PM, Gerhard Pircher wrote:

Am 2015-02-24 um 12:08 schrieb Julian Margetson:

Problems with  the Gib bisect
Kernel wont compile after 10th bisect .

You can try git bisect skip to select another commit for testing.
Hopefully that one compiles fine then.

Gerhard


drivers/built-in.o: In function `drm_mode_atomic_ioctl':
(.text+0x865dc): undefined reference to `__get_user_bad'
make: *** [vmlinux] Error 1
root@julian-VirtualBox:/usr/src/linux# git bisect log
git bisect start
# bad: [c517d838eb7d07bbe9507871fab3931deccff539] Linux 4.0-rc1
git bisect bad c517d838eb7d07bbe9507871fab3931deccff539
# good: [bfa76d49576599a4b9f9b7a71f23d73d6dcff735] Linux 3.19
git bisect good bfa76d49576599a4b9f9b7a71f23d73d6dcff735
# good: [02f1f2170d2831b3233e91091c60a66622f29e82] kernel.h: remove ancient 
__FUNCTION__ hack
git bisect good 02f1f2170d2831b3233e91091c60a66622f29e82
# bad: [796e1c55717e9a6ff5c81b12289ffa1ffd919b6f] Merge branch 'drm-next' of 

Re: [PATCH v2] cpufreq: ppc: Add missing #include asm/smp.h

2015-03-04 Thread Rafael J. Wysocki
On Wednesday, March 04, 2015 12:56:20 PM Geert Uytterhoeven wrote:
 If CONFIG_SMP=n, linux/smp.h does not include asm/smp.h, causing:
 
 drivers/cpufreq/ppc-corenet-cpufreq.c: In function 'corenet_cpufreq_cpu_init':
 drivers/cpufreq/ppc-corenet-cpufreq.c:173:3: error: implicit declaration of 
 function 'get_hard_smp_processor_id' [-Werror=implicit-function-declaration]
 
 Signed-off-by: Geert Uytterhoeven geert+rene...@glider.be
 ---
 Seen with e.g. corenet64_smp_defconfig + CONFIG_CPU_FREQ=y,
 CONFIG_PPC_CORENET_CPUFREQ=y, CONFIG_SMP=n
 
 v2:
   - Add comment for #include directive, as requested by Viresh

Applied, thanks!

 ---
  drivers/cpufreq/ppc-corenet-cpufreq.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c 
 b/drivers/cpufreq/ppc-corenet-cpufreq.c
 index bee5df7794d33d10..7cb4b766cf948d3f 100644
 --- a/drivers/cpufreq/ppc-corenet-cpufreq.c
 +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
 @@ -22,6 +22,8 @@
  #include linux/smp.h
  #include sysdev/fsl_soc.h
  
 +#include asm/smp.h /* for get_hard_smp_processor_id() in UP configs */
 +
  /**
   * struct cpu_data - per CPU data struct
   * @parent: the parent node of cpu clock
 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev