* Re: [2/9] powerpc/watchdog: fix typo 'can by' to 'can be'
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Wolfram Sang, trivial
Cc: linux-kernel, linux-renesas-soc, Wolfram Sang, Paul Mackerras,
linuxppc-dev
In-Reply-To: <20180506112404.24872-3-wsa+renesas@sang-engineering.com>
On Sun, 2018-05-06 at 11:23:46 UTC, Wolfram Sang wrote:
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/7c18659dd498b25c6651ba83d4267b
cheers
^ permalink raw reply
* Re: [v2, 1/2] powerpc/watchdog: don't update the watchdog timestamp if a lockup is detected
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20180505072600.13270-2-npiggin@gmail.com>
On Sat, 2018-05-05 at 07:25:59 UTC, Nicholas Piggin wrote:
> The watchdog heartbeat timestamp is updated when the local heartbeat
> timer fires (or touch_nmi_watchdog() is called).
>
> This is an interesting data point, so don't overwrite it when the
> soft-NMI interrupt detects a hard lockup. That code came from a pre-
> merge version to prevent hard lockup messages flood, but that's taken
> care of with the stuck CPU logic now, so there is no reason to
> update the heartbeat timestamp here.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/5a951c4e7e8df5d6df52bace1b4ff3
cheers
^ permalink raw reply
* Re: [v3] On ppc64le we HAVE_RELIABLE_STACKTRACE
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Torsten Duwe, Josh Poimboeuf
Cc: linux-kernel, Nicholas Piggin, Jiri Kosina, live-patching,
linuxppc-dev
In-Reply-To: <20180504123834.GA16581@lst.de>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]
On Fri, 2018-05-04 at 12:38:34 UTC, Torsten Duwe wrote:
> The "Power Architecture 64-Bit ELF V2 ABI" says in section 2.3.2.3:
>
> [...] There are several rules that must be adhered to in order to ensure
> reliable and consistent call chain backtracing:
>
> * Before a function calls any other function, it shall establish its
> own stack frame, whose size shall be a multiple of 16 bytes.
>
> – In instances where a function’s prologue creates a stack frame, the
> back-chain word of the stack frame shall be updated atomically with
> the value of the stack pointer (r1) when a back chain is implemented.
> (This must be supported as default by all ELF V2 ABI-compliant
> environments.)
> [...]
> – The function shall save the link register that contains its return
> address in the LR save doubleword of its caller’s stack frame before
> calling another function.
>
> To me this sounds like the equivalent of HAVE_RELIABLE_STACKTRACE.
> This patch may be unneccessarily limited to ppc64le, but OTOH the only
> user of this flag so far is livepatching, which is only implemented on
> PPCs with 64-LE, a.k.a. ELF ABI v2.
>
> Feel free to add other ppc variants, but so far only ppc64le got tested.
>
> This change also implements save_stack_trace_tsk_reliable() for ppc64le
> that checks for the above conditions, where possible.
>
> Signed-off-by: Torsten Duwe <duwe@suse.de>
> Signed-off-by: Nicolai Stange <nstange@suse.de>
> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/df78d3f6148092d33a9a24c7a9cfac
cheers
^ permalink raw reply
* Re: [1/6] powerpc/syscalls: Switch trivial cases to SYSCALL_DEFINE
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: viro, linux-kernel
In-Reply-To: <20180502132051.28861-1-mpe@ellerman.id.au>
On Wed, 2018-05-02 at 13:20:46 UTC, Michael Ellerman wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Series applied to powerpc next.
https://git.kernel.org/powerpc/c/3691d6145585f52a6292c158e72bcd
cheers
^ permalink raw reply
* Re: [v3] powerpc/config: powernv_defconfig updates
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20180430103150.21757-1-npiggin@gmail.com>
On Mon, 2018-04-30 at 10:31:50 UTC, Nicholas Piggin wrote:
> For consideration:
>
> * Add NVDIMM support - Enables greater testing, mambo device.
> * Add IPv6 support built in + additional modules - Because it's 2018 maan.
> * Add DEFERRED_STRUCT_PAGE_INIT - Let's see what breaks.
> * Add PPC_MEMTRACE - Small powernv debugfs driver for getting hardware traces.
> * Add MEMORY_FAILURE - Machine check exceptions can now drive memory failure.
> * Turn on FANOTIFY - This is the current filesystem notification feature.
> * Turn on SCOM_DEBUGFS - Handy for hardware/firmware debugging, security risk?
> * Turn on async SCSI scanning - Let's see what breaks.
> * Add MLX5 driver as a module - Popular demand.
> * Add CRYPTO_CRCT10DIF_VPMSUM - POWER8 T10DIF acceleration.
>
> * Make a bunch of USB hid drivers modules.
> * Make SCSI SG, SR, and FC modules - FC is huge.
> * Make video drivers except AST GPU modules - Also huge.
> * Make PCI serial driver a module - Uncommon.
> * Make more things modules, NFS FS, RAM disk, netconsole, MS-DOS fs.
>
> * Get rid of /dev/port - Not used.
> * Remove PPS and PTP subsystms - Unusual.
> * Remove legacy BSD ttys - Long dead.
> * Remove IDE - Deprecated and replaced with ATA.
> * Remove WIRELESS - Until we get POWER9 laptops.
> * Remove RAW - Long deprecated in favour of direct IO.
> * Remove floppy, parport, and PS2 input devices - not supported.
> * Remove virtio drivers, ballooning - We're host only.
> * Remove PPP - Sorry Paulus.
>
> This results in a significantly smaller vmlinux:
>
> text data bss dec filename
> 13143383 5277944 1317856 19739183 vanilla
> 12263281 4852074 1341720 18457075 patched
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/9a018fb1e14704fef39db05730599f
cheers
^ permalink raw reply
* Re: powerpc: Make it clearer that systbl check errors are errors
From: Michael Ellerman @ 2018-05-10 14:06 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
In-Reply-To: <20180430032736.2862-1-mpe@ellerman.id.au>
On Mon, 2018-04-30 at 03:27:36 UTC, Michael Ellerman wrote:
> If the systbl_chk.sh checks fail we print a message, but with no
> indication that it's an error. That makes it hard to find in build
> logs with eg. grep.
>
> So prefix any output with "Error:".
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/53da14d0833a663cb98ef111ed91c5
cheers
^ permalink raw reply
* [PATCH 9/8] powerpc/pkeys: Drop private VM_PKEY definitions
From: Michael Ellerman @ 2018-05-10 13:54 UTC (permalink / raw)
To: linuxram; +Cc: mingo, linuxppc-dev, linux-mm, x86, linux-kernel, dave.hansen
In-Reply-To: <20180508145948.9492-9-mpe@ellerman.id.au>
Now that we've updated the generic headers to support 5 PKEY bits for
powerpc we don't need our own #defines in arch code.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/include/asm/pkeys.h | 15 ---------------
1 file changed, 15 deletions(-)
One additional patch to finish cleaning things up.
I've added this to my branch.
cheers
diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h
index 18ef59a9886d..5ba80cffb505 100644
--- a/arch/powerpc/include/asm/pkeys.h
+++ b/arch/powerpc/include/asm/pkeys.h
@@ -15,21 +15,6 @@ DECLARE_STATIC_KEY_TRUE(pkey_disabled);
extern int pkeys_total; /* total pkeys as per device tree */
extern u32 initial_allocation_mask; /* bits set for reserved keys */
-/*
- * Define these here temporarily so we're not dependent on patching linux/mm.h.
- * Once it's updated we can drop these.
- */
-#ifndef VM_PKEY_BIT0
-# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
-# define VM_PKEY_BIT0 VM_HIGH_ARCH_0
-# define VM_PKEY_BIT1 VM_HIGH_ARCH_1
-# define VM_PKEY_BIT2 VM_HIGH_ARCH_2
-# define VM_PKEY_BIT3 VM_HIGH_ARCH_3
-# define VM_PKEY_BIT4 VM_HIGH_ARCH_4
-#elif !defined(VM_PKEY_BIT4)
-# define VM_PKEY_BIT4 VM_HIGH_ARCH_4
-#endif
-
#define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \
VM_PKEY_BIT3 | VM_PKEY_BIT4)
--
2.14.1
^ permalink raw reply related
* Re: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
From: Nicholas Piggin @ 2018-05-10 13:24 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linux-kbuild, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510131002.GN17342@gate.crashing.org>
On Thu, 10 May 2018 08:10:03 -0500
Segher Boessenkool <segher@kernel.crashing.org> wrote:
> On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> > The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> > kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> > powerpc machine type and scheduling model. 32-bit platforms and CPUs
> > can override this with -mcpu= options that come later on the command
> > line.
> >
> > This fixes a lot of build failures due to incompatible assembly when
> > compiling 32-bit kernel with 64-bit toolchain.
>
> So what ISA is set for gas without this patch? With what GCC version?
I'm not sure, how do I find that out?
> And, why is that wrong?
Some 32-bit platforms and CPU types do not provide -mcpu, so I assume
for 32-bit toolchains that must result in the "powerpc" machine. With
64-bit toolchains
arch/powerpc/mm/hash_low_32.S:353: Error: missing operand
Which is,
tlbie r4
Is that v2.06?
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2 4/5] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
From: Nicholas Piggin @ 2018-05-10 13:11 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linux-kbuild, Masahiro Yamada, linuxppc-dev
In-Reply-To: <878t8rzmr7.fsf@concordia.ellerman.id.au>
On Thu, 10 May 2018 23:03:08 +1000
Michael Ellerman <mpe@ellerman.id.au> wrote:
> Nicholas Piggin <npiggin@gmail.com> writes:
>
> > The powerpc toolchain can compile combinations of 32/64 bit and
> > big/little endian, so it's convenient to consider, e.g.,
> >
> > `CC -m64 -mbig-endian`
> >
> > To be the C compiler for the purpose of invoking it to build target
> > artifacts. So overriding the the CC variable to include thse flags
> > works for this purpose.
> >
> > Unfortunately that is not compatible with the way the proposed new
> > Kconfig macro language will work.
> >
> > After previous patches in this series, these flags can be carefully
> > passed in using flags instead.
> >
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> > arch/powerpc/Makefile | 16 +++++++++-------
> > scripts/recordmcount.pl | 8 ++++++++
>
> We should probably at least Cc Rostedt on the recordmcount.pl change.
Sure I'll send another iteration after some more time for reviews and
cc him on it.
>
> > diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> > index 191eb949d52c..919711dd9d6c 100755
> > --- a/scripts/recordmcount.pl
> > +++ b/scripts/recordmcount.pl
> > @@ -274,6 +274,14 @@ if ($arch eq "x86_64") {
>
> Despite what the above says you're patching the powerpc entry AFAICS, so
> I guess that's pretty harmless.
Yeah I didn't think it was worth a separate patch.
>
> > if ($bits == 64) {
> > $type = ".quad";
> > }
> > + $ld .= " -EB ";
> > + if ($endian eq "big") {
> > + $cc .= " -mbig-endian ";
> > + $ld .= " -EB ";
>
> Don't we end up with two "-EB"s for the big endian case?
>
> Or do I understand perl even less than I thought I did?
No I was testing things and that's leaked into the commit. Good eye. I
think it worked for le because the next -EL will override the first -EB,
but I'll take that out.
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
From: Segher Boessenkool @ 2018-05-10 13:10 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: linux-kbuild, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-2-npiggin@gmail.com>
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
> The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> powerpc machine type and scheduling model. 32-bit platforms and CPUs
> can override this with -mcpu= options that come later on the command
> line.
>
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with 64-bit toolchain.
So what ISA is set for gas without this patch? With what GCC version?
And, why is that wrong?
Segher
> +ifdef CONFIG_PPC32
> +# These options will be overridden by any -mcpu option that comes
> +# later on the command line, but they are needed to set a sane
> +# 32-bit cpu target for the 64-bit cross compiler.
> +KBUILD_CFLAGS += -mcpu=powerpc
> +KBUILD_AFLAGS += -mcpu=powerpc
> +endif
^ permalink raw reply
* [PATCH] powerpc/powernv: Fix memtrace build when NUMA=n
From: Michael Ellerman @ 2018-05-10 13:09 UTC (permalink / raw)
To: linuxppc-dev; +Cc: rashmica.g, anton
Currently memtrace doesn't build if NUMA=n:
In function ‘memtrace_alloc_node’:
arch/powerpc/platforms/powernv/memtrace.c:134:6:
error: the address of ‘contig_page_data’ will always evaluate as ‘true’
if (!NODE_DATA(nid) || !node_spanned_pages(nid))
^
This is because for NUMA=n NODE_DATA(nid) points to an always
allocated structure, contig_page_data.
But even in the NUMA=y case memtrace_alloc_node() is only called for
online nodes, and we should always have a NODE_DATA() allocated for an
online node. So remove the (hopefully) overly paranoid check, which
also means we can build when NUMA=n.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/powernv/memtrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index fc222a0c2ac4..b99283df8584 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -131,7 +131,7 @@ static u64 memtrace_alloc_node(u32 nid, u64 size)
u64 start_pfn, end_pfn, nr_pages;
u64 base_pfn;
- if (!NODE_DATA(nid) || !node_spanned_pages(nid))
+ if (!node_spanned_pages(nid))
return 0;
start_pfn = node_start_pfn(nid);
--
2.14.1
^ permalink raw reply related
* Re: [PATCH v2 4/5] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
From: Michael Ellerman @ 2018-05-10 13:03 UTC (permalink / raw)
To: Nicholas Piggin, linux-kbuild
Cc: Masahiro Yamada, linuxppc-dev, Nicholas Piggin
In-Reply-To: <20180510051659.15356-5-npiggin@gmail.com>
Nicholas Piggin <npiggin@gmail.com> writes:
> The powerpc toolchain can compile combinations of 32/64 bit and
> big/little endian, so it's convenient to consider, e.g.,
>
> `CC -m64 -mbig-endian`
>
> To be the C compiler for the purpose of invoking it to build target
> artifacts. So overriding the the CC variable to include thse flags
> works for this purpose.
>
> Unfortunately that is not compatible with the way the proposed new
> Kconfig macro language will work.
>
> After previous patches in this series, these flags can be carefully
> passed in using flags instead.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/Makefile | 16 +++++++++-------
> scripts/recordmcount.pl | 8 ++++++++
We should probably at least Cc Rostedt on the recordmcount.pl change.
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 191eb949d52c..919711dd9d6c 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -274,6 +274,14 @@ if ($arch eq "x86_64") {
Despite what the above says you're patching the powerpc entry AFAICS, so
I guess that's pretty harmless.
> if ($bits == 64) {
> $type = ".quad";
> }
> + $ld .= " -EB ";
> + if ($endian eq "big") {
> + $cc .= " -mbig-endian ";
> + $ld .= " -EB ";
Don't we end up with two "-EB"s for the big endian case?
Or do I understand perl even less than I thought I did?
> + } else {
> + $cc .= " -mlittle-endian ";
> + $ld .= " -EL ";
> + }
>
> } elsif ($arch eq "arm") {
> $alignment = 2;
cheers
^ permalink raw reply
* [PATCH] powerpc/powernv: call OPAL_QUIESCE before OPAL_SIGNAL_SYSTEM_RESET
From: Nicholas Piggin @ 2018-05-10 12:21 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nicholas Piggin
Although it is often possible to recover a CPU that was interrupted
from OPAL with a system reset NMI, it's undesirable to interrupt them
for a few reasons. Firstly because dump/debug code itself needs to
call firmware, so it could hang on a lock or possibly corrupt a
per-cpu data structure if it or another CPU was interrupted from
OPAL. Secondly, the kexec crash dump code will not return from
interrupt to unwind the OPAL call.
Call OPAL_QUIESCE with QUIESCE_HOLD before sending an NMI IPI to
another CPU, which wait for it to leave firmware (or time out) to
avoid this problem in normal conditions. Firmware bugs may still
result in a timeout and interrupting OPAL, but that is the best
option (stops the CPU, and possibly allows firmware to be debugged).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/include/asm/opal-api.h | 7 +++++++
arch/powerpc/include/asm/opal.h | 1 +
arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
arch/powerpc/platforms/powernv/smp.c | 17 ++++++++++++++++-
4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index d886a5b7ff21..f523c72d845f 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -201,6 +201,7 @@
#define OPAL_SET_POWER_SHIFT_RATIO 155
#define OPAL_SENSOR_GROUP_CLEAR 156
#define OPAL_PCI_SET_P2P 157
+#define OPAL_QUIESCE 158
#define OPAL_NPU_SPA_SETUP 159
#define OPAL_NPU_SPA_CLEAR_CACHE 160
#define OPAL_NPU_TL_SET 161
@@ -208,6 +209,12 @@
#define OPAL_PCI_SET_PBCQ_TUNNEL_BAR 165
#define OPAL_LAST 165
+#define QUIESCE_HOLD 1 /* Spin all calls at entry */
+#define QUIESCE_REJECT 2 /* Fail all calls with OPAL_BUSY */
+#define QUIESCE_LOCK_BREAK 3 /* Set to ignore locks. */
+#define QUIESCE_RESUME 4 /* Un-quiesce */
+#define QUIESCE_RESUME_FAST_REBOOT 5 /* Un-quiesce, fast reboot */
+
/* Device tree flags */
/*
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 03e1a920491e..aa677a45dafe 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -293,6 +293,7 @@ int opal_set_power_shift_ratio(u32 handle, int token, u32 psr);
int opal_sensor_group_clear(u32 group_hndl, int token);
s64 opal_signal_system_reset(s32 cpu);
+s64 opal_quiesce(u64 shutdown_type, s32 cpu);
/* Internal functions */
extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 3da30c2f26b4..5eb1466665a4 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -320,6 +320,7 @@ OPAL_CALL(opal_set_powercap, OPAL_SET_POWERCAP);
OPAL_CALL(opal_get_power_shift_ratio, OPAL_GET_POWER_SHIFT_RATIO);
OPAL_CALL(opal_set_power_shift_ratio, OPAL_SET_POWER_SHIFT_RATIO);
OPAL_CALL(opal_sensor_group_clear, OPAL_SENSOR_GROUP_CLEAR);
+OPAL_CALL(opal_quiesce, OPAL_QUIESCE);
OPAL_CALL(opal_npu_spa_setup, OPAL_NPU_SPA_SETUP);
OPAL_CALL(opal_npu_spa_clear_cache, OPAL_NPU_SPA_CLEAR_CACHE);
OPAL_CALL(opal_npu_tl_set, OPAL_NPU_TL_SET);
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 19af6de6b6f0..b80909957792 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -334,7 +334,16 @@ static int pnv_cause_nmi_ipi(int cpu)
int64_t rc;
if (cpu >= 0) {
- rc = opal_signal_system_reset(get_hard_smp_processor_id(cpu));
+ int h = get_hard_smp_processor_id(cpu);
+
+ if (opal_check_token(OPAL_QUIESCE))
+ opal_quiesce(QUIESCE_HOLD, h);
+
+ rc = opal_signal_system_reset(h);
+
+ if (opal_check_token(OPAL_QUIESCE))
+ opal_quiesce(QUIESCE_RESUME, h);
+
if (rc != OPAL_SUCCESS)
return 0;
return 1;
@@ -343,6 +352,8 @@ static int pnv_cause_nmi_ipi(int cpu)
bool success = true;
int c;
+ if (opal_check_token(OPAL_QUIESCE))
+ opal_quiesce(QUIESCE_HOLD, -1);
/*
* We do not use broadcasts (yet), because it's not clear
@@ -358,6 +369,10 @@ static int pnv_cause_nmi_ipi(int cpu)
if (rc != OPAL_SUCCESS)
success = false;
}
+
+ if (opal_check_token(OPAL_QUIESCE))
+ opal_quiesce(QUIESCE_RESUME, -1);
+
if (success)
return 1;
--
2.17.0
^ permalink raw reply related
* Re: [Skiboot] [PATCH 1/2] SLW: Remove stop1_lite and stop0 stop states
From: Nicholas Piggin @ 2018-05-10 10:02 UTC (permalink / raw)
To: Akshay Adiga; +Cc: Stewart Smith, skiboot, linuxppc-dev
In-Reply-To: <20180510085944.nllmwgeegifgh4kb@aksadiga.ibm>
On Thu, 10 May 2018 14:29:44 +0530
Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> wrote:
> On Thu, May 03, 2018 at 08:15:59PM +1000, Nicholas Piggin wrote:
> > On Thu, 03 May 2018 20:03:55 +1000
> > Stewart Smith <stewart@linux.vnet.ibm.com> wrote:
> >
> > > Nicholas Piggin <npiggin@gmail.com> writes:
> > > > On Thu, 3 May 2018 14:36:47 +0530
> > > > Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> wrote:
> > > >
> > > >> On Tue, May 01, 2018 at 01:47:23PM +1000, Nicholas Piggin wrote:
> > > >> > On Mon, 30 Apr 2018 14:42:08 +0530
> > > >> > Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> wrote:
> > > >> >
> > > >> > > Powersaving for stop0_lite and stop1_lite is observed to be quite similar
> > > >> > > and both states resume without state loss. Using context_switch test [1]
> > > >> > > we observe that stop0_lite has slightly lower latency, hence removing
> > > >> > > stop1_lite.
> > > >> > >
> > > >> > > [1] linux/tools/testing/selftests/powerpc/benchmarks/context_switch.c
> > > >> > >
> > > >> > > Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
> > > >> >
> > > >> > I'm okay for removing stop1_lite and stop2_lite -- SMT switching
> > > >> > is very latency critical. If we decide to actually start saving
> > > >> > real power then SMT should already have been switched.
> > > >> >
> > > >> > So I would put stop1_lite and stop2_lite removal in the same patch.
> > > >>
> > > >> I can do this.
> > > >>
> > > >> >
> > > >> > Then what do we have? stop0_lite, stop0, stop1 for our fast idle
> > > >> > states.
> > > >>
> > > >> Currently we were looking at stop0_lite , stop1 as the fast idle states
> > > >> because stop0 and stop1 have similar latency and powersaving.
> > > >> Having so many low latency states does not make sense.
> > > >>
> > > >> >
> > > >> > I would be against removing stop0 if that is our fastest way to
> > > >> > release SMT resources, even if there is only a small advantage. Why
> > > >> > not remove stop1 instead?
> > > >> >
> > > >> SMT-folding comes into picture only when we have at least one thread
> > > >> running in the core. stop0 and stop1 has exactly same power-saving and
> > > >> both will release SMT resources if at least one thread in the core is
> > > >> running.
> > > >
> > > > Right, but you don't know that other threads are running or will remain
> > > > running when you enter stop. If not, then latency is higher for stop1,
> > > > no? So we need to be using stop0.
> > > >
> > > >>
> > > >> As soon as all threads are idle core enters stop0/stop1, where stop1
> > > >> does a bit more powersaving than stop0.
> > > >>
> > > >> > We also need to better evaluate stop0_lite. How much advantage does
> > > >> > that have over snooze?
> > > >>
> > > >> I evaluated snooze and stop0_lite, there is an additional ipi latency of
> > > >> a few microseconds in case of stop0_lite. So snooze cannot still be
> > > >> replaced by stop0_lite.
> > > >
> > > > I meant the other way around. Replace stop0_lite with snooze.
> > > >
> > > > So we would have snooze, stop0, stop2, and stop4 and/or 5.
> > >
> > > Slightly stupid question: should we be disabling these here or should
> > > Linux be better and deciding what states to use?
> >
> > Yeah not a bad question, I don't have a good answer. I don't know how
> > smart Linux is at deciding what to use and when.
> >
> > I am pretty sure the way we set our _lite states wrong -- we don't
> > want to go into stop2_lite as a deeper sleep state than stop0 for
> > example, because that then prevents SMT folding.
>
> I think we should keep both stop0 and stop1, i was not able to get
> a good enough reason to remove stop0.
>
> I a diffrent patch we need to tweak residencies so that we can bias
> to more useful stop states.
>
Well I would say stop1_lite and stop2_lite should not be used if we
have stop0_lite, particularly they should not be used after stop0 in
the case that we have SMT enabled. If SMT is disabled then possibly
we could use the _lite states instead.
So we need some way to advertise and respond to that in Linux.
After that I guess it's a matter of measuring and tuning the others.
I think between snooze and stop0, it is an open question whether it
is worth using stop0_lite.
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH 2/2] KVM: PPC: Book3S HV: lockless tlbie for HPT hcalls
From: Paul Mackerras @ 2018-05-10 5:30 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Nicholas Piggin, kvm-ppc, linuxppc-dev
In-Reply-To: <87a7ugeucv.fsf@concordia.ellerman.id.au>
On Fri, Apr 06, 2018 at 04:12:32PM +1000, Michael Ellerman wrote:
> Nicholas Piggin <npiggin@gmail.com> writes:
> > diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> > index 78e6a392330f..0221a0f74f07 100644
> > --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> > +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
> > @@ -439,6 +439,9 @@ static inline int try_lock_tlbie(unsigned int *lock)
> > unsigned int tmp, old;
> > unsigned int token = LOCK_TOKEN;
> >
> > + if (mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
> > + return 1;
> > +
> > asm volatile("1:lwarx %1,0,%2\n"
> > " cmpwi cr0,%1,0\n"
> > " bne 2f\n"
> > @@ -452,6 +455,12 @@ static inline int try_lock_tlbie(unsigned int *lock)
> > return old == 0;
> > }
> >
> > +static inline void unlock_tlbie_after_sync(unsigned int *lock)
> > +{
> > + if (mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
> > + return;
> > +}
>
> So this is a bit hard to follow:
>
> #define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \
> MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2
> #define MMU_FTRS_POWER MMU_FTRS_DEFAULT_HPTE_ARCH_V2
> #define MMU_FTRS_PPC970 MMU_FTRS_POWER | MMU_FTR_TLBIE_CROP_VA // does NOT
> #define MMU_FTRS_POWER5 MMU_FTRS_POWER | MMU_FTR_LOCKLESS_TLBIE
> #define MMU_FTRS_POWER6 MMU_FTRS_POWER5 | MMU_FTR_KERNEL_RO | MMU_FTR_68_BIT_VA // includes lockless TLBIE
> #define MMU_FTRS_POWER7 MMU_FTRS_POWER6 // includes lockless TLBIE
> #define MMU_FTRS_POWER8 MMU_FTRS_POWER6 // includes lockless TLBIE
> #define MMU_FTRS_POWER9 MMU_FTRS_POWER6 // includes lockless TLBIE
> #define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | // does NOT
> MMU_FTR_CI_LARGE_PAGE
> #define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ // does NOT
> MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B
>
>
> So it's only 970, Cell and Pasemi that *don't* have lockless TLBIE.
>
> And KVM HV doesn't doesn't run on any of those.
>
> So we can just not check for the feature in the KVM HV code.
>
> Am I right?
Yes; that code was written when we still supported HV KVM on 970,
but we ripped that out some time ago.
Paul.
^ permalink raw reply
* Re: [Skiboot] [PATCH 1/2] SLW: Remove stop1_lite and stop0 stop states
From: Akshay Adiga @ 2018-05-10 8:59 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: Stewart Smith, skiboot, linuxppc-dev
In-Reply-To: <20180503201559.0aac84ca@roar.ozlabs.ibm.com>
On Thu, May 03, 2018 at 08:15:59PM +1000, Nicholas Piggin wrote:
> On Thu, 03 May 2018 20:03:55 +1000
> Stewart Smith <stewart@linux.vnet.ibm.com> wrote:
>
> > Nicholas Piggin <npiggin@gmail.com> writes:
> > > On Thu, 3 May 2018 14:36:47 +0530
> > > Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> wrote:
> > >
> > >> On Tue, May 01, 2018 at 01:47:23PM +1000, Nicholas Piggin wrote:
> > >> > On Mon, 30 Apr 2018 14:42:08 +0530
> > >> > Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> wrote:
> > >> >
> > >> > > Powersaving for stop0_lite and stop1_lite is observed to be quite similar
> > >> > > and both states resume without state loss. Using context_switch test [1]
> > >> > > we observe that stop0_lite has slightly lower latency, hence removing
> > >> > > stop1_lite.
> > >> > >
> > >> > > [1] linux/tools/testing/selftests/powerpc/benchmarks/context_switch.c
> > >> > >
> > >> > > Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
> > >> >
> > >> > I'm okay for removing stop1_lite and stop2_lite -- SMT switching
> > >> > is very latency critical. If we decide to actually start saving
> > >> > real power then SMT should already have been switched.
> > >> >
> > >> > So I would put stop1_lite and stop2_lite removal in the same patch.
> > >>
> > >> I can do this.
> > >>
> > >> >
> > >> > Then what do we have? stop0_lite, stop0, stop1 for our fast idle
> > >> > states.
> > >>
> > >> Currently we were looking at stop0_lite , stop1 as the fast idle states
> > >> because stop0 and stop1 have similar latency and powersaving.
> > >> Having so many low latency states does not make sense.
> > >>
> > >> >
> > >> > I would be against removing stop0 if that is our fastest way to
> > >> > release SMT resources, even if there is only a small advantage. Why
> > >> > not remove stop1 instead?
> > >> >
> > >> SMT-folding comes into picture only when we have at least one thread
> > >> running in the core. stop0 and stop1 has exactly same power-saving and
> > >> both will release SMT resources if at least one thread in the core is
> > >> running.
> > >
> > > Right, but you don't know that other threads are running or will remain
> > > running when you enter stop. If not, then latency is higher for stop1,
> > > no? So we need to be using stop0.
> > >
> > >>
> > >> As soon as all threads are idle core enters stop0/stop1, where stop1
> > >> does a bit more powersaving than stop0.
> > >>
> > >> > We also need to better evaluate stop0_lite. How much advantage does
> > >> > that have over snooze?
> > >>
> > >> I evaluated snooze and stop0_lite, there is an additional ipi latency of
> > >> a few microseconds in case of stop0_lite. So snooze cannot still be
> > >> replaced by stop0_lite.
> > >
> > > I meant the other way around. Replace stop0_lite with snooze.
> > >
> > > So we would have snooze, stop0, stop2, and stop4 and/or 5.
> >
> > Slightly stupid question: should we be disabling these here or should
> > Linux be better and deciding what states to use?
>
> Yeah not a bad question, I don't have a good answer. I don't know how
> smart Linux is at deciding what to use and when.
>
> I am pretty sure the way we set our _lite states wrong -- we don't
> want to go into stop2_lite as a deeper sleep state than stop0 for
> example, because that then prevents SMT folding.
I think we should keep both stop0 and stop1, i was not able to get
a good enough reason to remove stop0.
I a diffrent patch we need to tweak residencies so that we can bias
to more useful stop states.
^ permalink raw reply
* Re: [PATCH v2 3/5] kbuild: call cc-option with the current set of KBUILD_CFLAGS
From: Nicholas Piggin @ 2018-05-10 6:09 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, linuxppc-dev
In-Reply-To: <CAK7LNATnJ_xi7nFLA5-MeP=86bK19Z9-L=muCW8LKoDYBpDHGA@mail.gmail.com>
On Thu, 10 May 2018 14:29:49 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> 2018-05-10 14:16 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> > In some cases, the options that gcc will accept depend on options it
> > has already been given. For example -m32 / -m64 and -mbig-endian /
> > -mlittle-endian can have this affect.
>
> Is cc-option not working for you?
I thought it wasn't, but now I try again and it does work, sorry for
the noise. The bug must have been something in my previous series.
This series seems to work just as well after I remove this patch.
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2 3/5] kbuild: call cc-option with the current set of KBUILD_CFLAGS
From: Masahiro Yamada @ 2018-05-10 5:29 UTC (permalink / raw)
To: Nicholas Piggin; +Cc: Linux Kbuild mailing list, linuxppc-dev
In-Reply-To: <20180510051659.15356-4-npiggin@gmail.com>
2018-05-10 14:16 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> In some cases, the options that gcc will accept depend on options it
> has already been given. For example -m32 / -m64 and -mbig-endian /
> -mlittle-endian can have this affect.
Is cc-option not working for you?
> Passing in KBUILD_CFLAGS to cc-option allows an architecture to
> set such basic machine types at the beginning, rather than override
> CC itself.
KBUILD_CFLAGS is passed to cc-option already
because CC_OPTION_CFLAGS includes it:
CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
This patch drops KBUILD_CPPFLAGS,
and adds KBUILD_CFLAGS twice, doesn't it?
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> scripts/Kbuild.include | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index 9f7eb10079cc..66869bb815d2 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -121,7 +121,7 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
> # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
>
> cc-option = $(call __cc-option, $(CC),\
> - $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
> + $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
>
> # hostcc-option
> # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
> @@ -131,12 +131,12 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\
> # cc-option-yn
> # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
> cc-option-yn = $(call try-run,\
> - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
> + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
>
> # cc-disable-warning
> # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
> cc-disable-warning = $(call try-run,\
> - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
> + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>
> # cc-name
> # Expands to either gcc or clang
> @@ -160,7 +160,7 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo
> # cc-ldoption
> # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
> cc-ldoption = $(call try-run,\
> - $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
> + $(CC) $(1) $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
>
> # ld-option
> # Usage: LDFLAGS += $(call ld-option, -X)
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Best Regards
Masahiro Yamada
^ permalink raw reply
* Re: [PATCH] powerpc/kbuild: set generic machine type for compile with 64-bit toolchain
From: Nicholas Piggin @ 2018-05-10 5:18 UTC (permalink / raw)
To: linuxppc-dev
In-Reply-To: <20180510002637.3069-1-npiggin@gmail.com>
On Thu, 10 May 2018 10:26:37 +1000
Nicholas Piggin <npiggin@gmail.com> wrote:
> The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
> kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
> powerpc machine type and scheduling model. 32-bit platforms and CPUs
> can override this with -mcpu= options that come later on the command
> line.
>
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with 64-bit toolchain.
Actually ignore this patch, it had a few other problems. I'll send a new
version out.
Thanks,
Nick
^ permalink raw reply
* [PATCH v2 5/5] powerpc/kbuild: move -mprofile-kernel check to Kconfig
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-1-npiggin@gmail.com>
This eliminates the workaround that requires disabling
-mprofile-kernel by default in Kconfig.
[ Note: this depends on https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kconfig-shell-v3 ]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Kconfig | 16 +---------------
arch/powerpc/Makefile | 14 ++------------
arch/powerpc/tools/gcc-check-mprofile-kernel.sh | 4 ++--
3 files changed, 5 insertions(+), 29 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 512fcc177c87..af527f894f9b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -460,23 +460,9 @@ config LD_HEAD_STUB_CATCH
If unsure, say "N".
-config DISABLE_MPROFILE_KERNEL
- bool "Disable use of mprofile-kernel for kernel tracing"
- depends on PPC64 && CPU_LITTLE_ENDIAN
- default y
- help
- Selecting this options disables use of the mprofile-kernel ABI for
- kernel tracing. That will cause options such as live patching
- (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to
- be disabled also.
-
- If you have a toolchain which supports mprofile-kernel, then you can
- disable this. Otherwise leave it enabled. If you're not sure, say
- "Y".
-
config MPROFILE_KERNEL
depends on PPC64 && CPU_LITTLE_ENDIAN
- def_bool !DISABLE_MPROFILE_KERNEL
+ def_bool $(success $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
config IOMMU_HELPER
def_bool PPC64
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 5f3ec8029e50..9f69b1599c61 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -156,18 +156,8 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
endif
ifdef CONFIG_MPROFILE_KERNEL
- ifeq ($(shell $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK)
- CC_FLAGS_FTRACE := -pg -mprofile-kernel
- KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL
- else
- # If the user asked for mprofile-kernel but the toolchain doesn't
- # support it, emit a warning and deliberately break the build later
- # with mprofile-kernel-not-supported. We would prefer to make this an
- # error right here, but then the user would never be able to run
- # oldconfig to change their configuration.
- $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL)
- CC_FLAGS_FTRACE := -mprofile-kernel-not-supported
- endif
+ CC_FLAGS_FTRACE := -pg -mprofile-kernel
+ KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL
endif
CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
diff --git a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
index 061f8035bdbe..ec4486a9c4a3 100755
--- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
+++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
@@ -10,13 +10,13 @@ set -o pipefail
# Test whether the compile option -mprofile-kernel exists and generates
# profiling code (ie. a call to _mcount()).
echo "int func() { return 0; }" | \
- $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
+ $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
grep -q "_mcount"
# Test whether the notrace attribute correctly suppresses calls to _mcount().
echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
- $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
+ $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
grep -q "_mcount" && \
exit 1
--
2.17.0
^ permalink raw reply related
* [PATCH v2 4/5] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-1-npiggin@gmail.com>
The powerpc toolchain can compile combinations of 32/64 bit and
big/little endian, so it's convenient to consider, e.g.,
`CC -m64 -mbig-endian`
To be the C compiler for the purpose of invoking it to build target
artifacts. So overriding the the CC variable to include thse flags
works for this purpose.
Unfortunately that is not compatible with the way the proposed new
Kconfig macro language will work.
After previous patches in this series, these flags can be carefully
passed in using flags instead.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Makefile | 16 +++++++++-------
scripts/recordmcount.pl | 8 ++++++++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a40f59ca2afe..5f3ec8029e50 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -70,13 +70,15 @@ endif
endif
ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
-override LD += -EL
+KBUILD_CFLAGS += -mlittle-endian
+LDFLAGS += -EL
LDEMULATION := lppc
GNUTARGET := powerpcle
MULTIPLEWORD := -mno-multiple
KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
else
-override LD += -EB
+KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
+LDFLAGS += -EB
LDEMULATION := ppc
GNUTARGET := powerpc
MULTIPLEWORD := -mmultiple
@@ -89,19 +91,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
endif
-cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
ifneq ($(cc-name),clang)
cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
endif
+cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
ifeq ($(HAS_BIARCH),y)
-override AS += -a$(BITS)
-override LD += -m elf$(BITS)$(LDEMULATION)
-override CC += -m$(BITS)
+KBUILD_CFLAGS += -m$(BITS)
+KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
+LDFLAGS += -m elf$(BITS)$(LDEMULATION)
KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
endif
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 191eb949d52c..919711dd9d6c 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -274,6 +274,14 @@ if ($arch eq "x86_64") {
if ($bits == 64) {
$type = ".quad";
}
+ $ld .= " -EB ";
+ if ($endian eq "big") {
+ $cc .= " -mbig-endian ";
+ $ld .= " -EB ";
+ } else {
+ $cc .= " -mlittle-endian ";
+ $ld .= " -EL ";
+ }
} elsif ($arch eq "arm") {
$alignment = 2;
--
2.17.0
^ permalink raw reply related
* [PATCH v2 3/5] kbuild: call cc-option with the current set of KBUILD_CFLAGS
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-1-npiggin@gmail.com>
In some cases, the options that gcc will accept depend on options it
has already been given. For example -m32 / -m64 and -mbig-endian /
-mlittle-endian can have this affect.
Passing in KBUILD_CFLAGS to cc-option allows an architecture to
set such basic machine types at the beginning, rather than override
CC itself.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
scripts/Kbuild.include | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 9f7eb10079cc..66869bb815d2 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -121,7 +121,7 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
cc-option = $(call __cc-option, $(CC),\
- $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
+ $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2))
# hostcc-option
# Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
@@ -131,12 +131,12 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\
# cc-option-yn
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
cc-option-yn = $(call try-run,\
- $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
+ $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
# cc-disable-warning
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
cc-disable-warning = $(call try-run,\
- $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+ $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
# cc-name
# Expands to either gcc or clang
@@ -160,7 +160,7 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo
# cc-ldoption
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
cc-ldoption = $(call try-run,\
- $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+ $(CC) $(1) $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
# ld-option
# Usage: LDFLAGS += $(call ld-option, -X)
--
2.17.0
^ permalink raw reply related
* [PATCH v2 2/5] powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-1-npiggin@gmail.com>
Switch VDSO32 build over to use CROSS32_COMPILE directly, and have
it pass in -m32 after the standard c_flags. This allows endianness
overrides to be removed and the endian and bitness flags moved into
standard flags variables.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Makefile | 12 ------------
arch/powerpc/boot/Makefile | 16 +++++++++++-----
arch/powerpc/kernel/vdso32/Makefile | 15 +++++++++++----
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 7034b1ad50e0..a40f59ca2afe 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -17,16 +17,6 @@ HAS_BIARCH := $(call cc-option-yn, -m32)
# Set default 32 bits cross compilers for vdso and boot wrapper
CROSS32_COMPILE ?=
-CROSS32CC := $(CROSS32_COMPILE)gcc
-CROSS32AR := $(CROSS32_COMPILE)ar
-
-ifeq ($(HAS_BIARCH),y)
-ifeq ($(CROSS32_COMPILE),)
-CROSS32CC := $(CC) -m32
-KBUILD_ARFLAGS += --target=elf32-powerpc
-endif
-endif
-
ifdef CONFIG_PPC32
# These options will be overridden by any -mcpu option that comes
# later on the command line, but they are needed to set a sane
@@ -35,8 +25,6 @@ KBUILD_CFLAGS += -mcpu=powerpc
KBUILD_AFLAGS += -mcpu=powerpc
endif
-export CROSS32CC CROSS32AR
-
ifeq ($(CROSS_COMPILE),)
KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
else
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 26d5d2a5b8e9..49767e06202c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -23,19 +23,23 @@ all: $(obj)/zImage
compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP
compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ
+ifdef CROSS32_COMPILE
+ BOOTCC := $(CROSS32_COMPILE)gcc
+ BOOTAR := $(CROSS32_COMPILE)ar
+else
+ BOOTCC := $(CC)
+ BOOTAR := $(AR)
+endif
+
BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -Os -msoft-float -pipe \
-fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
-D$(compress-y)
-BOOTCC := $(CC)
ifdef CONFIG_PPC64_BOOT_WRAPPER
BOOTCFLAGS += -m64
else
BOOTCFLAGS += -m32
-ifdef CROSS32_COMPILE
- BOOTCC := $(CROSS32_COMPILE)gcc
-endif
endif
BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
@@ -49,6 +53,8 @@ endif
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
+BOOTARFLAGS := -cr$(KBUILD_ARFLAGS)
+
ifdef CONFIG_DEBUG_INFO
BOOTCFLAGS += -g
endif
@@ -202,7 +208,7 @@ quiet_cmd_bootas = BOOTAS $@
cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
quiet_cmd_bootar = BOOTAR $@
- cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
+ cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
$(call if_changed_dep,bootcc)
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index b8c434d1d459..50112d4473bb 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -8,8 +8,15 @@ obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \
# Build rules
-ifeq ($(CONFIG_PPC32),y)
-CROSS32CC := $(CC)
+ifdef CROSS32_COMPILE
+ VDSOCC := $(CROSS32_COMPILE)gcc
+else
+ VDSOCC := $(CC)
+endif
+
+CC32FLAGS :=
+ifdef CONFIG_PPC64
+CC32FLAGS += -m32
endif
targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
@@ -45,9 +52,9 @@ $(obj-vdso32): %.o: %.S FORCE
# actual build commands
quiet_cmd_vdso32ld = VDSO32L $@
- cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
+ cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
quiet_cmd_vdso32as = VDSO32A $@
- cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
+ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
# install commands for the unstripped file
quiet_cmd_vdso_install = INSTALL $@
--
2.17.0
^ permalink raw reply related
* [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
In-Reply-To: <20180510051659.15356-1-npiggin@gmail.com>
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit
kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit
powerpc machine type and scheduling model. 32-bit platforms and CPUs
can override this with -mcpu= options that come later on the command
line.
This fixes a lot of build failures due to incompatible assembly when
compiling 32-bit kernel with 64-bit toolchain.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Makefile | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 95813df90801..7034b1ad50e0 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -27,6 +27,14 @@ KBUILD_ARFLAGS += --target=elf32-powerpc
endif
endif
+ifdef CONFIG_PPC32
+# These options will be overridden by any -mcpu option that comes
+# later on the command line, but they are needed to set a sane
+# 32-bit cpu target for the 64-bit cross compiler.
+KBUILD_CFLAGS += -mcpu=powerpc
+KBUILD_AFLAGS += -mcpu=powerpc
+endif
+
export CROSS32CC CROSS32AR
ifeq ($(CROSS_COMPILE),)
--
2.17.0
^ permalink raw reply related
* [PATCH v2 0/5] kbuild and powerpc patches for new Kconfig language
From: Nicholas Piggin @ 2018-05-10 5:16 UTC (permalink / raw)
To: linux-kbuild; +Cc: Nicholas Piggin, Masahiro Yamada, linuxppc-dev
I came back to these patches and I think I have solved the remaining
problems -- it now builds with 64-bit big and little endian (using a
le toolchain), and also 32-bit big using 64le toolchain. There might
be some build failures still left, but it seems to be in much better
shape now.
Reviews would be welcome. I don't quite know how it should be merged,
maybe via the kbuild tree after acks from powerpc maintainer. We can
decide that after it gets more testing and review.
Thanks,
Nick
Nicholas Piggin (5):
powerpc/kbuild: set default generic machine type for 32-bit compile
powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
kbuild: call cc-option with the current set of KBUILD_CFLAGS
powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
powerpc/kbuild: move -mprofile-kernel check to Kconfig
arch/powerpc/Kconfig | 16 +------
arch/powerpc/Makefile | 46 +++++++------------
arch/powerpc/boot/Makefile | 16 +++++--
arch/powerpc/kernel/vdso32/Makefile | 15 ++++--
.../tools/gcc-check-mprofile-kernel.sh | 4 +-
scripts/Kbuild.include | 8 ++--
scripts/recordmcount.pl | 8 ++++
7 files changed, 54 insertions(+), 59 deletions(-)
--
2.17.0
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox