Re: [PATCH 1/9] powerpc/configs: Drop CONFIG_QLGE which moved to staging

2020-01-15 Thread Joel Stanley
On Thu, 16 Jan 2020 at 01:48, Michael Ellerman  wrote:
>
> The QLGE driver moved to staging in commit 955315b0dc8c ("qlge: Move
> drivers/net/ethernet/qlogic/qlge/ to drivers/staging/qlge/"), meaning
> our defconfigs that enable it have no effect as we don't enable
> CONFIG_STAGING.
>
> It sounds like the device is obsolete, so drop the driver.
>
> Signed-off-by: Michael Ellerman 

Acked-by: Joel Stanley 


Re: [PATCH 2/9] powerpc/configs: NET_CADENCE became NET_VENDOR_CADENCE

2020-01-15 Thread Joel Stanley
On Thu, 16 Jan 2020 at 01:48, Michael Ellerman  wrote:
>
> The NET_CADENCE symbol was renamed to NET_VENDOR_CADENCE, so we don't
> need to disable the former, see commit 0df5f81c481e ("net: ethernet:
> Add missing VENDOR to Cadence and Packet Engines symbols").
>
> Signed-off-by: Michael Ellerman 

Acked-by: Joel Stanley 


Re: [RFC PATCH 8/9] powerpc/configs/skiroot: Disable xmon default & enable reboot on panic

2020-01-15 Thread Joel Stanley
On Thu, 16 Jan 2020 at 01:48, Michael Ellerman  wrote:
>
> If the skiroot kernel crashes we don't want it sitting at an xmon
> prompt forever. Instead it's more helpful to reboot and bring the
> boot loader back up, and if the crash was transient we can then boot
> successfully.
>
> Similarly if we panic we should reboot, with a short timeout in case
> someone is watching the console.
>
> Signed-off-by: Michael Ellerman 

Acked-by: Joel Stanley 

> ---
>  arch/powerpc/configs/skiroot_defconfig | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/configs/skiroot_defconfig 
> b/arch/powerpc/configs/skiroot_defconfig
> index bd661a9a9410..12c96c8b0c1d 100644
> --- a/arch/powerpc/configs/skiroot_defconfig
> +++ b/arch/powerpc/configs/skiroot_defconfig
> @@ -29,6 +29,7 @@ CONFIG_ALTIVEC=y
>  CONFIG_VSX=y
>  CONFIG_NR_CPUS=2048
>  CONFIG_CPU_LITTLE_ENDIAN=y
> +CONFIG_PANIC_TIMEOUT=30
>  # CONFIG_PPC_VAS is not set
>  # CONFIG_PPC_PSERIES is not set
>  # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
> @@ -293,6 +294,7 @@ CONFIG_LIBCRC32C=y
>  CONFIG_PRINTK_TIME=y
>  CONFIG_MAGIC_SYSRQ=y
>  CONFIG_DEBUG_STACKOVERFLOW=y
> +CONFIG_PANIC_ON_OOPS=y
>  CONFIG_SOFTLOCKUP_DETECTOR=y
>  CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y
>  CONFIG_HARDLOCKUP_DETECTOR=y
> @@ -301,5 +303,4 @@ CONFIG_WQ_WATCHDOG=y
>  # CONFIG_SCHED_DEBUG is not set
>  # CONFIG_FTRACE is not set
>  CONFIG_XMON=y
> -CONFIG_XMON_DEFAULT=y
>  # CONFIG_RUNTIME_TESTING_MENU is not set
> --
> 2.21.1
>


Re: [PATCH 6/9] powerpc/configs/skiroot: Update for symbol movement only

2020-01-15 Thread Joel Stanley
On Thu, 16 Jan 2020 at 01:48, Michael Ellerman  wrote:
>
> Signed-off-by: Michael Ellerman 

Acked-by: Joel Stanley 


Re: [RFC PATCH 9/9] powerpc/configs/skiroot: Enable some more hardening options

2020-01-15 Thread Joel Stanley
On Thu, 16 Jan 2020 at 01:48, Michael Ellerman  wrote:
>
> Enable more hardening options.
>
> Note BUG_ON_DATA_CORRUPTION selects DEBUG_LIST and is essentially just
> a synonym for it.
>
> DEBUG_SG, DEBUG_NOTIFIERS, DEBUG_LIST, DEBUG_CREDENTIALS and
> SCHED_STACK_END_CHECK should all be low overhead and just add a few
> extra checks.
>
> Unselecting SLAB_MERGE_DEFAULT causes the SLAB to use more memory, but
> the skiroot kernel shouldn't be memory constrained on any of our
> systems, all it does is run a small bootloader.

Why do we unselect it?

> SLAB_FREELIST_RANDOM, and SLUB_DEBUG_ON will add some overhead to the
> SLAB allocator, but nothing that should be meaningful for skiroot.
>
> Signed-off-by: Michael Ellerman 

Acked-by: Joel Stanley 


> ---
>  arch/powerpc/configs/skiroot_defconfig | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/configs/skiroot_defconfig 
> b/arch/powerpc/configs/skiroot_defconfig
> index 12c96c8b0c1d..59c2de904fda 100644
> --- a/arch/powerpc/configs/skiroot_defconfig
> +++ b/arch/powerpc/configs/skiroot_defconfig
> @@ -23,6 +23,8 @@ CONFIG_EXPERT=y
>  # CONFIG_AIO is not set
>  CONFIG_PERF_EVENTS=y
>  # CONFIG_COMPAT_BRK is not set
> +# CONFIG_SLAB_MERGE_DEFAULT is not set
> +CONFIG_SLAB_FREELIST_RANDOM=y
>  CONFIG_SLAB_FREELIST_HARDENED=y
>  CONFIG_PPC64=y
>  CONFIG_ALTIVEC=y
> @@ -293,6 +295,8 @@ CONFIG_LIBCRC32C=y
>  # CONFIG_XZ_DEC_SPARC is not set
>  CONFIG_PRINTK_TIME=y
>  CONFIG_MAGIC_SYSRQ=y
> +CONFIG_SLUB_DEBUG_ON=y
> +CONFIG_SCHED_STACK_END_CHECK=y
>  CONFIG_DEBUG_STACKOVERFLOW=y
>  CONFIG_PANIC_ON_OOPS=y
>  CONFIG_SOFTLOCKUP_DETECTOR=y
> @@ -301,6 +305,10 @@ CONFIG_HARDLOCKUP_DETECTOR=y
>  CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y
>  CONFIG_WQ_WATCHDOG=y
>  # CONFIG_SCHED_DEBUG is not set
> +CONFIG_DEBUG_SG=y
> +CONFIG_DEBUG_NOTIFIERS=y
> +CONFIG_BUG_ON_DATA_CORRUPTION=y
> +CONFIG_DEBUG_CREDENTIALS=y
>  # CONFIG_FTRACE is not set
>  CONFIG_XMON=y
>  # CONFIG_RUNTIME_TESTING_MENU is not set
> --
> 2.21.1
>


[PATCH] powerpc/config: Enable secuity features in skiroot

2020-01-01 Thread Joel Stanley
This turns on HARDENED_USERCOPY with HARDENED_USERCOPY_PAGESPAN, and
FORTIFY_SOURCE.

It also enables SECURITY_LOCKDOWN_LSM with _EARLY and
LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY options enabled.

MODULE_SIG is selected by lockdown, so it is still enabled.

Signed-off-by: Joel Stanley 
---
 arch/powerpc/configs/skiroot_defconfig | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/configs/skiroot_defconfig 
b/arch/powerpc/configs/skiroot_defconfig
index 069f67f12731..0a441c414a57 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -33,7 +33,6 @@ CONFIG_JUMP_LABEL=y
 CONFIG_STRICT_KERNEL_RWX=y
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
-CONFIG_MODULE_SIG=y
 CONFIG_MODULE_SIG_FORCE=y
 CONFIG_MODULE_SIG_SHA512=y
 CONFIG_PARTITION_ADVANCED=y
@@ -297,5 +296,15 @@ CONFIG_WQ_WATCHDOG=y
 CONFIG_XMON=y
 CONFIG_XMON_DEFAULT=y
 CONFIG_ENCRYPTED_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_HARDENED_USERCOPY=y
+# CONFIG_HARDENED_USERCOPY_FALLBACK is not set
+CONFIG_HARDENED_USERCOPY_PAGESPAN=y
+CONFIG_FORTIFY_SOURCE=y
+CONFIG_SECURITY_LOCKDOWN_LSM=y
+CONFIG_SECURITY_LOCKDOWN_LSM_EARLY=y
+CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY=y
+# CONFIG_INTEGRITY is not set
+CONFIG_LSM="yama,loadpin,safesetid,integrity"
 # CONFIG_CRYPTO_ECHAINIV is not set
 # CONFIG_CRYPTO_HW is not set
-- 
2.24.1



Re: [PATCH v5 5/5] powerpc/configs: Enable STRICT_MODULE_RWX in skiroot_defconfig

2019-10-30 Thread Joel Stanley
On Wed, 30 Oct 2019 at 07:31, Russell Currey  wrote:
>
> skiroot_defconfig is the only powerpc defconfig with STRICT_KERNEL_RWX
> enabled, and if you want memory protection for kernel text you'd want it
> for modules too, so enable STRICT_MODULE_RWX there.
>
> Signed-off-by: Russell Currey 

Acked-by: Joel Stanley 

> ---
>  arch/powerpc/configs/skiroot_defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/configs/skiroot_defconfig 
> b/arch/powerpc/configs/skiroot_defconfig
> index 1253482a67c0..719d899081b3 100644
> --- a/arch/powerpc/configs/skiroot_defconfig
> +++ b/arch/powerpc/configs/skiroot_defconfig
> @@ -31,6 +31,7 @@ CONFIG_PERF_EVENTS=y
>  CONFIG_SLAB_FREELIST_HARDENED=y
>  CONFIG_JUMP_LABEL=y
>  CONFIG_STRICT_KERNEL_RWX=y
> +CONFIG_STRICT_MODULE_RWX=y
>  CONFIG_MODULES=y
>  CONFIG_MODULE_UNLOAD=y
>  CONFIG_MODULE_SIG=y
> --
> 2.23.0
>


[PATCH] powerpc/powernv: Print helpful message when cores guarded

2019-07-31 Thread Joel Stanley
Often the firmware will guard out cores after a crash. This often
undesirable, and is not immediately noticeable.

This adds an informative message when a CPU device tree nodes are marked
bad in the device tree.

Signed-off-by: Joel Stanley 
---
Tested on qemu 4.1 with this patch applied:

 
https://ozlabs.org/~joel/uta2019/0001-TESTING-mark-every-second-core-as-guarded.patch

This will show no cores guarded:

 qemu-system-ppc64 -M powernv8 -nographic -smp 1,cores=1,threads=1 -kernel 
zImage.epapr

This will show three:

 qemu-system-ppc64 -M powernv8 -nographic -smp 7,cores=7,threads=1 -kernel 
zImage.epapr

 arch/powerpc/platforms/powernv/setup.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/setup.c 
b/arch/powerpc/platforms/powernv/setup.c
index a5e52f9eed3c..7107583d0c6b 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -129,6 +129,28 @@ static void pnv_setup_rfi_flush(void)
setup_count_cache_flush();
 }
 
+static void __init pnv_check_guarded_cores(void)
+{
+   struct device_node *dn;
+   int bad_count = 0;
+
+   for_each_node_by_type(dn, "cpu") {
+   if (of_property_match_string(dn, "status", "bad") >= 0)
+   bad_count++;
+   };
+
+   if (bad_count) {
+   pr_cont("  __   \n");
+   pr_cont(" /  \\___\n");
+   pr_cont(" |  |   /   \\  \n");
+   pr_cont(" @  @   |WARNING!   |  \n");
+   pr_cont(" || ||  | It looks like |  \n");
+   pr_cont(" || ||   <--|  you have %*d |  \n", 3, bad_count);
+   pr_cont(" |\\_/|  | guarded cores |  \n");
+   pr_cont(" \\___/  \\___/  \n\n");
+   }
+}
+
 static void __init pnv_setup_arch(void)
 {
set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT);
@@ -149,6 +171,8 @@ static void __init pnv_setup_arch(void)
/* Enable NAP mode */
powersave_nap = 1;
 
+   pnv_check_guarded_cores();
+
/* XXX PMCS */
 }
 
-- 
2.20.1



Re: [PATCH] PPC: Set reserved PCR bits

2019-07-15 Thread Joel Stanley
On Tue, 16 Jul 2019 at 02:55, Jordan Niethe  wrote:
>
> Currently the reserved bits of the Processor Compatibility Register
> (PCR) are cleared as per the Programming Note in Section 1.3.3 of the
> ISA.  An update is planned for the ISA so that PCR reserved bits should
> be set. Set the reserved bits of the PCR as required.
>
> Acked-by: Alistair Popple 
> Signed-off-by: Jordan Niethe 

Tested-by: Joel Stanley 

I gave a powernv_defconfig build a spin in a qemu powernv machine.

Cheers,

Joel


[PATCH] powerpc/security: Fix build break

2019-05-14 Thread Joel Stanley
This fixes a build break introduced in with the recent round of CPU
bug patches.

  arch/powerpc/kernel/security.c: In function ‘setup_barrier_nospec’:
  arch/powerpc/kernel/security.c:59:21: error: implicit declaration of
  function ‘cpu_mitigations_off’ [-Werror=implicit-function-declaration]
if (!no_nospec && !cpu_mitigations_off())
   ^~~

Fixes: 782e69efb3df ("powerpc/speculation: Support 'mitigations=' cmdline 
option")
Signed-off-by: Joel Stanley 
---
This should be applied to the 4.14 and 4.19 trees. There is no issue
with 5.1. The commit message contains a fixes line for the commit in
Linus tree.
---
 arch/powerpc/kernel/security.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
index e9af5d9badf2..68d4ec373cfc 100644
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -4,6 +4,7 @@
 //
 // Copyright 2018, Michael Ellerman, IBM Corporation.
 
+#include 
 #include 
 #include 
 #include 
-- 
2.20.1



Re: [PATCH v2 2/2] powerpc/mm: Warn if W+X pages found on boot

2019-05-02 Thread Joel Stanley
On Thu, 2 May 2019 at 07:42, Russell Currey  wrote:
>
> Implement code to walk all pages and warn if any are found to be both
> writable and executable.  Depends on STRICT_KERNEL_RWX enabled, and is
> behind the DEBUG_WX config option.
>
> This only runs on boot and has no runtime performance implications.
>
> Very heavily influenced (and in some cases copied verbatim) from the
> ARM64 code written by Laura Abbott (thanks!), since our ptdump
> infrastructure is similar.
>
> Signed-off-by: Russell Currey 
> ---
> v2: A myriad of fixes and cleanups thanks to Christophe Leroy
>
>  arch/powerpc/Kconfig.debug | 19 ++
>  arch/powerpc/include/asm/pgtable.h |  6 +
>  arch/powerpc/mm/pgtable_32.c   |  3 +++
>  arch/powerpc/mm/pgtable_64.c   |  3 +++
>  arch/powerpc/mm/ptdump/ptdump.c| 41 +-
>  5 files changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
> index 4e00cb0a5464..9e8bcddd8b8f 100644
> --- a/arch/powerpc/Kconfig.debug
> +++ b/arch/powerpc/Kconfig.debug
> @@ -361,6 +361,25 @@ config PPC_PTDUMP
>
>   If you are unsure, say N.
>
> +config PPC_DEBUG_WX

The other architectures call this DEBUG_WX, in case you wanted to name
it the same.

> +   bool "Warn on W+X mappings at boot"
> +   select PPC_PTDUMP
> +   help
> + Generate a warning if any W+X mappings are found at boot.


Re: [PATCH] powerpc/security: Show powerpc_security_features in debugfs

2019-04-11 Thread Joel Stanley
On Tue, 9 Apr 2019 at 22:45, Michael Ellerman  wrote:
>
> This can be helpful for debugging problems with the security feature
> flags, especially on guests where the flags come from the hypervisor
> via an hcall and so can't be observed in the device tree.
>
> Signed-off-by: Michael Ellerman 

Reviewed-by: Joel Stanley 


> ---
>  arch/powerpc/kernel/security.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/kernel/security.c b/arch/powerpc/kernel/security.c
> index b33bafb8fcea..d6ba696d0ed0 100644
> --- a/arch/powerpc/kernel/security.c
> +++ b/arch/powerpc/kernel/security.c
> @@ -104,6 +104,14 @@ static __init int barrier_nospec_debugfs_init(void)
> return 0;
>  }
>  device_initcall(barrier_nospec_debugfs_init);
> +
> +static __init int security_feature_debugfs_init(void)
> +{
> +   debugfs_create_x64("security_features", 0400, powerpc_debugfs_root,
> +  (u64 *)_security_features);
> +   return 0;
> +}
> +device_initcall(security_feature_debugfs_init);
>  #endif /* CONFIG_DEBUG_FS */
>
>  #ifdef CONFIG_PPC_FSL_BOOK3E
> --
> 2.20.1
>


Re: [PATCH v2] powerpc/vmlinux.lds: Drop binutils < 2.18 workarounds

2019-04-04 Thread Joel Stanley
On Fri, 29 Mar 2019 at 09:53, Segher Boessenkool
 wrote:
>
> Hi!
>
> On Fri, Mar 29, 2019 at 05:14:53PM +1030, Joel Stanley wrote:
> > - NOTES :kernel :notes
> > + NOTES
>
> I think this still need to be
>
> NOTES :kernel
>
> or the linker will complain.  Did you try to build ppc64_defconfig?

Yeah, I did build (and boot, in qemu) the ppc64_defconfig. I tried
leaving in/removing the :kernel annotation in a bunch of places and as
long as I had it in the first spot, the kernel linked.

Shall I respin with this added?

> (And I do not know if there are any tools that expect the notes in a phdr,
> or even specifically the second phdr).
>
>
> Segher


[PATCH] powerpc: config: skiroot: Add (back) MLX5 ethernet support

2019-04-02 Thread Joel Stanley
It turns out that some defconfig changes and kernel config option
changes meant we accidentally dropped Ethernet support for Mellanox CLX5
cards.

Reported-by: Carol L Soto 
Suggested-by: Carol L Soto 
Signed-off-by: Stewart Smith 
Signed-off-by: Joel Stanley 
---
 arch/powerpc/configs/skiroot_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/configs/skiroot_defconfig 
b/arch/powerpc/configs/skiroot_defconfig
index 5ba131c30f6b..6038b9347d9e 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -163,6 +163,8 @@ CONFIG_S2IO=m
 CONFIG_MLX4_EN=m
 # CONFIG_MLX4_CORE_GEN2 is not set
 CONFIG_MLX5_CORE=m
+CONFIG_MLX5_CORE_EN=y
+# CONFIG_MLX5_EN_RXNFC is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_MICROSEMI is not set
 CONFIG_MYRI10GE=m
-- 
2.20.1



[PATCH] Documentation: powerpc: Expand the DAWR acronym

2019-04-01 Thread Joel Stanley
Those not of us not drowning in POWER might not know what this means.

Signed-off-by: Joel Stanley 
---
 Documentation/powerpc/DAWR-POWER9.txt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/powerpc/DAWR-POWER9.txt 
b/Documentation/powerpc/DAWR-POWER9.txt
index 2feaa6619658..f6c24e54ce83 100644
--- a/Documentation/powerpc/DAWR-POWER9.txt
+++ b/Documentation/powerpc/DAWR-POWER9.txt
@@ -1,10 +1,10 @@
 DAWR issues on POWER9
 
 
-On POWER9 the DAWR can cause a checkstop if it points to cache
-inhibited (CI) memory. Currently Linux has no way to disinguish CI
-memory when configuring the DAWR, so (for now) the DAWR is disabled by
-this commit:
+On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop
+if it points to cache inhibited (CI) memory. Currently Linux has no way to
+disinguish CI memory when configuring the DAWR, so (for now) the DAWR is
+disabled by this commit:
 
 commit 9654153158d3e0684a1bdb76dbababdb7111d5a0
 Author: Michael Neuling 
-- 
2.20.1



[PATCH v2] powerpc/vmlinux.lds: Drop binutils < 2.18 workarounds

2019-03-29 Thread Joel Stanley
Segher added some workarounds for binutils < 2.18 and GCC < 4.2. We
now set GCC 4.6 and binutils 2.20 as the minimum, so the workarounds
can be dropped.

This is mostly a revert of c6995fe4 ("powerpc: Fix build bug with
binutils < 2.18 and GCC < 4.2"), except we keep the kernel PHDRS
statement as ppc64_defconfig would fail to link without it:

 powerpc64-linux-ld: .tmp_vmlinux1: Not enough room for program headers, try 
linking with -N
 powerpc64-linux-ld: final link failed: Bad value

See https://lore.kernel.org/linuxppc-dev/20190321003253.22100-1-j...@jms.id.au/
for the discussion.

Signed-off-by: Joel Stanley 
---
v2: Fix ppc64_defconfig by keeping kernel PHDRS

Segher, Christophe, I did my best but to summarise your conversation.
Please suggest corrections or additions to the commit message if you
have any.

---
 arch/powerpc/kernel/vmlinux.lds.S | 25 +
 1 file changed, 1 insertion(+), 24 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 060a1acd7c6d..9ddc7c0dc672 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -19,21 +19,6 @@ ENTRY(_stext)
 
 PHDRS {
kernel PT_LOAD FLAGS(7); /* RWX */
-   notes PT_NOTE FLAGS(0);
-   dummy PT_NOTE FLAGS(0);
-
-   /* binutils < 2.18 has a bug that makes it misbehave when taking an
-  ELF file with all segments at load address 0 as input.  This
-  happens when running "strip" on vmlinux, because of the AT() magic
-  in this linker script.  People using GCC >= 4.2 won't run into
-  this problem, because the "build-id" support will put some data
-  into the "notes" segment (at a non-zero load address).
-
-  To work around this, we force some data into both the "dummy"
-  segment and the kernel segment, so the dummy segment will get a
-  non-zero load address.  It's not enough to always create the
-  "notes" segment, since if nothing gets assigned to it, its load
-  address will be zero.  */
 }
 
 #ifdef CONFIG_PPC64
@@ -177,15 +162,7 @@ SECTIONS
 #endif
EXCEPTION_TABLE(0)
 
-   NOTES :kernel :notes
-
-   /* The dummy segment contents for the bug workaround mentioned above
-  near PHDRS.  */
-   .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
-   LONG(0)
-   LONG(0)
-   LONG(0)
-   } :kernel :dummy
+   NOTES
 
 /*
  * Init sections discarded at runtime
-- 
2.20.1



[PATCH] powerpc: vmlinux.lds: Drop Binutils 2.18 workarounds

2019-03-20 Thread Joel Stanley
Segher added some workarounds for GCC 4.2 and bintuils 2.18. We now set
4.6 and 2.20 as the minimum, so they can be dropped.

This is mostly a revert of c6995fe4 ("powerpc: Fix build bug with
binutils < 2.18 and GCC < 4.2").

Signed-off-by: Joel Stanley 
---
 arch/powerpc/kernel/vmlinux.lds.S | 35 ---
 1 file changed, 4 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 060a1acd7c6d..0551e9846676 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -17,25 +17,6 @@
 
 ENTRY(_stext)
 
-PHDRS {
-   kernel PT_LOAD FLAGS(7); /* RWX */
-   notes PT_NOTE FLAGS(0);
-   dummy PT_NOTE FLAGS(0);
-
-   /* binutils < 2.18 has a bug that makes it misbehave when taking an
-  ELF file with all segments at load address 0 as input.  This
-  happens when running "strip" on vmlinux, because of the AT() magic
-  in this linker script.  People using GCC >= 4.2 won't run into
-  this problem, because the "build-id" support will put some data
-  into the "notes" segment (at a non-zero load address).
-
-  To work around this, we force some data into both the "dummy"
-  segment and the kernel segment, so the dummy segment will get a
-  non-zero load address.  It's not enough to always create the
-  "notes" segment, since if nothing gets assigned to it, its load
-  address will be zero.  */
-}
-
 #ifdef CONFIG_PPC64
 OUTPUT_ARCH(powerpc:common64)
 jiffies = jiffies_64;
@@ -77,7 +58,7 @@ SECTIONS
 #else /* !CONFIG_PPC64 */
HEAD_TEXT
 #endif
-   } :kernel
+   }
 
__head_end = .;
 
@@ -126,7 +107,7 @@ SECTIONS
__got2_end = .;
 #endif /* CONFIG_PPC32 */
 
-   } :kernel
+   }
 
. = ALIGN(ETEXT_ALIGN_SIZE);
_etext = .;
@@ -177,15 +158,7 @@ SECTIONS
 #endif
EXCEPTION_TABLE(0)
 
-   NOTES :kernel :notes
-
-   /* The dummy segment contents for the bug workaround mentioned above
-  near PHDRS.  */
-   .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
-   LONG(0)
-   LONG(0)
-   LONG(0)
-   } :kernel :dummy
+   NOTES
 
 /*
  * Init sections discarded at runtime
@@ -200,7 +173,7 @@ SECTIONS
 #ifdef CONFIG_PPC64
*(.tramp.ftrace.init);
 #endif
-   } :kernel
+   }
 
/* .exit.text is discarded at runtime, not link time,
 * to deal with references from __bug_table
-- 
2.20.1



[PATCH] powerpc: config: Sync skiroot defconfig

2019-03-04 Thread Joel Stanley
This updates the skiroot defconfig with the version from the OpenPower
firmwre build tree.

Important changes are the addition of QED and E1000E ethernet drivers.

Signed-off-by: Joel Stanley 
---
Generated on top of next-20190304

 arch/powerpc/configs/skiroot_defconfig | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/configs/skiroot_defconfig 
b/arch/powerpc/configs/skiroot_defconfig
index bf31334efbce..b3a9ea838244 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -52,10 +52,10 @@ CONFIG_MODULE_SIG=y
 CONFIG_MODULE_SIG_FORCE=y
 CONFIG_MODULE_SIG_SHA512=y
 CONFIG_PARTITION_ADVANCED=y
-# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_MQ_IOSCHED_DEADLINE is not set
+# CONFIG_MQ_IOSCHED_KYBER is not set
 # CONFIG_COMPACTION is not set
 # CONFIG_MIGRATION is not set
-# CONFIG_BOUNCE is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -136,9 +136,11 @@ CONFIG_ACENIC_OMIT_TIGON_I=y
 # CONFIG_NET_VENDOR_AQUANTIA is not set
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_VENDOR_ATHEROS is not set
+# CONFIG_NET_VENDOR_AURORA is not set
 CONFIG_TIGON3=m
 CONFIG_BNX2X=m
 # CONFIG_NET_VENDOR_BROCADE is not set
+# CONFIG_NET_VENDOR_CADENCE is not set
 # CONFIG_NET_VENDOR_CAVIUM is not set
 CONFIG_CHELSIO_T1=m
 # CONFIG_NET_VENDOR_CISCO is not set
@@ -150,6 +152,7 @@ CONFIG_BE2NET=m
 # CONFIG_NET_VENDOR_HP is not set
 # CONFIG_NET_VENDOR_HUAWEI is not set
 CONFIG_E1000=m
+CONFIG_E1000E=m
 CONFIG_IGB=m
 CONFIG_IXGB=m
 CONFIG_IXGBE=m
@@ -159,6 +162,7 @@ CONFIG_MLX4_EN=m
 # CONFIG_MLX4_CORE_GEN2 is not set
 CONFIG_MLX5_CORE=m
 # CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROSEMI is not set
 CONFIG_MYRI10GE=m
 # CONFIG_NET_VENDOR_NATSEMI is not set
 CONFIG_S2IO=m
@@ -166,8 +170,11 @@ CONFIG_S2IO=m
 # CONFIG_NET_VENDOR_NI is not set
 # CONFIG_NET_VENDOR_NVIDIA is not set
 # CONFIG_NET_VENDOR_OKI is not set
+# CONFIG_NET_VENDOR_PACKET_ENGINES is not set
 CONFIG_QLGE=m
 CONFIG_NETXEN_NIC=m
+CONFIG_QED=m
+CONFIG_QEDE=m
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RDC is not set
 # CONFIG_NET_VENDOR_REALTEK is not set
-- 
2.20.1



Re: [PATCH] powerpc/configs: Enable CONFIG_USB_XHCI_HCD by default

2019-02-11 Thread Joel Stanley
On Mon, 11 Feb 2019 at 22:07, Thomas Huth  wrote:
>
> Recent versions of QEMU provide a XHCI device by default these
> days instead of an old-fashioned OHCI device:
>
>  https://git.qemu.org/?p=qemu.git;a=commitdiff;h=57040d451315320b7d27

"recent" :D

> So to get the keyboard working in the graphical console there again,
> we should now include XHCI support in the kernel by default, too.
>
> Signed-off-by: Thomas Huth 

Acked-by: Joel Stanley 

> ---
>  arch/powerpc/configs/pseries_defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/configs/pseries_defconfig 
> b/arch/powerpc/configs/pseries_defconfig
> index ea79c51..62e12f6 100644
> --- a/arch/powerpc/configs/pseries_defconfig
> +++ b/arch/powerpc/configs/pseries_defconfig
> @@ -217,6 +217,7 @@ CONFIG_USB_MON=m
>  CONFIG_USB_EHCI_HCD=y
>  # CONFIG_USB_EHCI_HCD_PPC_OF is not set
>  CONFIG_USB_OHCI_HCD=y
> +CONFIG_USB_XHCI_HCD=y
>  CONFIG_USB_STORAGE=m
>  CONFIG_NEW_LEDS=y
>  CONFIG_LEDS_CLASS=m
> --
> 1.8.3.1
>


[PATCH] mtd: powernv: SPDX and comment fixups

2019-02-05 Thread Joel Stanley
This converts the powernv flash driver to use SPDX, and adds some
clarifying comments that came out of a discussion on how the mtd driver
works.

Signed-off-by: Joel Stanley 
---
 drivers/mtd/devices/powernv_flash.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/devices/powernv_flash.c 
b/drivers/mtd/devices/powernv_flash.c
index 22f753e555ac..0bf43336c3f7 100644
--- a/drivers/mtd/devices/powernv_flash.c
+++ b/drivers/mtd/devices/powernv_flash.c
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
+
 /*
  * OPAL PNOR flash MTD abstraction
  *
  * Copyright IBM 2015
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include 
@@ -261,6 +253,14 @@ static int powernv_flash_probe(struct platform_device 
*pdev)
 * The current flash that skiboot exposes is one contiguous flash chip
 * with an ffs partition at the start, it should prove easier for users
 * to deal with partitions or not as they see fit
+*
+* When developing the skiboot MTD driver an experiment with FFS
+* parsing in the kernel, and exposing a seperate /dev/mtdX for each
+* partition (eg BOOTKERNEL, PAYLOAD, NVRAM, etc), was done.
+*
+* We didn't go with that as it meant users couldn't do a full flash
+* re-write, as this can cause a partition to change size, and there
+* wasn't a way to tell the MTD layer that a device has shrunk/grown.
 */
return mtd_device_register(>mtd, NULL, 0);
 }
-- 
2.20.1



[PATCH] powerpc: Use ALIGN instead of BLOCK

2019-01-11 Thread Joel Stanley
In the ld documentation under Builtin Functions:

  BLOCK(exp)

This is a synonym for ALIGN, for compatibility with older linker scripts.

Clang's linker (lld) doesn't know about BLOCK so remove this use of it.

Link: https://github.com/ClangBuiltLinux/linux/issues/253
Signed-off-by: Joel Stanley 
---
 arch/powerpc/kernel/vmlinux.lds.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index ad1c77f71f54..3ae4c959f95b 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -86,11 +86,11 @@ SECTIONS
 
 #ifdef CONFIG_PPC64
/*
-* BLOCK(0) overrides the default output section alignment because
+* ALIGN(0) overrides the default output section alignment because
 * this needs to start right after .head.text in order for fixed
 * section placement to work.
 */
-   .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
+   .text ALIGN(0) : AT(ADDR(.text) - LOAD_OFFSET) {
 #ifdef CONFIG_LD_HEAD_STUB_CATCH
KEEP(*(.linker_stub_catch));
. = . ;
-- 
2.19.1



[PATCH] powerpc/vdso32: Drop -mabi=elfv1 for 32 bit objects

2019-01-09 Thread Joel Stanley
From: Daniel Axtens 

All 64-bit objects need to specify the flag to be compiled correctly, we
just don't need it for 32-bit objects. GCC just ignored it, but clang
doesn't.

Link: https://github.com/ClangBuiltLinux/linux/issues/240
Signed-off-by: Daniel Axtens 
Signed-off-by: Joel Stanley 
---
 arch/powerpc/kernel/vdso32/Makefile | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/arch/powerpc/kernel/vdso32/Makefile 
b/arch/powerpc/kernel/vdso32/Makefile
index 50112d4473bb..6bd41756e0c7 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -34,6 +34,20 @@ obj-y += vdso32_wrapper.o
 extra-y += vdso32.lds
 CPPFLAGS_vdso32.lds += -P -C -Upowerpc
 
+# clang refuses to accept -mabi=elfv1 for when using the
+# 64-bit target in 32-bit mode
+ifdef CONFIG_CC_IS_CLANG
+ifdef CONFIG_PPC64
+AFLAGS_REMOVE_getcpu.o += -mabi=elfv1
+endif
+AFLAGS_REMOVE_sigtramp.o += -mabi=elfv1
+AFLAGS_REMOVE_gettimeofday.o += -mabi=elfv1
+AFLAGS_REMOVE_datapage.o += -mabi=elfv1
+AFLAGS_REMOVE_cacheflush.o += -mabi=elfv1
+AFLAGS_REMOVE_note.o += -mabi=elfv1
+endif
+
+
 # Force dependency (incbin is bad)
 $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so
 
-- 
2.19.1



lockdep WARN_ON in ppc440 with -next

2018-12-13 Thread Joel Stanley
Hello,

I was booting next-20181213 in qemu with lockdep enabled and saw this:

spin_lock-torture:--- Start of test [debug]: nwriters_stress=2
nreaders_stress=0 stat_interval=60 verbose=1 shuffle_interval=3
stutter=5 shutdown_secs=0 onoff_interval=0 onoff_holdoff=0
spin_lock-torture: Creating torture_shuffle task
spin_lock-torture: Creating torture_stutter task
spin_lock-torture: torture_shuffle task started
spin_lock-torture: Creating lock_torture_writer task
spin_lock-torture: torture_stutter task started
spin_lock-torture: Creating lock_torture_writer task
spin_lock-torture: lock_torture_writer task started
spin_lock-torture: Creating lock_torture_stats task
spin_lock-torture: lock_torture_writer task started
spin_lock-torture: lock_torture_stats task started
torture_init_begin: Refusing rcu init: spin_lock running.
torture_init_begin: One torture test at a time!
workingset: timestamp_bits=30 max_order=15 bucket_order=0
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[ cut here ]
DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)
WARNING: CPU: 0 PID: 379 at kernel/locking/lockdep.c:3765
check_flags+0x230/0x248
Modules linked in:
CPU: 0 PID: 379 Comm: modprobe Not tainted 4.20.0-rc6-next-20181213-dirty #1
NIP:  c007c7a4 LR: c007c7a4 CTR: 
REGS: c7b95de0 TRAP: 0700   Not tainted  (4.20.0-rc6-next-20181213-dirty)
MSR:  00021000   CR: 22000c22  XER: 2000

GPR00: c007c7a4 c7b95e90 c7b9a580 002f  0001 c0fed2d6 c0fed2d7
GPR08:  21637572 c0f741df 0004 22000c22 100d803e  
GPR16:        
GPR24: c7b94000    c0860f98  00029000 10003d38
NIP [c007c7a4] check_flags+0x230/0x248
LR [c007c7a4] check_flags+0x230/0x248
Call Trace:
[c7b95e90] [c007c7a4] check_flags+0x230/0x248 (unreliable)
[c7b95ea0] [c007f430] lock_is_held_type+0x4c/0x114
[c7b95ed0] [c066801c] __schedule+0x84/0x934
[c7b95f30] [c066893c] schedule+0x70/0x9c
[c7b95f40] [c000f928] recheck+0x0/0x24
--- interrupt: 901 at 0xb7bdbe18
LR = 0xb7b6da7c
Instruction dump:
3c80c08d 2c03 8084e69c 2c84 4e823342 41940020 3c60c076 3c80c076
4cc63182 3863c724 38840cf8 4bfbdd1d <0fe0> 3c60c076 38630d13 4cc63182
irq event stamp: 428
hardirqs last  enabled at (426): [] _raw_spin_unlock_irq+0x30/0x58
hardirqs last disabled at (427): [] __do_softirq+0x394/0x52c
softirqs last  enabled at (428): [] irq_exit+0xdc/0x100
softirqs last disabled at (419): [] irq_exit+0xdc/0x100
---[ end trace 3f1ce6c3406f3dee ]---
possible reason: unannotated irqs-on.
irq event stamp: 428
hardirqs last  enabled at (426): [] _raw_spin_unlock_irq+0x30/0x58
hardirqs last disabled at (427): [] __do_softirq+0x394/0x52c
softirqs last  enabled at (428): [] irq_exit+0xdc/0x100
softirqs last disabled at (419): [] irq_exit+0xdc/0x100
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
io scheduler mq-deadline registered
io scheduler kyber registered

I am running ppc44x_defconfig under qemu with the bamboo machine:

qemu-system-ppc -m 128m -machine bamboo -dtb
arch/powerpc/boot/dts/bamboo.dtb -append console=ttyS0 -initrd
images/ppc32/rootfs.cpio -nographic -kernel
linux-next/arch/powerpc/boot/zImage


[PATCH v3 3/3] powerpc: Discard .branch_lt section

2018-12-10 Thread Joel Stanley
When building a 32 bit powerpc kernel with Binutils 2.31.1 this warning
is emitted:

 powerpc-linux-gnu-ld: warning: orphan section `.branch_lt' from
 `arch/powerpc/kernel/head_44x.o' being placed in section `.branch_lt'

As of binutils commit 2d7ad24e8726 ("Support PLT16 relocs against local
symbols")[1], 32 bit targets can produce .branch_lt sections in their
output.

These sections should be empty for the kernel build so discard them for
both PPC64 and PPC32.

[1] 
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d7ad24e8726ba4c45c9e67be08223a146a837ce
Signed-off-by: Joel Stanley 
---
v2: Discard instead of keep. Alan said "[discarding] can be a recipe for
finding linker bugs", so lets go with that.
---
 arch/powerpc/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 2c93a420f456..af0f81df8bb9 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -316,7 +316,6 @@ SECTIONS
DATA_DATA
*(.data.rel*)
*(.toc1)
-   *(.branch_lt)
}
 
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
@@ -388,6 +387,7 @@ SECTIONS
*(.hash .gnu.hash)
*(.interp)
*(.dynstr)
+   *(.branch_lt)
 #ifndef CONFIG_PPC32
*(.dynsym)
 #endif
-- 
2.19.1



[PATCH v3 2/3] powerpc: Discard dynsym section for !PPC32

2018-12-10 Thread Joel Stanley
Alan Modra  explains:

 > Likely you could discard .interp > and .dynstr too, and .dynsym when
 > !CONFIG_PPC32.

Discarding of interp and dynstr happened in a previous patch. The dynsym
cleanup was a bit less straightforward, so it gets it's own patch.

Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7

v3: Move dynstr hunk to patch 1 (it was incorrectly left in this patch)
---
 arch/powerpc/kernel/vmlinux.lds.S | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 779b8b3075a1..2c93a420f456 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -266,13 +266,13 @@ SECTIONS
}
 #ifdef CONFIG_RELOCATABLE
. = ALIGN(8);
+#ifdef CONFIG_PPC32
.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
{
-#ifdef CONFIG_PPC32
__dynamic_symtab = .;
-#endif
*(.dynsym)
}
+#endif
.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
{
__dynamic_start = .;
@@ -388,5 +388,8 @@ SECTIONS
*(.hash .gnu.hash)
*(.interp)
*(.dynstr)
+#ifndef CONFIG_PPC32
+   *(.dynsym)
+#endif
}
 }
-- 
2.19.1



[PATCH v3 1/3] powerpc: Discard more sections in linker script

2018-12-10 Thread Joel Stanley
Building the ppc64 kernel with a modern binutils results in this
warning:

 powerpc64le-linux-gnu-ld: warning: orphan section `.gnu.hash' from
 `linker stubs' being placed in section `.gnu.hash'

Alan Modra  explains:

 > .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
 > lookup.  I imagine you don't need either section in a kernel, so
 > discarding both sounds reasonable.  Likely you could discard .interp
 > and .dynstr too, and .dynsym when !CONFIG_PPC32.

Reported-by: Stephen Rothwell 
Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7

v3: Add dynstr hunk to this patch (it was incorrectly left in patch 2)
---
 arch/powerpc/kernel/vmlinux.lds.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 434581bcd5b4..779b8b3075a1 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -273,14 +273,11 @@ SECTIONS
 #endif
*(.dynsym)
}
-   .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
{
__dynamic_start = .;
*(.dynamic)
}
-   .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
-   .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
{
__rela_dyn_start = .;
@@ -388,5 +385,8 @@ SECTIONS
*(.gnu.version*)
*(.gnu.attributes)
*(.eh_frame)
+   *(.hash .gnu.hash)
+   *(.interp)
+   *(.dynstr)
}
 }
-- 
2.19.1



[PATCH v3 0/3] powerpc: Add to linker script discards

2018-12-10 Thread Joel Stanley
v3 fixes up the splitting of the patches, moving the dynstr hunk from
patch 2 to patch 1.

v2 pulls in the branch_lt patch too. No changes to the first two
patches.

Joel Stanley (3):
  powerpc: Discard more sections in linker script
  powerpc: Discard dynsym section for !PPC32
  powerpc: Discard .branch_lt section

 arch/powerpc/kernel/vmlinux.lds.S | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

-- 
2.19.1



Re: [PATCH v2 2/3] powerpc: Discard dynsym section for !PPC32

2018-12-10 Thread Joel Stanley
On Wed, 5 Dec 2018 at 04:11, Segher Boessenkool
 wrote:
>
> On Tue, Dec 04, 2018 at 11:24:28AM +1030, Joel Stanley wrote:
> > Alan Modra  explains:
> >
> >  > Likely you could discard .interp > and .dynstr too, and .dynsym when
> >  > !CONFIG_PPC32.
> >
> > Discarding of interp and dynstr happened in a previous patch. The dynsym
> > cleanup was a bit less straightforward, so it gets it's own patch.
>
> > diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
> > b/arch/powerpc/kernel/vmlinux.lds.S
> > index 6570209b0671..2c93a420f456 100644
> > --- a/arch/powerpc/kernel/vmlinux.lds.S
> > +++ b/arch/powerpc/kernel/vmlinux.lds.S
> > @@ -266,14 +266,13 @@ SECTIONS
> >   }
> >  #ifdef CONFIG_RELOCATABLE
> >   . = ALIGN(8);
> > +#ifdef CONFIG_PPC32
> >   .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
> >   {
> > -#ifdef CONFIG_PPC32
> >   __dynamic_symtab = .;
> > -#endif
> >   *(.dynsym)
> >   }
> > - .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
>
> So this last line belongs in the previous patch then, right?

Correct. Good catch.


[PATCH v2 3/3] powerpc: Discard .branch_lt section

2018-12-03 Thread Joel Stanley
When building a 32 bit powerpc kernel with Binutils 2.31.1 this warning
is emitted:

 powerpc-linux-gnu-ld: warning: orphan section `.branch_lt' from
 `arch/powerpc/kernel/head_44x.o' being placed in section `.branch_lt'

As of binutils commit 2d7ad24e8726 ("Support PLT16 relocs against local
symbols")[1], 32 bit targets can produce .branch_lt sections in their
output.

These sections should be empty for the kernel build so discard them for
both PPC64 and PPC32.

[1] 
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d7ad24e8726ba4c45c9e67be08223a146a837ce
Signed-off-by: Joel Stanley 
---
v2: Discard instead of keep. Alan said "[discarding] can be a recipe for
finding linker bugs", so lets go with that.
---
 arch/powerpc/kernel/vmlinux.lds.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 2c93a420f456..af0f81df8bb9 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -316,7 +316,6 @@ SECTIONS
DATA_DATA
*(.data.rel*)
*(.toc1)
-   *(.branch_lt)
}
 
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
@@ -388,6 +387,7 @@ SECTIONS
*(.hash .gnu.hash)
*(.interp)
*(.dynstr)
+   *(.branch_lt)
 #ifndef CONFIG_PPC32
*(.dynsym)
 #endif
-- 
2.19.1



[PATCH v2 2/3] powerpc: Discard dynsym section for !PPC32

2018-12-03 Thread Joel Stanley
Alan Modra  explains:

 > Likely you could discard .interp > and .dynstr too, and .dynsym when
 > !CONFIG_PPC32.

Discarding of interp and dynstr happened in a previous patch. The dynsym
cleanup was a bit less straightforward, so it gets it's own patch.

Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7
---
 arch/powerpc/kernel/vmlinux.lds.S | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 6570209b0671..2c93a420f456 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -266,14 +266,13 @@ SECTIONS
}
 #ifdef CONFIG_RELOCATABLE
. = ALIGN(8);
+#ifdef CONFIG_PPC32
.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
{
-#ifdef CONFIG_PPC32
__dynamic_symtab = .;
-#endif
*(.dynsym)
}
-   .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
+#endif
.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
{
__dynamic_start = .;
@@ -389,5 +388,8 @@ SECTIONS
*(.hash .gnu.hash)
*(.interp)
*(.dynstr)
+#ifndef CONFIG_PPC32
+   *(.dynsym)
+#endif
}
 }
-- 
2.19.1



[PATCH v2 1/3] powerpc: Discard more sections in linker script

2018-12-03 Thread Joel Stanley
Building the ppc64 kernel with a modern binutils results in this
warning:

 powerpc64le-linux-gnu-ld: warning: orphan section `.gnu.hash' from
 `linker stubs' being placed in section `.gnu.hash'

Alan Modra  explains:

 > .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
 > lookup.  I imagine you don't need either section in a kernel, so
 > discarding both sounds reasonable.  Likely you could discard .interp
 > and .dynstr too, and .dynsym when !CONFIG_PPC32.

Reported-by: Stephen Rothwell 
Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7
---
 arch/powerpc/kernel/vmlinux.lds.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 434581bcd5b4..6570209b0671 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -279,8 +279,6 @@ SECTIONS
__dynamic_start = .;
*(.dynamic)
}
-   .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
-   .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
{
__rela_dyn_start = .;
@@ -388,5 +386,8 @@ SECTIONS
*(.gnu.version*)
*(.gnu.attributes)
*(.eh_frame)
+   *(.hash .gnu.hash)
+   *(.interp)
+   *(.dynstr)
}
 }
-- 
2.19.1



[PATCH v2 0/3] powerpc: Add to linker script discards

2018-12-03 Thread Joel Stanley
v2 pulls in the branch_lt patch too. No changes to the first two
patches.

Joel Stanley (3):
  powerpc: Discard more sections in linker script
  powerpc: Discard dynsym section for !PPC32
  powerpc: Discard .branch_lt section

 arch/powerpc/kernel/vmlinux.lds.S | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

-- 
2.19.1



[PATCH 2/2] powerpc: Discard dynsym section for !PPC32

2018-12-03 Thread Joel Stanley
Alan Modra  explains:

 > Likely you could discard .interp > and .dynstr too, and .dynsym when
 > !CONFIG_PPC32.

Discarding of interp and dynstr happened in a previous patch. The dynsym
cleanup was a bit less straightforward, so it gets it's own patch.

Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7

 arch/powerpc/kernel/vmlinux.lds.S | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index e14cde32b003..49dd678a2de4 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -266,14 +266,13 @@ SECTIONS
}
 #ifdef CONFIG_RELOCATABLE
. = ALIGN(8);
+#ifdef CONFIG_PPC32
.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
{
-#ifdef CONFIG_PPC32
__dynamic_symtab = .;
-#endif
*(.dynsym)
}
-   .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
+#endif
.dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
{
__dynamic_start = .;
@@ -390,5 +389,8 @@ SECTIONS
*(.hash .gnu.hash)
*(.interp)
*(.dynstr)
+#ifndef CONFIG_PPC32
+   *(.dynsym)
+#endif
}
 }
-- 
2.19.1



[PATCH 1/2] powerpc: Discard more sections in linker script

2018-12-03 Thread Joel Stanley
Building the ppc64 kernel with a modern binutils results in this
warning:

 powerpc64le-linux-gnu-ld: warning: orphan section `.gnu.hash' from
 `linker stubs' being placed in section `.gnu.hash'

Alan Modra  explains:

 > .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
 > lookup.  I imagine you don't need either section in a kernel, so
 > discarding both sounds reasonable.  Likely you could discard .interp
 > and .dynstr too, and .dynsym when !CONFIG_PPC32.

Reported-by: Stephen Rothwell 
Signed-off-by: Joel Stanley 
---
See 
https://lore.kernel.org/lkml/CACPK8Xft3n5KkpTjN3=7_vucxhfck7mxvzm2rrqu7tppcbo...@mail.gmail.com/T/#m58532c86cf0c7b4fb01cc1fe724e48d4c7d8e4a7

 arch/powerpc/kernel/vmlinux.lds.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 5c5d559a23fd..e14cde32b003 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -279,8 +279,6 @@ SECTIONS
__dynamic_start = .;
*(.dynamic)
}
-   .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
-   .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
.rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
{
__rela_dyn_start = .;
@@ -389,5 +387,8 @@ SECTIONS
*(.gnu.version*)
*(.gnu.attributes)
*(.eh_frame)
+   *(.hash .gnu.hash)
+   *(.interp)
+   *(.dynstr)
}
 }
-- 
2.19.1



[PATCH 0/2] powerpc: Add to linker script discards

2018-12-03 Thread Joel Stanley
Joel Stanley (2):
  powerpc: Discard more sections in linker script
  powerpc: Discard dynsym section for !PPC32

 arch/powerpc/kernel/vmlinux.lds.S | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

-- 
2.19.1



Re: linux-next: build warnings from Linus' tree

2018-12-03 Thread Joel Stanley
On Sun, 18 Nov 2018 at 21:52, Alan Modra  wrote:
>
> On Wed, Nov 14, 2018 at 09:20:23PM +1100, Michael Ellerman wrote:
> > Joel Stanley  writes:
> > > Hello Alan,
> > >
> > > On Tue, 12 Jun 2018 at 07:44, Stephen Rothwell  
> > > wrote:
> > >
> > >> Building Linus' tree, today's linux-next build (powerpc ppc64_defconfig)
> > >> produced these warning:
> > >>
> > >> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed 
> > >> in section `.gnu.hash'.
> > >> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed 
> > >> in section `.gnu.hash'.
> > >> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed 
> > >> in section `.gnu.hash'.
> > >>
> > >> This may just be because I have started building using the native Debian
> > >> gcc for the powerpc builds ...
> > >
> > > Do you know why we started creating these?
> >
> > It's controlled by the ld option --hash-style, which AFAICS still
> > defaults to sysv (generating .hash).
> >
> > But it seems gcc can be configured to have a different default, and at
> > least my native ppc64le toolchains are passing gnu, eg:
> >
> >  /usr/lib/gcc/powerpc64le-linux-gnu/6/collect2 -plugin
> >  /usr/lib/gcc/powerpc64le-linux-gnu/6/liblto_plugin.so
> >  -plugin-opt=/usr/lib/gcc/powerpc64le-linux-gnu/6/lto-wrapper
> >  -plugin-opt=-fresolution=/tmp/ccw1U2fF.res
> >  -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s
> >  -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc
> >  -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr
> >  -V -shared -m elf64lppc
> >  --hash-style=gnu
> >  
> >
> > So that's presumably why we're seeing it, some GCCs are configured to
> > use it.
> >
> > > If it's intentional, should we be putting including them in the same
> > > way as .hash sections?
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/vmlinux.lds.S#n282
> > >
> > >   .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
> >
> > That would presumably work.
> >
> > My question though is do we even need it?
> >
> > >From what I can see for it to be useful you need the section as well as
> > an entry in the dynamic section pointing at it, and we don't have a
> > dynamic section at all:
> >
> >   $ readelf -S vmlinux | grep gnu.hash
> > [ 4] .gnu.hash GNU_HASH c0dbbdb0  00dcbdb0
> >   $ readelf -d vmlinux
> >
> >   There is no dynamic section in this file.
> >
> > Compare to the vdso:
> >
> > $ readelf -d arch/powerpc/kernel/vdso64/vdso64.so
> >
> > Dynamic section at offset 0x868 contains 12 entries:
> >   TagType Name/Value
> >  0x000e (SONAME) Library soname: [linux-vdso64.so.1]
> >  0x0004 (HASH)   0x120
> >  0x6ef5 (GNU_HASH)   0x170
> >  0x0005 (STRTAB) 0x320
> >  0x0006 (SYMTAB) 0x1d0
> >  0x000a (STRSZ)  269 (bytes)
> >  0x000b (SYMENT) 24 (bytes)
> >  0x7003 (PPC64_OPT)  0x0
> >  0x6ffc (VERDEF) 0x450
> >  0x6ffd (VERDEFNUM)  2
> >  0x6ff0 (VERSYM) 0x42e
> >  0x (NULL)   0x0
> >
> >
> > So can't we just discard .gnu.hash? And in fact do we need .hash either?
> >
> > Actually arm64 discards the latter, and parisc discards both.
> >
> > Would still be good to hear from Alan or someone else who knows anything
> > about toolchain stuff, ie. not me :)
>
> .gnu.hash, like .hash, is used by glibc ld.so for dynamic symbol
> lookup.  I imagine you don't need either section in a kernel, so
> discarding both sounds reasonable.  Likely you could discard .interp
> and .dynstr too, and .dynsym when !CONFIG_PPC32.

Thanks for the digging Michael, and thanks Alan for clarifying the
details. I'll cook up a patch or two.

Cheers,

Joel


[PATCH v3] powerpc/math-emu: Update macros from GCC

2018-12-03 Thread Joel Stanley
The add_ss, sub_ddmmss, umul_ppmm and udiv_qrnnd macros originate
from GCC's longlong.h which in turn was copied from GMP's longlong.h a
few decades ago.

This was found when compiling with clang:

   arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
   inline asm context requiring an l-value: remove the cast or build with
   -fheinous-gnu-extensions
   FP_ADD_D(R, T, B);
   ^
   ...

   ./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
   macro 'sub_ddmmss'
  : "=r" ((USItype)(sh)),  \
  ~~^~~

Segher points out: this was fixed in GCC over 16 years ago
( https://gcc.gnu.org/r56600 ), and in GMP (where it comes from)
presumably before that.

Update the add_ss, sub_ddmmss, umul_ppmm and udiv_qrnnd macros to
the latest GCC version in order to git rid of the invalid casts. These
were taken as-is from GCC's longlong in order to make future syncs
obvious. Other parts of sfp-machine.h were left as-is as the file
contains more features than present in longlong.h.

Link: https://github.com/ClangBuiltLinux/linux/issues/260
Signed-off-by: Joel Stanley 
---
v1:
 https://lore.kernel.org/linuxppc-dev/20181102033713.31916-1-j...@jms.id.au/
v2:
 Instead of setting the -fheinous-gnu-extensions for clang, fix the code.
v3:
 Sync with GCC version instead of GMP version
---
 arch/powerpc/include/asm/sfp-machine.h | 92 --
 1 file changed, 29 insertions(+), 63 deletions(-)

diff --git a/arch/powerpc/include/asm/sfp-machine.h 
b/arch/powerpc/include/asm/sfp-machine.h
index d89beaba26ff..8b957aabb826 100644
--- a/arch/powerpc/include/asm/sfp-machine.h
+++ b/arch/powerpc/include/asm/sfp-machine.h
@@ -213,30 +213,18 @@
  * respectively.  The result is placed in HIGH_SUM and LOW_SUM.  Overflow
  * (i.e. carry out) is not stored anywhere, and is lost.
  */
-#define add_ss(sh, sl, ah, al, bh, bl) \
+#define add_ss(sh, sl, ah, al, bh, bl) \
   do { \
 if (__builtin_constant_p (bh) && (bh) == 0)
\
-  __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2"  \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
-else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
-  __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2"  \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
+  __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
+else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)
\
+  __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
 else   \
-  __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "r" ((USItype)(bh)), \
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
+  __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \
+: "=r" (sh), "=" (sl)\
+: "%r" (ah), "r" (bh), "%r" (al), "rI" (bl));  \
   } while (0)
 
 /* sub_ddmmss is used in op-2.h and udivmodti4.c and should be equivalent to
@@ -248,44 +236,24 @@
  * and LOW_DIFFERENCE.  Overflow (i.e. carry out) is not stored anyw

Re: [PATCH v2] raid6/ppc: Fix build for clang

2018-12-03 Thread Joel Stanley
On Tue, 4 Dec 2018 at 05:15, Nick Desaulniers  wrote:
> > > > +ifdef CONFIG_CC_IS_CLANG
> > > > +# clang ppc port does not yet support -maltivec when -msoft-float is
> > > > +# enabled. A future release of clang will resolve this
> > > > +# https://bugs.llvm.org/show_bug.cgi?id=31177
> > > > +CFLAGS_REMOVE_altivec1.o  += -msoft-float
> > > > +CFLAGS_REMOVE_altivec2.o  += -msoft-float
> > > > +CFLAGS_REMOVE_altivec4.o  += -msoft-float
> > > > +CFLAGS_REMOVE_altivec8.o  += -msoft-float
> > > > +CFLAGS_REMOVE_altivec8.o  += -msoft-float
> > > > +CFLAGS_REMOVE_vpermxor1.o += -msoft-float
> > > > +CFLAGS_REMOVE_vpermxor2.o += -msoft-float
> > > > +CFLAGS_REMOVE_vpermxor4.o += -msoft-float
> > > > +CFLAGS_REMOVE_vpermxor8.o += -msoft-float
> > > > +endif
> > >
> > > Hi Joel, thanks for this patch!  My same thoughts about
> > > CONFIG_CC_IS_CLANG vs cc-option from
> > > https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-November/180939.html
> > > apply here as well.  I don't feel strongly about either though.  What
> > > are your thoughts?
> >
> > I'm not sure that we can test for this one with cc-option. The result
> > of having -maltivec with -msoft-float is a error about the internals
> > of clang, which isn't something that kbuild is set up to test for.
>
> As in clang itself crashes, and cc-option/kbuild can't handle that gracefully?

The developer gets something like this:

SplitVectorResult #0: t196: v16i8 = llvm.ppc.altivec.vcmpgtsb
TargetConstant:i64<4823>, t146, t195
fatal error: error in backend: Do not know how to split the result of
this operator!
clang-8: error: clang frontend command failed with exit code 70 (use
-v to see invocation)

>
> >
> > When clang is fixed to allow this combination we will still build this
> > code in the same way, so in that sense it fails "open".
> >


Re: [PATCH v2] raid6/ppc: Fix build for clang

2018-12-03 Thread Joel Stanley
On Sat, 3 Nov 2018 at 04:04, Nick Desaulniers  wrote:
>
> On Thu, Nov 1, 2018 at 5:45 PM Joel Stanley  wrote:
> >
> > We cannot build these files with clang as it does not allow altivec
> > instructions in assembly when -msoft-float is passed.
> >
> > Jinsong Ji  wrote:
> > > We currently disable Altivec/VSX support when enabling soft-float.  So
> > > any usage of vector builtins will break.
> > >
> > > Enable Altivec/VSX with soft-float may need quite some clean up work, so
> > > I guess this is currently a limitation.
> > >
> > > Removing -msoft-float will make it work (and we are lucky that no
> > > floating point instructions will be generated as well).
> >
> > This is a workaround until the issue is resolved in clang.
> >
> > Link: https://bugs.llvm.org/show_bug.cgi?id=31177
> > Link: https://github.com/ClangBuiltLinux/linux/issues/239
> > Signed-off-by: Joel Stanley 
> > ---
> > v2: fix typo in comment, thanks Jinsong
> >
> >  lib/raid6/Makefile | 15 +++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
> > index 2f8b61dfd9b0..7ed43eaa02ef 100644
> > --- a/lib/raid6/Makefile
> > +++ b/lib/raid6/Makefile
> > @@ -18,6 +18,21 @@ quiet_cmd_unroll = UNROLL  $@
> >
> >  ifeq ($(CONFIG_ALTIVEC),y)
> >  altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
> > +
> > +ifdef CONFIG_CC_IS_CLANG
> > +# clang ppc port does not yet support -maltivec when -msoft-float is
> > +# enabled. A future release of clang will resolve this
> > +# https://bugs.llvm.org/show_bug.cgi?id=31177
> > +CFLAGS_REMOVE_altivec1.o  += -msoft-float
> > +CFLAGS_REMOVE_altivec2.o  += -msoft-float
> > +CFLAGS_REMOVE_altivec4.o  += -msoft-float
> > +CFLAGS_REMOVE_altivec8.o  += -msoft-float
> > +CFLAGS_REMOVE_altivec8.o  += -msoft-float
> > +CFLAGS_REMOVE_vpermxor1.o += -msoft-float
> > +CFLAGS_REMOVE_vpermxor2.o += -msoft-float
> > +CFLAGS_REMOVE_vpermxor4.o += -msoft-float
> > +CFLAGS_REMOVE_vpermxor8.o += -msoft-float
> > +endif
>
> Hi Joel, thanks for this patch!  My same thoughts about
> CONFIG_CC_IS_CLANG vs cc-option from
> https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-November/180939.html
> apply here as well.  I don't feel strongly about either though.  What
> are your thoughts?

I'm not sure that we can test for this one with cc-option. The result
of having -maltivec with -msoft-float is a error about the internals
of clang, which isn't something that kbuild is set up to test for.

When clang is fixed to allow this combination we will still build this
code in the same way, so in that sense it fails "open".

Cheers,

Joel


Re: [PATCH v2] powerpc/math-emu: Update macros from gmp-6.1.2

2018-11-19 Thread Joel Stanley
On Tue, 20 Nov 2018 at 05:24, Nick Desaulniers  wrote:
> >
> > The only functional change I noticed was this in udiv_qrnnd.
> >
> > __r1 = (n1) % __d1;
> > __q1 = (n1) / __d1;
> >
> > Becomes this:
> >
> > __q1 = (n1) / __d1;
> > __r1 = (n1) - __q1 * __d1;
> >
> > This is equivalent as it instead of calculating the remainder
> > using modulo, it uses the result of integer division to subtract the
> > count of 'whole' d1 from r1.
>
> I don't understand this; why was this functional change made?

I couldn't see why. It pre-dates GMP's mecurial history that  .
  \
> > -(q) = (UWtype) __q1 * __ll_B | __q0;   \
> > +(q) = __q1 * __ll_B | __q0;
> > \
> >  (r) = __r0;
> > \
> >} while (0)
>
> This appears to now differ from the upstream source:
> https://github.com/gcc-mirror/gcc/blob/f7289f563a5e447ac21a5901ed75aad0dbd37732/include/longlong.h#L1679

AIUI the upstream source is GMP:

 https://gmplib.org/repo/gmp/file/tip/longlong.h

> If we're going to borrow implementations from GCC, let's borrow the
> same implementation. Otherwise it's hard to have confidence in this
> part of the patch.

I agree we should use the upstream source.

Segher, which tree contains the One True Upstream for longlong.h?

Cheers,

Joel


Re: [PATCH] powerpc/powernv: Remove PCI_MSI ifdef checks

2018-11-13 Thread Joel Stanley
On Wed, 14 Nov 2018 at 16:50, Oliver O'Halloran  wrote:
>
> CONFIG_PCI_MSI was made mandatory by commit a311e738b6d8
> ("powerpc/powernv: Make PCI non-optional") so the #ifdef
> checks around CONFIG_PCI_MSI here can be removed entirely.
>
> Signed-off-by: Oliver O'Halloran 

Reviewed-by: Joel Stanley 

Can we do the same to the CONFIG_PCI_MSI in
arch/powerpc/sysdev/xics/ics-opal.c ?

Cheers,

Joel


Re: linux-next: build warnings from Linus' tree

2018-11-13 Thread Joel Stanley
Hello Alan,

On Tue, 12 Jun 2018 at 07:44, Stephen Rothwell  wrote:

> Building Linus' tree, today's linux-next build (powerpc ppc64_defconfig)
> produced these warning:
>
> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in 
> section `.gnu.hash'.
> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in 
> section `.gnu.hash'.
> ld: warning: orphan section `.gnu.hash' from `linker stubs' being placed in 
> section `.gnu.hash'.
>
> This may just be because I have started building using the native Debian
> gcc for the powerpc builds ...

Do you know why we started creating these?

If it's intentional, should we be putting including them in the same
way as .hash sections?

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/vmlinux.lds.S#n282

  .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }

Cheers,

Joel


[PATCH] powerpc/32: Include .branch_lt in data section

2018-11-13 Thread Joel Stanley
When building a 32 bit powerpc kernel with Binutils 2.31.1 this warning
is emitted:

 powerpc-linux-gnu-ld: warning: orphan section `.branch_lt' from
 `arch/powerpc/kernel/head_44x.o' being placed in section `.branch_lt'

