Re: [PATCH v4 0/3] powerpc: Enable seccomp filter support

2015-02-26 Thread Purcareata Bogdan

Ping?

On 18.02.2015 10:16, Bogdan Purcareata wrote:

Add the missing pieces in order to enable SECCOMP_FILTER on PowerPC
architectures, and enable this support.

Testing has been pursued using libseccomp with the latest ppc support patches
[1][2], on Freescale platforms for both ppc and ppc64. Support on ppc64le has
also been tested, courtesy of Mike Strosaker.

[1] https://groups.google.com/forum/#!topic/libseccomp/oz42LfMDsxg
[2] https://groups.google.com/forum/#!topic/libseccomp/TQWfCt_nD7c

v4:
- rebased on top of 3.19

v3:
- keep setting ENOSYS in syscall entry assembly when syscall tracing is disabled

v2:
- move setting ENOSYS from syscall entry assembly to do_syscall_trace_enter

Bogdan Purcareata (3):
   powerpc: Don't force ENOSYS as error on syscall fail
   powerpc: Relax secure computing on syscall entry trace
   powerpc: Enable HAVE_ARCH_SECCOMP_FILTER

  arch/powerpc/Kconfig   | 1 +
  arch/powerpc/kernel/entry_32.S | 7 ++-
  arch/powerpc/kernel/entry_64.S | 5 +++--
  arch/powerpc/kernel/ptrace.c   | 8 ++--
  4 files changed, 16 insertions(+), 5 deletions(-)


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

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

2015-02-26 Thread Ingo Molnar

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

 This separates ET_DYN ASLR from mmap ASLR, as already 
 done on s390. The various 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

Nice!

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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread David Daney

On 02/26/2015 02:38 PM, Andrew Morton wrote:
[...]


From: Andrew Mortona...@linux-foundation.org
Subject: fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix

Consolidate randomize_et_dyn() implementations into fs/binfmt_elf.c.

There doesn't seem to be a compile-time way of making randomize_et_dyn()
go away on architectures which don't need it, so mark it __weak to cause
it to be discarded at link time.

Cc: H. Peter Anvinh...@zytor.com
Cc: Benjamin Herrenschmidtb...@kernel.crashing.org
Cc: Catalin Marinascatalin.mari...@arm.com
Cc: Hector Marco Gisberthecma...@upv.es
Cc: Hector Marco-Gisberthecma...@upv.es
Cc: Ingo Molnarmi...@kernel.org
Cc: Ismael Ripollirip...@upv.es
Cc: Kees Cookkeesc...@chromium.org
Cc: Ralf Baechler...@linux-mips.org
Cc: Russell Kingr...@arm.linux.org.uk
Cc: Thomas Gleixnert...@linutronix.de
Cc: Will Deaconwill.dea...@arm.com
Signed-off-by: Andrew Mortona...@linux-foundation.org

[...]

diff -puN 
arch/arm64/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 arch/arm64/include/asm/elf.h
--- 
a/arch/arm64/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
+++ a/arch/arm64/include/asm/elf.h
@@ -1,5 +1,5 @@
  /*
- * Copyright (C) 2012 ARM Ltd.
+ * Copyright (C) 20q12 ARM Ltd.


This particular change looks like it may be a typo.


   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as


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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Thu, 26 Feb 2015 23:00:52 + Russell King - ARM Linux 
li...@arm.linux.org.uk wrote:

 On Thu, Feb 26, 2015 at 02:38:15PM -0800, Andrew Morton wrote:
  diff -puN 
  arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
  arch/arm64/Kconfig
  --- 
  a/arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
  +++ a/arch/arm64/Kconfig
  @@ -1,4 +1,4 @@
  -config ARM64
  +qconfig ARM64
 
 Is this a typo?

yup.  But the coffee's nice and strong.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Kees Cook
On Thu, Feb 26, 2015 at 4:11 PM, Kees Cook keesc...@chromium.org wrote:
 On Thu, Feb 26, 2015 at 4:06 PM, Andrew Morton
 a...@linux-foundation.org wrote:
 On Thu, 26 Feb 2015 15:37:37 -0800 Kees Cook keesc...@chromium.org wrote:

 Agh, no, please let's avoid the CONFIG addition.

 That is precisely how we do this.

 Hector mentioned in private mail that he was looking at an alternative
 that adds exec_base to struct mm which would avoid all this insanity.

 Can't we do something like:

 #ifndef mmap_rnd
 # define mmap_rnd 0
 #endif

 Sure, and sprinkle

 #define mmap_rnd mmap_rnd

 in five arch header files where nobody thinks to look.

 For better or for worse, we are consolidating such things into 
 arch/*/Kconfig.

 Okay, fair enough. Even with your configs (though shouldn't they be
 ARCH_HAS or just HAVE?) I've now stumbled over the issue that we can't
 put randomize_et_dyn in binfmt_elf because it conflicts with linking
 against compat_binfmt_elf.

Instead of all this, how about we rework the existing CONFIG and just
change around how s390 does this to match the other architectures and
remove the ifdef in binfmt_elf.c at the same time? Let me work
something up...

-Kees

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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Thu, 26 Feb 2015 15:37:37 -0800 Kees Cook keesc...@chromium.org wrote:

 Agh, no, please let's avoid the CONFIG addition.

That is precisely how we do this.

 Hector mentioned in private mail that he was looking at an alternative
 that adds exec_base to struct mm which would avoid all this insanity.
 
 Can't we do something like:
 
 #ifndef mmap_rnd
 # define mmap_rnd 0
 #endif

Sure, and sprinkle

#define mmap_rnd mmap_rnd

in five arch header files where nobody thinks to look.

For better or for worse, we are consolidating such things into arch/*/Kconfig.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

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

2015-02-26 Thread Christophe Leroy
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()

In the current implementation, in function fsl_spi_cpm_get_pram() there is
a confusion between the SPI_BASE register and the base of the SPI
parameter RAM. Fortunatly, it is working properly with MPC866 and MPC885
because they do set SPI_BASE, but on MPC860 and other old MPC8xx that doesn't
set SPI_BASE, pram_ofs is not properly set.
Also, the parameter RAM is not properly mapped with of_iomap() as it should
but still gets accessible by chance through the full RAM which is mapped
from somewhere else.

This patch applies to the SPI driver the same principle as for the CPM UART:
when the CPM is of type CPM1, we simply do an of_iomap() of the area provided
via the device tree.

Signed-off-by: Christophe Leroy christophe.le...@c-s.fr

---
 drivers/spi/spi-fsl-cpm.c | 32 +++-
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c
index e85ab1c..97c28d7 100644
--- a/drivers/spi/spi-fsl-cpm.c
+++ b/drivers/spi/spi-fsl-cpm.c
@@ -264,17 +264,6 @@ static unsigned long fsl_spi_cpm_get_pram(struct 
mpc8xxx_spi *mspi)
if (mspi-flags  SPI_CPM2) {
pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64);
out_be16(spi_base, pram_ofs);
-   } else {
-   struct spi_pram __iomem *pram = spi_base;
-   u16 rpbase = in_be16(pram-rpbase);
-
-   /* Microcode relocation patch applied? */
-   if (rpbase) {
-   pram_ofs = rpbase;
-   } else {
-   pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64);
-   out_be16(spi_base, pram_ofs);
-   }
}
 
iounmap(spi_base);
@@ -287,7 +276,6 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
struct device_node *np = dev-of_node;
const u32 *iprop;
int size;
-   unsigned long pram_ofs;
unsigned long bds_ofs;
 
if (!(mspi-flags  SPI_CPM_MODE))
@@ -314,8 +302,17 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
}
}
 
-   pram_ofs = fsl_spi_cpm_get_pram(mspi);
-   if (IS_ERR_VALUE(pram_ofs)) {
+   if (mspi-flags  SPI_CPM1) {
+   mspi-pram = of_iomap(np, 1);
+   } else {
+   unsigned long pram_ofs = fsl_spi_cpm_get_pram(mspi);
+
+   if (IS_ERR_VALUE(pram_ofs))
+   mspi-pram = NULL;
+   else
+   mspi-pram = cpm_muram_addr(pram_ofs);
+   }
+   if (mspi-pram == NULL) {
dev_err(dev, can't allocate spi parameter ram\n);
goto err_pram;
}
@@ -341,8 +338,6 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
goto err_dummy_rx;
}
 
-   mspi-pram = cpm_muram_addr(pram_ofs);
-
mspi-tx_bd = cpm_muram_addr(bds_ofs);
mspi-rx_bd = cpm_muram_addr(bds_ofs + sizeof(*mspi-tx_bd));
 
@@ -370,7 +365,10 @@ err_dummy_rx:
 err_dummy_tx:
cpm_muram_free(bds_ofs);
 err_bds:
-   cpm_muram_free(pram_ofs);
+   if (mspi-flags  SPI_CPM1)
+   iounmap(mspi-pram);
+   else
+   cpm_muram_free(cpm_muram_offset(mspi-pram));
 err_pram:
fsl_spi_free_dummy_rx();
return -ENOMEM;
-- 
2.1.0

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

[PATCH 2/3] powerpc/mpc85xx: Create dts components for the FSL QorIQ DPAA FMan

2015-02-26 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Based on prior work by Andy Fleming aflem...@gmail.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
Signed-off-by: Shruti Kanetkar kanetkar.shr...@gmail.com
Signed-off-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-10g-0.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-0.dtsi   |  69 ++
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-1.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-2.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-3.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-4.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-0.dtsi| 101 
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-10g-0.dtsi  |  61 
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-0.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-1.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-2.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-3.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-4.dtsi   |  68 +
 arch/powerpc/boot/dts/fsl/qoriq-fman-1.dtsi| 101 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi |  61 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi |  61 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-0.dtsi   | 106 +
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi |  61 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi |  61 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi  |  62 
 arch/powerpc/boot/dts/fsl/qoriq-fman3-1.dtsi   | 106 +
 32 files changed, 2206 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-10g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-2.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-3.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0-1g-4.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-10g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-2.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-3.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1-1g-4.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/qoriq-fman3-1.dtsi

diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman-0-10g-0.dtsi 
b/arch/powerpc/boot/dts/fsl/qoriq-fman-0-10g-0.dtsi
new file mode 100644
index 

[PATCH 3/3] powerpc/mpc85xx: Add FSL QorIQ DPAA FMan support to the SoC device tree(s)

2015-02-26 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Based on prior work by Andy Fleming aflem...@gmail.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
Signed-off-by: Shruti Kanetkar kanetkar.shr...@gmail.com
Signed-off-by: Emil Medve emilian.me...@freescale.com
---
 arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi  |   9 ++-
 arch/powerpc/boot/dts/fsl/b4860si-post.dtsi |  20 -
 arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi  |  12 ++-
 arch/powerpc/boot/dts/fsl/b4si-post.dtsi|  31 +++-
 arch/powerpc/boot/dts/fsl/p1023si-post.dtsi | 115 +++-
 arch/powerpc/boot/dts/fsl/p1023si-pre.dtsi  |   5 +-
 arch/powerpc/boot/dts/fsl/p2041si-post.dtsi |  29 ++-
 arch/powerpc/boot/dts/fsl/p2041si-pre.dtsi  |  10 ++-
 arch/powerpc/boot/dts/fsl/p3041si-post.dtsi |  29 ++-
 arch/powerpc/boot/dts/fsl/p3041si-pre.dtsi  |  10 ++-
 arch/powerpc/boot/dts/fsl/p4080si-post.dtsi |  48 +++-
 arch/powerpc/boot/dts/fsl/p4080si-pre.dtsi  |  15 +++-
 arch/powerpc/boot/dts/fsl/p5020si-post.dtsi |  29 ++-
 arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi  |  10 ++-
 arch/powerpc/boot/dts/fsl/p5040si-post.dtsi |  56 +-
 arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi  |  17 +++-
 arch/powerpc/boot/dts/fsl/t1040si-post.dtsi |  31 
 arch/powerpc/boot/dts/fsl/t104xsi-pre.dtsi  |   9 ++-
 arch/powerpc/boot/dts/fsl/t2081si-post.dtsi |  43 +++
 arch/powerpc/boot/dts/fsl/t208xsi-pre.dtsi  |  11 +++
 arch/powerpc/boot/dts/fsl/t4240si-post.dtsi |  88 -
 arch/powerpc/boot/dts/fsl/t4240si-pre.dtsi  |  22 +-
 22 files changed, 629 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi 
b/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
index 338af7e..70e2096 100644
--- a/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
@@ -1,7 +1,7 @@
 /*
  * B4420 Silicon/SoC Device Tree Source (pre include)
  *
- * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012 - 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:
@@ -54,8 +54,13 @@
dma0 = dma0;
dma1 = dma1;
sdhc = sdhc;
-   };
 
+   fman0 = fman0;
+   ethernet0 = enet0;
+   ethernet1 = enet1;
+   ethernet2 = enet2;
+   ethernet3 = enet3;
+   };
 
cpus {
#address-cells = 1;
diff --git a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
index 02ccde6..006e95c 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
@@ -1,7 +1,7 @@
 /*
  * B4860 Silicon/SoC Device Tree Source (post include)
  *
- * Copyright 2012 - 2014 Freescale Semiconductor Inc.
+ * Copyright 2012 - 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:
@@ -260,6 +260,24 @@
compatible = fsl,b4860-rcpm, fsl,qoriq-rcpm-2.0;
};
 
+/include/ qoriq-fman3-0-1g-4.dtsi
+/include/ qoriq-fman3-0-1g-5.dtsi
+/include/ qoriq-fman3-0-10g-0.dtsi
+/include/ qoriq-fman3-0-10g-1.dtsi
+   fman@40 {
+   enet4: ethernet@e8000 {
+   };
+
+   enet5: ethernet@ea000 {
+   };
+
+   enet6: ethernet@f {
+   };
+
+   enet7: ethernet@f2000 {
+   };
+   };
+
L2: l2-cache-controller@c2 {
compatible = fsl,b4860-l2-cache-controller;
};
diff --git a/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi 
b/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
index 1948f73..0fbda72 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
@@ -1,7 +1,7 @@
 /*
  * B4860 Silicon/SoC Device Tree Source (pre include)
  *
- * Copyright 2012 Freescale Semiconductor Inc.
+ * Copyright 2012 - 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:
@@ -54,6 +54,16 @@
dma0 = dma0;
dma1 = dma1;
sdhc = sdhc;
+
+   fman0 = fman0;
+   ethernet0 = enet0;
+   ethernet1 = enet1;
+   ethernet2 = enet2;
+   ethernet3 = enet3;
+   ethernet4 = enet4;
+   ethernet5 = enet5;
+   ethernet6 = enet6;
+   ethernet7 = enet7;
};
 
 
diff --git a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
index 38621ef..b2ff0cb 100644
--- a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
@@ 

[PATCH 1/3] powerpc/mpc85xx: Add FMan clock nodes

2015-02-26 Thread Emil Medve
From: Igal Liberman igal.liber...@freescale.com

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 arch/powerpc/boot/dts/fsl/b4si-post.dtsi| 11 +++
 arch/powerpc/boot/dts/fsl/p2041si-post.dtsi |  8 
 arch/powerpc/boot/dts/fsl/p3041si-post.dtsi |  8 
 arch/powerpc/boot/dts/fsl/p4080si-post.dtsi | 16 
 arch/powerpc/boot/dts/fsl/p5020si-post.dtsi | 13 +
 arch/powerpc/boot/dts/fsl/p5040si-post.dtsi | 26 ++
 arch/powerpc/boot/dts/fsl/t1040si-post.dtsi |  8 
 arch/powerpc/boot/dts/fsl/t2081si-post.dtsi | 11 +++
 arch/powerpc/boot/dts/fsl/t4240si-post.dtsi | 20 
 9 files changed, 121 insertions(+)

diff --git a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
index f8c325e..38621ef 100644
--- a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
@@ -395,6 +395,17 @@
reg = 0xe 0xe00;
fsl,has-rstcr;
fsl,liodn-bits = 12;
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = pll0 0, pll0 1, pll0 2, pll0 3,
+platform_pll 0, pll1 1, pll1 2;
+   clock-names = pll0, pll0-div2, pll0-div3,
+ pll0-div4, platform-pll, pll1-div2,
+ pll1-div3;
+   clock-output-names = fm0-clk;
+   };
};
 
 /include/ qoriq-clockgen2.dtsi
diff --git a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
index 1f18b8b..60f63dc 100644
--- a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
@@ -316,6 +316,14 @@
fsl,has-rstcr;
#sleep-cells = 1;
fsl,liodn-bits = 12;
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = platform_pll 1, pll1 1;
+   clock-names = platform-pll-div2, pll1-div2;
+   clock-output-names = fm0-clk;
+   };
};
 
pins: global-utilities@e0e00 {
diff --git a/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
index a555d24..d4e6677 100644
--- a/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
@@ -343,6 +343,14 @@
fsl,has-rstcr;
#sleep-cells = 1;
fsl,liodn-bits = 12;
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = platform_pll 1, pll1 1;
+   clock-names = platform-pll-div2, pll1-div2;
+   clock-output-names = fm0-clk;
+   };
};
 
pins: global-utilities@e0e00 {
diff --git a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
index 0fe7281..d1cb691 100644
--- a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
@@ -363,6 +363,22 @@
fsl,has-rstcr;
#sleep-cells = 1;
fsl,liodn-bits = 12;
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = platform_pll 1, pll2 1;
+   clock-names = platform-pll-div2, pll2-div2;
+   clock-output-names = fm0-clk;
+   };
+
+   fm1clk: fm1-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = platform_pll 1, pll2 1;
+   clock-names = platform-pll-div2, pll2-div2;
+   clock-output-names = fm1-clk;
+   };
};
 
pins: global-utilities@e0e00 {
diff --git a/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
index a34ca20..9f3049d 100644
--- a/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
@@ -348,6 +348,15 @@
fsl,has-rstcr;
#sleep-cells = 1;
fsl,liodn-bits = 12;
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   compatible = fsl,fman-clk-mux;
+   clocks = platform_pll 1, pll1 1, pll1 2;
+   clock-names = platform-pll-div2, pll1-div2,
+ pll1-div4;
+   clock-output-names = fm0-clk;
+   };
};
 
pins: 

Re: [PATCH] ibmveth: Add function to enable live MAC address changes

2015-02-26 Thread Brian King
On 02/25/2015 06:34 PM, Thomas Falcon wrote:
 @@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct 
 vio_dev *vdev)
   return ret;
  }
 
 +static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
 +{
 + struct ibmveth_adapter *adapter = netdev_priv(dev);
 + struct sockaddr *addr = p;
 + u64 mac_address;
 + int rc;
 +
 + if (!is_valid_ether_addr(addr-sa_data))
 + return -EADDRNOTAVAIL;
 +
 + ether_addr_copy(dev-dev_addr, addr-sa_data);
 +
 + mac_address = ibmveth_encode_mac_addr(dev-dev_addr);
 + rc = h_change_logical_lan_mac(adapter-vdev-unit_address, mac_address);
 +
 + return rc;

Do you still want to be changing dev-dev_addr if h_change_logical_lan_mac
returns a failure?

-Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


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

Re: [PATCH 0/2] powerpc/kvm: Enable running guests on RT Linux

2015-02-26 Thread Sebastian Andrzej Siewior
On 02/26/2015 02:02 PM, Paolo Bonzini wrote:
 
 
 On 24/02/2015 00:27, Scott Wood wrote:
 This isn't a host PIC driver.  It's guest PIC emulation, some of which
 is indeed not suitable for a rawlock (in particular, openpic_update_irq
 which loops on the number of vcpus, with a loop body that calls
 IRQ_check() which loops over all pending IRQs).
 
 The question is what behavior is wanted of code that isn't quite
 RT-ready.  What is preferred, bugs or bad latency?
 
 If the answer is bad latency (which can be avoided simply by not running
 KVM on a RT kernel in production), patch 1 can be applied.  If the
can be applied *but* makes no difference if applied or not.

 answer is bugs, patch 1 is not upstream material.
 
 I myself prefer to have bad latency; if something takes a spinlock in
 atomic context, that spinlock should be raw.  If it hurts (latency),
 don't do it (use the affected code).

The problem, that is fixed by this s/spin_lock/raw_spin_lock/, exists
only in -RT. There is no change upstream. In general we fix such things
in -RT first and forward the patches upstream if possible. This convert
thingy would be possible.
Bug fixing comes before latency no matter if RT or not. Converting
every lock into a rawlock is not always the answer.
Last thing I read from Scott is that he is not entirely sure if this is
the right approach or not and patch #1 was not acked-by him either.

So for now I wait for Scott's feedback and maybe a backtrace :)

 
 Paolo

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

Re: [PATCH 0/2] powerpc/kvm: Enable running guests on RT Linux

2015-02-26 Thread Paolo Bonzini


On 24/02/2015 00:27, Scott Wood wrote:
 This isn't a host PIC driver.  It's guest PIC emulation, some of which
 is indeed not suitable for a rawlock (in particular, openpic_update_irq
 which loops on the number of vcpus, with a loop body that calls
 IRQ_check() which loops over all pending IRQs).

The question is what behavior is wanted of code that isn't quite
RT-ready.  What is preferred, bugs or bad latency?

If the answer is bad latency (which can be avoided simply by not running
KVM on a RT kernel in production), patch 1 can be applied.  If the
answer is bugs, patch 1 is not upstream material.

I myself prefer to have bad latency; if something takes a spinlock in
atomic context, that spinlock should be raw.  If it hurts (latency),
don't do it (use the affected code).

Paolo

 The vcpu limits are a
 temporary bandaid to avoid the worst latencies, but I'm still skeptical
 about this being upstream material.

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

Re: [PATCH 5/5] crypto: talitos: Add software backlog queue handling

2015-02-26 Thread Martin Hicks
Hi Horia,

On Tue, Feb 24, 2015 at 1:21 PM, Horia Geantă
horia.gea...@freescale.com wrote:
 On 2/20/2015 6:21 PM, Martin Hicks wrote:
 + int ret = -EINPROGRESS;

   spin_lock_irqsave(priv-chan[ch].head_lock, flags);

 + if (edesc) {
 + orig_request = edesc-req;
 + crypto_enqueue_request(priv-chan[ch].queue, 
 orig_request-base);
 + }

 The request goes through the SW queue even if there are empty slots in
 the HW queue, doing unnecessary crypto_queue_encrypt() and
 crypto_queue_decrypt(). Trying to use the HW queue first would be better.


Definitely a valid point.  In trying to reorganize this it really
complicates things.
Splitting the submit from issuing requests from the backlog seems to
make it much more straightforward.

 @@ -1170,6 +1211,8 @@ static struct talitos_edesc 
 *talitos_edesc_alloc(struct device *dev,
edesc-dma_len,
DMA_BIDIRECTIONAL);
   edesc-req.desc = edesc-desc;
 + /* A copy of the crypto_async_request to use the crypto_queue backlog 
 */
 + memcpy(edesc-req.base, areq, sizeof(struct crypto_async_request));

 Why not have a
 struct crypto_async_request *base;
 instead of
 struct crypto_async_request base;
 in talitos_request structure?

 This way:
 1. memcopy above is avoided
 2. talitos_request structure gets smaller - remember that
 talitos_request is now embedded in talitos_edesc structure, which gets
 kmalloc-ed for every request

The trouble I ran into was that after a request is backlogged and put
on the crypto queue, I couldn't see how else I could go from the
crypto_async_request that is pulled from the queue back to the
talitos_request that is needed in order put the pointer into the
hardware FIFO.

This is the one issue from you review that I didn't address in v2 of the patch.

Thanks for the review.  Not releasing / re-acquiring the spinlock
while trying to flush the backlog really improved performance.

mh

-- 
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: [PATCH] ibmveth: Add function to enable live MAC address changes

2015-02-26 Thread Jiri Pirko
Thu, Feb 26, 2015 at 02:08:06PM CET, brk...@linux.vnet.ibm.com wrote:
On 02/25/2015 06:34 PM, Thomas Falcon wrote:
 @@ -1327,6 +1327,24 @@ static unsigned long ibmveth_get_desired_dma(struct 
 vio_dev *vdev)
  return ret;
  }
 
 +static int ibmveth_set_mac_addr(struct net_device *dev, void *p)
 +{
 +struct ibmveth_adapter *adapter = netdev_priv(dev);
 +struct sockaddr *addr = p;
 +u64 mac_address;
 +int rc;
 +
 +if (!is_valid_ether_addr(addr-sa_data))
 +return -EADDRNOTAVAIL;
 +
 +ether_addr_copy(dev-dev_addr, addr-sa_data);
 +
 +mac_address = ibmveth_encode_mac_addr(dev-dev_addr);
 +rc = h_change_logical_lan_mac(adapter-vdev-unit_address, mac_address);
 +
 +return rc;

Do you still want to be changing dev-dev_addr if h_change_logical_lan_mac
returns a failure?

That should not be done. dev_addr should be in sync with real hw addr.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v4 07/30] PCI: Pass PCI domain number combined with root bus number

2015-02-26 Thread Yijing Wang
Now we could pass PCI domain combined with bus number
in u32 argu. Because in arm/arm64, PCI domain number
is assigned by pci_bus_assign_domain_nr(). So we leave
pci_scan_root_bus() and pci_create_root_bus() in arm/arm64
unchanged. A new function pci_host_assign_domain_nr()
will be introduced for arm/arm64 to assign domain number
in later patch.

Signed-off-by: Yijing Wang wangyij...@huawei.com
CC: Richard Henderson r...@twiddle.net
CC: Ivan Kokshaysky i...@jurassic.park.msu.ru
CC: Matt Turner matts...@gmail.com
CC: Tony Luck tony.l...@intel.com
CC: Fenghua Yu fenghua...@intel.com
CC: Michal Simek mon...@monstr.eu
CC: Ralf Baechle r...@linux-mips.org
CC: Benjamin Herrenschmidt b...@kernel.crashing.org
CC: Paul Mackerras pau...@samba.org
CC: Michael Ellerman m...@ellerman.id.au
CC: Sebastian Ott seb...@linux.vnet.ibm.com
CC: Gerald Schaefer gerald.schae...@de.ibm.com
CC: David S. Miller da...@davemloft.net
CC: Chris Metcalf cmetc...@ezchip.com
CC: Thomas Gleixner t...@linutronix.de
CC: Konrad Rzeszutek Wilk konrad.w...@oracle.com
CC: linux-al...@vger.kernel.org
CC: linux-ker...@vger.kernel.org
CC: linux-i...@vger.kernel.org
CC: linux-m...@linux-mips.org
CC: linuxppc-dev@lists.ozlabs.org
CC: linux-s...@vger.kernel.org
CC: linux...@vger.kernel.org
CC: sparcli...@vger.kernel.org
CC: xen-de...@lists.xenproject.org
---
 arch/alpha/kernel/pci.c  |5 +++--
 arch/alpha/kernel/sys_nautilus.c |3 ++-
 arch/ia64/pci/pci.c  |4 ++--
 arch/ia64/sn/kernel/io_init.c|5 +++--
 arch/microblaze/pci/pci-common.c |5 +++--
 arch/mips/pci/pci.c  |4 ++--
 arch/powerpc/kernel/pci-common.c |5 +++--
 arch/s390/pci/pci.c  |5 +++--
 arch/sh/drivers/pci/pci.c|5 +++--
 arch/sparc/kernel/pci.c  |5 +++--
 arch/tile/kernel/pci.c   |4 ++--
 arch/tile/kernel/pci_gx.c|5 +++--
 arch/x86/pci/acpi.c  |6 +++---
 arch/x86/pci/common.c|3 ++-
 drivers/pci/xen-pcifront.c   |5 +++--
 15 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 518b767..b053888 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -336,8 +336,9 @@ common_init_pci(void)
pci_add_resource_offset(resources, hose-mem_space,
hose-mem_space-start);
 
-   bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-   hose, resources);
+   bus = pci_scan_root_bus(NULL, 
+   PCI_DOMBUS(hose-index, next_busno), 
alpha_mv.pci_ops,
+   hose, resources);
if (bus)
pci_bus_add_devices(bus);
hose-bus = bus;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 2c864bb..f7bfdf3 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -206,7 +206,8 @@ nautilus_init_pci(void)
unsigned long memtop = max_low_pfn  PAGE_SHIFT;
 
/* Scan our single hose.  */
-   bus = pci_scan_bus_legacy(0, alpha_mv.pci_ops, hose);
+   bus = pci_scan_bus_legacy(PCI_DOMBUS(hose-index, 0), 
+   alpha_mv.pci_ops, hose);
hose-bus = bus;
pcibios_claim_one_bus(bus);
 
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 48cc657..e4cda61 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root 
*root)
 * should handle the case here, but it appears that IA64 hasn't
 * such quirk. So we just ignore the case now.
 */
-   pbus = pci_create_root_bus(NULL, bus, pci_root_ops, controller,
-  info-resources);
+   pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus), 
+   pci_root_ops, controller, info-resources);
if (!pbus) {
pci_free_resource_list(info-resources);
__release_pci_root_info(info);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 63b43a6..bcdc5b8 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct 
pci_bus *bus)
pci_add_resource_offset(resources, res[1],
prom_bussoft_ptr-bs_legacy_mem);
 
-   bus = pci_scan_root_bus(NULL, busnum, pci_root_ops, controller,
-   resources);
+   bus = pci_scan_root_bus(NULL, 
+   PCI_DOMBUS(controller-segment, busnum), 
+   pci_root_ops, controller, resources);
if (bus == NULL) {
kfree(res);
kfree(controller);
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 

Re: [PATCH 1/1]: thermal driver therm_adt746.c

2015-02-26 Thread Thomas Haschka
Hello, 

I hope I get it correct this time, thanks again.

Just to recapitulate, here's a quick list of the changes made:

1. changes in sensors limits, we are down from 70, 50, 70 
   to 45, 50, 70, where the first value is the environement sensor that is 
   located on the bottumside of the Harddrive. Empirical testing 
   shows that this speeds up the Fan almoast in the same moment as in OS X

2. A function has been added in order to take the environement sensor into 
   account on SingleFan Apple Notebooks (i.e. those that have air inlets
   next to the harddrive and that are cooling, besides other components 
   using the single fan in these machines.

3. Output values in /sys/devices/temperatures/ etc.. have been changed. 
   First: All three sensors can be monitored right now instead of only the 
   GPU and CPU sensors. 
   Second: The units have been changed in order to correspond to the units
   given by other temperature sensors, such as the coretemp (intel) sensor. 
   This allows to monitor them using several applications, notably xosview.

cheers, 

Signed-off-by: Thomas Haschka hasc...@gmail.com
---
 drivers/macintosh/therm_adt746x.c | 118 +++---
 1 file changed, 109 insertions(+), 9 deletions(-)

diff --git a/drivers/macintosh/therm_adt746x.c 
b/drivers/macintosh/therm_adt746x.c
index f433521..3ade51a 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -1,7 +1,8 @@
 /*
  * Device driver for the i2c thermostat found on the iBook G4, Albook G4
  *
- * Copyright (C) 2003, 2004 Colin Leroy, Rasmus Rohde, Benjamin Herrenschmidt
+ * Copyright (C) 2003, 2004, 2015 
+ *   Colin Leroy, Rasmus Rohde, Benjamin Herrenschmidt, Thomas Haschka
  *
  * Documentation from 115254175ADT7467_pra.pdf and 3686221171167ADT7460_b.pdf
  * http://www.onsemi.com/PowerSolutions/product.do?id=ADT7467
@@ -45,8 +46,10 @@ static u8 REM_CONTROL[2] = {0x00, 0x40};
 static u8 FAN_SPEED[2]   = {0x28, 0x2a};
 static u8 FAN_SPD_SET[2] = {0x30, 0x31};
 
-static u8 default_limits_local[3] = {70, 50, 70};/* local, sensor1, 
sensor2 */
-static u8 default_limits_chip[3] = {80, 65, 80};/* local, sensor1, sensor2 
*/
+/* Local sensor is down to 45 in order to assure stable harddrive and 
+ * components temperature on single fan machines */
+static u8 default_limits_local[3] = {45, 50, 70}; /* local, sensor1, sensor2 */
+static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */
 static const char *sensor_location[3] = { ?, ?, ? };
 
 static int limit_adjust;
@@ -223,7 +226,7 @@ static void display_stats(struct thermostat *th)
 }
 #endif
 
-static void update_fans_speed (struct thermostat *th)
+static void update_fans_speed_multifan (struct thermostat *th)
 {
int lastvar = 0; /* last variation, for iBook */
int i = 0;
@@ -278,6 +281,83 @@ static void update_fans_speed (struct thermostat *th)
}
 }
 
+static void update_fans_speed_singlefan (struct thermostat *th) {
+
+   /* Single Fan Laptops i.e. 12 inch Powerbook, Ibook etc.
+* Necessites the readout of all three thermal sensors
+* in order to avoid the harddisk and other components to overheat
+* in the case of cold CPU. */
+   
+   int lastvar = 0; /* last variation, for iBook */
+   int i = 0;
+   int var = 0;
+   int var_sensor[3];
+   int started = 0;
+   int fan_number = 0;
+   for (i = 0; i  3; i++) {
+   var_sensor[i] = th-temps[i] - th-limits[i];
+   }
+   var = var_sensor[0];
+   for (i = 1; i  3; i++) {
+   if (var_sensor[i]  var) {
+   var = var_sensor[i]; 
+   }
+   }
+   if (var  -1) {
+   int step = (255 - fan_speed) / 7;
+   int new_speed = 0;
+   /* hysteresis : change fan speed only if variation is
+* more than two degrees */
+   if (abs(var - th-last_var[fan_number])  2) { 
+
+   started = 1;
+   new_speed = fan_speed + ((var-1)*step);
+
+   if (new_speed  fan_speed)
+   new_speed = fan_speed;
+   if (new_speed  255)
+   new_speed = 255;
+
+   if (verbose)
+   printk(KERN_DEBUG adt746x:
+   Setting fans speed to %d 
+  (limit exceeded by %d on %s)\n,
+  new_speed, var,
+  sensor_location[fan_number+1]);
+   write_both_fan_speed(th, new_speed);
+   th-last_var[fan_number] = var; 
+   }
+   } else if (var  -2) {
+   /* don't stop fan if sensor2 is cold and sensor1 is not
+* so cold (lastvar = -1) */
+   if (i == 2  lastvar  -1) {
+  

[PATCH v4 18/30] PCI/powerpc: Use pci_scan_root_bridge() for simplicity

2015-02-26 Thread Yijing Wang
Now we could use pci_scan_root_bridge() to scan
pci buses, provide powerpc specific pci_host_bridge_ops.

Suggested-by: Arnd Bergmann a...@arndb.de
Signed-off-by: Yijing Wang wangyij...@huawei.com
CC: Benjamin Herrenschmidt b...@kernel.crashing.org
CC: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/machdep.h   |2 +-
 arch/powerpc/kernel/pci-common.c |   63 +-
 arch/powerpc/platforms/pseries/pci.c |8 ++--
 arch/powerpc/platforms/pseries/pseries.h |2 +-
 4 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index 8e7f2a8..b811d12 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
void(*pcibios_fixup)(void);
int (*pci_probe_mode)(struct pci_bus *);
void(*pci_irq_fixup)(struct pci_dev *dev);
-   int (*pcibios_set_root_bus_speed)(struct pci_host_bridge
+   void(*pcibios_set_root_bus_speed)(struct pci_host_bridge
*bridge);
 
/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 4401b6a..48a6cff 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -767,14 +767,33 @@ int pci_proc_domain(struct pci_bus *bus)
return 1;
 }
 
-int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
+static void pci_host_bridge_set_root_bus_speed(
+   struct pci_host_bridge *bridge)
 {
if (ppc_md.pcibios_set_root_bus_speed)
-   return ppc_md.pcibios_set_root_bus_speed(bridge);
-   
-   return 0;
+   ppc_md.pcibios_set_root_bus_speed(bridge);
 }
 
+static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host)
+{
+   int mode = PCI_PROBE_NORMAL;
+   struct pci_bus *bus = host-bus;
+   struct pci_controller *hose = dev_get_drvdata(host-dev);
+
+   /* Get probe mode and perform scan */
+   if (hose-dn  ppc_md.pci_probe_mode)
+   mode = ppc_md.pci_probe_mode(bus);
+
+   pr_debug(probe mode: %d\n, mode);
+   if (mode == PCI_PROBE_DEVTREE)
+   of_scan_bus(hose-dn, bus);
+
+   if (mode == PCI_PROBE_NORMAL) {
+   pci_bus_update_busn_res_end(bus, 255);
+   hose-last_busno = pci_scan_child_bus(bus);
+   pci_bus_update_busn_res_end(bus, hose-last_busno);
+   }
+}
 /* This header fixup will do the resource fixup for all devices as they are
  * probed, but not for bridge ranges
  */
@@ -1587,6 +1606,11 @@ struct device_node *pcibios_get_phb_of_node(struct 
pci_bus *bus)
return of_node_get(hose-dn);
 }
 
+static struct pci_host_bridge_ops phb_ops = {
+   .phb_set_root_bus_speed = pci_host_bridge_set_root_bus_speed,
+   .phb_of_scan_bus = pci_host_bridge_of_scan_bus,
+};
+
 /**
  * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
  * @hose: Pointer to the PCI host controller instance structure
@@ -1594,9 +1618,8 @@ struct device_node *pcibios_get_phb_of_node(struct 
pci_bus *bus)
 void pcibios_scan_phb(struct pci_controller *hose)
 {
LIST_HEAD(resources);
-   struct pci_bus *bus;
+   struct pci_host_bridge *host;
struct device_node *node = hose-dn;
-   int mode;
 
pr_debug(PCI: Scanning PHB %s\n, of_node_full_name(node));
 
@@ -1612,30 +1635,16 @@ void pcibios_scan_phb(struct pci_controller *hose)
pci_add_resource(resources, hose-busn);
 
/* Create an empty bus for the toplevel */
-   bus = pci_create_root_bus(hose-parent, 
+   host = pci_scan_root_bridge(hose-parent, 
PCI_DOMBUS(hose-global_number, hose-first_busno),
-   hose-ops, hose, resources);
-   if (bus == NULL) {
-   pr_err(Failed to create bus for PCI domain %04x\n,
+   hose-ops, hose, resources, phb_ops);
+   if (host == NULL) {
+   pr_err(Failed to create host bridge for PCI domain %04x\n,
hose-global_number);
pci_free_resource_list(resources);
return;
}
-   hose-bus = bus;
-
-   /* Get probe mode and perform scan */
-   mode = PCI_PROBE_NORMAL;
-   if (node  ppc_md.pci_probe_mode)
-   mode = ppc_md.pci_probe_mode(bus);
-   pr_debug(probe mode: %d\n, mode);
-   if (mode == PCI_PROBE_DEVTREE)
-   of_scan_bus(node, bus);
-
-   if (mode == PCI_PROBE_NORMAL) {
-   pci_bus_update_busn_res_end(bus, 255);
-   hose-last_busno = pci_scan_child_bus(bus);
-   pci_bus_update_busn_res_end(bus, hose-last_busno);
-   }
+   hose-bus = host-bus;
 
/* Platform gets a chance to do some 

RE: [PATCH] powerpc/fsl: add power_off support for fsl platform

2015-02-26 Thread dongsheng.w...@freescale.com


 -Original Message-
 From: Wood Scott-B07421
 Sent: Wednesday, February 25, 2015 10:30 AM
 To: Wang Dongsheng-B40534
 Cc: Jin Zhengxiong-R64188; Li Yang-Leo-R58472; Jia Hongtao-B38951; linuxppc-
 d...@lists.ozlabs.org
 Subject: Re: [PATCH] powerpc/fsl: add power_off support for fsl platform
 
 On Wed, 2015-02-04 at 14:47 +0800, Dongsheng Wang wrote:
  +void ppc_md_fixup(void)
  +{
 
 This name is way too generic (though it's moot since you shouldn't use ppc_md
 for this).
 

Agree.

  +   struct device_node *np;
  +
  +   np = of_find_compatible_node(NULL, NULL, fsl,fpga-qixis);
  +   if (!np)
  +   return;
  +
  +   of_node_put(np);
  +
  +   pm_power_off = fsl_power_off;
  +   ppc_md.halt = fsl_power_off;
  +}
 
 Please implement this as a drivers/power/reset driver, and consider basing on
 top of http://lists.infradead.org/pipermail/linux-arm-kernel/2014-
 October/293089.html
 

Thanks.

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

[PATCH v4 17/30] PCI/powerpc: Rename pcibios_root_bridge_prepare()

2015-02-26 Thread Yijing Wang
Pcibios_root_bridge_prepare() in powerpc is used
to set root bus speed. Rename it to
pcibios_set_root_bus_speed() for better readability.

Signed-off-by: Yijing Wang wangyij...@huawei.com
CC: Benjamin Herrenschmidt b...@kernel.crashing.org
CC: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/machdep.h   |2 +-
 arch/powerpc/kernel/pci-common.c |6 +++---
 arch/powerpc/platforms/pseries/pci.c |2 +-
 arch/powerpc/platforms/pseries/pseries.h |2 +-
 arch/powerpc/platforms/pseries/setup.c   |2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index c8175a3..8e7f2a8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -129,7 +129,7 @@ struct machdep_calls {
void(*pcibios_fixup)(void);
int (*pci_probe_mode)(struct pci_bus *);
void(*pci_irq_fixup)(struct pci_dev *dev);
-   int (*pcibios_root_bridge_prepare)(struct pci_host_bridge
+   int (*pcibios_set_root_bus_speed)(struct pci_host_bridge
*bridge);
 
/* To setup PHBs when using automatic OF platform driver for PCI */
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 78cd41b..4401b6a 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -769,9 +769,9 @@ int pci_proc_domain(struct pci_bus *bus)
 
 int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
 {
-   if (ppc_md.pcibios_root_bridge_prepare)
-   return ppc_md.pcibios_root_bridge_prepare(bridge);
-
+   if (ppc_md.pcibios_set_root_bus_speed)
+   return ppc_md.pcibios_set_root_bus_speed(bridge);
+   
return 0;
 }
 
diff --git a/arch/powerpc/platforms/pseries/pci.c 
b/arch/powerpc/platforms/pseries/pci.c
index fe16a50..af685d6 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
 fixup_winbond_82c105);
 
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)
 {
struct device_node *dn, *pdn;
struct pci_bus *bus;
diff --git a/arch/powerpc/platforms/pseries/pseries.h 
b/arch/powerpc/platforms/pseries/pseries.h
index 1796c54..5d0be3a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);
 
 /* PCI root bridge prepare function override for pseries */
 struct pci_host_bridge;
-int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
+int pseries_set_root_bus_speed(struct pci_host_bridge *bridge);
 
 unsigned long pseries_memory_block_size(void);
 
diff --git a/arch/powerpc/platforms/pseries/setup.c 
b/arch/powerpc/platforms/pseries/setup.c
index e445b67..b196c0d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void)
ppc_md.enable_pmcs = power4_enable_pmcs;
}
 