As of binutils commit 2d7ad24e8726 ("Support PLT16 relocs against local
symbols")[1], 32 bit targets can produce .branch_lt sections in their
output.

Include these symbols in the .data section as the ppc64 kernel does.

[1] 
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d7ad24e8726ba4c45c9e67be08223a146a837ce
Signed-off-by: Joel Stanley 
---
I wasn't sure where this should go or if the ordering matters.
---
 arch/powerpc/kernel/vmlinux.lds.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S 
b/arch/powerpc/kernel/vmlinux.lds.S
index 434581bcd5b4..6d5fd1b95311 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -313,6 +313,7 @@ SECTIONS
*(.sdata2)
*(.got.plt) *(.got)
*(.plt)
+   *(.branch_lt)
}
 #else
.data : AT(ADDR(.data) - LOAD_OFFSET) {
-- 
2.19.1



[PATCH v2] powerpc/math-emu: Update macros from gmp-6.1.2

2018-11-13 Thread Joel Stanley
The add_ss, sub_ddmmss, umul_ppmm and udiv_qrnnd macros originate
from GMP's longlong.h.
This was found when compiling with clang:

   arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
   inline asm context requiring an l-value: remove the cast or build with
   -fheinous-gnu-extensions
   FP_ADD_D(R, T, B);
   ^
   ...

   ./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
   macro 'sub_ddmmss'
  : "=r" ((USItype)(sh)),  \
  ~~^~~

Segher points out: this was fixed in GCC over 16 years ago
( https://gcc.gnu.org/r56600 ), and in GMP (where it comes from)
presumably before that.

Update to the latest version in order to git rid of the invalid casts.

The only functional change I noticed was this in udiv_qrnnd.

__r1 = (n1) % __d1;
__q1 = (n1) / __d1;

Becomes this:

__q1 = (n1) / __d1;
__r1 = (n1) - __q1 * __d1;

This is equivalent as it instead of calculating the remainder
using modulo, it uses the result of integer division to subtract the
count of 'whole' d1 from r1.

Link: https://github.com/ClangBuiltLinux/linux/issues/260
Signed-off-by: Joel Stanley 
---
v1:
 https://lore.kernel.org/linuxppc-dev/20181102033713.31916-1-j...@jms.id.au/
v2:
 Instead of setting the -fheinous-gnu-extensions for clang, fix the code.

 arch/powerpc/include/asm/sfp-machine.h | 99 +-
 1 file changed, 32 insertions(+), 67 deletions(-)

diff --git a/arch/powerpc/include/asm/sfp-machine.h 
b/arch/powerpc/include/asm/sfp-machine.h
index d89beaba26ff..a6353d9dd5ba 100644
--- a/arch/powerpc/include/asm/sfp-machine.h
+++ b/arch/powerpc/include/asm/sfp-machine.h
@@ -213,30 +213,18 @@
  * respectively.  The result is placed in HIGH_SUM and LOW_SUM.  Overflow
  * (i.e. carry out) is not stored anywhere, and is lost.
  */
-#define add_ss(sh, sl, ah, al, bh, bl) \
+#define add_ss(sh, sl, ah, al, bh, bl) \
   do { \
 if (__builtin_constant_p (bh) && (bh) == 0)
\
-  __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2"  \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
-else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
-  __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2"  \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
+  __asm__ ("add%I4c %1,%3,%4\n\taddze %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl)); \
+else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)
\
+  __asm__ ("add%I4c %1,%3,%4\n\taddme %0,%2"   \
+: "=r" (sh), "=" (sl) : "r" (ah), "%r" (al), "rI" (bl)); \
 else   \
-  __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
-: "=r" ((USItype)(sh)),\
-  "=" ((USItype)(sl))\
-: "%r" ((USItype)(ah)),\
-  "r" ((USItype)(bh)), \
-  "%r" ((USItype)(al)),\
-  "rI" ((USItype)(bl)));   \
+  __asm__ ("add%I5c %1,%4,%5\n\tadde %0,%2,%3" \
+: "=r" (sh), "=" (sl)\
+: "r" (ah), "r" (bh), "%r" (al), "rI" (bl));   \
   } while (0)
 
 /* sub_ddmmss is used in op-2.h and udivmodti4.c and should be equivalent to
@@ -248,44 +236,24 @@
  * and LOW_DIFFERENCE.  Overflow (i.e. carry out) is not stored anyw

Re: [PATCH] powerpc/math-emu: Fix building with clang

2018-11-12 Thread Joel Stanley
On Sat, 3 Nov 2018 at 03:24, Nick Desaulniers  wrote:
>
> On Thu, Nov 1, 2018 at 8:37 PM Joel Stanley  wrote:
> >
> >   make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  
> > ppc44x_defconfig
> >   make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
> >
> >   ...
> >
> >   arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
> >   inline asm context requiring an l-value: remove the cast or build with
> >   -fheinous-gnu-extensions
> >   FP_ADD_D(R, T, B);
> >   ^
> >   ./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
> >   #define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
> >   ^~
> >   ./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
> >   #define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
> >^~
> >   ./include/math-emu/op-common.h:264:4: note: expanded from macro 
> > '_FP_ADD_INTERNAL'
> > _FP_FRAC_ADD_##wc(R, X, Y); 
> >\
> > ^~
> >   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 
> > to see all)
>
> ^^^ Hi Joel, would you mind recompiling with
> `-fmacro-backtrace-limit=0` hacked in and including the full
> backtrace?  I'm curious if there's a more appropriate fix, but can't
> tell where the inline asm is that clang is complaining about.

Sure. Here's the full backtrace:

arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
inline asm context requiring an l-value: remove
  the cast or build with -fheinous-gnu-extensions
FP_ADD_D(R, T, B);
^
./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
#define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
^~
./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
#define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
 ^~
./include/math-emu/op-common.h:274:4: note: expanded from macro
'_FP_ADD_INTERNAL'
  _FP_FRAC_SUB_##wc(R, X, Y);\
  ^~
:268:1: note: expanded from here
_FP_FRAC_SUB_2
^
./include/math-emu/op-2.h:97:19: note: expanded from macro '_FP_FRAC_SUB_2'
  __FP_FRAC_SUB_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
  ^~~
:269:1: note: expanded from here
R_f1
^
./arch/powerpc/include/asm/sfp-machine.h:283:27: note: expanded from
macro 'sub_ddmmss'
   : "=r" ((USItype)(sh)),  \
   ~~^~~


[PATCH v2] powerpc/32: Avoid unsupported flags with clang

2018-11-11 Thread Joel Stanley
When building for ppc32 with clang these flags are unsupported:

  -ffixed-r2 and -mmultiple

llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
when building for SVR4ABI and !ppc64:

  // The SVR4 ABI reserves r2 and r13
  if (Subtarget.isSVR4ABI()) {
// We only reserve r2 if we need to use the TOC pointer. If we have no
// explicit uses of the TOC pointer (meaning we're a leaf function with
// no constant-pool loads, etc.) and we have no potential uses inside an
// inline asm block, then we can treat r2 has an ordinary callee-saved
// register.
const PPCFunctionInfo *FuncInfo = MF.getInfo();
if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
  markSuperRegs(Reserved, PPC::R2);  // System-reserved register
markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
  }

This means we can safely omit -ffixed-r2 when building for 32-bit
targets.

The -mmultiple/-mno-multiple flags are not supported by clang, so
platforms that might support multiple miss out on using multiple word
instructions.

We wrap these flags in cc-option so that when Clang gains support the
kernel will be able use these flags.

Clang 8 can then build a ppc44x_defconfig which boots in Qemu:

  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  
ppc44x_defconfig
  ./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  qemu-system-ppc -M bamboo \
   -kernel arch/powerpc/boot/zImage \
   -dtb arch/powerpc/boot/dts/bamboo.dtb \
   -initrd ~/ppc32-440-rootfs.cpio \
   -nographic -serial stdio -monitor pty -append "console=ttyS0"

Link: https://github.com/ClangBuiltLinux/linux/issues/261
Link: https://bugs.llvm.org/show_bug.cgi?id=39556
Link: https://bugs.llvm.org/show_bug.cgi?id=39555
Signed-off-by: Joel Stanley 
---
 arch/powerpc/Makefile | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 8a2ce14d68d0..4685671dfb4f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -152,7 +152,14 @@ endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
 
-CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
+# Clang unconditionally reserves r2 on ppc32 and does not support the flag
+# https://bugs.llvm.org/show_bug.cgi?id=39555
+CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
+
+# Clang doesn't support -mmultiple / -mno-multiple
+# https://bugs.llvm.org/show_bug.cgi?id=39556
+CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
+
 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
 
 ifdef CONFIG_PPC_BOOK3S_64
-- 
2.19.1



Re: [PATCH v2 2/2] kbuild: consolidate Clang compiler flags

2018-11-11 Thread Joel Stanley
On Mon, 12 Nov 2018 at 13:59, Masahiro Yamada
 wrote:
>
> On Mon, Nov 12, 2018 at 10:05 AM Michael Ellerman  wrote:
> >
> > Masahiro Yamada  writes:
> > > On Sat, Nov 10, 2018 at 3:35 AM Greg Hackmann  
> > > wrote:
> > >>
> > >> On 11/09/2018 10:29 AM, Nick Desaulniers wrote:
> > >> > On Mon, Nov 5, 2018 at 7:05 PM Masahiro Yamada
> > >> >  wrote:
> > >> >>
> > >> >> Collect basic Clang options such as --target, --prefix, 
> > >> >> --gcc-toolchain,
> > >> >> -no-integrated-as into a single variable CLANG_FLAGS so that it can be
> > >> >> easily reused in other parts of Makefile.
> > >> >>
> > >> >> Signed-off-by: Masahiro Yamada 
> > >> >> ---
> > >> >>
> > >> >> Changes in v2:
> > >> >>   - Use := flavor instead of = because $(CLANG_FLAGS) is expanded 
> > >> >> soon anyway
> > >> >>
> > >> >>   Makefile | 13 ++---
> > >> >>   1 file changed, 6 insertions(+), 7 deletions(-)
> > >> >>
> > >> >> diff --git a/Makefile b/Makefile
> > >> >> index da11700..e173a73 100644
> > >> >> --- a/Makefile
> > >> >> +++ b/Makefile
> > >> >> @@ -487,18 +487,17 @@ endif
> > >> >>
> > >> >>   ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
> > >> >>   ifneq ($(CROSS_COMPILE),)
> > >> >> -CLANG_TARGET   := --target=$(notdir $(CROSS_COMPILE:%-=%))
> > >> >> +CLANG_FLAGS:= --target=$(notdir $(CROSS_COMPILE:%-=%))
> > >> >>   GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
> > >> >> -CLANG_PREFIX   := --prefix=$(GCC_TOOLCHAIN_DIR)
> > >> >> +CLANG_FLAGS+= --prefix=$(GCC_TOOLCHAIN_DIR)
> > >> >>   GCC_TOOLCHAIN  := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
> > >> >>   endif
> > >> >>   ifneq ($(GCC_TOOLCHAIN),)
> > >> >> -CLANG_GCC_TC   := --gcc-toolchain=$(GCC_TOOLCHAIN)
> > >> >> +CLANG_FLAGS+= --gcc-toolchain=$(GCC_TOOLCHAIN)
> > >> >>   endif
> > >> >> -KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> > >> >> -KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
> > >> >> -KBUILD_CFLAGS += -no-integrated-as
> > >> >> -KBUILD_AFLAGS += -no-integrated-as
> > >> >> +CLANG_FLAGS+= -no-integrated-as
> > >> >> +KBUILD_CFLAGS  += $(CLANG_FLAGS)
> > >> >> +KBUILD_AFLAGS  += $(CLANG_FLAGS)
> > >> >>   endif
> > >> >>
> > >> >>   RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern 
> > >> >> -mindirect-branch-register
> > >> >> --
> > >> >> 2.7.4
> > >> >>
> > >> >
> > >> > Thanks for this patch, Masahiro, it's a good simplification.
> > >> > Reviewed-by: Nick Desaulniers 
> > >> > Tested-by: Nick Desaulniers 
> > >> >
> > >> > Would you mind waiting for a tested-by from Stefan, and maybe an ack
> > >> > from Greg (added to cc)?
> > >> >
> > >>
> > >> Acked-by: Greg Hackmann 
> > >
> > >
> > > Thanks for your review!
> > >
> > >
> > > So, how to organize this series, and Joel's one together?
> > >
> > > I'd like Joel to use this series as a base for his work.
> > > (https://lore.kernel.org/patchwork/patch/1006696/)
> > >
> > > It will be much cleaner.
> > >
> > >
> > > Shall I merge all the patches to kbuild tree, or
> > > maybe will they go through powerpc tree?
> >
> > Joel's changes are fairly small so you may as well merge them along with
> > the rest of the series, if that's OK with you and Joel.
>
>
> OK, I will.
>
>
> Joel,
> If you send v2, I will merge it to kbuild tree.

Thanks, I've done that now.

Cheers,

Joel


[PATCH v2 2/2] powerpc/boot: Set target when cross-compiling for clang

2018-11-11 Thread Joel Stanley
Clang needs to be told which target it is building for when cross
compiling.

Link: https://github.com/ClangBuiltLinux/linux/issues/259
Signed-off-by: Joel Stanley 
---
 arch/powerpc/boot/Makefile | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 39354365f54a..111f97b1ccec 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -55,6 +55,11 @@ BOOTAFLAGS   := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional 
-nostdinc
 
 BOOTARFLAGS:= -cr$(KBUILD_ARFLAGS)
 
+ifdef CONFIG_CC_IS_CLANG
+BOOTCFLAGS += $(CLANG_FLAGS)
+BOOTAFLAGS += $(CLANG_FLAGS)
+endif
+
 ifdef CONFIG_DEBUG_INFO
 BOOTCFLAGS += -g
 endif
-- 
2.19.1



[PATCH v2 1/2] Makefile: Export clang toolchain variables

2018-11-11 Thread Joel Stanley
The powerpc makefile will use these in it's boot wrapper.

Signed-off-by: Joel Stanley 
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 09278330282d..840efe6eb54c 100644
--- a/Makefile
+++ b/Makefile
@@ -495,6 +495,7 @@ endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_FLAGS+= --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
+export CLANG_FLAGS
 CLANG_FLAGS+= -no-integrated-as
 KBUILD_CFLAGS  += $(CLANG_FLAGS)
 KBUILD_AFLAGS  += $(CLANG_FLAGS)
-- 
2.19.1



[PATCH v2 0/2] powerpc/boot: Fix cross compiling with clang

2018-11-11 Thread Joel Stanley
v2: rebase on "kbuild: consolidate Clang compiler flags"

These patches allow clang to cross-compile the powerpc boot wrapper.
The boot wrapper constructs it's own compiler flags as it may not be
built for the same arch as the kernel.

The powerpc64le kernel builds natively with clang and with this patch it
can cross compile too.

Joel Stanley (2):
  Makefile: Export clang toolchain variables
  powerpc/boot: Set target when cross-compiling for clang

 Makefile   | 1 +
 arch/powerpc/boot/Makefile | 5 +
 2 files changed, 6 insertions(+)

-- 
2.19.1



Re: [PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang

2018-11-05 Thread Joel Stanley
On Tue, 6 Nov 2018 at 09:07, Nick Desaulniers  wrote:
>
> On Sun, Nov 4, 2018 at 3:11 PM Joel Stanley  wrote:
> >
> > Hello,
> >
> > These patches allow clang to cross-compile the powerpc boot wrapper.
> > The boot wrapper constructs it's own compiler flags as it may not be
> > built for the same arch as the kernel.
>
> Hi Joel, thanks for the series!  I'm just curious, how does the boot
> wrapper run on a different arch than the kernel?

The kernel can have a ppc32 boot wrapper for a ppc64 kernel. There's
some rationale in the boot wrapper's Makefile:

 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/boot/Makefile#n10

Cheers,

Joel


Re: [PATCH] powerpc/32: Avoid unsupported flags with clang

2018-11-04 Thread Joel Stanley
On Mon, 5 Nov 2018 at 14:18, Michael Ellerman  wrote:
> > I considered putting these behind a cc-option test. If someone has an
> > opinion on that I'm happy to change.

> > -CFLAGS-$(CONFIG_PPC32)   := -ffixed-r2 $(MULTIPLEWORD)
> > +ifndef CONFIG_CC_IS_CLANG
> > +#CFLAGS-$(CONFIG_PPC32)  := -ffixed-r2 $(MULTIPLEWORD)
> > +endif
>
> I think using cc-option with a comment would be nicer, you could avoid
> the ifdef and it would also future-proof it against the option either
> appearing in a future clang or disappearing in a future gcc.

Thanks Nick and Michael. I agree, I'll re-spin using cc-option.

Cheers,

Joel


[PATCH 2/2] powerpc/boot: Set target when cross-compiling for clang

2018-11-04 Thread Joel Stanley
Clang needs to be told which target it is building for when cross
compiling.

Link: https://github.com/ClangBuiltLinux/linux/issues/259
Signed-off-by: Joel Stanley 
---
 arch/powerpc/boot/Makefile | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 39354365f54a..8fdb1890f09a 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -55,6 +55,13 @@ BOOTAFLAGS   := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional 
-nostdinc
 
 BOOTARFLAGS:= -cr$(KBUILD_ARFLAGS)
 
+ifdef CONFIG_CC_IS_CLANG
+BOOTCFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+BOOTAFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
+BOOTCFLAGS += $(call cc-option, -no-integrated-as)
+BOOTAFLAGS += $(call cc-option, -no-integrated-as)
+endif
+
 ifdef CONFIG_DEBUG_INFO
 BOOTCFLAGS += -g
 endif
-- 
2.19.1



[PATCH 1/2] Makefile: Export clang toolchain variables

2018-11-04 Thread Joel Stanley
The powerpc makefile will use these in it's boot wrapper.

Signed-off-by: Joel Stanley 
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 9aa352b38815..a2db3c885b38 100644
--- a/Makefile
+++ b/Makefile
@@ -495,6 +495,9 @@ endif
 ifneq ($(GCC_TOOLCHAIN),)
 CLANG_GCC_TC   := --gcc-toolchain=$(GCC_TOOLCHAIN)
 endif
+export CLANG_TARGET
+export CLANG_GCC_TC
+export CLANG_PREFIX
 KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX)
 KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
-- 
2.19.1



[PATCH 0/2] poewrpc/Boot: Fix cross compiling with clang

2018-11-04 Thread Joel Stanley
Hello,

These patches allow clang to cross-compile the powerpc boot wrapper.
The boot wrapper constructs it's own compiler flags as it may not be
built for the same arch as the kernel.

The powerpc64le kernel builds natively with clang and with this patch it
can cross compile too.

Joel Stanley (2):
  Makefile: Export clang toolchain variables
  powerpc/boot: Set target when cross-compiling for clang

 Makefile   | 3 +++
 arch/powerpc/boot/Makefile | 7 +++
 2 files changed, 10 insertions(+)

-- 
2.19.1



Re: [PATCH] powerpc/32: Avoid unsupported flags with clang

2018-11-01 Thread Joel Stanley
On Fri, 2 Nov 2018 at 15:09, Joel Stanley  wrote:
>
> When building for ppc32 with clang these flags are unsupported:
>
>   -ffixed-r2 and -mmultiple
>
> llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
> when building for SVR4ABI and !ppc64:
>
>   // The SVR4 ABI reserves r2 and r13
>   if (Subtarget.isSVR4ABI()) {
> // We only reserve r2 if we need to use the TOC pointer. If we have no
> // explicit uses of the TOC pointer (meaning we're a leaf function with
> // no constant-pool loads, etc.) and we have no potential uses inside an
> // inline asm block, then we can treat r2 has an ordinary callee-saved
> // register.
> const PPCFunctionInfo *FuncInfo = MF.getInfo();
> if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
>   markSuperRegs(Reserved, PPC::R2);  // System-reserved register
> markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
>   }
>
> This means we can safely omit -ffixed-r2 when building for 32-bit
> targets.
>
> The -mmultiple/-mno-multiple flags are not supported by clang, so
> platforms that might support multiple miss out on using multiple word
> instructions.
>
> Clang 8 can then build a ppc44x_defconfig which boots in Qemu:
>
>   make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  
> ppc44x_defconfig
>   make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
>
>   qemu-system-ppc -M bamboo \
>-kernel arch/powerpc/boot/zImage \
>-dtb arch/powerpc/boot/dts/bamboo.dtb \
>-initrd ~/ppc32-440-rootfs.cpio \
>-nographic -serial stdio -monitor pty -append "console=ttyS0"
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/261
> Signed-off-by: Joel Stanley 
> ---
> I considered putting these behind a cc-option test. If someone has an
> opinion on that I'm happy to change.
>
>  arch/powerpc/Makefile | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 17be664dafa2..5fa678eee747 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -152,7 +152,9 @@ endif
>  CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
> cc-option,-mminimal-toc))
>  CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
>
> -CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
> +ifndef CONFIG_CC_IS_CLANG
> +#CFLAGS-$(CONFIG_PPC32):= -ffixed-r2 $(MULTIPLEWORD)

Whoops. I'll wait for any other comments before re-posting with this fixed.

> +endif
>  CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
>
>  ifdef CONFIG_PPC_BOOK3S_64
> --
> 2.19.1
>


[PATCH] powerpc/32: Avoid unsupported flags with clang

2018-11-01 Thread Joel Stanley
When building for ppc32 with clang these flags are unsupported:

  -ffixed-r2 and -mmultiple

llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
when building for SVR4ABI and !ppc64:

  // The SVR4 ABI reserves r2 and r13
  if (Subtarget.isSVR4ABI()) {
// We only reserve r2 if we need to use the TOC pointer. If we have no
// explicit uses of the TOC pointer (meaning we're a leaf function with
// no constant-pool loads, etc.) and we have no potential uses inside an
// inline asm block, then we can treat r2 has an ordinary callee-saved
// register.
const PPCFunctionInfo *FuncInfo = MF.getInfo();
if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
  markSuperRegs(Reserved, PPC::R2);  // System-reserved register
markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
  }

This means we can safely omit -ffixed-r2 when building for 32-bit
targets.

The -mmultiple/-mno-multiple flags are not supported by clang, so
platforms that might support multiple miss out on using multiple word
instructions.

Clang 8 can then build a ppc44x_defconfig which boots in Qemu:

  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  
ppc44x_defconfig
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  qemu-system-ppc -M bamboo \
   -kernel arch/powerpc/boot/zImage \
   -dtb arch/powerpc/boot/dts/bamboo.dtb \
   -initrd ~/ppc32-440-rootfs.cpio \
   -nographic -serial stdio -monitor pty -append "console=ttyS0"

Link: https://github.com/ClangBuiltLinux/linux/issues/261
Signed-off-by: Joel Stanley 
---
I considered putting these behind a cc-option test. If someone has an
opinion on that I'm happy to change.

 arch/powerpc/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 17be664dafa2..5fa678eee747 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -152,7 +152,9 @@ endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
 
-CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
+ifndef CONFIG_CC_IS_CLANG
+#CFLAGS-$(CONFIG_PPC32):= -ffixed-r2 $(MULTIPLEWORD)
+endif
 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
 
 ifdef CONFIG_PPC_BOOK3S_64
-- 
2.19.1



[PATCH] powerpc/math-emu: Fix building with clang

2018-11-01 Thread Joel Stanley
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-  
ppc44x_defconfig
  make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-

  ...

  arch/powerpc/math-emu/fnmsub.c:46:2: error: invalid use of a cast in a
  inline asm context requiring an l-value: remove the cast or build with
  -fheinous-gnu-extensions
  FP_ADD_D(R, T, B);
  ^
  ./include/math-emu/double.h:110:27: note: expanded from macro 'FP_ADD_D'
  #define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
  ^~
  ./include/math-emu/op-common.h:367:34: note: expanded from macro '_FP_ADD'
  #define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
   ^~
  ./include/math-emu/op-common.h:264:4: note: expanded from macro 
'_FP_ADD_INTERNAL'
_FP_FRAC_ADD_##wc(R, X, Y);\
^~
  note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
  ./include/math-emu/op-2.h:94:27: note: expanded from macro '_FP_FRAC_ADD_2'
__FP_FRAC_ADD_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
^~~

Link: https://github.com/ClangBuiltLinux/linux/issues/260
Signed-off-by: Joel Stanley 
---
 arch/powerpc/math-emu/Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/math-emu/Makefile b/arch/powerpc/math-emu/Makefile
index 494df26c5988..b9cb797445ac 100644
--- a/arch/powerpc/math-emu/Makefile
+++ b/arch/powerpc/math-emu/Makefile
@@ -18,3 +18,7 @@ CFLAGS_fabs.o = -fno-builtin-fabs
 CFLAGS_math.o = -fno-builtin-fabs
 
 ccflags-y = -I. -Iinclude/math-emu -w
+
+ifdef CONFIG_CC_IS_CLANG
+ccflags-y += -fheinous-gnu-extensions
+endif
-- 
2.19.1



[PATCH v2] raid6/ppc: Fix build for clang

2018-11-01 Thread Joel Stanley
We cannot build these files with clang as it does not allow altivec
instructions in assembly when -msoft-float is passed.

Jinsong Ji  wrote:
> We currently disable Altivec/VSX support when enabling soft-float.  So
> any usage of vector builtins will break.
>
> Enable Altivec/VSX with soft-float may need quite some clean up work, so
> I guess this is currently a limitation.
>
> Removing -msoft-float will make it work (and we are lucky that no
> floating point instructions will be generated as well).

This is a workaround until the issue is resolved in clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=31177
Link: https://github.com/ClangBuiltLinux/linux/issues/239
Signed-off-by: Joel Stanley 
---
v2: fix typo in comment, thanks Jinsong

 lib/raid6/Makefile | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index 2f8b61dfd9b0..7ed43eaa02ef 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -18,6 +18,21 @@ quiet_cmd_unroll = UNROLL  $@
 
 ifeq ($(CONFIG_ALTIVEC),y)
 altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
+
+ifdef CONFIG_CC_IS_CLANG
+# clang ppc port does not yet support -maltivec when -msoft-float is
+# enabled. A future release of clang will resolve this
+# https://bugs.llvm.org/show_bug.cgi?id=31177
+CFLAGS_REMOVE_altivec1.o  += -msoft-float
+CFLAGS_REMOVE_altivec2.o  += -msoft-float
+CFLAGS_REMOVE_altivec4.o  += -msoft-float
+CFLAGS_REMOVE_altivec8.o  += -msoft-float
+CFLAGS_REMOVE_altivec8.o  += -msoft-float
+CFLAGS_REMOVE_vpermxor1.o += -msoft-float
+CFLAGS_REMOVE_vpermxor2.o += -msoft-float
+CFLAGS_REMOVE_vpermxor4.o += -msoft-float
+CFLAGS_REMOVE_vpermxor8.o += -msoft-float
+endif
 endif
 
 # The GCC option -ffreestanding is required in order to compile code containing
-- 
2.19.1



[PATCH] raid6/ppc: Fix build for clang

2018-10-30 Thread Joel Stanley
We cannot build these files with clang as it does not allow altivec
instructions in assembly when -msoft-float is passed.

Jinsong Ji  wrote:
> We currently disable Altivec/VSX support when enabling soft-float.  So
> any usage of vector builtins will break.
>
> Enable Altivec/VSX with soft-float may need quite some clean up work, so
> I guess this is currently a limitation.
>
> Removing -msoft-float will make it work (and we are lucky that no
> floating point instructions will be generated as well).

This is a workaround until the issue is resolved in clang.

Link: https://bugs.llvm.org/show_bug.cgi?id=31177
Link: https://github.com/ClangBuiltLinux/linux/issues/239
Signed-off-by: Joel Stanley 
---
 lib/raid6/Makefile | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index 2f8b61dfd9b0..3a844e6fd01c 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -18,6 +18,21 @@ quiet_cmd_unroll = UNROLL  $@
 
 ifeq ($(CONFIG_ALTIVEC),y)
 altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
+
+ifdef CONFIG_CC_IS_CLANG
+# clang ppc port does not yet support -maltifec when -msoft-float is
+# enabled. A future release of clang will resolve this
+# https://bugs.llvm.org/show_bug.cgi?id=31177
+CFLAGS_REMOVE_altivec1.o  += -msoft-float
+CFLAGS_REMOVE_altivec2.o  += -msoft-float
+CFLAGS_REMOVE_altivec4.o  += -msoft-float
+CFLAGS_REMOVE_altivec8.o  += -msoft-float
+CFLAGS_REMOVE_altivec8.o  += -msoft-float
+CFLAGS_REMOVE_vpermxor1.o += -msoft-float
+CFLAGS_REMOVE_vpermxor2.o += -msoft-float
+CFLAGS_REMOVE_vpermxor4.o += -msoft-float
+CFLAGS_REMOVE_vpermxor8.o += -msoft-float
+endif
 endif
 
 # The GCC option -ffreestanding is required in order to compile code containing
-- 
2.19.1



[PATCH] powerpc/xmon: Relax frame size for clang

2018-10-30 Thread Joel Stanley
When building with clang (8 trunk, 7.0 release) the frame size limit is
hit:

 arch/powerpc/xmon/xmon.c:452:12: warning: stack frame size of 2576
 bytes in function 'xmon_core' [-Wframe-larger-than=]

Some investigation by Naveen indicates this is due to clang saving the
addresses to printf format strings on the stack.

While this issue is investigated, bump up the frame size limit for xmon
when building with clang.

Link: https://github.com/ClangBuiltLinux/linux/issues/252
Signed-off-by: Joel Stanley 
---
 arch/powerpc/xmon/Makefile | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 69e7fb47bcaa..878f9c1d3615 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -11,6 +11,12 @@ UBSAN_SANITIZE := n
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
 KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
 
+ifdef CONFIG_CC_IS_CLANG
+# clang stores addresses on the stack causing the frame size to blow
+# out. See https://github.com/ClangBuiltLinux/linux/issues/252
+KBUILD_CFLAGS += -Wframe-larger-than=4096
+endif
+
 ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
 
 obj-y  += xmon.o nonstdio.o spr_access.o
-- 
2.19.1



Re: [PATCH v2 1/2] kbuild: replace cc-name test with CONFIG_CC_IS_CLANG

2018-10-30 Thread Joel Stanley
On Tue, 30 Oct 2018 at 23:58, Masahiro Yamada
 wrote:
>
> Evaluating cc-name invokes the compiler every time even when you are
> not compiling anything, like 'make help'. This is not efficient.
>
> The compiler type has been already detected in the Kconfig stage.
> Use CONFIG_CC_IS_CLANG, instead.

Thanks, I didn't know about this.

>
> Signed-off-by: Masahiro Yamada 
> Acked-by: Michael Ellerman  (powerpc)

Acked-by: Joel Stanley 

Cheers,

Joel


Re: [PATCH] selftests/powerpc: Relax L1d miss targets for rfi_flush test

2018-10-25 Thread Joel Stanley
On Tue, 23 Oct 2018 at 18:35, Naveen N. Rao
 wrote:
>
> When running the rfi_flush test, if the system is loaded, we see two
> issues:
> 1. The L1d misses when rfi_flush is disabled increase significantly due
> to other workloads interfering with the cache.
> 2. The L1d misses when rfi_flush is enabled sometimes goes slightly
> below the expected number of misses.
>
> To address these, let's relax the expected number of L1d misses:
> 1. When rfi_flush is disabled, we allow upto half the expected number of
> the misses for when rfi_flush is enabled.
> 2. When rfi_flush is enabled, we allow ~1% lower number of cache misses.
>
> Reported-by: Joel Stanley 
> Signed-off-by: Naveen N. Rao 

Thanks, this now passes 10/10 runs on my Romulus machine. A log is
attached below.

Tested-by: Joel Stanley 

Cheers,

Joel

---

for i in `seq 1 10`; do sudo ./rfi_flush; done
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 5013939 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195054696 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 11015957 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195053292 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 8017248 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195145579 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 11015308 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195042376 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 1021356 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195031624 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 6015342 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195037322 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 16635 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195032476 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 6013599 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195060037 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 25236 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195052859 > 19000) [10/10 pass]
success: rfi_flush_test
test: rfi_flush_test
tags: git_version:next-20181018-67-g61f7abf00719
PASS (L1D misses with rfi_flush=0: 18120 < 9500) [10/10 pass]
PASS (L1D misses with rfi_flush=1: 195014212 > 19000) [10/10 pass]
success: rfi_flush_test


[PATCH 6/6] selftests: powerpc/pmu: Link ebb tests with -no-pie

2018-10-23 Thread Joel Stanley
When running the ebb tests after building on a ppc64le Ubuntu machine:

 $ pmu/ebb/reg_access_test: error while loading shared libraries:
 R_PPC64_ADDR16_HI reloc at 0x00013a965130 for symbol `' out of
 range

This is because the Ubuntu toolchain builds has PIE enabled by default.
Change it to be always off instead.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/pmu/ebb/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile 
b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index bd5dfa509272..23f4caf48ffc 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -5,6 +5,9 @@ noarg:
 # The EBB handler is 64-bit code and everything links against it
 CFLAGS += -m64
 
+# Toolchains may build PIE by default which breaks the assembly
+LDFLAGS += -no-pie
+
 TEST_GEN_PROGS := reg_access_test event_attributes_test cycles_test\
 cycles_with_freeze_test pmc56_overflow_test\
 ebb_vs_cpu_event_test cpu_event_vs_ebb_test\
-- 
2.19.1



[PATCH 5/6] selftests: powerpc/signal: Fix signal_tm CFLAGS

2018-10-23 Thread Joel Stanley
signal_tm tries to build with -mhtm but it currently does not.

The targets is modified in lib.mk to add the $(OUTPUT) prefix. The
makefile needs to specify that modifying the rules, or else it does
not match and we miss out on the extra flag.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/signal/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/signal/Makefile 
b/tools/testing/selftests/powerpc/signal/Makefile
index 25d0973df5b3..209a958dca12 100644
--- a/tools/testing/selftests/powerpc/signal/Makefile
+++ b/tools/testing/selftests/powerpc/signal/Makefile
@@ -2,7 +2,7 @@
 TEST_GEN_PROGS := signal signal_tm
 
 CFLAGS += -maltivec
-signal_tm: CFLAGS += -mhtm
+$(OUTPUT)/signal_tm: CFLAGS += -mhtm
 
 top_srcdir = ../../../../..
 include ../../lib.mk
-- 
2.19.1



[PATCH 4/6] selftests: powerpc/signal: Make tests build

2018-10-23 Thread Joel Stanley
According to lib.mk, TEST_PROGS is for shell scripts. It appears we need
to define the programs as TEST_GEN_PROGS to ensure they are built.

The definition must also happen below the inclusion of lib.mk.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/signal/Makefile | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/powerpc/signal/Makefile 
b/tools/testing/selftests/powerpc/signal/Makefile
index d34a7c7710db..25d0973df5b3 100644
--- a/tools/testing/selftests/powerpc/signal/Makefile
+++ b/tools/testing/selftests/powerpc/signal/Makefile
@@ -1,7 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-TEST_PROGS := signal signal_tm
-
-$(TEST_PROGS): ../harness.c ../utils.c signal.S
+TEST_GEN_PROGS := signal signal_tm
 
 CFLAGS += -maltivec
 signal_tm: CFLAGS += -mhtm
@@ -9,5 +7,4 @@ signal_tm: CFLAGS += -mhtm
 top_srcdir = ../../../../..
 include ../../lib.mk
 
-clean:
-   rm -f $(TEST_PROGS) *.o
+$(TEST_GEN_PROGS): ../harness.c ../utils.c signal.S
-- 
2.19.1



[PATCH 3/6] selftests: powerpc/ptrace: Fix linking against pthread

2018-10-23 Thread Joel Stanley
Some of the ptrace tests require -ptrace when linking:

 /usr/bin/ld: /tmp/ccH32S9w.o: in function `init_child_sync':
 core-pkey.c:(.text+0x1d64): undefined reference to `sem_init'

The targets for these tests are modfied in lib.mk to add the $(OUTPUT)
prefix. The makefile needs to specify that modifying those rules, or
else they do not match and we miss out on the extra flags.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/ptrace/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile 
b/tools/testing/selftests/powerpc/ptrace/Makefile
index 58de6d4a0cf4..8d3f006c98cc 100644
--- a/tools/testing/selftests/powerpc/ptrace/Makefile
+++ b/tools/testing/selftests/powerpc/ptrace/Makefile
@@ -9,7 +9,7 @@ include ../../lib.mk
 
 CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie
 
-ptrace-pkey core-pkey: child.h
-ptrace-pkey core-pkey: LDLIBS += -pthread
+$(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: child.h
+$(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h
-- 
2.19.1



[PATCH 2/6] selftests: powerpc/ptrace: Remove clean rule

2018-10-23 Thread Joel Stanley
When running 'make ptrace':

 make[1]: Entering directory 'tools/testing/selftests/powerpc/ptrace'
 Makefile:18: warning: overriding recipe for target 'clean'
 ../../lib.mk:137: warning: ignoring old recipe for target 'clean'

The rule is unnecessary as TEST_GEN_FILES are cleaned up by the rule in
lib.mk.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/ptrace/Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile 
b/tools/testing/selftests/powerpc/ptrace/Makefile
index e9a3850aae86..58de6d4a0cf4 100644
--- a/tools/testing/selftests/powerpc/ptrace/Makefile
+++ b/tools/testing/selftests/powerpc/ptrace/Makefile
@@ -13,6 +13,3 @@ ptrace-pkey core-pkey: child.h
 ptrace-pkey core-pkey: LDLIBS += -pthread
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h
-
-clean:
-   rm -f $(TEST_GEN_PROGS) *.o
-- 
2.19.1



[PATCH 1/6] selftests: powerpc/ptrace: Make tests build

2018-10-23 Thread Joel Stanley
According to lib.mk, TEST_PROGS is for shell scripts. It appears we need
to define the programs as TEST_GEN_PROGS to ensure they are built.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/ptrace/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile 
b/tools/testing/selftests/powerpc/ptrace/Makefile
index 6ac71b629276..e9a3850aae86 100644
--- a/tools/testing/selftests/powerpc/ptrace/Makefile
+++ b/tools/testing/selftests/powerpc/ptrace/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-TEST_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \
+TEST_GEN_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \
   ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx 
ptrace-tm-vsx \
   ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak ptrace-pkey 
core-pkey \
   perf-hwbreak ptrace-syscall
@@ -12,7 +12,7 @@ CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm 
-fno-pie
 ptrace-pkey core-pkey: child.h
 ptrace-pkey core-pkey: LDLIBS += -pthread
 
-$(TEST_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h
+$(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h
 
 clean:
-   rm -f $(TEST_PROGS) *.o
+   rm -f $(TEST_GEN_PROGS) *.o
-- 
2.19.1



[PATCH 0/6] selftests: powerpc build fixes

2018-10-23 Thread Joel Stanley
This series fixes issues I encountered building and running the
selftests on a Ubuntu Cosmic ppc64le system.

Joel Stanley (6):
  selftests: powerpc/ptrace: Make tests build
  selftests: powerpc/ptrace: Remove clean rule
  selftests: powerpc/ptrace: Fix linking against pthread
  selftests: powerpc/signal: Make tests build
  selftests: powerpc/signal: Fix signal_tm CFLAGS
  selftests: powerpc/pmu: Link ebb tests with -no-pie

 tools/testing/selftests/powerpc/pmu/ebb/Makefile |  3 +++
 tools/testing/selftests/powerpc/ptrace/Makefile  | 11 ---
 tools/testing/selftests/powerpc/signal/Makefile  |  9 +++--
 3 files changed, 10 insertions(+), 13 deletions(-)

-- 
2.19.1



[PATCH] selftests: powerpc: Fix warning for security subdir

2018-10-22 Thread Joel Stanley
typing 'make' inside tools/testing/selftests/powerpc gave a build
warning:

BUILD_TARGET=tools/testing/selftests/powerpc/security; mkdir -p $BUILD_TARGET; 
make OUTPUT=$BUILD_TARGET -k -C security all
make[1]: Entering directory 'tools/testing/selftests/powerpc/security'
../../lib.mk:20: ../../../../scripts/subarch.include: No such file or directory
make[1]: *** No rule to make target '../../../../scripts/subarch.include'.
make[1]: Failed to remake makefile '../../../../scripts/subarch.include'.

The build is one level deeper than lib.mk thinks it is. Set top_srcdir
to set things straight.

Note that the test program is still built.

Signed-off-by: Joel Stanley 
---
 tools/testing/selftests/powerpc/security/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/powerpc/security/Makefile 
b/tools/testing/selftests/powerpc/security/Makefile
index 44690f1bb26a..85861c46b445 100644
--- a/tools/testing/selftests/powerpc/security/Makefile
+++ b/tools/testing/selftests/powerpc/security/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 TEST_GEN_PROGS := rfi_flush
+top_srcdir = ../../../../..
 
 CFLAGS += -I../../../../../usr/include
 
-- 
2.19.1



[PATCH] powerpc: Use SWITCH_FRAME_SIZE for prom and rtas entry

2018-10-11 Thread Joel Stanley
Commit 6c1719942e19 ("powerpc/of: Remove useless register save/restore
when calling OF back") removed the saving of srr0 and srr1 when calling
into OpenFirmware. Commit e31aa453bbc4 ("powerpc: Use LOAD_REG_IMMEDIATE
only for constants on 64-bit") did the same for rtas.

This means we don't need to save the extra stack space and can use
the common SWITCH_FRAME_SIZE.

There were already no users of _SRR0 and _SRR1 so we can remove them
too.

Link: https://github.com/linuxppc/linux/issues/83
Signed-off-by: Joel Stanley 
---
 arch/powerpc/kernel/asm-offsets.c |  9 -
 arch/powerpc/kernel/entry_64.S| 10 +-
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index a6d70fd2e499..2eb4923f8468 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -280,11 +280,6 @@ int main(void)
/* Interrupt register frame */
DEFINE(INT_FRAME_SIZE, STACK_INT_FRAME_SIZE);
DEFINE(SWITCH_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct 
pt_regs));
-#ifdef CONFIG_PPC64
-   /* Create extra stack space for SRR0 and SRR1 when calling prom/rtas. */
-   DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 
16);
-   DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 
16);
-#endif /* CONFIG_PPC64 */
STACK_PT_REGS_OFFSET(GPR0, gpr[0]);
STACK_PT_REGS_OFFSET(GPR1, gpr[1]);
STACK_PT_REGS_OFFSET(GPR2, gpr[2]);
@@ -328,10 +323,6 @@ int main(void)
STACK_PT_REGS_OFFSET(_ESR, dsisr);
 #else /* CONFIG_PPC64 */