-   ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare;
+   ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;
 
if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
long rc;
-- 
1.7.1

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

[PATCH v2 00/11] powerpc: kill PPC_OF

2015-02-26 Thread Kevin Hao
Hi,

v2:
   - Drop the following patches which were already merged.
be802bf955a1 (mtd: kconfig: replace PPC_OF with PPC)
0a4a3529df40 (gpio: kconfig: replace PPC_OF with PPC)
c31316cb6c5a (usb: kconfig: replace PPC_OF with PPC)
f0b66a2cf68e (PCI: Add pci_device_to_OF_node() stub for !CONFIG_OF)
   - Add the ack in v1 cycle.
   - Resolve the comments in v1 cycle.

We plan to merge this patch series via the powerpc tree in 4.1 cycle. So please
ack the corresponding patches if you are OK with these changes.

Kevin Hao (11):
  sata_svw: remove the dependency on PPC_OF
  fbdev: aty128fb: replace PPC_OF with PPC
  fbdev: radeon: replace PPC_OF with PPC
  fbdev: imsttfb: remove the dependency on PPC_OF
  fbdev: nvidia: remove the dependency on PPC_OF
  fbdev: riva: remove the dependency on PPC_OF
  fbdev: remove the unnecessary includes of ppc specific header files
  fbdev: kconfig: replace PPC_OF with PPC
  mmc: kconfig: replace PPC_OF with PPC
  tty: kconfig: remove the superfluous dependency on PPC_OF
  powerpc: kill PPC_OF

 arch/powerpc/Kconfig |  3 ---
 arch/powerpc/Kconfig.debug   |  2 +-
 arch/powerpc/kernel/Makefile |  4 ++--
 drivers/ata/sata_svw.c   | 11 +--
 drivers/mmc/host/Kconfig |  4 ++--
 drivers/tty/serial/Kconfig   |  4 ++--
 drivers/video/fbdev/Kconfig  |  4 ++--
 drivers/video/fbdev/aty/aty128fb.c   |  4 ++--
 drivers/video/fbdev/aty/radeon_base.c| 24 
 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++--
 drivers/video/fbdev/aty/radeon_pm.c  | 16 
 drivers/video/fbdev/aty/radeonfb.h   |  4 ++--
 drivers/video/fbdev/core/fbmon.c |  4 
 drivers/video/fbdev/imsttfb.c|  6 +-
 drivers/video/fbdev/nvidia/Makefile  |  3 +--
 drivers/video/fbdev/nvidia/nv_of.c   |  3 ---
 drivers/video/fbdev/nvidia/nv_proto.h|  8 
 drivers/video/fbdev/nvidia/nvidia.c  |  4 
 drivers/video/fbdev/riva/fbdev.c | 17 +++--
 19 files changed, 53 insertions(+), 92 deletions(-)

-- 
1.9.3

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

[PATCH v2 01/11] sata_svw: remove the dependency on PPC_OF

2015-02-26 Thread Kevin Hao
The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao haoke...@gmail.com
Acked-by: Tejun Heo t...@kernel.org
---
v2: Add the ack from Tejun Heo.

 drivers/ata/sata_svw.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index c630fa812624..4c06f6281d74 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -47,11 +47,7 @@
 #include scsi/scsi_cmnd.h
 #include scsi/scsi.h
 #include linux/libata.h
-
-#ifdef CONFIG_PPC_OF
-#include asm/prom.h
-#include asm/pci-bridge.h
-#endif /* CONFIG_PPC_OF */
+#include linux/of.h
 
 #define DRV_NAME   sata_svw
 #define DRV_VERSION2.3
@@ -320,7 +316,6 @@ static u8 k2_stat_check_status(struct ata_port *ap)
return readl(ap-ioaddr.status_addr);
 }
 
-#ifdef CONFIG_PPC_OF
 static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost)
 {
struct ata_port *ap;
@@ -350,14 +345,10 @@ static int k2_sata_show_info(struct seq_file *m, struct 
Scsi_Host *shost)
}
return 0;
 }
-#endif /* CONFIG_PPC_OF */
-
 
 static struct scsi_host_template k2_sata_sht = {
ATA_BMDMA_SHT(DRV_NAME),
-#ifdef CONFIG_PPC_OF
.show_info  = k2_sata_show_info,
-#endif
 };
 
 
-- 
1.9.3

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

[PATCH v2 02/11] fbdev: aty128fb: replace PPC_OF with PPC

2015-02-26 Thread Kevin Hao
The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/aty/aty128fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/aty/aty128fb.c 
b/drivers/video/fbdev/aty/aty128fb.c
index aedf2fbf9bf6..0156954bf340 100644
--- a/drivers/video/fbdev/aty/aty128fb.c
+++ b/drivers/video/fbdev/aty/aty128fb.c
@@ -965,7 +965,7 @@ static void __iomem *aty128_find_mem_vbios(struct 
aty128fb_par *par)
 /* fill in known card constants if pll_block is not available */
 static void aty128_timings(struct aty128fb_par *par)
 {
-#ifdef CONFIG_PPC_OF
+#ifdef CONFIG_PPC
/* instead of a table lookup, assume OF has properly
 * setup the PLL registers and use their values
 * to set the XCLK values and reference divider values */
@@ -979,7 +979,7 @@ static void aty128_timings(struct aty128fb_par *par)
if (!par-constants.ref_clk)
par-constants.ref_clk = 2950;
 
-#ifdef CONFIG_PPC_OF
+#ifdef CONFIG_PPC
x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV);
xclk_cntl = aty_ld_pll(XCLK_CNTL)  0x7;
Nx = (x_mpll_ref_fb_div  0x00ff00)  8;
-- 
1.9.3

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

[PATCH v2 03/11] fbdev: radeon: replace PPC_OF with PPC

2015-02-26 Thread Kevin Hao
The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/Kconfig  |  2 +-
 drivers/video/fbdev/aty/radeon_base.c| 24 
 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++--
 drivers/video/fbdev/aty/radeon_pm.c  | 16 
 drivers/video/fbdev/aty/radeonfb.h   |  4 ++--
 5 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index b3dd417b4719..3b818d7a0983 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -1333,7 +1333,7 @@ config FB_RADEON
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-   select FB_MACMODES if PPC_OF
+   select FB_MACMODES if PPC
help
  Choose this option if you want to use an ATI Radeon graphics card as
  a framebuffer device.  There are both PCI and AGP versions.  You
diff --git a/drivers/video/fbdev/aty/radeon_base.c 
b/drivers/video/fbdev/aty/radeon_base.c
index 26d80a4486fb..01237c8fcdc6 100644
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -74,7 +74,7 @@
 #include asm/io.h
 #include linux/uaccess.h
 
-#ifdef CONFIG_PPC_OF
+#ifdef CONFIG_PPC
 
 #include asm/pci-bridge.h
 #include ../macmodes.h
@@ -83,7 +83,7 @@
 #include asm/btext.h
 #endif
 
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC */
 
 #ifdef CONFIG_MTRR
 #include asm/mtrr.h
@@ -418,7 +418,7 @@ static int  radeon_find_mem_vbios(struct radeonfb_info 
*rinfo)
 }
 #endif
 
-#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
+#if defined(CONFIG_PPC) || defined(CONFIG_SPARC)
 /*
  * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device
  * tree. Hopefully, ATI OF driver is kind enough to fill these
@@ -448,7 +448,7 @@ static int radeon_read_xtal_OF(struct radeonfb_info *rinfo)
 
return 0;
 }
-#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
+#endif /* CONFIG_PPC || CONFIG_SPARC */
 
 /*
  * Read PLL infos from chip registers
@@ -653,7 +653,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo)
rinfo-pll.ref_div = INPLL(PPLL_REF_DIV)  PPLL_REF_DIV_MASK;
 
 
-#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
+#if defined(CONFIG_PPC) || defined(CONFIG_SPARC)
/*
 * Retrieve PLL infos from Open Firmware first
 */
@@ -661,7 +661,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo)
printk(KERN_INFO radeonfb: Retrieved PLL infos from 
Open Firmware\n);
goto found;
}
-#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
+#endif /* CONFIG_PPC || CONFIG_SPARC */
 
/*
 * Check out if we have an X86 which gave us some PLL informations
@@ -1910,7 +1910,7 @@ static int radeon_set_fbinfo(struct radeonfb_info *rinfo)
  * I put the card's memory at 0 in card space and AGP at some random high
  * local (0xe000 for now) that will be changed by XFree/DRI anyway
  */
-#ifdef CONFIG_PPC_OF
+#ifdef CONFIG_PPC
 #undef SET_MC_FB_FROM_APERTURE
 static void fixup_memory_mappings(struct radeonfb_info *rinfo)
 {
@@ -1984,7 +1984,7 @@ static void fixup_memory_mappings(struct radeonfb_info 
*rinfo)
((aper_base + aper_size - 1)  0x) | (aper_base  16),
0x | (agp_base  16));
 }
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC */
 
 
 static void radeon_identify_vram(struct radeonfb_info *rinfo)
@@ -2236,7 +2236,7 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
rinfo-family == CHIP_FAMILY_RS200)
rinfo-errata |= CHIP_ERRATA_PLL_DELAY;
 
-#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC)
+#if defined(CONFIG_PPC) || defined(CONFIG_SPARC)
/* On PPC, we obtain the OF device-node pointer to the firmware
 * data for this chip
 */
@@ -2245,14 +2245,14 @@ static int radeonfb_pci_register(struct pci_dev *pdev,
printk(KERN_WARNING radeonfb (%s): Cannot match card to OF 
node !\n,
   pci_name(rinfo-pdev));
 
-#endif /* CONFIG_PPC_OF || CONFIG_SPARC */
-#ifdef CONFIG_PPC_OF
+#endif /* CONFIG_PPC || CONFIG_SPARC */
+#ifdef CONFIG_PPC
/* On PPC, the firmware sets up a memory mapping that tends
 * to cause lockups when enabling the engine. We reconfigure
 * the card internal memory mappings properly
 */
fixup_memory_mappings(rinfo);
-#endif /* CONFIG_PPC_OF */
+#endif /* CONFIG_PPC */
 
/* Get VRAM size and type */
radeon_identify_vram(rinfo);
diff --git a/drivers/video/fbdev/aty/radeon_monitor.c 
b/drivers/video/fbdev/aty/radeon_monitor.c
index 

[PATCH v2 04/11] fbdev: imsttfb: remove the dependency on PPC_OF

2015-02-26 Thread Kevin Hao
The OF functionality has moved to a common place and be used by many
archs. So we don't need to depend on PPC_OF option any more. This is
a preparation for killing PPC_OF.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: Only print the error log when CONFIG_OF is enabled.

 drivers/video/fbdev/imsttfb.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c
index aae10ce74f14..9b167f7ef6c6 100644
--- a/drivers/video/fbdev/imsttfb.c
+++ b/drivers/video/fbdev/imsttfb.c
@@ -1470,15 +1470,13 @@ static int imsttfb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
unsigned long addr, size;
struct imstt_par *par;
struct fb_info *info;
-#ifdef CONFIG_PPC_OF
struct device_node *dp;

dp = pci_device_to_OF_node(pdev);
if(dp)
printk(KERN_INFO %s: OF name %s\n,__func__, dp-name);
-   else
+   else if (IS_ENABLED(CONFIG_OF))
printk(KERN_ERR imsttfb: no OF node for pci device\n);
-#endif /* CONFIG_PPC_OF */
 
info = framebuffer_alloc(sizeof(struct imstt_par), pdev-dev);
 
@@ -1501,11 +1499,9 @@ static int imsttfb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
switch (pdev-device) {
case PCI_DEVICE_ID_IMS_TT128: /* IMS,tt128mbA */
par-ramdac = IBM;
-#ifdef CONFIG_PPC_OF
if (dp  ((strcmp(dp-name, IMS,tt128mb8) == 0) ||
   (strcmp(dp-name, IMS,tt128mb8A) == 0)))
par-ramdac = TVP;
-#endif /* CONFIG_PPC_OF */
break;
case PCI_DEVICE_ID_IMS_TT3D:  /* IMS,tt3d */
par-ramdac = TVP;
-- 
1.9.3

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

[PATCH v2 05/11] fbdev: nvidia: remove the dependency on PPC_OF

2015-02-26 Thread Kevin Hao
The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/nvidia/Makefile   | 3 +--
 drivers/video/fbdev/nvidia/nv_of.c| 3 ---
 drivers/video/fbdev/nvidia/nv_proto.h | 8 
 drivers/video/fbdev/nvidia/nvidia.c   | 4 
 4 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/video/fbdev/nvidia/Makefile 
b/drivers/video/fbdev/nvidia/Makefile
index ca47432113e0..917d3eb05feb 100644
--- a/drivers/video/fbdev/nvidia/Makefile
+++ b/drivers/video/fbdev/nvidia/Makefile
@@ -5,9 +5,8 @@
 obj-$(CONFIG_FB_NVIDIA)  += nvidiafb.o
 
 nvidiafb-y   := nvidia.o nv_hw.o nv_setup.o \
-   nv_accel.o
+   nv_accel.o nv_of.o
 nvidiafb-$(CONFIG_FB_NVIDIA_I2C) += nv_i2c.o
 nvidiafb-$(CONFIG_FB_NVIDIA_BACKLIGHT)  += nv_backlight.o
-nvidiafb-$(CONFIG_PPC_OF)   += nv_of.o
 
 nvidiafb-objs:= $(nvidiafb-y)
diff --git a/drivers/video/fbdev/nvidia/nv_of.c 
b/drivers/video/fbdev/nvidia/nv_of.c
index 3bc13df4b120..5f3e5179c25a 100644
--- a/drivers/video/fbdev/nvidia/nv_of.c
+++ b/drivers/video/fbdev/nvidia/nv_of.c
@@ -19,9 +19,6 @@
 
 #include asm/io.h
 
-#include asm/prom.h
-#include asm/pci-bridge.h
-
 #include nv_type.h
 #include nv_local.h
 #include nv_proto.h
diff --git a/drivers/video/fbdev/nvidia/nv_proto.h 
b/drivers/video/fbdev/nvidia/nv_proto.h
index ff5c410355ea..878a5ce02299 100644
--- a/drivers/video/fbdev/nvidia/nv_proto.h
+++ b/drivers/video/fbdev/nvidia/nv_proto.h
@@ -42,16 +42,8 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int 
conn,
 #define nvidia_probe_i2c_connector(p, c, edid) (-1)
 #endif
 
-#ifdef CONFIG_PPC_OF
 int nvidia_probe_of_connector(struct fb_info *info, int conn,
  u8 ** out_edid);
-#else
-static inline int nvidia_probe_of_connector(struct fb_info *info, int conn,
- u8 ** out_edid)
-{
-   return -1;
-}
-#endif
 
 /* in nv_accel.c */
 extern void NVResetGraphics(struct fb_info *info);
diff --git a/drivers/video/fbdev/nvidia/nvidia.c 
b/drivers/video/fbdev/nvidia/nvidia.c
index def041204676..4273c6ee8cf6 100644
--- a/drivers/video/fbdev/nvidia/nvidia.c
+++ b/drivers/video/fbdev/nvidia/nvidia.c
@@ -24,10 +24,6 @@
 #ifdef CONFIG_MTRR
 #include asm/mtrr.h
 #endif
-#ifdef CONFIG_PPC_OF
-#include asm/prom.h
-#include asm/pci-bridge.h
-#endif
 #ifdef CONFIG_BOOTX_TEXT
 #include asm/btext.h
 #endif
-- 
1.9.3

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

[PATCH v2 06/11] fbdev: riva: remove the dependency on PPC_OF

2015-02-26 Thread Kevin Hao
The OF functionality has moved to a common place and be used by many
archs. So we don't need to include the ppc arch specific header files
and depend on PPC_OF option any more. This is a preparation for
killing PPC_OF.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/riva/fbdev.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c
index be73727c7227..294a80908c8c 100644
--- a/drivers/video/fbdev/riva/fbdev.c
+++ b/drivers/video/fbdev/riva/fbdev.c
@@ -44,10 +44,6 @@
 #ifdef CONFIG_MTRR
 #include asm/mtrr.h
 #endif
-#ifdef CONFIG_PPC_OF
-#include asm/prom.h
-#include asm/pci-bridge.h
-#endif
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include asm/machdep.h
 #include asm/backlight.h
@@ -1735,7 +1731,6 @@ static int riva_set_fbinfo(struct fb_info *info)
return (rivafb_check_var(info-var, info));
 }
 
-#ifdef CONFIG_PPC_OF
 static int riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd)
 {
struct riva_par *par = info-par;
@@ -1766,9 +1761,8 @@ static int riva_get_EDID_OF(struct fb_info *info, struct 
pci_dev *pd)
NVTRACE_LEAVE();
return 0;
 }
-#endif /* CONFIG_PPC_OF */
 