STACK_PT_REGS_OFFSET(SOFTE, softe);
-
-   /* These _only_ to be used with {PROM,RTAS}_FRAME_SIZE!!! */
-   DEFINE(_SRR0, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs));
-   DEFINE(_SRR1, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs)+8);
 #endif /* CONFIG_PPC64 */
 
 #if defined(CONFIG_PPC32)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index ed6f6c7f4264..7db00ee6be48 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1124,7 +1124,7 @@ _ASM_NOKPROBE_SYMBOL(fast_exception_return);
 _GLOBAL(enter_rtas)
mflrr0
std r0,16(r1)
-stdu   r1,-RTAS_FRAME_SIZE(r1) /* Save SP and create stack space. */
+stdu   r1,-SWITCH_FRAME_SIZE(r1) /* Save SP and create stack space. */
 
/* Because RTAS is running in 32b mode, it clobbers the high order half
 * of all registers that it saves.  We therefore save those registers
@@ -1256,7 +1256,7 @@ rtas_restore_regs:
ld  r8,_DSISR(r1)
mtdsisr r8
 
-addi   r1,r1,RTAS_FRAME_SIZE   /* Unstack our frame */
+addi   r1,r1,SWITCH_FRAME_SIZE /* Unstack our frame */
ld  r0,16(r1)   /* get return address */
 