-#if defined(CONFIG_FB_RIVA_I2C)  !defined(CONFIG_PPC_OF)
+#if defined(CONFIG_FB_RIVA_I2C)
 static int riva_get_EDID_i2c(struct fb_info *info)
 {
struct riva_par *par = info-par;
@@ -1828,10 +1822,13 @@ static void riva_update_default_var(struct 
fb_var_screeninfo *var,
 static void riva_get_EDID(struct fb_info *info, struct pci_dev *pdev)
 {
NVTRACE_ENTER();
-#ifdef CONFIG_PPC_OF
-   if (!riva_get_EDID_OF(info, pdev))
+   if (riva_get_EDID_OF(info, pdev)) {
+   NVTRACE_LEAVE();
+   return;
+   }
+   if (IS_ENABLED(CONFIG_OF))
printk(PFX could not retrieve EDID from OF\n);
-#elif defined(CONFIG_FB_RIVA_I2C)
+#if defined(CONFIG_FB_RIVA_I2C)
if (!riva_get_EDID_i2c(info))
printk(PFX could not retrieve EDID from DDC/I2C\n);
 #endif
-- 
1.9.3

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

[PATCH v2 07/11] fbdev: remove the unnecessary includes of ppc specific header files

2015-02-26 Thread Kevin Hao
In the current kernel, we don't need to include these arch specific
header files for ppc.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/core/fbmon.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c
index 95338593ebf4..3ae868c58cef 100644
--- a/drivers/video/fbdev/core/fbmon.c
+++ b/drivers/video/fbdev/core/fbmon.c
@@ -33,10 +33,6 @@
 #include video/edid.h
 #include video/of_videomode.h
 #include video/videomode.h
-#ifdef CONFIG_PPC_OF
-#include asm/prom.h
-#include asm/pci-bridge.h
-#endif
 #include ../edid.h
 
 /*
-- 
1.9.3

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

[PATCH v2 08/11] fbdev: kconfig: replace PPC_OF with PPC

2015-02-26 Thread Kevin Hao
The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/video/fbdev/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 3b818d7a0983..109462303087 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -479,7 +479,7 @@ config FB_ATARI
 
 config FB_OF
bool Open Firmware frame buffer device support
-   depends on (FB = y)  (PPC64 || PPC_OF)  (!PPC_PSERIES || PCI)
+   depends on (FB = y)  PPC  (!PPC_PSERIES || PCI)
select FB_CFB_FILLRECT
select FB_CFB_COPYAREA
select FB_CFB_IMAGEBLIT
-- 
1.9.3

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

[PATCH v2 09/11] mmc: kconfig: replace PPC_OF with PPC

2015-02-26 Thread Kevin Hao
The PPC_OF is a ppc specific option which is used to mean that the
firmware device tree access functions are available. Since all the
ppc platforms have a device tree, it is aways set to 'y' for ppc.
So it makes no sense to keep a such option in the current kernel.
Replace it with PPC.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/mmc/host/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 61ac63a3776a..7858d7a52818 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -132,7 +132,7 @@ config MMC_SDHCI_OF_ARASAN
 config MMC_SDHCI_OF_ESDHC
tristate SDHCI OF support for the Freescale eSDHC controller
depends on MMC_SDHCI_PLTFM
-   depends on PPC_OF
+   depends on PPC
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
help
  This selects the Freescale eSDHC controller support.
@@ -144,7 +144,7 @@ config MMC_SDHCI_OF_ESDHC
 config MMC_SDHCI_OF_HLWD
tristate SDHCI OF support for the Nintendo Wii SDHCI controllers
depends on MMC_SDHCI_PLTFM
-   depends on PPC_OF
+   depends on PPC
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
help
  This selects the Secure Digital Host Controller Interface (SDHCI)
-- 
1.9.3

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

[PATCH v2 10/11] tty: kconfig: remove the superfluous dependency on PPC_OF

2015-02-26 Thread Kevin Hao
In the current kernel, the CONFIG_PPC_OF is always 'y' for the ppc
arch. So we don't need to check it with other ppc specific options.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 drivers/tty/serial/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index d2501f01cd03..77471d3db8d3 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -835,7 +835,7 @@ config SERIAL_MCF_CONSOLE
 
 config SERIAL_PMACZILOG
tristate Mac or PowerMac z85c30 ESCC support
-   depends on (M68K  MAC) || (PPC_OF  PPC_PMAC)
+   depends on (M68K  MAC) || PPC_PMAC
select SERIAL_CORE
help
  This driver supports the Zilog z85C30 serial ports found on
@@ -1153,7 +1153,7 @@ config SERIAL_OMAP_CONSOLE
 
 config SERIAL_OF_PLATFORM_NWPSERIAL
tristate NWP serial port driver
-   depends on PPC_OF  PPC_DCR
+   depends on PPC_DCR
select SERIAL_OF_PLATFORM
select SERIAL_CORE_CONSOLE
select SERIAL_CORE
-- 
1.9.3

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

[PATCH v2 11/11] powerpc: kill PPC_OF

2015-02-26 Thread Kevin Hao
We have set CONFIG_PPC_OF to always 'y' in commit 0a498d96a332
(powerpc: set CONFIG_PPC_OF=y always for ARCH=powerpc) nine years
ago. And the arch/ppc also has gone away for many years. The OF
functionality was also moved to a common place and be used by many
archs. So it does make no sense to keep such a option in the current
kernel. Just kill it.

Signed-off-by: Kevin Hao haoke...@gmail.com
---
v2: No change.

 arch/powerpc/Kconfig | 3 ---
 arch/powerpc/Kconfig.debug   | 2 +-
 arch/powerpc/kernel/Makefile | 4 ++--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5084bdcc6046..1734f8a338eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -189,9 +189,6 @@ config ARCH_MAY_HAVE_PC_FDC
bool
default PCI
 
-config PPC_OF
-   def_bool y
-
 config PPC_UDBG_16550
bool
default n
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index ec2e40f2cc11..bfd823abff93 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -117,7 +117,7 @@ config BDI_SWITCH
 
 config BOOTX_TEXT
bool Support for early boot text console (BootX or OpenFirmware only)
-   depends on PPC_OF  PPC_BOOK3S
+   depends on PPC_BOOK3S
help
  Say Y here to see progress messages from the boot firmware in text
  mode. Requires either BootX or Open Firmware.
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 502cf69b6c89..c1ebbdaac28f 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -33,7 +33,8 @@ obj-y := cputable.o ptrace.o 
syscalls.o \
   signal.o sysfs.o cacheinfo.o time.o \
   prom.o traps.o setup-common.o \
   udbg.o misc.o io.o dma.o \
-  misc_$(CONFIG_WORD_SIZE).o vdso32/
+  misc_$(CONFIG_WORD_SIZE).o vdso32/ \
+  of_platform.o prom_parse.o
 obj-$(CONFIG_PPC64)+= setup_64.o sys_ppc32.o \
   signal_64.o ptrace32.o \
   paca.o nvram_64.o firmware.o
@@ -47,7 +48,6 @@ obj-$(CONFIG_PPC64)   += vdso64/
 obj-$(CONFIG_ALTIVEC)  += vecemu.o
 obj-$(CONFIG_PPC_970_NAP)  += idle_power4.o
 obj-$(CONFIG_PPC_P7_NAP)   += idle_power7.o
-obj-$(CONFIG_PPC_OF)   += of_platform.o prom_parse.o
 procfs-y   := proc_powerpc.o
 obj-$(CONFIG_PROC_FS)  += $(procfs-y)
 rtaspci-$(CONFIG_PPC64)-$(CONFIG_PCI)  := rtas_pci.o
-- 
1.9.3

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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Thu, 26 Feb 2015 14:38:15 -0800 Andrew Morton a...@linux-foundation.org 
wrote:

 Does that __weak trick even work?

Nope.

--- a/fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix
+++ a/fs/binfmt_elf.c
@@ -2307,10 +2307,10 @@ unsigned long __weak mmap_rnd(void)
 }
 
 /*
- * Not all architectures use randomize_et_dyn(), so use __weak to let the
- * linker omit it from vmlinux
+ * Not all architectures use randomize_et_dyn(), but there doesn't seem to be
+ * a compile-time way of avoiding its generation.
  */
-unsigned long __weak randomize_et_dyn(unsigned long base)
+unsigned long randomize_et_dyn(unsigned long base)
 {
unsigned long ret;
 
_

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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Stephen Rothwell
Hi Andrew,

On Thu, 26 Feb 2015 14:38:15 -0800 Andrew Morton a...@linux-foundation.org 
wrote:

 diff -puN 
 fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
 fs/binfmt_elf.c
 --- a/fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 +++ a/fs/binfmt_elf.c
 @@ -22,6 +22,7 @@
  #include linux/slab.h
  #include linux/personality.h
  #include linux/elfcore.h
 +#include linux/elf-randomization.h
  #include linux/init.h
  #include linux/highuid.h
  #include linux/compiler.h
 @@ -2300,6 +2301,26 @@ out:
  
  #endif   /* CONFIG_ELF_CORE */
  
 +/* Not all architectures implement mmap_rnd() */
 +unsigned long __weak mmap_rnd(void)
 +{
 +}
 +
 +/*
 + * Not all architectures use randomize_et_dyn(), so use __weak to let the
 + * linker omit it from vmlinux
 + */
 +unsigned long __weak randomize_et_dyn(unsigned long base)
 +{
 + unsigned long ret;
 +
 + if ((current-personality  ADDR_NO_RANDOMIZE) ||
 + !(current-flags  PF_RANDOMIZE))
 + return base;
 + ret = base + mmap_rnd();
 + return max(ret, base);
 +}
 +

Didn't we have some trouble with some compilers when the weak function
(mmap_rnd) was defined and used in the same file i.e. the wrong one was
used?

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpYe5cuXTmDE.pgp
Description: OpenPGP digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Thu, 26 Feb 2015 15:34:36 -0800 Kees Cook keesc...@chromium.org wrote:

  That pointless repetition should be avoided.
 
  That's surprisingly hard!
 
  After renaming mips brk_rnd() to mmap_rnd() I had a shot.  I'm not very
  confident in the result.  Does that __weak trick even work?
 
 In theory, it shouldn't be needed since only randomize_et_dyn will
 call mmap_rnd, and only architectures that use randomize_et_dyn will
 call it ... and will define mmap_rnd.

But randomize_et_dyn() is compiled for all architectures.  Or it was,
until I did the CONFIG_ARCH_HAVE_ELF_ASLR thing.

It seems odd that we have this per-arch feature but no Kconfig switch
for it.

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

Re: [RFC V2 12/12] i2c: bcm-iproc: make use of the new infrastructure for quirks

2015-02-26 Thread Ray Jui


On 2/25/2015 8:02 AM, Wolfram Sang wrote:
 From: Wolfram Sang wsa+rene...@sang-engineering.com
 
 Signed-off-by: Wolfram Sang wsa+rene...@sang-engineering.com
 ---
  drivers/i2c/busses/i2c-bcm-iproc.c | 15 +++
  1 file changed, 7 insertions(+), 8 deletions(-)
 
 diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c 
 b/drivers/i2c/busses/i2c-bcm-iproc.c
 index d3c89157b33774..f9f2c2082151e2 100644
 --- a/drivers/i2c/busses/i2c-bcm-iproc.c
 +++ b/drivers/i2c/busses/i2c-bcm-iproc.c
 @@ -160,14 +160,6 @@ static int bcm_iproc_i2c_xfer_single_msg(struct 
 bcm_iproc_i2c_dev *iproc_i2c,
   u32 val;
   unsigned long time_left = msecs_to_jiffies(I2C_TIMEOUT_MESC);
  
 - /* need to reserve one byte in the FIFO for the slave address */
 - if (msg-len  M_TX_RX_FIFO_SIZE - 1) {
 - dev_err(iproc_i2c-device,
 - only support data length up to %u bytes\n,
 - M_TX_RX_FIFO_SIZE - 1);
 - return -EOPNOTSUPP;
 - }
 -
   /* check if bus is busy */
   if (!!(readl(iproc_i2c-base + M_CMD_OFFSET) 
  BIT(M_CMD_START_BUSY_SHIFT))) {
 @@ -287,6 +279,12 @@ static const struct i2c_algorithm bcm_iproc_algo = {
   .functionality = bcm_iproc_i2c_functionality,
  };
  
 +static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
 + /* need to reserve one byte in the FIFO for the slave address */
 + .max_read_len = M_TX_RX_FIFO_SIZE - 1,
 + .max_write_len = M_TX_RX_FIFO_SIZE - 1,
 +};
 +
  static int bcm_iproc_i2c_cfg_speed(struct bcm_iproc_i2c_dev *iproc_i2c)
  {
   unsigned int bus_speed;
 @@ -413,6 +411,7 @@ static int bcm_iproc_i2c_probe(struct platform_device 
 *pdev)
   i2c_set_adapdata(adap, iproc_i2c);
   strlcpy(adap-name, Broadcom iProc I2C adapter, sizeof(adap-name));
   adap-algo = bcm_iproc_algo;
 + adap-quirks = bcm_iproc_i2c_quirks;
   adap-dev.parent = pdev-dev;
   adap-dev.of_node = pdev-dev.of_node;
  
 

Change on the iproc i2c driver looks good to me. Sanity tested the
change from Wolfram's i2c/quirks branch on Cygnus 958300K combo board.
Sanity tested with an attempt to transfer large amount of I2C data to
ensure the transfer is denied by the i2c-core:

/ # cat /dev/i2c-0
[  657.310261] i2c i2c-0: quirk: msg too long (addr 0x, size 4096, read)

Reviewed-by: Ray Jui r...@broadcom.com
Tested-by: Ray Jui r...@broadcom.com

Thanks,

Ray

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

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Tue, 24 Feb 2015 08:39:06 +0100 Ingo Molnar mi...@kernel.org wrote:

 
 * Hector Marco Gisbert hecma...@upv.es wrote:
 
  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}
 
  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}
 
  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + brk_rnd();
  +   return (ret  base) ? ret : base;
  +}
 
  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}
 
  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}
 
 That pointless repetition should be avoided.

That's surprisingly hard!

After renaming mips brk_rnd() to mmap_rnd() I had a shot.  I'm not very
confident in the result.  Does that __weak trick even work?

Someone tell me how important Hector's patch is?


From: Andrew Morton a...@linux-foundation.org
Subject: fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix

Consolidate randomize_et_dyn() implementations into fs/binfmt_elf.c.

There doesn't seem to be a compile-time way of making randomize_et_dyn()
go away on architectures which don't need it, so mark it __weak to cause
it to be discarded at link time.

Cc: H. Peter Anvin h...@zytor.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Catalin Marinas catalin.mari...@arm.com
Cc: Hector Marco Gisbert hecma...@upv.es
Cc: Hector Marco-Gisbert hecma...@upv.es
Cc: Ingo Molnar mi...@kernel.org
Cc: Ismael Ripoll irip...@upv.es
Cc: Kees Cook keesc...@chromium.org
Cc: Ralf Baechle r...@linux-mips.org
Cc: Russell King r...@arm.linux.org.uk
Cc: Thomas Gleixner t...@linutronix.de
Cc: Will Deacon will.dea...@arm.com
Signed-off-by: Andrew Morton a...@linux-foundation.org
---

 arch/arm/include/asm/elf.h|3 +--
 arch/arm/mm/mmap.c|   13 ++---
 arch/arm64/Kconfig|2 +-
 arch/arm64/include/asm/elf.h  |3 +--
 arch/arm64/mm/mmap.c  |   14 ++
 arch/mips/include/asm/elf.h   |1 -
 arch/mips/mm/mmap.c   |   13 ++---
 arch/powerpc/include/asm/elf.h|2 --
 arch/powerpc/mm/mmap.c|   13 ++---
 arch/x86/include/asm/elf.h|2 --
 arch/x86/mm/mmap.c|   12 ++--
 fs/binfmt_elf.c   |   21 +
 include/linux/elf-randomization.h |7 +++
 13 files changed, 41 insertions(+), 65 deletions(-)

diff -puN 
arch/arm/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
arch/arm/Kconfig
diff -puN 
arch/arm/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 arch/arm/include/asm/elf.h
--- 
a/arch/arm/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
+++ a/arch/arm/include/asm/elf.h
@@ -2,7 +2,7 @@
 #define __ASMARM_ELF_H
 
 #include asm/hwcap.h
-
+#include linux/elf-randomization.h
 /*
  * ELF register definitions..
  */
@@ -115,7 +115,6 @@ int dump_task_regs(struct task_struct *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(randomize_et_dyn(2 * TASK_SIZE / 3))
 
 /* When the program starts, a1 contains a pointer to a function to be 
diff -puN 
arch/arm/mm/mmap.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
arch/arm/mm/mmap.c
--- a/arch/arm/mm/mmap.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
+++ a/arch/arm/mm/mmap.c
@@ -7,6 +7,7 @@
 #include linux/shm.h
 #include linux/sched.h
 #include linux/io.h
+#include linux/elf-randomization.h
 #include linux/personality.h
 #include linux/random.h
 #include asm/cachetype.h
@@ -30,7 +31,7 @@ static int mmap_is_legacy(void)
return sysctl_legacy_va_layout;
 }
 
-static unsigned long mmap_rnd(void)
+unsigned long mmap_rnd(void)
 {
unsigned long rnd = 0;
 
@@ -241,13 +242,3 @@ int devmem_is_allowed(unsigned long pfn)
 }
 

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Andrew Morton
On Fri, 27 Feb 2015 10:21:36 +1100 Stephen Rothwell s...@canb.auug.org.au 
wrote:

  +/* Not all architectures implement mmap_rnd() */
  +unsigned long __weak mmap_rnd(void)
  +{
  +}
  +
  +/*
  + * Not all architectures use randomize_et_dyn(), so use __weak to let the
  + * linker omit it from vmlinux
  + */
  +unsigned long __weak randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return max(ret, base);
  +}
  +
 
 Didn't we have some trouble with some compilers when the weak function
 (mmap_rnd) was defined and used in the same file i.e. the wrong one was
 used?

I have vague memories, but I forget the details.

This sucks anyway - let's do it properly.

I'm just flinging together trollpatches here.  Someone please review,
test and fix this stuff.  Kees?

diff -puN 
arch/arm/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
arch/arm/Kconfig
--- 
a/arch/arm/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/arch/arm/Kconfig
@@ -5,6 +5,7 @@ config ARM
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_HAS_GCOV_PROFILE_ALL
+   select ARCH_HAVE_ELF_ASLR
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_USE_BUILTIN_BSWAP
diff -puN 
arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
arch/arm64/Kconfig
--- 
a/arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/arch/arm64/Kconfig
@@ -9,6 +9,7 @@ config ARM64
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
select ARCH_WANT_FRAME_POINTERS
+   select ARCH_HAVE_ELF_ASLR
select ARM_AMBA
select ARM_ARCH_TIMER
select ARM_GIC
diff -puN 
arch/mips/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
arch/mips/Kconfig
--- 
a/arch/mips/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/arch/mips/Kconfig
@@ -39,6 +39,7 @@ config MIPS
select HAVE_MEMBLOCK
select HAVE_MEMBLOCK_NODE_MAP
select ARCH_DISCARD_MEMBLOCK
+   select ARCH_HAVE_ELF_ASLR
select GENERIC_SMP_IDLE_THREAD
select BUILDTIME_EXTABLE_SORT
select GENERIC_CLOCKEVENTS
diff -puN 
arch/powerpc/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
 arch/powerpc/Kconfig
--- 
a/arch/powerpc/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/arch/powerpc/Kconfig
@@ -97,6 +97,7 @@ config PPC
select HAVE_FUNCTION_GRAPH_TRACER
select SYSCTL_EXCEPTION_TRACE
select ARCH_WANT_OPTIONAL_GPIOLIB
+   select ARCH_HAVE_ELF_ASLR
select VIRT_TO_BUS if !PPC64
select HAVE_IDE
select HAVE_IOREMAP_PROT
diff -puN 
arch/x86/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
arch/x86/Kconfig
--- 
a/arch/x86/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/arch/x86/Kconfig
@@ -28,6 +28,7 @@ config X86
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_MIGHT_HAVE_PC_PARPORT
select ARCH_MIGHT_HAVE_PC_SERIO
+   select ARCH_HAVE_ELF_ASLR
select HAVE_AOUT if X86_32
select HAVE_UNSTABLE_SCHED_CLOCK
select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
diff -puN 
fs/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
fs/Kconfig
--- a/fs/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/fs/Kconfig
@@ -50,6 +50,9 @@ config FS_DAX
 
 endif # BLOCK
 
+config ARCH_HAVE_ELF_ASLR
+   bool
+
 # Posix ACL utility routines
 #
 # Note: Posix ACLs can be implemented without these helpers.  Never use
diff -puN 
fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2 
fs/binfmt_elf.c
--- 
a/fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix-fix-2
+++ a/fs/binfmt_elf.c
@@ -2301,15 +2301,7 @@ out:
 
 #endif /* CONFIG_ELF_CORE */
 
-/* Not all architectures implement mmap_rnd() */
-unsigned long __weak mmap_rnd(void)
-{
-}
-
-/*
- * Not all architectures use randomize_et_dyn(), but there doesn't seem to be
- * a compile-time way of avoiding its generation.
- */
+#ifdef ARCH_HAVE_ELF_ASLR
 unsigned long randomize_et_dyn(unsigned long base)
 {
unsigned long ret;
@@ -2320,6 +2312,7 @@ unsigned long randomize_et_dyn(unsigned
ret = base + mmap_rnd();
return max(ret, base);
 }
+#endif
 
 static int __init init_elf_binfmt(void)
 {
_

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

Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC

2015-02-26 Thread Benjamin Herrenschmidt
On Sat, 2015-01-31 at 21:47 +0800, Kevin Hao wrote:
 The PPC_OF is a ppc specific option which is used to mean that the
 firmware device tree access functions are available. Since all the
 ppc platforms have a device tree, it is aways set to 'y' for ppc.
 So it makes no sense to keep a such option in the current kernel.
 Replace it with PPC.
 
 Signed-off-by: Kevin Hao haoke...@gmail.com

For this and generally the whole series,

Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org

Which tree do we expect this to go through ?

Cheers,
Ben.

 ---
  drivers/video/fbdev/aty/aty128fb.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/video/fbdev/aty/aty128fb.c 
 b/drivers/video/fbdev/aty/aty128fb.c
 index aedf2fbf9bf6..0156954bf340 100644
 --- a/drivers/video/fbdev/aty/aty128fb.c
 +++ b/drivers/video/fbdev/aty/aty128fb.c
 @@ -965,7 +965,7 @@ static void __iomem *aty128_find_mem_vbios(struct 
 aty128fb_par *par)
  /* fill in known card constants if pll_block is not available */
  static void aty128_timings(struct aty128fb_par *par)
  {
 -#ifdef CONFIG_PPC_OF
 +#ifdef CONFIG_PPC
   /* instead of a table lookup, assume OF has properly
* setup the PLL registers and use their values
* to set the XCLK values and reference divider values */
 @@ -979,7 +979,7 @@ static void aty128_timings(struct aty128fb_par *par)
   if (!par-constants.ref_clk)
   par-constants.ref_clk = 2950;
  
 -#ifdef CONFIG_PPC_OF
 +#ifdef CONFIG_PPC
   x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV);
   xclk_cntl = aty_ld_pll(XCLK_CNTL)  0x7;
   Nx = (x_mpll_ref_fb_div  0x00ff00)  8;


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

Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC

2015-02-26 Thread Kevin Hao
On Fri, Feb 27, 2015 at 11:11:15AM +1100, Benjamin Herrenschmidt wrote:
 On Sat, 2015-01-31 at 21:47 +0800, Kevin Hao wrote:
  The PPC_OF is a ppc specific option which is used to mean that the
  firmware device tree access functions are available. Since all the
  ppc platforms have a device tree, it is aways set to 'y' for ppc.
  So it makes no sense to keep a such option in the current kernel.
  Replace it with PPC.
  
  Signed-off-by: Kevin Hao haoke...@gmail.com
 
 For this and generally the whole series,
 
 Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org

Thanks Ben.

 
 Which tree do we expect this to go through ?

I just sent out a v2 [1] a few hours earlier with some minor updates. We plan
to merge this patch series via the powerpc tree in 4.1 cycle if I can collect
all the acks from the corresponding driver maintainers.

[1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-February/125331.html

Thanks,
Kevin


pgpGAzIqKrvcR.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Russell King - ARM Linux
On Thu, Feb 26, 2015 at 02:38:15PM -0800, Andrew Morton wrote:
 diff -puN 
 arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
 arch/arm64/Kconfig
 --- a/arch/arm64/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 +++ a/arch/arm64/Kconfig
 @@ -1,4 +1,4 @@
 -config ARM64
 +qconfig ARM64

Is this a typo?

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Stephen Rothwell
Hi Andrew,

[Just resending to correct addresses - sorry for those who get a duplicate]

On Thu, 26 Feb 2015 14:38:15 -0800 Andrew Morton a...@linux-foundation.org 
wrote:

 diff -puN 
 fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
 fs/binfmt_elf.c
 --- a/fs/binfmt_elf.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 +++ a/fs/binfmt_elf.c
 @@ -22,6 +22,7 @@
  #include linux/slab.h
  #include linux/personality.h
  #include linux/elfcore.h
 +#include linux/elf-randomization.h
  #include linux/init.h
  #include linux/highuid.h
  #include linux/compiler.h
 @@ -2300,6 +2301,26 @@ out:
  
  #endif   /* CONFIG_ELF_CORE */
  
 +/* Not all architectures implement mmap_rnd() */
 +unsigned long __weak mmap_rnd(void)
 +{
 +}
 +
 +/*
 + * Not all architectures use randomize_et_dyn(), so use __weak to let the
 + * linker omit it from vmlinux
 + */
 +unsigned long __weak randomize_et_dyn(unsigned long base)
 +{
 + unsigned long ret;
 +
 + if ((current-personality  ADDR_NO_RANDOMIZE) ||
 + !(current-flags  PF_RANDOMIZE))
 + return base;
 + ret = base + mmap_rnd();
 + return max(ret, base);
 +}
 +  

Didn't we have some trouble with some compilers when the weak function
(mmap_rnd) was defined and used in the same file i.e. the wrong one was
used?

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au


pgpFQjeciaw5p.pgp
Description: OpenPGP digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] Fix offset2lib issue for x86*, ARM*, PowerPC and MIPS

2015-02-26 Thread Kees Cook
On Thu, Feb 26, 2015 at 2:38 PM, Andrew Morton
a...@linux-foundation.org wrote:
 On Tue, 24 Feb 2015 08:39:06 +0100 Ingo Molnar mi...@kernel.org wrote:


 * Hector Marco Gisbert hecma...@upv.es wrote:

  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}

  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}

  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + brk_rnd();
  +   return (ret  base) ? ret : base;
  +}

  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}

  +unsigned long randomize_et_dyn(unsigned long base)
  +{
  +   unsigned long ret;
  +   if ((current-personality  ADDR_NO_RANDOMIZE) ||
  +   !(current-flags  PF_RANDOMIZE))
  +   return base;
  +   ret = base + mmap_rnd();
  +   return (ret  base) ? ret : base;
  +}

 That pointless repetition should be avoided.

 That's surprisingly hard!

 After renaming mips brk_rnd() to mmap_rnd() I had a shot.  I'm not very
 confident in the result.  Does that __weak trick even work?

In theory, it shouldn't be needed since only randomize_et_dyn will
call mmap_rnd, and only architectures that use randomize_et_dyn will
call it ... and will define mmap_rnd.


 Someone tell me how important Hector's patch is?

I consider it a reasonable improvement to userspace ASLR. I look at it
more as a new feature than a bug fix, but it could be argued as a bug
fix too.



 From: Andrew Morton a...@linux-foundation.org
 Subject: fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix

 Consolidate randomize_et_dyn() implementations into fs/binfmt_elf.c.

 There doesn't seem to be a compile-time way of making randomize_et_dyn()
 go away on architectures which don't need it, so mark it __weak to cause
 it to be discarded at link time.

 Cc: H. Peter Anvin h...@zytor.com
 Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
 Cc: Catalin Marinas catalin.mari...@arm.com
 Cc: Hector Marco Gisbert hecma...@upv.es
 Cc: Hector Marco-Gisbert hecma...@upv.es
 Cc: Ingo Molnar mi...@kernel.org
 Cc: Ismael Ripoll irip...@upv.es
 Cc: Kees Cook keesc...@chromium.org
 Cc: Ralf Baechle r...@linux-mips.org
 Cc: Russell King r...@arm.linux.org.uk
 Cc: Thomas Gleixner t...@linutronix.de
 Cc: Will Deacon will.dea...@arm.com
 Signed-off-by: Andrew Morton a...@linux-foundation.org

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

Thanks for fixing it up!

-Kees

 ---

  arch/arm/include/asm/elf.h|3 +--
  arch/arm/mm/mmap.c|   13 ++---
  arch/arm64/Kconfig|2 +-
  arch/arm64/include/asm/elf.h  |3 +--
  arch/arm64/mm/mmap.c  |   14 ++
  arch/mips/include/asm/elf.h   |1 -
  arch/mips/mm/mmap.c   |   13 ++---
  arch/powerpc/include/asm/elf.h|2 --
  arch/powerpc/mm/mmap.c|   13 ++---
  arch/x86/include/asm/elf.h|2 --
  arch/x86/mm/mmap.c|   12 ++--
  fs/binfmt_elf.c   |   21 +
  include/linux/elf-randomization.h |7 +++
  13 files changed, 41 insertions(+), 65 deletions(-)

 diff -puN 
 arch/arm/Kconfig~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
 arch/arm/Kconfig
 diff -puN 
 arch/arm/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
  arch/arm/include/asm/elf.h
 --- 
 a/arch/arm/include/asm/elf.h~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix
 +++ a/arch/arm/include/asm/elf.h
 @@ -2,7 +2,7 @@
  #define __ASMARM_ELF_H

  #include asm/hwcap.h
 -
 +#include linux/elf-randomization.h
  /*
   * ELF register definitions..
   */
 @@ -115,7 +115,6 @@ int dump_task_regs(struct task_struct *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(randomize_et_dyn(2 * TASK_SIZE / 3))

  /* When the program starts, a1 contains a pointer to a function to be
 diff -puN 
 arch/arm/mm/mmap.c~fix-offset2lib-issue-for-x86-arm-powerpc-and-mips-fix 
 arch/arm/mm/mmap.c
 --- 

Re: [PATCH 4/4] powerpc/mpic: remove unused functions

2015-02-26 Thread Arseny Solokha
 @@ -1676,31 +1666,6 @@ void __init mpic_init(struct mpic *mpic)
   mpic_err_int_init(mpic, MPIC_FSL_ERR_INT);
  }
  
 -void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)
 -{
 - u32 v;
 -
 - v = mpic_read(mpic-gregs, MPIC_GREG_GLOBAL_CONF_1);
 - v = ~MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK;
 - v |= MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO(clock_ratio);
 - mpic_write(mpic-gregs, MPIC_GREG_GLOBAL_CONF_1, v);
 -}
 -
 -void __init mpic_set_serial_int(struct mpic *mpic, int enable)
 -{
 - unsigned long flags;
 - u32 v;
 -
 - raw_spin_lock_irqsave(mpic_lock, flags);
 - v = mpic_read(mpic-gregs, MPIC_GREG_GLOBAL_CONF_1);
 - if (enable)
 - v |= MPIC_GREG_GLOBAL_CONF_1_SIE;
 - else
 - v = ~MPIC_GREG_GLOBAL_CONF_1_SIE;
 - mpic_write(mpic-gregs, MPIC_GREG_GLOBAL_CONF_1, v);
 - raw_spin_unlock_irqrestore(mpic_lock, flags);
 -}
 -
  void mpic_irq_set_priority(unsigned int irq, unsigned int pri)
  {
   struct mpic *mpic = mpic_find(irq);

Thinking about it some more, I wonder whether it makes sense to propagate these
values through device tree (and refuse to apply them if they are 0), just like
what timer_group_get_freq() and timer_group_get_irq() in
arch/powerpc/sysdev/mpic_timer.c do.

Does it have any real use?
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 3/5] mm: move randomize_et_dyn into ELF_ET_DYN_BASE

2015-02-26 Thread Kees Cook
This moves s390's randomize_et_dyn base into ELF_ET_DYN_BASE, and removes
an unused arm64 extern.

Signed-off-by: Kees Cook keesc...@chromium.org
---
 arch/arm64/include/asm/elf.h |  1 -
 arch/s390/include/asm/elf.h  |  9 +
 arch/s390/mm/mmap.c  | 11 ---
 3 files changed, 5 insertions(+), 16 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/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index c9df40b5c0ac..9ed68e7ee856 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -161,10 +161,11 @@ 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.  */
-
-extern unsigned long randomize_et_dyn(void);
-#define ELF_ET_DYN_BASErandomize_et_dyn()
+   that it will exec, and that there is sufficient room for the brk. 64-bit
+   tasks are aligned to 4GB. */
+#define ELF_ET_DYN_BASE (arch_mmap_rnd() + (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 77759e35671b..ec4c20448aef 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -179,17 +179,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
return addr;
 }
 