mtlrr0
@@ -1267,7 +1267,7 @@ rtas_restore_regs:
 _GLOBAL(enter_prom)
mflrr0
std r0,16(r1)
-stdu   r1,-PROM_FRAME_SIZE(r1) /* Save SP and create stack space */
+stdu   r1,-SWITCH_FRAME_SIZE(r1) /* Save SP and create stack space */
 
/* Because PROM is running in 32b mode, it clobbers the high order half
 * of all registers that it saves.  We therefore save those registers
@@ -1324,8 +1324,8 @@ _GLOBAL(enter_prom)
REST_10GPRS(22, r1)
ld  r4,_CCR(r1)
mtcrr4
-   
-addi   r1,r1,PROM_FRAME_SIZE
+
+addi   r1,r1,SWITCH_FRAME_SIZE
ld  r0,16(r1)
mtlrr0
 blr
-- 
2.17.1



[PATCH v3] powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS

2018-10-10 Thread Joel Stanley
Ever since commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type
to POWER4") we force -mpower4 to be passed to the assembler irrespective
of the CFLAGS used.

When building a powerpc64 kernel with clang, clang will not add -many to
the assembler flags, so any instructions that the compiler has generated
that are not available on power4 will cause an error:

 /usr/bin/as -a64 -mppc64 -mlittle-endian -mpower8 \
  -I ./arch/powerpc/include -I ./arch/powerpc/include/generated \
  -I ./include -I ./arch/powerpc/include/uapi \
  -I ./arch/powerpc/include/generated/uapi -I ./include/uapi \
  -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc \
  -maltivec -mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s
 /tmp/do_mounts-51ce54.s:748: Error: unrecognized opcode: `isel'

GCC does include -many, so the GCC driven gas call will succeed:

  as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I
  ./include -I ./arch/powerpc/include/uapi
  -I ./arch/powerpc/include/generated/uapi -I ./include/uapi
  -I ./include/generated/uapi -I arch/powerpc -I arch/powerpc
   -a64 -mpower8 -many -mlittle -maltivec -mpower4 -o init/do_mounts.o

Note that isel is power7 and above for IBM CPUs. GCC only generates it
for Power9 and above, but the above test was run against the clang
generated assembly.

Peter Bergner explains:

 > When using -many -mpower4, gas will first try and find a matching
 > power4 mnemonic and failing that, it will then allow any valid mnemonic
 > that gas knows about.  GCC's use of -many predates me though.
 >
 > IIRC, Alan looked at trying to remove it, but I forget why he didn't.
 > Could be either a gcc or gas issue at the time.  I'm not sure whether
 > issue still exists or not.  He and I have modified how gas works
 > internally a fair amount since he tried removing gcc use of -many
 >
 > I will also note that when using -many, gas will choose the first
 > mnemonic that matches in the mnemonic table and we have (mostly) sorted
 > the table so that server mnemonics show up earlier in the table than
 > other mnemonics, so they'll be seen/chosen first

By explicitly setting -many we can build with Clang and GCC while
retaining the -mpower4 option.

Signed-off-by: Joel Stanley 
---
Following up on:
https://lore.kernel.org/linuxppc-dev/20180914040649.1794-2-j...@jms.id.au/
https://lore.kernel.org/linuxppc-dev/20180821010203.23213-1-an...@ozlabs.org/

mpe, please trim the commit message if you think it's a bit verbose

We could test for these flags in case -many is removed in the future,
but if an assembler does not support -many then -mpower4 will probably
break it anyway.

 arch/powerpc/Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 81552c7b46eb..ae097fa9abe9 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -249,7 +249,10 @@ cpu-as-$(CONFIG_4xx)   += -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)   += $(call as-option,-Wa$(comma)-maltivec)
 cpu-as-$(CONFIG_E200)  += -Wa,-me200
 cpu-as-$(CONFIG_E500)  += -Wa,-me500
-cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4
+# When using -many -mpower4 gas will first try and find a matching power4
+# mnemonic and failing that it will allow any valid mnemonic that GAS knows
+# about. GCC will pass -many to GAS when assembling, clang does not
+cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many
 cpu-as-$(CONFIG_PPC_E500MC)+= $(call as-option,-Wa$(comma)-me500mc)
 
 KBUILD_AFLAGS += $(cpu-as-y)
-- 
2.17.1



Re: [PATCH 1/2] powerpc/boot: Expose Kconfig symbols to wrapper

2018-10-10 Thread Joel Stanley
On Thu, 11 Oct 2018 at 10:32, Michael Ellerman  wrote:
>
> Michael Ellerman  writes:
> > Joel Stanley  writes:
> >> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> >> index 0fb96c26136f..eeed74e0dfca 100644
> >> --- a/arch/powerpc/boot/Makefile
> >> +++ b/arch/powerpc/boot/Makefile
> >> @@ -197,9 +197,14 @@ $(obj)/empty.c:
> >>  $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: 
> >> $(srctree)/$(src)/%.S
> >>  $(Q)cp $< $@
> >>
> >> +$(obj)/serial.c: $(obj)/autoconf.h
> >> +
> >> +$(obj)/autoconf.h: $(obj)/%: $(srctree)/include/generated/%
> >> +$(Q)cp $< $@
> >> +
> >
> > This gives me:
> >   make[2]: *** No rule to make target '../include/generated/autoconf.h', 
> > needed by 'arch/powerpc/boot/autoconf.h'.  Stop.
> >
> > The ../ is $(srctree).
>
> Seems autoconf.h is in objtree:
>
>   ~/linux$ make O=build prepare
>   ...
>   ~/linux$ find . -name autoconf.h
>   ./drivers/staging/rtl8723bs/include/autoconf.h
>   ./tools/testing/radix-tree/generated/autoconf.h
>   ./build/include/generated/autoconf.h

Ah. That's obvious now that you point it out. Obviously myself and
0day do in-tree builds.

> So I'll fix that up.

Thanks!


Re: [PATCH 1/2] powerpc/boot: Disable vector instructions

2018-10-10 Thread Joel Stanley
On Wed, 10 Oct 2018 at 22:41, Michael Ellerman  wrote:
>
> Joel Stanley  writes:
>
> > This will avoid auto-vectorisation when building with higher
> > optimisation levels.
> >
> > We don't know if the machine can support VSX and even if it's present
> > it's probably not going to be enabled at this point in boot.
> >
> > Signed-off-by: Joel Stanley 
> > ---
> >  arch/powerpc/boot/Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> > index 0fb96c26136f..739ef8d43b91 100644
> > --- a/arch/powerpc/boot/Makefile
> > +++ b/arch/powerpc/boot/Makefile
> > @@ -32,8 +32,8 @@ else
> >  endif
> >
> >  BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> > -  -fno-strict-aliasing -Os -msoft-float -pipe \
> > -  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
> > +  -fno-strict-aliasing -Os -msoft-float -mno-altivec -mno-vsx \
>
> That's going to break if the compiler doesn't understand -mno-vsx isn't it?
>
> I'm not sure if "support" a compiler that old though.

Segher, the kernel mandates 4.6 as the minimum. Do we need to worry
about the compiler not supporting  -mno-altivec -mno-vsx?


[PATCH 2/2] powerpc/boot: Build boot wrapper with optimisations

2018-10-09 Thread Joel Stanley
The boot wrapper is currently built with -Os. By building with O2 we
can meaningfully reduce the time decompressing the kernel.

I tested by comparing 10 runs of each option in Qemu and on hardware.
The kernel is compressed with KERNEL_XZ built with GCC 8.2.0-7ubuntu1.
The values are counts of the timebase.

Qemu TCG powernv Power8:

  OsO2O3
 median   10221123889   62015184386568186825
 stddev1361267211429090641 657930076
 improvement39.33%35.74%

Palmetto Power8:

  OsO2O3
 median   50279 50599  35790
 stddev   992144533 627130655  623721078
 improvement   36.79% 37.13%

Romulus Power9:

  OsO2O3
 median   670312391 454733720  448881398
 stddev  157569107276 108760
 improvement   32.16% 33.03%

TCG was quite noisy, with every few runs producing an outlier. Even so,
O2 is faster than O3. On hardware the numbers were less noisy and O3 is
slightly faster than O2.

The wrapper size increases when moving from Os. Comparing zImage.epapr
to the existing Os build using bloat-o-meter:

  Before=43401, After=56837 (13KB), chg +30.96%
  Before=43401, After=64305 (20KB), chg +48.16%

I chose O2 for a balance between Qemu and hardware speed up.

Signed-off-by: Joel Stanley 
---
 arch/powerpc/boot/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 739ef8d43b91..c6c5a1a6627d 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,7 +32,7 @@ else
 endif
 
 BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
--fno-strict-aliasing -Os -msoft-float -mno-altivec -mno-vsx \
+-fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
 -D$(compress-y)
 
-- 
2.17.1



[PATCH 1/2] powerpc/boot: Disable vector instructions

2018-10-09 Thread Joel Stanley
This will avoid auto-vectorisation when building with higher
optimisation levels.

We don't know if the machine can support VSX and even if it's present
it's probably not going to be enabled at this point in boot.

Signed-off-by: Joel Stanley 
---
 arch/powerpc/boot/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0fb96c26136f..739ef8d43b91 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,8 +32,8 @@ else
 endif
 
 BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
--fno-strict-aliasing -Os -msoft-float -pipe \
--fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
+-fno-strict-aliasing -Os -msoft-float -mno-altivec -mno-vsx \
+-pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
 -D$(compress-y)
 
 ifdef CONFIG_PPC64_BOOT_WRAPPER
-- 
2.17.1



[PATCH 0/2] powerpc/boot: Build wrapper with optimisations

2018-10-09 Thread Joel Stanley
We currently build the wrapper with Os. This builds it with O2 instead,
reducing boot time when decompressing a compressed kernel. See patch
2 for details.

I've given this a spin with CONFIG_KERNEL_XZ on P9 and P8 as the
petitboot kernel.

Joel Stanley (2):
  powerpc/boot: Disable vector instructions
  powerpc/boot: Build boot wrapper with optimisations

 arch/powerpc/boot/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1



[PATCH 2/2] powerpc/boot: Fix opal console in boot wrapper

2018-10-09 Thread Joel Stanley
As of commit 10c77dba40ff ("powerpc/boot: Fix build failure in 32-bit
boot wrapper") the opal code is hidden behind CONFIG_PPC64_BOOT_WRAPPER,
but the boot wrapper avoids include/linux, so it does not get the normal
Kconfig flags.

We can drop the guard entirely as in commit f8e8e69cea49 ("powerpc/boot:
Only build OPAL code when necessary") the makefile only includes opal.c
in the build if CONFIG_PPC64_BOOT_WRAPPER is set.

Fixes: 10c77dba40ff ("powerpc/boot: Fix build failure in 32-bit boot wrapper")
Signed-off-by: Joel Stanley 
---
I wrote this patch before the kconfig one. We could use autoconf.h, or
fold this in, but I think the clean up of the redundant ifdef is cleaner.

 arch/powerpc/boot/opal.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/arch/powerpc/boot/opal.c b/arch/powerpc/boot/opal.c
index 0272570d02de..dfb199ef5b94 100644
--- a/arch/powerpc/boot/opal.c
+++ b/arch/powerpc/boot/opal.c
@@ -13,8 +13,6 @@
 #include 
 #include "../include/asm/opal-api.h"
 
-#ifdef CONFIG_PPC64_BOOT_WRAPPER
-
 /* Global OPAL struct used by opal-call.S */
 struct opal {
u64 base;
@@ -101,9 +99,3 @@ int opal_console_init(void *devp, struct serial_console_data 
*scdp)
 
return 0;
 }
-#else
-int opal_console_init(void *devp, struct serial_console_data *scdp)
-{
-   return -1;
-}
-#endif /* __powerpc64__ */
-- 
2.17.1



[PATCH 1/2] powerpc/boot: Expose Kconfig symbols to wrapper

2018-10-09 Thread Joel Stanley
Currently the wrapper is built without including anything in
$(src)/include/, which means there are no CONFIG_ symbols defined. This
means the platform specific serial drivers were never enabled.

We now copy the definitions into the boot directory, so any C file can
now include autoconf.h to depend on configuration options.

Fixes: 866bfc75f40e ("powerpc: conditionally compile platform-specific serial 
drivers")
Signed-off-by: Joel Stanley 
---
 arch/powerpc/boot/.gitignore | 1 +
 arch/powerpc/boot/Makefile   | 7 ++-
 arch/powerpc/boot/serial.c   | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index f92d0530ceb1..32034a0cc554 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -44,4 +44,5 @@ fdt_sw.c
 fdt_wip.c
 libfdt.h
 libfdt_internal.h
+autoconf.h
 
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0fb96c26136f..eeed74e0dfca 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -197,9 +197,14 @@ $(obj)/empty.c:
 $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S
$(Q)cp $< $@
 
+$(obj)/serial.c: $(obj)/autoconf.h
+
+$(obj)/autoconf.h: $(obj)/%: $(srctree)/include/generated/%
+   $(Q)cp $< $@
+
 clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
$(zlib-decomp-) $(libfdt) $(libfdtheader) \
-   empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
+   autoconf.h empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
 
 quiet_cmd_bootcc = BOOTCC  $@
   cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index 48e3743faedf..f045f8494bf9 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -18,6 +18,7 @@
 #include "stdio.h"
 #include "io.h"
 #include "ops.h"
+#include "autoconf.h"
 
 static int serial_open(void)
 {
-- 
2.17.1



[PATCH 0/2] powerpc/boot: Fix serial output in boot wrapper

2018-10-09 Thread Joel Stanley
While doing some work on the wrapper I noticed we no longer get serial
output on a powernv system. This is because we compile out the opal
code.

As it turns out, none of the system-specific serial outputs will be
compiled in. This series fixes that. Tested on Qemu powernv, Romulus and
Palmetto.

Joel Stanley (2):
  powerpc/boot: Expose Kconfig symbols to wrapper
  powerpc/boot: Fix opal console in boot wrapper

 arch/powerpc/boot/.gitignore | 1 +
 arch/powerpc/boot/Makefile   | 7 ++-
 arch/powerpc/boot/opal.c | 8 
 arch/powerpc/boot/serial.c   | 1 +
 4 files changed, 8 insertions(+), 9 deletions(-)

-- 
2.17.1



[PATCH v2] powerpc/perf: Quiet IMC PMU registration message

2018-10-09 Thread Joel Stanley
On a Power9 box we get a few screens full of these on boot. Drop
them to pr_debug.

[5.993645] nest_centaur6_imc performance monitor hardware support registered
[5.993728] nest_centaur7_imc performance monitor hardware support registered
[5.996510] core_imc performance monitor hardware support registered
[5.996569] nest_mba0_imc performance monitor hardware support registered
[5.996631] nest_mba1_imc performance monitor hardware support registered
[5.996685] nest_mba2_imc performance monitor hardware support registered

Signed-off-by: Joel Stanley 
---
v2: patch the correct file, update commit title

 arch/powerpc/perf/imc-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 1fafc32b12a0..6954636b16d1 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -1392,7 +1392,7 @@ int init_imc_pmu(struct device_node *parent, struct 
imc_pmu *pmu_ptr, int pmu_id
if (ret)
goto err_free_cpuhp_mem;
 
-   pr_info("%s performance monitor hardware support registered\n",
+   pr_debug("%s performance monitor hardware support registered\n",
pmu_ptr->pmu.name);
 
return 0;
-- 
2.17.1



[PATCH] powerpc/perf: Quiet PMU registration message

2018-10-08 Thread Joel Stanley
On a Power9 box we get a few screens full of these on boot. Drop
them to pr_debug.

[5.993645] nest_centaur6_imc performance monitor hardware support registered
[5.993728] nest_centaur7_imc performance monitor hardware support registered
[5.996510] core_imc performance monitor hardware support registered
[5.996569] nest_mba0_imc performance monitor hardware support registered
[5.996631] nest_mba1_imc performance monitor hardware support registered
[5.996685] nest_mba2_imc performance monitor hardware support registered

Signed-off-by: Joel Stanley 
---
 arch/powerpc/perf/core-book3s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 81f8a0c838ae..a01c521694e8 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2249,8 +2249,8 @@ int register_power_pmu(struct power_pmu *pmu)
return -EBUSY;  /* something's already registered */
 
ppmu = pmu;
-   pr_info("%s performance monitor hardware support registered\n",
-   pmu->name);
+   pr_debug("%s performance monitor hardware support registered\n",
+pmu->name);
 
power_pmu.attr_groups = ppmu->attr_groups;
 
-- 
2.17.1



[PATCH] lib/xz: Put CRC32_POLY_LE in xz_private.h

2018-09-20 Thread Joel Stanley
This fixes a regression introduced by faa16bc404d72a5 ("lib: Use
existing define with polynomial").

The cleanup added a dependency on include/linux, which broke the PowerPC
boot wrapper/decompresser when KERNEL_XZ is enabled:

  BOOTCC  arch/powerpc/boot/decompress.o
 In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
 from arch/powerpc/boot/decompress.c:42:
 arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
 linux/crc32poly.h: No such file or directory
  #include 
   ^~~

The powerpc decompresser is a hairy corner of the kernel. Even while building
a 64-bit kernel it needs to build a 32-bit binary and therefore avoid including
files from include/linux.

This allows users of the xz library to avoid including headers from
'include/linux/' while still achieving the cleanup of the magic number.

Fixes: faa16bc404d72a5 ("lib: Use existing define with polynomial")
Reported-by: Meelis Roos 
Reported-by: kbuild test robot 
Suggested-by: Christophe LEROY 
Signed-off-by: Joel Stanley 
---
 lib/xz/xz_crc32.c   | 1 -
 lib/xz/xz_private.h | 4 
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
index 25a5d87e2e4c..912aae5fa09e 100644
--- a/lib/xz/xz_crc32.c
+++ b/lib/xz/xz_crc32.c
@@ -15,7 +15,6 @@
  * but they are bigger and use more memory for the lookup table.
  */
 
-#include 
 #include "xz_private.h"
 
 /*
diff --git a/lib/xz/xz_private.h b/lib/xz/xz_private.h
index 482b90f363fe..09360ebb510e 100644
--- a/lib/xz/xz_private.h
+++ b/lib/xz/xz_private.h
@@ -102,6 +102,10 @@
 #  endif
 #endif
 
+#ifndef CRC32_POLY_LE
+#define CRC32_POLY_LE 0xedb88320
+#endif
+
 /*
  * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
  * before calling xz_dec_lzma2_run().
-- 
2.17.1



Re: [PATCH] lib/xz: Fix powerpc build with KERNEL_XZ

2018-09-20 Thread Joel Stanley
On Wed, 19 Sep 2018 at 16:09, Krzysztof Kozlowski  wrote:
>
> On Wed, 19 Sep 2018 at 01:08, Joel Stanley  wrote:
> >
> > This partially reverts faa16bc404d72a5 ("lib: Use existing define with
> > polynomial").
> >
> > The cleanup added a dependency on include/linux, which broke the PowerPC
> > boot wrapper/decompresser when KERNEL_XZ is enabled:
> >
> >   BOOTCC  arch/powerpc/boot/decompress.o
> >  In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
> >  from arch/powerpc/boot/decompress.c:42:
> >  arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
> >  linux/crc32poly.h: No such file or directory
> >   #include 
> >^~~
> >
> > The powerpc decompressor is a hairy corner of the kernel. Even while 
> > building
> > a 64-bit kernel it needs to build a 32-bit binary and therefore avoid 
> > including
> > files from include/linux.
>
> I fixed the build error here:
> https://lkml.org/lkml/2018/8/29/179
>
> If you choose to remove any includes from /linux, then go ahead but
> please use original reported-by :)

Okay. I'll try Christophe's suggestion instead.

Cheers,

Joel


Re: [PATCH v2 1/5] powerpc/Makefiles: Fix clang/llvm build

2018-09-20 Thread Joel Stanley
On Sat, 15 Sep 2018 at 03:11, Nick Desaulniers  wrote:
>
> On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley  wrote:
> >
> > From: Anton Blanchard 
> >
> > Commit 15a3204d24a3 ("powerpc/64s: Set assembler machine type to POWER4")
> > passes -mpower4 to the assembler. We have more recent instructions in our
> > assembly files, but gas permits them. The clang/llvm integrated assembler
> > is more strict, and we get a build failure.
>
> Note that we disable clang's integrated assembler in the top level
> Makefile for now, but it will still validate constraints for inline
> assembly.  Do you know which case is meant by "build failure?"

An example of a failure is:

  CC  init/do_mounts.o
/tmp/do_mounts-58cd1d.s: Assembler messages:
/tmp/do_mounts-58cd1d.s:251: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:748: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:759: Error: unrecognized opcode: `isel'
/tmp/do_mounts-58cd1d.s:1373: Error: unrecognized opcode: `isel'

The full build line at the bottom of this email. The m flags:

 -mlittle-endian -m64 -msoft-float -mabi=elfv2 -mcmodel=medium
-mcpu=power8 -mtune=power9 -mno-altivec -mno-vsx -Wa,-maltivec
-Wa,-mpower4 -mlittle-endian

If we remove the -Wa,-mpower4 it works. This is because isel is not
available on power4.

Digging deeper, clang drives gas like this:

"/usr/bin/as" -a64 -mppc64 -mlittle-endian -mpower8 -I
./arch/powerpc/include -I ./arch/powerpc/include/generated -I
./include -I ./arch/powerpc/include/uapi -I
./arch/powerpc/include/generated/uapi -I ./include/uapi -I
./include/generated/uapi -I arch/powerpc -I arch/powerpc -maltivec
-mpower4 -o init/do_mounts.o /tmp/do_mounts-3b0a3d.s

GCC drives it:

as -v -I ./arch/powerpc/include -I ./arch/powerpc/include/generated -I
./include -I ./arch/powerpc/include/uapi -I
./arch/powerpc/include/generated/uapi -I ./include/uapi -I
./include/generated/uapi -I arch/powerpc -I arch/powerpc -a64 -mpower8
-many -mlittle -maltivec -mpower4 -o init/do_mounts.o

I think the important difference is GCC adds -many:

-many
   Generate code for any architecture (PWR/PWRX/PPC).

This is probably what we mean when building the kernel. I will get
some advice from our toolchain people first to understand what -many
does.

> Is there a link to the Clang bug?  It would be good to have that
> context in the commit message.

I haven't opened a clang bug. I'm not sure that we need one, unless we
want it to add -many to the assembler call like gcc does.

Cheers,

Joel

--
  /scratch/joel/llvm-build/bin/clang-8 -Wp,-MD,init/.do_mounts.o.d
-nostdinc -isystem /scratch/joel/llvm-build/lib/clang/8.0.0/include
-I./arch/powerpc/include -I./arch/powerpc/include/generated
-I./include -I./arch/powerpc/include/uapi
-I./arch/powerpc/include/generated/uapi -I./include/uapi
-I./include/generated/uapi -include ./include/linux/kconfig.h -include
./include/linux/compiler_types.h -D__KERNEL__ -Iarch/powerpc
-DHAVE_AS_ATHIGH=1 -Qunused-arguments -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-fshort-wchar -Werror-implicit-function-declaration
-Wno-format-security -std=gnu89 -no-integrated-as -fno-PIE
-mlittle-endian -m64 -msoft-float -pipe -Iarch/powerpc -mabi=elfv2
-mcmodel=medium -mcpu=power8 -mtune=power9 -mno-altivec -mno-vsx
-funit-at-a-time -fno-dwarf2-cfi-asm -Wa,-maltivec -Wa,-mpower4
-mlittle-endian -fno-delete-null-pointer-checks -Oz
-Wframe-larger-than=2048 -fno-stack-protector
-Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member
-Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable
-fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign
-fno-strict-overflow -fno-merge-all-constants -fno-stack-check
-Werror=implicit-int -Werror=strict-prototypes -Werror=date-time
-Werror=incompatible-pointer-types -Wno-initializer-overrides
-Wno-unused-value -Wno-format -Wno-sign-compare
-Wno-format-zero-length -Wno-uninitialized -fno-function-sections
-fno-data-sections-DKBUILD_BASENAME='"do_mounts"'
-DKBUILD_MODNAME='"mounts"' -c -o init/do_mounts.o init/do_mounts.c


Re: [PATCH v2 4/5] powerpc: Fix duplicate const clang warning in user access code

2018-09-19 Thread Joel Stanley
On Sat, 15 Sep 2018 at 03:27, Nick Desaulniers  wrote:
>
> On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley  wrote:
> >
> > From: Anton Blanchard 
> >
> > This re-applies b91c1e3e7a6f which was reverted in f2ca80905929
> > d466f6c5cac1 f84ed59a612d (powerpc/sparse: Constify the address pointer
> > ...").
> >
> > We see a large number of duplicate const errors in the user access
> > code when building with llvm/clang:
> >
> >   include/linux/pagemap.h:576:8: warning: duplicate 'const' declaration 
> > specifier
> >   [-Wduplicate-decl-specifier]
> > ret = __get_user(c, uaddr);
> >
> > The problem is we are doing const __typeof__(*(ptr)), which will hit the
> > warning if ptr is marked const.
> >
> > Removing const does not seem to have any effect on GCC code generation.
>
> I wouldn't expect it to for a local variable with such localized
> usage.  I myself am quite liberal in applying `const` to everything,
> so I will try to fix this in Clang as well, but this should silence
> the warning for users of older versions of Clang and results in no
> functional change.
> Reviewed-by: Nick Desaulniers 

Nick has written a clang patch that suppresses the warning in the same
way as GCC. Assuming it gets merged, as we depend on clang-8 we could
chose to not merge the kernel patch.

https://reviews.llvm.org/D52248

Cheers,

Joel


[PATCH] lib/xz: Fix powerpc build with KERNEL_XZ

2018-09-18 Thread Joel Stanley
This partially reverts faa16bc404d72a5 ("lib: Use existing define with
polynomial").

The cleanup added a dependency on include/linux, which broke the PowerPC
boot wrapper/decompresser when KERNEL_XZ is enabled:

  BOOTCC  arch/powerpc/boot/decompress.o
 In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:233,
 from arch/powerpc/boot/decompress.c:42:
 arch/powerpc/boot/../../../lib/xz/xz_crc32.c:18:10: fatal error:
 linux/crc32poly.h: No such file or directory
  #include 
   ^~~

The powerpc decompressor is a hairy corner of the kernel. Even while building
a 64-bit kernel it needs to build a 32-bit binary and therefore avoid including
files from include/linux.

Fixes: faa16bc404d7 ("lib: Use existing define with polynomial")
Signed-off-by: Joel Stanley 
---
We need to clean up the powerpc boot decompresser but that work will be
more involved than we would include in a late -rc. Please consider
merging this fix for 4.19. Thanks!

 lib/xz/xz_crc32.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/xz/xz_crc32.c b/lib/xz/xz_crc32.c
index 25a5d87e2e4c..34532d14fd4c 100644
--- a/lib/xz/xz_crc32.c
+++ b/lib/xz/xz_crc32.c
@@ -15,7 +15,6 @@
  * but they are bigger and use more memory for the lookup table.
  */
 
-#include 
 #include "xz_private.h"
 
 /*
@@ -30,7 +29,7 @@ STATIC_RW_DATA uint32_t xz_crc32_table[256];
 
 XZ_EXTERN void xz_crc32_init(void)
 {
-   const uint32_t poly = CRC32_POLY_LE;
+   const uint32_t poly = 0xEDB88320;
 
uint32_t i;
uint32_t j;
-- 
2.17.1



Re: [PATCH] powerpc/makefile: remove check on obsolete GCC versions

2018-09-17 Thread Joel Stanley
Hey Christophe,

On Tue, 18 Sep 2018 at 15:13, Christophe Leroy  wrote:
>
> Since commit cafa0010cd51 ("Raise the minimum required gcc version
> to 4.6"), it is not possible to build kernel with GCC lower than 4.6
>
> This patch removes checkbin tests addressing older versions of GCC.

This is the same as Nick's patch:

 https://patchwork.ozlabs.org/patch/969624/

Cheers,

Joel


[PATCH v2] powerpc/configs: Update skiroot defconfig

2018-09-17 Thread Joel Stanley
Disable new features from recent releases, and clean out some other
unused options:

  - Enable EXPERT, so we can disable some things
  - Disable non-powerpc BPF decoders
  - Disable TASKSTATS
  - Disable unused syscalls
  - Set more things to be modules
  - Turn off unused network vendors
  - PPC_OF_BOOT_TRAMPOLINE and FB_OF are unused on powernv
  - Drop unused Radeon and Matrox GPU drivers
  - IPV6 support landed in petitboot
  - Bringup related command line powersave=off dropped, switch to quiet

Set CONFIG_I2C_CHARDEV=y as the module is not loaded automatically, and
without this i2cget etc. will fail in the skiroot environment.

This defconfig gets us build coverage of KERNEL_XZ, which was broken in
the 4.19 merge window for powerpc.

Signed-off-by: Joel Stanley 
---
v2: re-sync with version used in op-build
---
 arch/powerpc/configs/skiroot_defconfig | 154 +
 1 file changed, 108 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/configs/skiroot_defconfig 
b/arch/powerpc/configs/skiroot_defconfig
index 6bd5e7261335..cfdd08897a06 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -3,20 +3,17 @@ CONFIG_ALTIVEC=y
 CONFIG_VSX=y
 CONFIG_NR_CPUS=2048
 CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_KERNEL_XZ=y
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 # CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
-CONFIG_TASKSTATS=y
-CONFIG_TASK_DELAY_ACCT=y
-CONFIG_TASK_XACCT=y
-CONFIG_TASK_IO_ACCOUNTING=y
+# CONFIG_CPU_ISOLATION is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=20
-CONFIG_RELAY=y
 CONFIG_BLK_DEV_INITRD=y
 # CONFIG_RD_GZIP is not set
 # CONFIG_RD_BZIP2 is not set
@@ -24,8 +21,14 @@ CONFIG_BLK_DEV_INITRD=y
 # CONFIG_RD_LZO is not set
 # CONFIG_RD_LZ4 is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_EXPERT=y
+# CONFIG_SGETMASK_SYSCALL is not set
+# CONFIG_SYSFS_SYSCALL is not set
+# CONFIG_SHMEM is not set
+# CONFIG_AIO is not set
 CONFIG_PERF_EVENTS=y
 # CONFIG_COMPAT_BRK is not set
+CONFIG_SLAB_FREELIST_HARDENED=y
 CONFIG_JUMP_LABEL=y
 CONFIG_STRICT_KERNEL_RWX=y
 CONFIG_MODULES=y
@@ -35,7 +38,9 @@ CONFIG_MODULE_SIG_FORCE=y
 CONFIG_MODULE_SIG_SHA512=y
 CONFIG_PARTITION_ADVANCED=y
 # CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_PPC_VAS is not set
 # CONFIG_PPC_PSERIES is not set
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_IDLE=y
 CONFIG_HZ_100=y
@@ -48,8 +53,9 @@ CONFIG_NUMA=y
 CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_CMDLINE_BOOL=y
-CONFIG_CMDLINE="console=tty0 console=hvc0 powersave=off"
+CONFIG_CMDLINE="console=tty0 console=hvc0 ipr.fast_reboot=1 quiet"
 # CONFIG_SECCOMP is not set
+# CONFIG_PPC_MEM_KEYS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -60,7 +66,6 @@ CONFIG_SYN_COOKIES=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_IPV6 is not set
 CONFIG_DNS_RESOLVER=y
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -73,8 +78,10 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=65536
 CONFIG_VIRTIO_BLK=m
 CONFIG_BLK_DEV_NVME=m
-CONFIG_EEPROM_AT24=y
+CONFIG_NVME_MULTIPATH=y
+CONFIG_EEPROM_AT24=m
 # CONFIG_CXL is not set
+# CONFIG_OCXL is not set
 CONFIG_BLK_DEV_SD=m
 CONFIG_BLK_DEV_SR=m
 CONFIG_BLK_DEV_SR_VENDOR=y
@@ -85,7 +92,6 @@ CONFIG_SCSI_FC_ATTRS=y
 CONFIG_SCSI_CXGB3_ISCSI=m
 CONFIG_SCSI_CXGB4_ISCSI=m
 CONFIG_SCSI_BNX2_ISCSI=m
-CONFIG_BE2ISCSI=m
 CONFIG_SCSI_AACRAID=m
 CONFIG_MEGARAID_NEWGEN=y
 CONFIG_MEGARAID_MM=m
@@ -102,7 +108,7 @@ CONFIG_SCSI_VIRTIO=m
 CONFIG_SCSI_DH=y
 CONFIG_SCSI_DH_ALUA=m
 CONFIG_ATA=y
-CONFIG_SATA_AHCI=y
+CONFIG_SATA_AHCI=m
 # CONFIG_ATA_SFF is not set
 CONFIG_MD=y
 CONFIG_BLK_DEV_MD=m
@@ -119,25 +125,72 @@ CONFIG_DM_SNAPSHOT=m
 CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_NET_VENDOR_ADAPTEC is not set
+# CONFIG_NET_VENDOR_AGERE is not set
+# CONFIG_NET_VENDOR_ALACRITECH is not set
 CONFIG_ACENIC=m
 CONFIG_ACENIC_OMIT_TIGON_I=y
-CONFIG_TIGON3=y
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_AQUANTIA is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_ATHEROS is not set
+CONFIG_TIGON3=m
 CONFIG_BNX2X=m
-CONFIG_CHELSIO_T1=y
+# CONFIG_NET_VENDOR_BROCADE is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_CAVIUM is not set
+CONFIG_CHELSIO_T1=m
+# CONFIG_NET_VENDOR_CISCO is not set
+# CONFIG_NET_VENDOR_CORTINA is not set
+# CONFIG_NET_VENDOR_DEC is not set
+# CONFIG_NET_VENDOR_DLINK is not set
 CONFIG_BE2NET=m
-CONFIG_S2IO=m
-CONFIG_E100=m
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_HP is not set
+# CONFIG_NET_VENDOR_HUAWEI is not set
 CONFIG_E1000=m
-CONFIG_E1000E=m
+CONFIG_IGB=m
 CONFIG_IXGB=m
 CONFIG_IXGBE=m
+CONFIG_I40E=m
+CONFIG_S2IO=m
+# CONFIG

Re: [PATCH v2 2/5] powerpc/boot: Fix crt0.S syntax for clang

2018-09-17 Thread Joel Stanley
On Tue, 18 Sep 2018 at 06:11, Nick Desaulniers  wrote:
>
> On Fri, Sep 14, 2018 at 2:08 PM Segher Boessenkool
>  wrote:
> >
> > On Fri, Sep 14, 2018 at 10:47:08AM -0700, Nick Desaulniers wrote:
> > > On Thu, Sep 13, 2018 at 9:07 PM Joel Stanley  wrote:
> > > >  10:addis   r12,r12,(-RELACOUNT)@ha
> > > > -   cmpdi   r12,RELACOUNT@l
> > > > +   cmpdi   r12,(RELACOUNT)@l
> > >
> > > Yep, as we can see above, when RELACOUNT is negated, it's wrapped in
> > > parens.
>
> Looks like this was just fixed in Clang-8:
> https://bugs.llvm.org/show_bug.cgi?id=38945
> https://reviews.llvm.org/D52188

Nice!

mpe, given we need the local references to labels fix which is also in
clang-8 I suggest we drop this patch.

Cheers,

Joel


[PATCH] powerpc: Disable -Wbuiltin-requires-header when setjmp is used

2018-09-17 Thread Joel Stanley
The powerpc kernel uses setjmp which causes a warning when building with
clang:

CC  arch/powerpc/xmon/xmon.o
  In file included from arch/powerpc/xmon/xmon.c:51:
  ./arch/powerpc/include/asm/setjmp.h:15:13: error: declaration of
  built-in function 'setjmp' requires inclusion of the header 
[-Werror,-Wbuiltin-requires-header]
  extern long setjmp(long *);
  ^
  ./arch/powerpc/include/asm/setjmp.h:16:13: error: declaration of
  built-in function 'longjmp' requires inclusion of the header 
[-Werror,-Wbuiltin-requires-header]
  extern void longjmp(long *, long);
  ^

This *is* the header and we're not using the built-in setjump but
rather the one in arch/powerpc/kernel/misc.S. As the compiler warning
does not make sense, it for the files where setjmp is used.

Signed-off-by: Joel Stanley 
---
We could instead disable this for all of the kernel as I don't think the
warning is going to ever provide useful information for the kernel.

 arch/powerpc/kernel/Makefile | 3 +++
 arch/powerpc/xmon/Makefile   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 1e64cfe22a83..9845a94f5f68 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -7,6 +7,9 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
 
 subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
 
+# Disable clang warning for using setjmp without setjmp.h header
+CFLAGS_crash.o += $(call cc-disable-warning, builtin-requires-header)
+
 ifdef CONFIG_PPC64
 CFLAGS_prom_init.o += $(NO_MINIMAL_TOC)
 endif
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 93cc1f1b8b61..a38db48f9f6d 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -14,6 +14,9 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
 
 obj-y  += xmon.o nonstdio.o spr_access.o
 
+# Disable clang warning for using setjmp without setjmp.h header
+subdir-ccflags-y := $(call cc-disable-warning, builtin-requires-header)
+
 ifdef CONFIG_XMON_DISASSEMBLY
 obj-y  += ppc-dis.o ppc-opc.o
 obj-$(CONFIG_SPU_BASE) += spu-dis.o spu-opc.o
-- 
2.17.1



Re: [PATCH 01/12] powerpc/64s/hash: Fix stab_rr off by one initialization

2018-09-17 Thread Joel Stanley
On Sat, 15 Sep 2018 at 01:03, Nicholas Piggin  wrote:
>
> This causes SLB alloation to start 1 beyond the start of the SLB.
> There is no real problem because after it wraps it stats behaving

starts?

> properly, it's just surprisig to see when looking at SLB traces.

surprising

>
> Signed-off-by: Nicholas Piggin 

> ---
>  arch/powerpc/mm/slb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
> index 9f574e59d178..2f162c6e52d4 100644
> --- a/arch/powerpc/mm/slb.c
> +++ b/arch/powerpc/mm/slb.c
> @@ -355,7 +355,7 @@ void slb_initialize(void)
>  #endif
> }
>
> -   get_paca()->stab_rr = SLB_NUM_BOLTED;
> +   get_paca()->stab_rr = SLB_NUM_BOLTED - 1;
>
> lflags = SLB_VSID_KERNEL | linear_llp;
> vflags = SLB_VSID_KERNEL | vmalloc_llp;
> --
> 2.18.0
>


Re: [PATCH 2/2] powerpc/pseries: Remove VLA from lparcfg_write()

2018-09-16 Thread Joel Stanley
On Wed, 5 Sep 2018 at 11:40, Suraj Jitindar Singh
 wrote:
>
> In lparcfg_write we hard code kbuf_sz and then use this as the variable
> length of kbuf creating a variable length array. Since we're hard coding
> the length anyway just define the array using this as the length and
> remove the need for kbuf_sz, thus removing the variable length array.
>
> Signed-off-by: Suraj Jitindar Singh 

Reviewed-by: Joel Stanley 


Re: [PATCH 1/2] powerpc/prom: Remove VLA in prom_check_platform_support()

2018-09-16 Thread Joel Stanley
On Wed, 5 Sep 2018 at 11:40, Suraj Jitindar Singh
 wrote:
>
> In prom_check_platform_support() we retrieve and parse the
> "ibm,arch-vec-5-platform-support" property of the chosen node.
> Currently we use a variable length array however to avoid this use an
> array of constant length 8.
>
> This property is used to indicate the supported options of vector 5
> bytes 23-26 of the ibm,architecture.vec node. Each of these options
> is a pair of bytes, thus for 4 options we have a max length of 8 bytes.
>
> Signed-off-by: Suraj Jitindar Singh 

Reviewed-by: Joel Stanley 


Re: [PATCH 3/3] powerpc: avoid -mno-sched-epilog on GCC 4.9 and newer

2018-09-16 Thread Joel Stanley
On Fri, 14 Sep 2018 at 14:39, Nicholas Piggin  wrote:
>
> Signed-off-by: Nicholas Piggin 

Reviewed-by: Joel Stanley 

I gave this a spin with clang trunk on the powernv kernel and it did
the trick. Thanks!

mpe, this series supersedes [v2,5/5] powerpc: Remove -mno-sched-epilog
(https://patchwork.ozlabs.org/patch/969615/).

Cheers,

Joel


Re: [PATCH 2/3] powerpc: consolidate -mno-sched-epilog into FTRACE flags

2018-09-16 Thread Joel Stanley
On Fri, 14 Sep 2018 at 14:39, Nicholas Piggin  wrote:
>
> Signed-off-by: Nicholas Piggin 

Reviewed-by: Joel Stanley 


Re: [PATCH 1/3] powerpc: remove old GCC version checks

2018-09-16 Thread Joel Stanley
On Fri, 14 Sep 2018 at 14:39, Nicholas Piggin  wrote:
>
> GCC 4.6 is the minimum supported now.
>
> Signed-off-by: Nicholas Piggin 

Reviewed-by: Joel Stanley 


[PATCH v2 5/5] powerpc: Remove -mno-sched-epilog

2018-09-13 Thread Joel Stanley
This effectively reverts 7563dc645853 ("powerpc: Work around gcc's
-fno-omit-frame-pointer bug"), a workaround for a bug in GCC 4.1.3 when
building 2.6.26 kernel.

The flag is not supported by clang, but reading the history of the
bug[1] suggests it is no longer required by supported GCC versions, with
GCC 4.6 now being the minimum.

[1] https://bugzilla.kernel.org/show_bug.cgi?id=11414
Signed-off-by: Joel Stanley 
---
Last time this was proposed there was an issue reported:

 https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-September/121214.html

If some machines still have an issue, we could instead wrap this in a
flag check.
---
 arch/powerpc/Makefile| 5 -
 arch/powerpc/kernel/Makefile | 8 
 arch/powerpc/kernel/trace/Makefile   | 2 +-
 arch/powerpc/platforms/powermac/Makefile | 2 +-
 arch/powerpc/xmon/Makefile   | 2 +-
 5 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a70639482053..ef8eca40ffef 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -229,11 +229,6 @@ ifdef CONFIG_6xx
 KBUILD_CFLAGS  += -mcpu=powerpc
 endif
 
-# Work around a gcc code-gen bug with -fno-omit-frame-pointer.
-ifdef CONFIG_FUNCTION_TRACER
-KBUILD_CFLAGS  += -mno-sched-epilog
-endif
-
 cpu-as-$(CONFIG_4xx)   += -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)   += $(call as-option,-Wa$(comma)-maltivec)
 cpu-as-$(CONFIG_E200)  += -Wa,-me200
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 3b66f2c19c84..1e64cfe22a83 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -22,10 +22,10 @@ CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
-CFLAGS_REMOVE_cputable.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_prom_init.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_btext.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_prom.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_cputable.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_prom_init.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_btext.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_prom.o = $(CC_FLAGS_FTRACE)
 endif
 
 obj-y  := cputable.o ptrace.o syscalls.o \
diff --git a/arch/powerpc/kernel/trace/Makefile 
b/arch/powerpc/kernel/trace/Makefile
index d22d8bafb643..d868ba42032f 100644
--- a/arch/powerpc/kernel/trace/Makefile
+++ b/arch/powerpc/kernel/trace/Makefile
@@ -7,7 +7,7 @@ subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
 
 ifdef CONFIG_FUNCTION_TRACER
 # do not trace tracer code
-CFLAGS_REMOVE_ftrace.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
 endif
 
 obj32-$(CONFIG_FUNCTION_TRACER)+= ftrace_32.o
diff --git a/arch/powerpc/platforms/powermac/Makefile 
b/arch/powerpc/platforms/powermac/Makefile
index f2839eed0f89..561a67d65e4d 100644
--- a/arch/powerpc/platforms/powermac/Makefile
+++ b/arch/powerpc/platforms/powermac/Makefile
@@ -3,7 +3,7 @@ CFLAGS_bootx_init.o += -fPIC
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not trace early boot code
-CFLAGS_REMOVE_bootx_init.o = -mno-sched-epilog $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_bootx_init.o = $(CC_FLAGS_FTRACE)
 endif
 
 obj-y  += pic.o setup.o time.o feature.o pci.o \
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 1bc3abb237cd..93cc1f1b8b61 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -8,7 +8,7 @@ UBSAN_SANITIZE := n
 
 # Disable ftrace for the entire directory
 ORIG_CFLAGS := $(KBUILD_CFLAGS)
-KBUILD_CFLAGS = $(subst -mno-sched-epilog,,$(subst 
$(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)))
+KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
 
 ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC)
 
-- 
2.17.1



[PATCH v2 4/5] powerpc: Fix duplicate const clang warning in user access code

2018-09-13 Thread Joel Stanley
From: Anton Blanchard 

This re-applies b91c1e3e7a6f which was reverted in f2ca80905929
d466f6c5cac1 f84ed59a612d (powerpc/sparse: Constify the address pointer
...").

We see a large number of duplicate const errors in the user access
code when building with llvm/clang:

  include/linux/pagemap.h:576:8: warning: duplicate 'const' declaration 
specifier
  [-Wduplicate-decl-specifier]
ret = __get_user(c, uaddr);

The problem is we are doing const __typeof__(*(ptr)), which will hit the
warning if ptr is marked const.

Removing const does not seem to have any effect on GCC code generation.

Signed-off-by: Anton Blanchard 
Signed-off-by: Joel Stanley 
---
If we don't want to apply this, other options are suppressing the
warning, or wait for a fix to land in clang
(https://github.com/ClangBuiltLinux/linux/issues/52).
---
 arch/powerpc/include/asm/uaccess.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/uaccess.h 
b/arch/powerpc/include/asm/uaccess.h
index bac225bb7f64..15bea9a0f260 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -260,7 +260,7 @@ do {
\
 ({ \
long __gu_err;  \
__long_type(*(ptr)) __gu_val;   \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
__chk_user_ptr(ptr);\
if (!is_kernel_addr((unsigned long)__gu_addr))  \
might_fault();  \
@@ -274,7 +274,7 @@ do {
\
 ({ \
long __gu_err = -EFAULT;\
__long_type(*(ptr)) __gu_val = 0;   \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
might_fault();  \
if (access_ok(VERIFY_READ, __gu_addr, (size))) {\
barrier_nospec();   \
@@ -288,7 +288,7 @@ do {
\
 ({ \
long __gu_err;  \
__long_type(*(ptr)) __gu_val;   \
-   const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
+   __typeof__(*(ptr)) __user *__gu_addr = (ptr);   \
__chk_user_ptr(ptr);\
barrier_nospec();   \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
-- 
2.17.1



<    1   2   3   >