-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);
-   return base + arch_mmap_rnd();
-}
-
 #ifndef CONFIG_64BIT
 
 /*
-- 
1.9.1

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

[PATCH 0/5] split ET_DYN ASLR from mmap ASLR

2015-02-26 Thread Kees Cook
This separates ET_DYN ASLR from mmap ASLR, as already done on s390. The
various 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

Thanks!

-Kees

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

[PATCH] powerpc: Make corenet64_defconfig a bit more useful

2015-02-26 Thread Benjamin Herrenschmidt
CONFIG_BLK_DEV_SD, SR, ... are needed for pretty much any SATA or USB
storage device (corenet32_defconfig has them) and modern any with
systemd needs the CGROUPS gunk.

Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org
---
 diff --git a/arch/powerpc/configs/corenet64_smp_defconfig 
b/arch/powerpc/configs/corenet64_smp_defconfig
index 04737aa..066eb45 100644
--- a/arch/powerpc/configs/corenet64_smp_defconfig
+++ b/arch/powerpc/configs/corenet64_smp_defconfig
@@ -12,6 +12,10 @@ CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
+CONFIG_CGROUPS=y
+CONFIG_CPUSETS=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_SCHED=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_KALLSYMS_ALL=y
@@ -75,6 +79,10 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=131072
 CONFIG_EEPROM_LEGACY=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLK_DEV_SR=y
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=y
 CONFIG_ATA=y
 CONFIG_SATA_FSL=y
 CONFIG_SATA_SIL24=y


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

[PATCH 2/5] mm: expose arch_mmap_rnd when available

2015-02-26 Thread Kees Cook
When an architecture fully supports randomizing the ELF load location, the
arch_mmap_rnd() function becomes available. Rename and expose these functions
where they exist. Introduces CONFIG_ARCH_HAS_ELF_RANDOMIZE.

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   |  9 ++---
 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|  6 +++---
 fs/binfmt_elf.c   |  1 +
 include/linux/elf-randomize.h | 10 ++
 15 files changed, 43 insertions(+), 16 deletions(-)
 create mode 100644 include/linux/elf-randomize.h

diff --git a/arch/Kconfig b/arch/Kconfig
index 05d7a8a458d5..e315cc79ebe7 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(), must respect (current-flags  PF_RANDOMIZE)
+
 #
 # 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 0f8bc158f2c6..3c1fedb034bb 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 = 0UL;
 
@@ -183,7 +183,7 @@ static unsigned long mmap_rnd(void)
 
 void arch_pick_mmap_layout(struct mm_struct *mm)
 {
-   unsigned long random_factor = mmap_rnd();
+   unsigned long 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 54922d1275b8..b7117cb4bc07 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 = 0;
 
@@ -66,7 +66,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 - arch_mmap_rnd());
 }
 
 /*
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 f1baadd56e82..d32490d99671 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -164,9 +164,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
}
 }
 
-static inline unsigned long brk_rnd(void)
+unsigned long arch_mmap_rnd(void)
 {
-   unsigned long rnd = get_random_int();
+   unsigned long rnd = 0;
+
+   if (current-flags  PF_RANDOMIZE)
+   rnd = get_random_int();
 
rnd = rnd  PAGE_SHIFT;
/* 8MB for 32bit, 256MB for 64bit */
@@ -183,7 +186,7 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
unsigned long base = mm-brk;
unsigned long ret;
 
-   ret = PAGE_ALIGN(base + brk_rnd());
+ 

Re: [3/3] powerpc/dma: Remove ZONE_DMA completely

2015-02-26 Thread Michael Ellerman
On Thu, 2015-02-26 at 17:38 +1100, Michael Ellerman wrote:
 On Fri, 2015-20-02 at 08:35:44 UTC, Benjamin Herrenschmidt wrote:
  diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
  index e24e0ae..6306d4e 100644
  --- a/arch/powerpc/kernel/dma.c
  +++ b/arch/powerpc/kernel/dma.c
  @@ -63,16 +63,8 @@ void *dma_direct_alloc_coherent(struct device *dev, 
  size_t size,
  return NULL;
  }
   
  -   switch (zone) {
  -   case ZONE_DMA:
  -   flag |= GFP_DMA;
  -   break;
  -#ifdef CONFIG_ZONE_DMA32
  -   case ZONE_DMA32:
  +   if (zone == ZONE_DMA32)
  flag |= GFP_DMA32;
  -   break;
  -#endif
  -   };
 
 You still need the ifdef, else eg. ppc6xx_defconfig:
 
   arch/powerpc/kernel/dma.c:66:14: error: 'ZONE_DMA32' undeclared (first use 
 in this function)

And the rest :)

  http://kisskb.ellerman.id.au/kisskb/head/8505/

  Successful:   45% 49/109

cheers


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

Re: [PATCH 0/2] powerpc/kvm: Enable running guests on RT Linux

2015-02-26 Thread Scott Wood
On Thu, 2015-02-26 at 14:31 +0100, Sebastian Andrzej Siewior wrote:
 On 02/26/2015 02:02 PM, Paolo Bonzini wrote:
  
  
  On 24/02/2015 00:27, Scott Wood wrote:
  This isn't a host PIC driver.  It's guest PIC emulation, some of which
  is indeed not suitable for a rawlock (in particular, openpic_update_irq
  which loops on the number of vcpus, with a loop body that calls
  IRQ_check() which loops over all pending IRQs).
  
  The question is what behavior is wanted of code that isn't quite
  RT-ready.  What is preferred, bugs or bad latency?
  
  If the answer is bad latency (which can be avoided simply by not running
  KVM on a RT kernel in production), patch 1 can be applied.  If the
 can be applied *but* makes no difference if applied or not.
 
  answer is bugs, patch 1 is not upstream material.
  
  I myself prefer to have bad latency; if something takes a spinlock in
  atomic context, that spinlock should be raw.  If it hurts (latency),
  don't do it (use the affected code).
 
 The problem, that is fixed by this s/spin_lock/raw_spin_lock/, exists
 only in -RT. There is no change upstream. In general we fix such things
 in -RT first and forward the patches upstream if possible. This convert
 thingy would be possible.
 Bug fixing comes before latency no matter if RT or not. Converting
 every lock into a rawlock is not always the answer.
 Last thing I read from Scott is that he is not entirely sure if this is
 the right approach or not and patch #1 was not acked-by him either.
 
 So for now I wait for Scott's feedback and maybe a backtrace :)

Obviously leaving it in a buggy state is not what we want -- but I lean
towards a short term fix of putting depends on !PREEMPT_RT on the
in-kernel MPIC emulation (which is itself just an optimization -- you
can still use KVM without it).  This way people don't enable it with RT
without being aware of the issue, and there's more of an incentive to
fix it properly.

I'll let Bogdan supply the backtrace.

-Scott


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

Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC

2015-02-26 Thread Benjamin Herrenschmidt
On Fri, 2015-02-27 at 09:05 +0800, Kevin Hao wrote:
 On Fri, Feb 27, 2015 at 11:11:15AM +1100, Benjamin Herrenschmidt wrote:
  On Sat, 2015-01-31 at 21:47 +0800, Kevin Hao wrote:
   The PPC_OF is a ppc specific option which is used to mean that the
   firmware device tree access functions are available. Since all the
   ppc platforms have a device tree, it is aways set to 'y' for ppc.
   So it makes no sense to keep a such option in the current kernel.
   Replace it with PPC.
   
   Signed-off-by: Kevin Hao haoke...@gmail.com
  
  For this and generally the whole series,
  
  Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org
 
 Thanks Ben.
 
  
  Which tree do we expect this to go through ?
 
 I just sent out a v2 [1] a few hours earlier with some minor updates. We plan
 to merge this patch series via the powerpc tree in 4.1 cycle if I can collect
 all the acks from the corresponding driver maintainers.
 
 [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-February/125331.html

Anything I'm the maintainer by default for has my ack (radeonfb,
aty128fb, ...)

Cheers,
Ben.


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

[PATCH 1/5] arm: factor out mmap ASLR into mmap_rnd

2015-02-26 Thread Kees Cook
Move logic for mmap ASLR into separate function.

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

diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..0f8bc158f2c6 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -169,14 +169,21 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
return addr;
 }
 
-void arch_pick_mmap_layout(struct mm_struct *mm)
+static unsigned long mmap_rnd(void)
 {
-   unsigned long random_factor = 0UL;
+   unsigned long rnd = 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;
+   rnd = (get_random_int() % (1  8))  PAGE_SHIFT;
+
+   return rnd;
+}
+
+void arch_pick_mmap_layout(struct mm_struct *mm)
+{
+   unsigned long 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 5/5] mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE

2015-02-26 Thread Kees Cook
On architectures that define CONFIG_ARCH_HAS_ELF_RANDOMIZE, collapse the
function declarations while continuing to handle 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 e315cc79ebe7..1c7e98f137db 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(), must respect (current-flags  PF_RANDOMIZE)
+ - 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 617f7fabdb0a..7cc271003ff6 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 203c2e6f9a25..96459c18d1eb 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1041,15 +1041,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 =
arch_randomize_brk(current-mm);
-#ifdef CONFIG_COMPAT_BRK
+#ifdef compat_brk_randomized

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

2015-02-26 Thread Kees Cook
This moves arch_mmap_rnd() into the ELF loader for handling ET_DYN ASLR
in a separate region from mmap ASLR, as already done on s390. Removes
CONFIG_BINFMT_ELF_RANDOMIZE_PIE.

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 |  4 ++--
 arch/x86/Kconfig|  1 -
 fs/Kconfig.binfmt   |  3 ---
 fs/binfmt_elf.c | 17 ++---
 8 files changed, 4 insertions(+), 25 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 9ed68e7ee856..617f7fabdb0a 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -163,9 +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. */
-#define ELF_ET_DYN_BASE (arch_mmap_rnd() + (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/x86/Kconfig b/arch/x86/Kconfig
index 9aa91727fbf8..328be0fab910 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -87,7 +87,6 @@ config X86
select HAVE_ARCH_KMEMCHECK
select HAVE_ARCH_KASAN if X86_64  SPARSEMEM_VMEMMAP
select HAVE_USER_RETURN_NOTIFIER
-   select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ELF_RANDOMIZE
select HAVE_ARCH_JUMP_LABEL
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
index 270c48148f79..2d0cbbd14cfc 100644
--- a/fs/Kconfig.binfmt
+++ b/fs/Kconfig.binfmt
@@ -27,9 +27,6 @@ config COMPAT_BINFMT_ELF
bool
depends on COMPAT  BINFMT_ELF
 
-config ARCH_BINFMT_ELF_RANDOMIZE_PIE
-   bool
-
 config ARCH_BINFMT_ELF_STATE
bool
 
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index b1c5ef5d9322..203c2e6f9a25 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -910,21 +910,8 @@ static int load_elf_binary(struct linux_binprm *bprm)
 * default mmap base, as well as whatever program they
 * might try to exec.  This is because the brk will
 * follow the loader, and is not movable.  */
-#ifdef CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE
-   /* Memory randomization might have been switched off
-* in runtime via sysctl or explicit setting of
-* personality flags.
-* If that is the case, retain the original non-zero
-* load_bias value in order to establish proper
-* non-randomized mappings.
-*/
-   if (current-flags  PF_RANDOMIZE)
-   load_bias = 0;
-   else
-   

Re: [3/3] powerpc/dma: Remove ZONE_DMA completely

2015-02-26 Thread Benjamin Herrenschmidt
On Fri, 2015-02-27 at 14:39 +1100, Michael Ellerman wrote:
 On Thu, 2015-02-26 at 17:38 +1100, Michael Ellerman wrote:
  On Fri, 2015-20-02 at 08:35:44 UTC, Benjamin Herrenschmidt wrote:
   diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
   index e24e0ae..6306d4e 100644
   --- a/arch/powerpc/kernel/dma.c
   +++ b/arch/powerpc/kernel/dma.c
   @@ -63,16 +63,8 @@ void *dma_direct_alloc_coherent(struct device *dev, 
   size_t size,
 return NULL;
 }

   - switch (zone) {
   - case ZONE_DMA:
   - flag |= GFP_DMA;
   - break;
   -#ifdef CONFIG_ZONE_DMA32
   - case ZONE_DMA32:
   + if (zone == ZONE_DMA32)
 flag |= GFP_DMA32;
   - break;
   -#endif
   - };
  
  You still need the ifdef, else eg. ppc6xx_defconfig:
  
arch/powerpc/kernel/dma.c:66:14: error: 'ZONE_DMA32' undeclared (first 
  use in this function)
 
 And the rest :)
 
   http://kisskb.ellerman.id.au/kisskb/head/8505/
 
   Successful: 45% 49/109

Yup, I forgot I didn't have it unconditionally on ppc32 :-)

I'll respin some time next week.

Cheers,
Ben.

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