* [PATCH v3] powerpc/lib: implement strlen() in assembly
From: Christophe Leroy @ 2018-05-30 8:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, segher
Cc: linux-kernel, linuxppc-dev
The generic implementation of strlen() reads strings byte per byte.
This patch implements strlen() in assembly based on a read of entire
words, in the same spirit as what some other arches and glibc do.
On a 8xx the time spent in strlen is reduced by 50-60% for long strings.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
Not tested on PPC64.
To avoid trivial conflict, apply on top of serie "[v6 0/2] powerpc/lib: Optimisation of memcmp() and __clear_user() for PPC32".
Changes in v3:
- Made it common to PPC32 and PPC64
Changes in v2:
- Moved handling of unaligned strings outside of the main path as it is very unlikely.
- Removed the verification of the fourth byte in case none of the three first ones are NUL.
arch/powerpc/include/asm/asm-compat.h | 4 +++
arch/powerpc/include/asm/string.h | 1 +
arch/powerpc/lib/string.S | 55 +++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 7f2a7702596c..0e99fe7570c0 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -20,8 +20,10 @@
/* operations for longs and pointers */
#define PPC_LL stringify_in_c(ld)
+#define PPC_LLU stringify_in_c(ldu)
#define PPC_STL stringify_in_c(std)
#define PPC_STLU stringify_in_c(stdu)
+#define PPC_ROTLI stringify_in_c(rotldi)
#define PPC_LCMPI stringify_in_c(cmpdi)
#define PPC_LCMPLI stringify_in_c(cmpldi)
#define PPC_LCMP stringify_in_c(cmpd)
@@ -53,8 +55,10 @@
/* operations for longs and pointers */
#define PPC_LL stringify_in_c(lwz)
+#define PPC_LLU stringify_in_c(lwzu)
#define PPC_STL stringify_in_c(stw)
#define PPC_STLU stringify_in_c(stwu)
+#define PPC_ROTLI stringify_in_c(rotlwi)
#define PPC_LCMPI stringify_in_c(cmpwi)
#define PPC_LCMPLI stringify_in_c(cmplwi)
#define PPC_LCMP stringify_in_c(cmpw)
diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h
index 9b8cedf618f4..8fdcb532de72 100644
--- a/arch/powerpc/include/asm/string.h
+++ b/arch/powerpc/include/asm/string.h
@@ -13,6 +13,7 @@
#define __HAVE_ARCH_MEMCHR
#define __HAVE_ARCH_MEMSET16
#define __HAVE_ARCH_MEMCPY_FLUSHCACHE
+#define __HAVE_ARCH_STRLEN
extern char * strcpy(char *,const char *);
extern char * strncpy(char *,const char *, __kernel_size_t);
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index 4b41970e9ed8..cf8a86c9feb5 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -67,3 +67,58 @@ _GLOBAL(memchr)
2: li r3,0
blr
EXPORT_SYMBOL(memchr)
+
+_GLOBAL(strlen)
+ andi. r9, r3, (SZL - 1)
+ addi r10, r3, -SZL
+ bne- 1f
+2: lis r6, 0x8080
+ ori r6, r6, 0x8080 /* r6 = 0x80808080 (himagic) */
+#ifdef CONFIG_PPC64
+ rldimi r6, r6, 32, 0 /* r6 = 0x8080808080808080 (himagic) */
+#endif
+ PPC_ROTLI r7, r6, 1 /* r7 = 0x01010101(01010101) (lomagic)*/
+3: PPC_LLU r9, SZL(r10)
+ /* ((x - lomagic) & ~x & himagic) == 0 means no byte in x is NUL */
+ subf r8, r7, r9
+ andc r11, r6, r9
+ and. r8, r8, r11
+ beq+ 3b
+#ifdef CONFIG_PPC64
+ rldicl. r8, r9, 8, 56
+ beq 20f
+ rldicl. r8, r9, 16, 56
+ beq 21f
+ rldicl. r8, r9, 24, 56
+ beq 22f
+ rldicl. r8, r9, 32, 56
+ beq 23f
+ addi r10, r10, 4
+#endif
+ rlwinm. r8, r9, 0, 0xff000000
+ beq 20f
+ rlwinm. r8, r9, 0, 0x00ff0000
+ beq 21f
+ rlwinm. r8, r9, 0, 0x0000ff00
+ beq 22f
+23: subf r3, r3, r10
+ addi r3, r3, 3
+ blr
+22: subf r3, r3, r10
+ addi r3, r3, 2
+ blr
+21: subf r3, r3, r10
+ addi r3, r3, 1
+ blr
+19: addi r10, r10, (SZL - 1)
+20: subf r3, r3, r10
+ blr
+
+1: lbz r9, SZL(r10)
+ addi r10, r10, 1
+ cmpwi cr1, r9, 0
+ andi. r9, r10, (SZL - 1)
+ beq cr1, 19b
+ bne 1b
+ b 2b
+EXPORT_SYMBOL(strlen)
--
2.13.3
^ permalink raw reply related
* Re: [PATCH v6 1/4] powerpc/64: Align bytes before fall back to .Lshort in powerpc64 memcmp()
From: Segher Boessenkool @ 2018-05-30 8:27 UTC (permalink / raw)
To: Simon Guo; +Cc: linuxppc-dev, Naveen N. Rao, Cyril Bur
In-Reply-To: <20180530081150.GA5951@simonLocalRHEL7.x64>
Hi!
On Wed, May 30, 2018 at 04:11:50PM +0800, Simon Guo wrote:
> On Mon, May 28, 2018 at 05:35:12AM -0500, Segher Boessenkool wrote:
> > On Fri, May 25, 2018 at 12:07:33PM +0800, wei.guo.simon@gmail.com wrote:
> > If this doesn't use cr0 anymore, you can do rlwinm r6,r6,0,7 instead of
> > andi r6,r6,7 .
> >
> CR0 is used at .Lno_short handling.
Tricky.
> > > + subfc. r5,r6,r5
> >
> > Why subfc? You don't use the carry.
> OK. I will use subfc instead.
I meant subf -- no carry. If you want CR0 set there is subf. just fine.
> > > + bgt cr0,8f
> > > + li r3,-1
> > > +8:
> > > + blr
> >
> > blelr
> > li r3,-1
> > blr
> Sure. That looks more impact.
Should have been bgtlr of course -- well check please :-)
Segher
^ permalink raw reply
* Re: [PATCH v6 2/4] powerpc/64: enhance memcmp() with VMX instruction for long bytes comparision
From: Simon Guo @ 2018-05-30 8:15 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras, Naveen N. Rao, Cyril Bur
In-Reply-To: <87fu2c3s9q.fsf@concordia.ellerman.id.au>
Hi Michael,
On Mon, May 28, 2018 at 09:59:29PM +1000, Michael Ellerman wrote:
> Hi Simon,
>
> wei.guo.simon@gmail.com writes:
> > diff --git a/arch/powerpc/lib/memcmp_64.S b/arch/powerpc/lib/memcmp_64.S
> > index f20e883..4ba7bb6 100644
> > --- a/arch/powerpc/lib/memcmp_64.S
> > +++ b/arch/powerpc/lib/memcmp_64.S
> > @@ -174,6 +235,13 @@ _GLOBAL(memcmp)
> > blr
> >
> > .Llong:
> > +#ifdef CONFIG_ALTIVEC
> > + /* Try to use vmx loop if length is equal or greater than 4K */
> > + cmpldi cr6,r5,VMX_THRESH
> > + bge cr6,.Lsameoffset_vmx_cmp
> > +
>
> Here we decide to use vmx, but we don't do any CPU feature checks.
>
>
> > @@ -332,7 +400,94 @@ _GLOBAL(memcmp)
> > 8:
> > blr
> >
> > +#ifdef CONFIG_ALTIVEC
> > +.Lsameoffset_vmx_cmp:
> > + /* Enter with src/dst addrs has the same offset with 8 bytes
> > + * align boundary
> > + */
> > + ENTER_VMX_OPS
> > + beq cr1,.Llong_novmx_cmp
> > +
> > +3:
> > + /* need to check whether r4 has the same offset with r3
> > + * for 16 bytes boundary.
> > + */
> > + xor r0,r3,r4
> > + andi. r0,r0,0xf
> > + bne .Ldiffoffset_vmx_cmp_start
> > +
> > + /* len is no less than 4KB. Need to align with 16 bytes further.
> > + */
> > + andi. rA,r3,8
> > + LD rA,0,r3
> > + beq 4f
> > + LD rB,0,r4
> > + cmpld cr0,rA,rB
> > + addi r3,r3,8
> > + addi r4,r4,8
> > + addi r5,r5,-8
> > +
> > + beq cr0,4f
> > + /* save and restore cr0 */
> > + mfocrf r5,64
> > + EXIT_VMX_OPS
> > + mtocrf 64,r5
> > + b .LcmpAB_lightweight
> > +
> > +4:
> > + /* compare 32 bytes for each loop */
> > + srdi r0,r5,5
> > + mtctr r0
> > + clrldi r5,r5,59
> > + li off16,16
> > +
> > +.balign 16
> > +5:
> > + lvx v0,0,r3
> > + lvx v1,0,r4
> > + vcmpequd. v0,v0,v1
>
> vcmpequd is only available on Power8 and later CPUs.
>
> Which means this will crash on Power7 or earlier.
>
> Something like this should fix it I think.
>
> diff --git a/arch/powerpc/lib/memcmp_64.S b/arch/powerpc/lib/memcmp_64.S
> index 96eb08b2be2e..0a11ff14dcd9 100644
> --- a/arch/powerpc/lib/memcmp_64.S
> +++ b/arch/powerpc/lib/memcmp_64.S
> @@ -236,9 +236,11 @@ _GLOBAL(memcmp)
>
> .Llong:
> #ifdef CONFIG_ALTIVEC
> +BEGIN_FTR_SECTION
> /* Try to use vmx loop if length is equal or greater than 4K */
> cmpldi cr6,r5,VMX_THRESH
> bge cr6,.Lsameoffset_vmx_cmp
> +END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
>
> .Llong_novmx_cmp:
> #endif
Thanks for the good catch! I will update that.
>
>
> There's another problem which is that old toolchains don't know about
> vcmpequd. To fix that we'll need to add a macro that uses .long to
> construct the instruction.
Right. I will add the corresponding macros.
Thanks for your review.
BR,
- Simon
^ permalink raw reply
* Re: [PATCH v6 2/4] powerpc/64: enhance memcmp() with VMX instruction for long bytes comparision
From: Simon Guo @ 2018-05-30 8:14 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev, Naveen N. Rao, Cyril Bur
In-Reply-To: <20180528110558.GZ17342@gate.crashing.org>
Hi Segher,
On Mon, May 28, 2018 at 06:05:59AM -0500, Segher Boessenkool wrote:
> On Fri, May 25, 2018 at 12:07:34PM +0800, wei.guo.simon@gmail.com wrote:
> > + /* save and restore cr0 */
> > + mfocrf r5,64
> > + EXIT_VMX_OPS
> > + mtocrf 64,r5
> > + b .LcmpAB_lightweight
>
> That's cr1, not cr0. You can use mcrf instead, it is cheaper (esp. if
> you have it in a non-volatile CR field before so you need only one, if any).
>
You are right :) How about using mtcr/mfcr instead, I think they are
fast as well and more readable.
> > + vcmpequb. v7,v9,v10
> > + bnl cr6,.Ldiffoffset_vmx_diff_found
>
> In other places you say bf 24,... Dunno which is more readable, but
> please pick one?
I will update to bnl for other cases.
>
>
> Segher
Thanks for your review.
BR,
- Simon
^ permalink raw reply
* Re: [PATCH v6 1/4] powerpc/64: Align bytes before fall back to .Lshort in powerpc64 memcmp()
From: Simon Guo @ 2018-05-30 8:11 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev, Naveen N. Rao, Cyril Bur
In-Reply-To: <20180528103505.GY17342@gate.crashing.org>
Hi Segher,
On Mon, May 28, 2018 at 05:35:12AM -0500, Segher Boessenkool wrote:
> On Fri, May 25, 2018 at 12:07:33PM +0800, wei.guo.simon@gmail.com wrote:
> > _GLOBAL(memcmp)
> > cmpdi cr1,r5,0
> >
> > - /* Use the short loop if both strings are not 8B aligned */
> > - or r6,r3,r4
> > + /* Use the short loop if the src/dst addresses are not
> > + * with the same offset of 8 bytes align boundary.
> > + */
> > + xor r6,r3,r4
> > andi. r6,r6,7
> >
> > - /* Use the short loop if length is less than 32B */
> > - cmpdi cr6,r5,31
> > + /* Fall back to short loop if compare at aligned addrs
> > + * with less than 8 bytes.
> > + */
> > + cmpdi cr6,r5,7
> >
> > beq cr1,.Lzero
> > - bne .Lshort
> > - bgt cr6,.Llong
> > + bgt cr6,.Lno_short
>
> If this doesn't use cr0 anymore, you can do rlwinm r6,r6,0,7 instead of
> andi r6,r6,7 .
>
CR0 is used at .Lno_short handling.
> > +.Lsameoffset_8bytes_make_align_start:
> > + /* attempt to compare bytes not aligned with 8 bytes so that
> > + * rest comparison can run based on 8 bytes alignment.
> > + */
> > + andi. r6,r3,7
> > +
> > + /* Try to compare the first double word which is not 8 bytes aligned:
> > + * load the first double word at (src & ~7UL) and shift left appropriate
> > + * bits before comparision.
> > + */
> > + clrlwi r6,r3,29
> > + rlwinm r6,r6,3,0,28
>
> Those last two lines are together just
> rlwinm r6,r3,3,0x1c
>
Yes. I will combine them.
> > + subfc. r5,r6,r5
>
> Why subfc? You don't use the carry.
OK. I will use subfc instead.
>
> > + rlwinm r6,r6,3,0,28
>
> That's
> slwi r6,r6,3
Yes.
>
> > + bgt cr0,8f
> > + li r3,-1
> > +8:
> > + blr
>
> blelr
> li r3,-1
> blr
Sure. That looks more impact.
>
> (and more of the same things elsewhere).
>
>
> Segher
Thanks for your good comments.
BR,
- Simon
^ permalink raw reply
* [PATCH v6 2/2] powerpc/lib: optimise PPC32 memcmp
From: Christophe Leroy @ 2018-05-30 7:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, segher
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527663626.git.christophe.leroy@c-s.fr>
At the time being, memcmp() compares two chunks of memory
byte per byte.
This patch optimises the comparison by comparing word by word.
On the same way as commit 15c2d45d17418 ("powerpc: Add 64bit
optimised memcmp"), this patch moves memcmp() into a dedicated
file named memcmp_32.S
A small benchmark performed on an 8xx comparing two chuncks
of 512 bytes performed 100000 times gives:
Before : 5852274 TB ticks
After: 1488638 TB ticks
This is almost 4 times faster
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/lib/Makefile | 4 ++--
arch/powerpc/lib/memcmp_32.S | 45 ++++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/lib/string.S | 17 -----------------
3 files changed, 47 insertions(+), 19 deletions(-)
create mode 100644 arch/powerpc/lib/memcmp_32.S
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 2c9b8c0adf22..d0ca13ad8231 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -26,14 +26,14 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
memcpy_power7.o
obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
- memcpy_64.o memcmp_64.o pmem.o
+ memcpy_64.o pmem.o
obj64-$(CONFIG_SMP) += locks.o
obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
obj64-$(CONFIG_KPROBES_SANITY_TEST) += test_emulate_step.o
obj-y += checksum_$(BITS).o checksum_wrappers.o \
- string_$(BITS).o
+ string_$(BITS).o memcmp_$(BITS).o
obj-y += sstep.o ldstfp.o quad.o
obj64-y += quad.o
diff --git a/arch/powerpc/lib/memcmp_32.S b/arch/powerpc/lib/memcmp_32.S
new file mode 100644
index 000000000000..dcb6ab45be66
--- /dev/null
+++ b/arch/powerpc/lib/memcmp_32.S
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * memcmp for PowerPC32
+ *
+ * Copyright (C) 1996 Paul Mackerras.
+ *
+ */
+
+#include <asm/ppc_asm.h>
+#include <asm/export.h>
+
+ .text
+
+_GLOBAL(memcmp)
+ srawi. r7, r5, 2 /* Divide len by 4 */
+ mr r6, r3
+ beq- 3f
+ mtctr r7
+ li r7, 0
+1: lwzx r3, r6, r7
+ lwzx r0, r4, r7
+ addi r7, r7, 4
+ cmplw cr0, r3, r0
+ bdnzt eq, 1b
+ bne 5f
+3: andi. r3, r5, 3
+ beqlr
+ cmplwi cr1, r3, 2
+ blt- cr1, 4f
+ lhzx r3, r6, r7
+ lhzx r0, r4, r7
+ addi r7, r7, 2
+ subf. r3, r0, r3
+ beqlr cr1
+ bnelr
+4: lbzx r3, r6, r7
+ lbzx r0, r4, r7
+ subf. r3, r0, r3
+ blr
+5: li r3, 1
+ bgtlr
+ li r3, -1
+ blr
+EXPORT_SYMBOL(memcmp)
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index 5343a88e619e..4b41970e9ed8 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -54,23 +54,6 @@ _GLOBAL(strncmp)
blr
EXPORT_SYMBOL(strncmp)
-#ifdef CONFIG_PPC32
-_GLOBAL(memcmp)
- PPC_LCMPI 0,r5,0
- beq- 2f
- mtctr r5
- addi r6,r3,-1
- addi r4,r4,-1
-1: lbzu r3,1(r6)
- lbzu r0,1(r4)
- subf. r3,r0,r3
- bdnzt 2,1b
- blr
-2: li r3,0
- blr
-EXPORT_SYMBOL(memcmp)
-#endif
-
_GLOBAL(memchr)
PPC_LCMPI 0,r5,0
beq- 2f
--
2.13.3
^ permalink raw reply related
* [PATCH v6 1/2] powerpc/lib: optimise 32 bits __clear_user()
From: Christophe Leroy @ 2018-05-30 7:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, segher
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527663626.git.christophe.leroy@c-s.fr>
Rewrite clear_user() on the same principle as memset(0), making use
of dcbz to clear complete cache lines.
This code is a copy/paste of memset(), with some modifications
in order to retrieve remaining number of bytes to be cleared,
as it needs to be returned in case of error.
On the same way as done on PPC64 in commit 17968fbbd19f1
("powerpc: 64bit optimised __clear_user"), the patch moves
__clear_user() into a dedicated file string_32.S
On a MPC885, throughput is almost doubled:
Before:
~# dd if=/dev/zero of=/dev/null bs=1M count=1000
1048576000 bytes (1000.0MB) copied, 18.990779 seconds, 52.7MB/s
After:
~# dd if=/dev/zero of=/dev/null bs=1M count=1000
1048576000 bytes (1000.0MB) copied, 9.611468 seconds, 104.0MB/s
On a MPC8321, throughput is multiplied by 2.12:
Before:
root@vgoippro:~# dd if=/dev/zero of=/dev/null bs=1M count=1000
1048576000 bytes (1000.0MB) copied, 6.844352 seconds, 146.1MB/s
After:
root@vgoippro:~# dd if=/dev/zero of=/dev/null bs=1M count=1000
1048576000 bytes (1000.0MB) copied, 3.218854 seconds, 310.7MB/s
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/lib/Makefile | 5 ++-
arch/powerpc/lib/string.S | 46 ----------------------
arch/powerpc/lib/string_32.S | 90 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+), 48 deletions(-)
create mode 100644 arch/powerpc/lib/string_32.S
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 653901042ad7..2c9b8c0adf22 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -26,13 +26,14 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
memcpy_power7.o
obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
- string_64.o memcpy_64.o memcmp_64.o pmem.o
+ memcpy_64.o memcmp_64.o pmem.o
obj64-$(CONFIG_SMP) += locks.o
obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
obj64-$(CONFIG_KPROBES_SANITY_TEST) += test_emulate_step.o
-obj-y += checksum_$(BITS).o checksum_wrappers.o
+obj-y += checksum_$(BITS).o checksum_wrappers.o \
+ string_$(BITS).o
obj-y += sstep.o ldstfp.o quad.o
obj64-y += quad.o
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S
index 0378def28d41..5343a88e619e 100644
--- a/arch/powerpc/lib/string.S
+++ b/arch/powerpc/lib/string.S
@@ -8,8 +8,6 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
-#include <asm/processor.h>
-#include <asm/errno.h>
#include <asm/ppc_asm.h>
#include <asm/export.h>
#include <asm/cache.h>
@@ -86,47 +84,3 @@ _GLOBAL(memchr)
2: li r3,0
blr
EXPORT_SYMBOL(memchr)
-
-#ifdef CONFIG_PPC32
-_GLOBAL(__clear_user)
- addi r6,r3,-4
- li r3,0
- li r5,0
- cmplwi 0,r4,4
- blt 7f
- /* clear a single word */
-11: stwu r5,4(r6)
- beqlr
- /* clear word sized chunks */
- andi. r0,r6,3
- add r4,r0,r4
- subf r6,r0,r6
- srwi r0,r4,2
- andi. r4,r4,3
- mtctr r0
- bdz 7f
-1: stwu r5,4(r6)
- bdnz 1b
- /* clear byte sized chunks */
-7: cmpwi 0,r4,0
- beqlr
- mtctr r4
- addi r6,r6,3
-8: stbu r5,1(r6)
- bdnz 8b
- blr
-90: mr r3,r4
- blr
-91: mfctr r3
- slwi r3,r3,2
- add r3,r3,r4
- blr
-92: mfctr r3
- blr
-
- EX_TABLE(11b, 90b)
- EX_TABLE(1b, 91b)
- EX_TABLE(8b, 92b)
-
-EXPORT_SYMBOL(__clear_user)
-#endif
diff --git a/arch/powerpc/lib/string_32.S b/arch/powerpc/lib/string_32.S
new file mode 100644
index 000000000000..6de67d2dbad6
--- /dev/null
+++ b/arch/powerpc/lib/string_32.S
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * String handling functions for PowerPC32
+ *
+ * Copyright (C) 1996 Paul Mackerras.
+ *
+ */
+
+#include <asm/ppc_asm.h>
+#include <asm/export.h>
+#include <asm/cache.h>
+
+ .text
+
+CACHELINE_BYTES = L1_CACHE_BYTES
+LG_CACHELINE_BYTES = L1_CACHE_SHIFT
+CACHELINE_MASK = (L1_CACHE_BYTES-1)
+
+_GLOBAL(__clear_user)
+/*
+ * Use dcbz on the complete cache lines in the destination
+ * to set them to zero. This requires that the destination
+ * area is cacheable.
+ */
+ cmplwi cr0, r4, 4
+ mr r10, r3
+ li r3, 0
+ blt 7f
+
+11: stw r3, 0(r10)
+ beqlr
+ andi. r0, r10, 3
+ add r11, r0, r4
+ subf r6, r0, r10
+
+ clrlwi r7, r6, 32 - LG_CACHELINE_BYTES
+ add r8, r7, r11
+ srwi r9, r8, LG_CACHELINE_BYTES
+ addic. r9, r9, -1 /* total number of complete cachelines */
+ ble 2f
+ xori r0, r7, CACHELINE_MASK & ~3
+ srwi. r0, r0, 2
+ beq 3f
+ mtctr r0
+4: stwu r3, 4(r6)
+ bdnz 4b
+3: mtctr r9
+ li r7, 4
+10: dcbz r7, r6
+ addi r6, r6, CACHELINE_BYTES
+ bdnz 10b
+ clrlwi r11, r8, 32 - LG_CACHELINE_BYTES
+ addi r11, r11, 4
+
+2: srwi r0 ,r11 ,2
+ mtctr r0
+ bdz 6f
+1: stwu r3, 4(r6)
+ bdnz 1b
+6: andi. r11, r11, 3
+ beqlr
+ mtctr r11
+ addi r6, r6, 3
+8: stbu r3, 1(r6)
+ bdnz 8b
+ blr
+
+7: cmpwi cr0, r4, 0
+ beqlr
+ mtctr r4
+ addi r6, r10, -1
+9: stbu r3, 1(r6)
+ bdnz 9b
+ blr
+
+90: mr r3, r4
+ blr
+91: add r3, r10, r4
+ subf r3, r6, r3
+ blr
+
+ EX_TABLE(11b, 90b)
+ EX_TABLE(4b, 91b)
+ EX_TABLE(10b, 91b)
+ EX_TABLE(1b, 91b)
+ EX_TABLE(8b, 91b)
+ EX_TABLE(9b, 91b)
+
+EXPORT_SYMBOL(__clear_user)
--
2.13.3
^ permalink raw reply related
* [PATCH v6 0/2] powerpc/lib: Optimisation of memcmp() and __clear_user() for PPC32
From: Christophe Leroy @ 2018-05-30 7:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, segher
Cc: linux-kernel, linuxppc-dev
This serie intends to optimise memcmp() and __clear_user() for PPC32
in the same spirit as already done on PPC64.
The first patch rewrites __clear_user() by using dcbz intruction
The second patch rewrites memcmp() to compare 32 bits words instead
of comparing byte per byte.
As shown in each individual commit log, second and third patches
provide significant improvment.
Changes in v6:
- Dropped first patch of the serie which was just moving memcmp() and __clear_user()
into new string_32.S file
- As suggested by Mathieu, to be consistant with PPC64:
- __clear_user() is moved into new file string_32.S
- memcmp() is moved into new file memcmp_32.S
- Removed unneccessary included header files.
Changes in v5:
- Removed the handling of Little Endian, as PPC32 kernel only support Big Endian
at the time being, and because unaligned accesses should be handled differently
in LE.
Changes in v4:
- In memcmp(), dropped the special handling for when length is 0. Handling it
through the small length path.
Changes in v3:
- Fixed the sign of the result returned by memcmp() by using a logical
comparison of u32 words and returning -1, 0 or 1 instead of doing a substract.
- In first patch, replaced PPC_LCMPI by cmpwi
- Fixed licence in string_32.S
- Removed the two last patches from the serie. They will be handled later as
they require further tests and analysis to properly identify their real benefit
in all possible cases.
Changes in v2:
- Moved out the patch removing the hot loop alignment on PPC32
- Squashed the changes related to NUL size verification in a single patch
- Reordered the patches in a more logical order
- Modified the inlining patch to avoid warning about impossibility to version symbols.
Christophe Leroy (2):
powerpc/lib: optimise 32 bits __clear_user()
powerpc/lib: optimise PPC32 memcmp
arch/powerpc/lib/Makefile | 5 ++-
arch/powerpc/lib/memcmp_32.S | 45 ++++++++++++++++++++++
arch/powerpc/lib/string.S | 63 -------------------------------
arch/powerpc/lib/string_32.S | 90 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 138 insertions(+), 65 deletions(-)
create mode 100644 arch/powerpc/lib/memcmp_32.S
create mode 100644 arch/powerpc/lib/string_32.S
--
2.13.3
^ permalink raw reply
* Re: [PATCH] powerpc/ptrace: Use copy_{from, to}_user() rather than open-coding
From: Samuel Mendoza-Jonas @ 2018-05-30 6:48 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev, viro; +Cc: malat
In-Reply-To: <20180529125738.24271-1-mpe@ellerman.id.au>
On Tue, 2018-05-29 at 22:57 +1000, Michael Ellerman wrote:
> From: Al Viro <viro@ZenIV.linux.org.uk>
>
> In PPC_PTRACE_GETHWDBGINFO and PPC_PTRACE_SETHWDEBUG we do an
> access_ok() check and then __copy_{from,to}_user().
>
> Instead we should just use copy_{from,to}_user() which does all that
> for us and is less error prone.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> ---
> arch/powerpc/kernel/ptrace.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
> index 0f63dd5972e9..9667666eb18e 100644
> --- a/arch/powerpc/kernel/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace.c
> @@ -3082,27 +3082,19 @@ long arch_ptrace(struct task_struct *child, long request,
> #endif /* CONFIG_HAVE_HW_BREAKPOINT */
> #endif /* CONFIG_PPC_ADV_DEBUG_REGS */
>
> - if (!access_ok(VERIFY_WRITE, datavp,
> - sizeof(struct ppc_debug_info)))
> + if (copy_to_user(datavp, &dbginfo,
> + sizeof(struct ppc_debug_info)))
> return -EFAULT;
> - ret = __copy_to_user(datavp, &dbginfo,
> - sizeof(struct ppc_debug_info)) ?
> - -EFAULT : 0;
> - break;
> + return 0;
> }
>
> case PPC_PTRACE_SETHWDEBUG: {
> struct ppc_hw_breakpoint bp_info;
>
> - if (!access_ok(VERIFY_READ, datavp,
> - sizeof(struct ppc_hw_breakpoint)))
> + if (copy_from_user(&bp_info, datavp,
> + sizeof(struct ppc_hw_breakpoint)))
> return -EFAULT;
> - ret = __copy_from_user(&bp_info, datavp,
> - sizeof(struct ppc_hw_breakpoint)) ?
> - -EFAULT : 0;
> - if (!ret)
> - ret = ppc_set_hwdebug(child, &bp_info);
> - break;
> + return ppc_set_hwdebug(child, &bp_info);
> }
>
> case PPC_PTRACE_DELHWDEBUG: {
^ permalink raw reply
* Re: [PATCH v2] powerpc/numa: Correct kernel message severity
From: Vipin K Parashar @ 2018-05-30 6:43 UTC (permalink / raw)
To: linuxppc-dev; +Cc: nfont, Christophe LEROY, Michael Ellerman
In-Reply-To: <1521013954-21348-1-git-send-email-vipin@linux.vnet.ibm.com>
Hi,
Any progress/update with this patch ?
Please do let know, if something more is needed here.
Regards,
Vipin
On Wednesday 14 March 2018 01:22 PM, Vipin K Parashar wrote:
> printk() in unmap_cpu_from_node() uses KERN_ERR message severity,
> for a WARNING message. Change it to pr_warn().
>
> Signed-off-by: Vipin K Parashar <vipin@linux.vnet.ibm.com>
> ---
> arch/powerpc/mm/numa.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index edd8d0b..1632f4b 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -163,8 +163,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
> if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) {
> cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);
> } else {
> - printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
> - cpu, node);
> + pr_warn("WARNING: cpu %lu not found in node %d\n", cpu, node);
> }
> }
> #endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */
^ permalink raw reply
* Re: [PATCH v4 04/29] KVM: PPC: Book3S PR: Move kvmppc_save_tm/kvmppc_restore_tm to separate file
From: Paul Mackerras @ 2018-05-29 23:40 UTC (permalink / raw)
To: wei.guo.simon; +Cc: linuxppc-dev, kvm, kvm-ppc
In-Reply-To: <1527058932-7434-5-git-send-email-wei.guo.simon@gmail.com>
On Wed, May 23, 2018 at 03:01:47PM +0800, wei.guo.simon@gmail.com wrote:
> From: Simon Guo <wei.guo.simon@gmail.com>
>
> It is a simple patch just for moving kvmppc_save_tm/kvmppc_restore_tm()
> functionalities to tm.S. There is no logic change. The reconstruct of
> those APIs will be done in later patches to improve readability.
>
> It is for preparation of reusing those APIs on both HV/PR PPC KVM.
>
> Some slight change during move the functions includes:
> - surrounds some HV KVM specific code with CONFIG_KVM_BOOK3S_HV_POSSIBLE
> for compilation.
> - use _GLOBAL() to define kvmppc_save_tm/kvmppc_restore_tm()
>
> Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
> ---
> arch/powerpc/kvm/Makefile | 3 +
> arch/powerpc/kvm/book3s_hv_rmhandlers.S | 322 ----------------------------
> arch/powerpc/kvm/tm.S | 363 ++++++++++++++++++++++++++++++++
> 3 files changed, 366 insertions(+), 322 deletions(-)
> create mode 100644 arch/powerpc/kvm/tm.S
>
> diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
> index 4b19da8..f872c04 100644
> --- a/arch/powerpc/kvm/Makefile
> +++ b/arch/powerpc/kvm/Makefile
> @@ -63,6 +63,9 @@ kvm-pr-y := \
> book3s_64_mmu.o \
> book3s_32_mmu.o
>
> +kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
> + tm.o
> +
> ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
> kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
> book3s_rmhandlers.o
> diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> index 5e6e493..4db2b10 100644
> --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
> @@ -39,8 +39,6 @@ BEGIN_FTR_SECTION; \
> extsw reg, reg; \
> END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
>
> -#define VCPU_GPRS_TM(reg) (((reg) * ULONG_SIZE) + VCPU_GPR_TM)
> -
> /* Values in HSTATE_NAPPING(r13) */
> #define NAPPING_CEDE 1
> #define NAPPING_NOVCPU 2
> @@ -3119,326 +3117,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
> mr r4,r31
> blr
>
> -#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> -/*
> - * Save transactional state and TM-related registers.
> - * Called with r9 pointing to the vcpu struct.
> - * This can modify all checkpointed registers, but
> - * restores r1, r2 and r9 (vcpu pointer) before exit.
> - */
> -kvmppc_save_tm:
> - mflr r0
> - std r0, PPC_LR_STKOFF(r1)
> - stdu r1, -PPC_MIN_STKFRM(r1)
> -
> - /* Turn on TM. */
> - mfmsr r8
> - li r0, 1
> - rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG
> - mtmsrd r8
> -
> - ld r5, VCPU_MSR(r9)
> - rldicl. r5, r5, 64 - MSR_TS_S_LG, 62
> - beq 1f /* TM not active in guest. */
> -
> - std r1, HSTATE_HOST_R1(r13)
> - li r3, TM_CAUSE_KVM_RESCHED
> -
> -BEGIN_FTR_SECTION
> - lbz r0, HSTATE_FAKE_SUSPEND(r13) /* Were we fake suspended? */
> - cmpwi r0, 0
> - beq 3f
> - rldicl. r8, r8, 64 - MSR_TS_S_LG, 62 /* Did we actually hrfid? */
> - beq 4f
> -BEGIN_FTR_SECTION_NESTED(96)
> - bl pnv_power9_force_smt4_catch
> -END_FTR_SECTION_NESTED(CPU_FTR_P9_TM_XER_SO_BUG, CPU_FTR_P9_TM_XER_SO_BUG, 96)
> - nop
> - b 6f
> -3:
> - /* Emulation of the treclaim instruction needs TEXASR before treclaim */
> - mfspr r6, SPRN_TEXASR
> - std r6, VCPU_ORIG_TEXASR(r9)
> -6:
> -END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
It worries me that we now have this TM hypervisor assist stuff in a
place where it could be active with PR KVM. I think it would be
better to factor out the TM assist code into a separate function which
then calls kvmppc_save_tm if it needs to do an actual treclaim. I'll
look at doing that.
Paul.
^ permalink raw reply
* Re: [PATCH V2 4/4] powerpc/mm/radix: Change pte relax sequence to handle nest MMU hang
From: Nicholas Piggin @ 2018-05-29 22:44 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: benh, paulus, mpe, linuxppc-dev
In-Reply-To: <20180529142841.19428-4-aneesh.kumar@linux.ibm.com>
On Tue, 29 May 2018 19:58:41 +0530
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> wrote:
> When relaxing access (read -> read_write update), pte needs to be marked invalid
> to handle a nest MMU bug. We also need to do a tlb flush after the pte is
> marked invalid before updating the pte with new access bits.
>
> We also move tlb flush to platform specific __ptep_set_access_flags. This will
> help us to gerid of unnecessary tlb flush on BOOK3S 64 later. We don't do that
> in this patch. This also helps in avoiding multiple tlbies with coprocessor
> attached.
I thought you should move this part of the change back into patch 3 as
well.
Thanks,
Nick
^ permalink raw reply
* Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices
From: Benjamin Herrenschmidt @ 2018-05-29 22:13 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Michael S. Tsirkin, Anshuman Khandual, virtualization,
linux-kernel, linuxppc-dev, aik, robh, joe, elfring, david,
jasowang, mpe, luto
In-Reply-To: <20180529140319.GA19972@infradead.org>
On Tue, 2018-05-29 at 07:03 -0700, Christoph Hellwig wrote:
> On Tue, May 29, 2018 at 09:56:24AM +1000, Benjamin Herrenschmidt wrote:
> > I don't think forcing the addition of an emulated iommu in the middle
> > just to work around the fact that virtio "cheats" and doesn't use the
> > dma API unless there is one, is the right "fix".
>
> Agreed.
>
> > The right long term fix is to always use the DMA API, reducing code
> > path etc... and just have a single point where virtio can "chose"
> > alternate DMA ops (via an arch hook to deal with our case).
>
> Also agreed.
>
> When Andi added vring_use_dma_api it was marked as temporary.
>
> So I'd much rather move to blacklisting platforms that needs this
> hack now than adding another exception.
>
> And then once we have the blacklist move it to a quirk in the arch
> code that just forces dma_direct_ops as the per-device dma ops.
>
> I don't really think this is crazy long term, but something we could
> do relatively quickly. Interestingly enough the original commit
> mentions PPC64 as a case where this quirk is needed.
Not sure why, it's not so much a platform issue today. It's qemu itself
who by defaults bypasses any iommu. I suppose ppc64 stood out because
unlike x86 we always have an iommu by default.
Anyway, Anshuman, I think that's the right approach, first make virtio
always use the DMA API with a quirk early to override the ops.
Christoph: the overriding of the ops isn't a platform thing. It's a
qemu thing, ie, from a Linux perspective, it's a feature of the
"device". So it should be done in virtio itself, not the platform code.
However, we do want the ability in platform code to force the bounce
buffering to solve our secure VM issue.
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH v5 3/3] powerpc/lib: optimise PPC32 memcmp
From: Mathieu Malaterre @ 2018-05-29 20:03 UTC (permalink / raw)
To: Christophe Leroy
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Segher Boessenkool, linuxppc-dev, LKML
In-Reply-To: <88c8cc033b4ea364d62d1d8ba811a8f8d56c297d.1527503958.git.christophe.leroy@c-s.fr>
On Mon, May 28, 2018 at 12:49 PM, Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
> At the time being, memcmp() compares two chunks of memory
> byte per byte.
>
> This patch optimises the comparison by comparing word by word.
>
> A small benchmark performed on an 8xx comparing two chuncks
> of 512 bytes performed 100000 times gives:
>
> Before : 5852274 TB ticks
> After: 1488638 TB ticks
>
> This is almost 4 times faster
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/lib/string_32.S | 37 +++++++++++++++++++++++++++----------
> 1 file changed, 27 insertions(+), 10 deletions(-)
Would it possible for you to move the actual code instead to:
./arch/powerpc/lib/memcmp_32.S
This will seat right next to memcmp_64.S implementation.
> diff --git a/arch/powerpc/lib/string_32.S b/arch/powerpc/lib/string_32.S
> index 40a576d56ac7..4fbaa046aa84 100644
> --- a/arch/powerpc/lib/string_32.S
> +++ b/arch/powerpc/lib/string_32.S
> @@ -16,17 +16,34 @@
> .text
>
> _GLOBAL(memcmp)
> - cmpwi cr0, r5, 0
> - beq- 2f
> - mtctr r5
> - addi r6,r3,-1
> - addi r4,r4,-1
> -1: lbzu r3,1(r6)
> - lbzu r0,1(r4)
> - subf. r3,r0,r3
> - bdnzt 2,1b
> + srawi. r7, r5, 2 /* Divide len by 4 */
> + mr r6, r3
> + beq- 3f
> + mtctr r7
> + li r7, 0
> +1: lwzx r3, r6, r7
> + lwzx r0, r4, r7
> + addi r7, r7, 4
> + cmplw cr0, r3, r0
> + bdnzt eq, 1b
> + bne 5f
> +3: andi. r3, r5, 3
> + beqlr
> + cmplwi cr1, r3, 2
> + blt- cr1, 4f
> + lhzx r3, r6, r7
> + lhzx r0, r4, r7
> + addi r7, r7, 2
> + subf. r3, r0, r3
> + beqlr cr1
> + bnelr
> +4: lbzx r3, r6, r7
> + lbzx r0, r4, r7
> + subf. r3, r0, r3
> blr
> -2: li r3,0
> +5: li r3, 1
> + bgtlr
> + li r3, -1
> blr
> EXPORT_SYMBOL(memcmp)
>
> --
> 2.13.3
>
^ permalink raw reply
* [PATCH] powerpc/prom: Fix %u/%llx usage since prom_printf() change
From: Mathieu Malaterre @ 2018-05-29 19:20 UTC (permalink / raw)
To: Michael Ellerman
Cc: Stephen Rothwell, Mathieu Malaterre, Benjamin Herrenschmidt,
Paul Mackerras, linuxppc-dev, linux-kernel
In commit eae5f709a4d7 ("powerpc: Add __printf verification to
prom_printf") __printf attribute was added to prom_printf(), which
means GCC started warning about type/format mismatches. As part of that
commit we changed some "%lx" formats to "%llx" where the type is
actually unsigned long long.
Unfortunately prom_printf() doesn't know how to print "%llx", it just
prints a literal "lx", eg:
reserved memory map:
lx - lx
lx - lx
prom_printf() also doesn't know how to print "%u" (only "%lu"), it just
print a literal "u", eg:
Max number of cores passed to firmware: u (NR_CPUS = 2048)
instead of:
Max number of cores passed to firmware: 2048 (NR_CPUS = 2048)
This commit adds support for the missing formatters.
Fixes: eae5f709a4d7 ("powerpc: Add __printf verification to prom_printf")
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
I've reviewed all formatters added in eae5f709a4d7 and only %u and %llx were
actually missing (eg. llu or lld are not used)
arch/powerpc/kernel/prom_init.c | 72 +++++++++++++++++++++++++++--------------
1 file changed, 48 insertions(+), 24 deletions(-)
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4d62f561f272..2c04516fe274 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -301,6 +301,9 @@ static void __init prom_print(const char *msg)
}
+/* both prom_print_hex & prom_print_dec takes an unsigned long as input so that
+ * we do not need __udivdi3 or __umoddi3 on 32bits
+ */
static void __init prom_print_hex(unsigned long val)
{
int i, nibbles = sizeof(val)*2;
@@ -341,6 +344,7 @@ static void __init prom_printf(const char *format, ...)
va_list args;
unsigned long v;
long vs;
+ int n = 0;
va_start(args, format);
for (p = format; *p != 0; p = q) {
@@ -359,6 +363,10 @@ static void __init prom_printf(const char *format, ...)
++q;
if (*q == 0)
break;
+ while (*q == 'l') {
+ ++q;
+ ++n;
+ }
switch (*q) {
case 's':
++q;
@@ -367,39 +375,55 @@ static void __init prom_printf(const char *format, ...)
break;
case 'x':
++q;
- v = va_arg(args, unsigned long);
+ switch (n) {
+ case 0:
+ v = va_arg(args, unsigned int);
+ break;
+ case 1:
+ v = va_arg(args, unsigned long);
+ break;
+ case 2:
+ default:
+ v = va_arg(args, unsigned long long);
+ break;
+ }
prom_print_hex(v);
break;
- case 'd':
+ case 'u':
++q;
- vs = va_arg(args, int);
- if (vs < 0) {
- prom_print("-");
- vs = -vs;
+ switch (n) {
+ case 0:
+ v = va_arg(args, unsigned int);
+ break;
+ case 1:
+ v = va_arg(args, unsigned long);
+ break;
+ case 2:
+ default:
+ v = va_arg(args, unsigned long long);
+ break;
}
- prom_print_dec(vs);
+ prom_print_dec(v);
break;
- case 'l':
+ case 'd':
++q;
- if (*q == 0)
+ switch (n) {
+ case 0:
+ vs = va_arg(args, int);
break;
- else if (*q == 'x') {
- ++q;
- v = va_arg(args, unsigned long);
- prom_print_hex(v);
- } else if (*q == 'u') { /* '%lu' */
- ++q;
- v = va_arg(args, unsigned long);
- prom_print_dec(v);
- } else if (*q == 'd') { /* %ld */
- ++q;
+ case 1:
vs = va_arg(args, long);
- if (vs < 0) {
- prom_print("-");
- vs = -vs;
- }
- prom_print_dec(vs);
+ break;
+ case 2:
+ default:
+ vs = va_arg(args, long long);
+ break;
+ }
+ if (vs < 0) {
+ prom_print("-");
+ vs = -vs;
}
+ prom_print_dec(vs);
break;
}
}
--
2.11.0
^ permalink raw reply related
* Re: [RFC PATCH] powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book E
From: Scott Wood @ 2018-05-29 19:14 UTC (permalink / raw)
To: Diana Madalina Craciun, linuxppc-dev@lists.ozlabs.org
Cc: mpe@ellerman.id.au, Leo Li
In-Reply-To: <VI1PR0401MB246345AD11EC8666B7187F8DFF6D0@VI1PR0401MB2463.eurprd04.prod.outlook.com>
On Tue, 2018-05-29 at 15:22 +0000, Diana Madalina Craciun wrote:
> Hi Scott,
>
> Thanks for the review.
>
> On 05/22/2018 11:31 PM, Scott Wood wrote:
> > On Tue, 2018-05-22 at 10:10 +0300, Diana Craciun wrote:
> > > Implement the barrier_nospec as a isync;sync instruction sequence.
> > > The implementation uses the infrastructure built for BOOK3S 64
> > > with the difference that for NXP platforms there is no firmware involved
> > > and the need for a speculation barrier is read from the device tree.
> > > I have used the same name for the property:
> > > fsl,needs-spec-barrier-for-bounds-check
> >
> > Using the device tree this way means that anyone without an updated device
> > tree won't get the protection. I also don't see any device tree updates
> > --
> > which chips are affected?
>
> I was planning to have the device tree changes in a different patch-set.
> The affected cores are e500, e500mc, e5500, e6500.
So, all supported FSL/NXP book E chips. Why not just enable the workaround
unconditionally (and revisit if NXP ever produces a book E chip that doesn't
need it and/or e200 is ever supported if that's simple enough to be immune)?
> > Why patch nops in if not enabled? Aren't those locations already
> > nops? For
> > that matter, how can this function even be called on FSL_BOOK3E with
> > enable !=
> > true?
>
> There is some code in arch/powerpc/kernel/security.c which allows
> control of barrier_nospec via debugfs.
OK.
> > Should there be a way for the user to choose not to enable this (editing
> > the
> > device tree doesn't count), for a use case that is not sufficiently
> > security
> > sensitive to justify the performance loss? What is the performance impact
> > of
> > this patch?
>
> My reason was that on the other architectures Spectre variant 1
> mitigations are not disabled either. But I think that it might be a good
> idea to add a bootarg parameter to disable the barrier.
Is there a specific policy reason why they allow spectre v2 to be disabled but
not v1, or just a matter of not having a mechanism to disable it, or the parts
which could practically be disabled not impacting performance much?
-Scott
^ permalink raw reply
* Re: [PATCH v2 2/2] i2c: busses: make use of i2c_8bit_addr_from_msg
From: Wolfram Sang @ 2018-05-29 18:31 UTC (permalink / raw)
To: Peter Rosin
Cc: linux-kernel, Brendan Higgins, Benjamin Herrenschmidt,
Joel Stanley, Andrew Jeffery, Guenter Roeck,
Uwe Kleine-König, Pengutronix Kernel Team, Wolfram Sang,
Peter Korsgaard, Andy Gross, David Brown, Linus Walleij,
linux-i2c, openbmc, linux-arm-kernel, linux-aspeed, linuxppc-dev,
linux-arm-msm, linux-soc
In-Reply-To: <20180516071647.29277-3-peda@axentia.se>
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
On Wed, May 16, 2018 at 09:16:47AM +0200, Peter Rosin wrote:
> Because it looks neater.
>
> For diolan, this allows factoring out some code that is now common
> between if and else.
>
> For eg20t, pch_i2c_writebytes is always called with a write in
> msgs->flags, and pch_i2c_readbytes with a read.
>
> For imx, i2c_imx_dma_write and i2c_imx_write are always called with a
> write in msgs->flags, and i2c_imx_read with a read.
>
> For qup, qup_i2c_write_tx_fifo_v1 is always called with a write in
> qup->msg->flags.
>
> For stu300, also restructure debug output for resends, since that
> code as a result is only handling debug output.
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net> [diolan]
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [emf32 and imx]
> Acked-by: Linus Walleij <linus.walleij@linaro.org> [stu300]
> Signed-off-by: Peter Rosin <peda@axentia.se>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH v2 1/2] i2c: algos: make use of i2c_8bit_addr_from_msg
From: Wolfram Sang @ 2018-05-29 18:31 UTC (permalink / raw)
To: Peter Rosin
Cc: linux-kernel, Brendan Higgins, Benjamin Herrenschmidt,
Joel Stanley, Andrew Jeffery, Guenter Roeck,
Uwe Kleine-König, Pengutronix Kernel Team, Wolfram Sang,
Peter Korsgaard, Andy Gross, David Brown, Linus Walleij,
linux-i2c, openbmc, linux-arm-kernel, linux-aspeed, linuxppc-dev,
linux-arm-msm, linux-soc
In-Reply-To: <20180516071647.29277-2-peda@axentia.se>
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
On Wed, May 16, 2018 at 09:16:46AM +0200, Peter Rosin wrote:
> Because it looks neater.
>
> Signed-off-by: Peter Rosin <peda@axentia.se>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH] kvm: no need to check return value of debugfs_create functions
From: Paolo Bonzini @ 2018-05-29 17:06 UTC (permalink / raw)
To: Greg Kroah-Hartman, kvm
Cc: Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman,
Christoffer Dall, Marc Zyngier, Radim Krčmář,
Arvind Yadav, Eric Auger, Andre Przywara, kvm-ppc, linuxppc-dev,
linux-kernel, linux-arm-kernel, kvmarm
In-Reply-To: <20180529162204.11757-1-gregkh@linuxfoundation.org>
On 29/05/2018 18:22, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value. The function can work or not, but the code logic should
> never do something different based on this.
>
> This cleans up the error handling a lot, as this code will never get
> hit.
>
> Cc: Paul Mackerras <paulus@ozlabs.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Christoffer Dall <christoffer.dall@arm.com>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: Andre Przywara <andre.przywara@arm.com>
> Cc: kvm-ppc@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: kvmarm@lists.cs.columbia.edu
> Cc: kvm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> arch/powerpc/kvm/book3s_hv.c | 3 +--
> virt/kvm/arm/vgic/vgic-debug.c | 17 ++++-----------
> virt/kvm/arm/vgic/vgic.h | 4 ++--
> virt/kvm/kvm_main.c | 40 +++++++---------------------------
> 4 files changed, 15 insertions(+), 49 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 4d07fca5121c..67d7de1470cc 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -3950,8 +3950,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
> */
> snprintf(buf, sizeof(buf), "vm%d", current->pid);
> kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
> - if (!IS_ERR_OR_NULL(kvm->arch.debugfs_dir))
> - kvmppc_mmu_debugfs_init(kvm);
> + kvmppc_mmu_debugfs_init(kvm);
>
> return 0;
> }
> diff --git a/virt/kvm/arm/vgic/vgic-debug.c b/virt/kvm/arm/vgic/vgic-debug.c
> index 10b38178cff2..0140b29079b6 100644
> --- a/virt/kvm/arm/vgic/vgic-debug.c
> +++ b/virt/kvm/arm/vgic/vgic-debug.c
> @@ -263,21 +263,12 @@ static const struct file_operations vgic_debug_fops = {
> .release = seq_release
> };
>
> -int vgic_debug_init(struct kvm *kvm)
> +void vgic_debug_init(struct kvm *kvm)
> {
> - if (!kvm->debugfs_dentry)
> - return -ENOENT;
> -
> - if (!debugfs_create_file("vgic-state", 0444,
> - kvm->debugfs_dentry,
> - kvm,
> - &vgic_debug_fops))
> - return -ENOMEM;
> -
> - return 0;
> + debugfs_create_file("vgic-state", 0444, kvm->debugfs_dentry, kvm,
> + &vgic_debug_fops);
> }
>
> -int vgic_debug_destroy(struct kvm *kvm)
> +void vgic_debug_destroy(struct kvm *kvm)
> {
> - return 0;
> }
> diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
> index 830e815748a0..3c38c5349953 100644
> --- a/virt/kvm/arm/vgic/vgic.h
> +++ b/virt/kvm/arm/vgic/vgic.h
> @@ -229,8 +229,8 @@ void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
> int vgic_lazy_init(struct kvm *kvm);
> int vgic_init(struct kvm *kvm);
>
> -int vgic_debug_init(struct kvm *kvm);
> -int vgic_debug_destroy(struct kvm *kvm);
> +void vgic_debug_init(struct kvm *kvm);
> +void vgic_debug_destroy(struct kvm *kvm);
>
> bool lock_all_vcpus(struct kvm *kvm);
> void unlock_all_vcpus(struct kvm *kvm);
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index c7b2e927f699..0ad400f353fc 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -572,10 +572,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
> return 0;
>
> snprintf(dir_name, sizeof(dir_name), "%d-%d", task_pid_nr(current), fd);
> - kvm->debugfs_dentry = debugfs_create_dir(dir_name,
> - kvm_debugfs_dir);
> - if (!kvm->debugfs_dentry)
> - return -ENOMEM;
> + kvm->debugfs_dentry = debugfs_create_dir(dir_name, kvm_debugfs_dir);
>
> kvm->debugfs_stat_data = kcalloc(kvm_debugfs_num_entries,
> sizeof(*kvm->debugfs_stat_data),
> @@ -591,11 +588,8 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
> stat_data->kvm = kvm;
> stat_data->offset = p->offset;
> kvm->debugfs_stat_data[p - debugfs_entries] = stat_data;
> - if (!debugfs_create_file(p->name, 0644,
> - kvm->debugfs_dentry,
> - stat_data,
> - stat_fops_per_vm[p->kind]))
> - return -ENOMEM;
> + debugfs_create_file(p->name, 0644, kvm->debugfs_dentry,
> + stat_data, stat_fops_per_vm[p->kind]);
> }
> return 0;
> }
> @@ -3896,29 +3890,18 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm)
> kfree(env);
> }
>
> -static int kvm_init_debug(void)
> +static void kvm_init_debug(void)
> {
> - int r = -EEXIST;
> struct kvm_stats_debugfs_item *p;
>
> kvm_debugfs_dir = debugfs_create_dir("kvm", NULL);
> - if (kvm_debugfs_dir == NULL)
> - goto out;
>
> kvm_debugfs_num_entries = 0;
> for (p = debugfs_entries; p->name; ++p, kvm_debugfs_num_entries++) {
> - if (!debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
> - (void *)(long)p->offset,
> - stat_fops[p->kind]))
> - goto out_dir;
> + debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
> + (void *)(long)p->offset,
> + stat_fops[p->kind]);
> }
> -
> - return 0;
> -
> -out_dir:
> - debugfs_remove_recursive(kvm_debugfs_dir);
> -out:
> - return r;
> }
>
> static int kvm_suspend(void)
> @@ -4046,20 +4029,13 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
> kvm_preempt_ops.sched_in = kvm_sched_in;
> kvm_preempt_ops.sched_out = kvm_sched_out;
>
> - r = kvm_init_debug();
> - if (r) {
> - pr_err("kvm: create debugfs files failed\n");
> - goto out_undebugfs;
> - }
> + kvm_init_debug();
>
> r = kvm_vfio_ops_init();
> WARN_ON(r);
>
> return 0;
>
> -out_undebugfs:
> - unregister_syscore_ops(&kvm_syscore_ops);
> - misc_deregister(&kvm_dev);
> out_unreg:
> kvm_async_pf_deinit();
> out_free:
>
Queued, thanks.
Paolo
^ permalink raw reply
* [PATCH] kvm: no need to check return value of debugfs_create functions
From: Greg Kroah-Hartman @ 2018-05-29 16:22 UTC (permalink / raw)
To: kvm
Cc: Greg Kroah-Hartman, Paul Mackerras, Benjamin Herrenschmidt,
Michael Ellerman, Christoffer Dall, Marc Zyngier, Paolo Bonzini,
Radim Krčmář, Arvind Yadav, Eric Auger,
Andre Przywara, kvm-ppc, linuxppc-dev, linux-kernel,
linux-arm-kernel, kvmarm
When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.
This cleans up the error handling a lot, as this code will never get
hit.
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Christoffer Dall <christoffer.dall@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: kvm-ppc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_hv.c | 3 +--
virt/kvm/arm/vgic/vgic-debug.c | 17 ++++-----------
virt/kvm/arm/vgic/vgic.h | 4 ++--
virt/kvm/kvm_main.c | 40 +++++++---------------------------
4 files changed, 15 insertions(+), 49 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 4d07fca5121c..67d7de1470cc 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3950,8 +3950,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
*/
snprintf(buf, sizeof(buf), "vm%d", current->pid);
kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
- if (!IS_ERR_OR_NULL(kvm->arch.debugfs_dir))
- kvmppc_mmu_debugfs_init(kvm);
+ kvmppc_mmu_debugfs_init(kvm);
return 0;
}
diff --git a/virt/kvm/arm/vgic/vgic-debug.c b/virt/kvm/arm/vgic/vgic-debug.c
index 10b38178cff2..0140b29079b6 100644
--- a/virt/kvm/arm/vgic/vgic-debug.c
+++ b/virt/kvm/arm/vgic/vgic-debug.c
@@ -263,21 +263,12 @@ static const struct file_operations vgic_debug_fops = {
.release = seq_release
};
-int vgic_debug_init(struct kvm *kvm)
+void vgic_debug_init(struct kvm *kvm)
{
- if (!kvm->debugfs_dentry)
- return -ENOENT;
-
- if (!debugfs_create_file("vgic-state", 0444,
- kvm->debugfs_dentry,
- kvm,
- &vgic_debug_fops))
- return -ENOMEM;
-
- return 0;
+ debugfs_create_file("vgic-state", 0444, kvm->debugfs_dentry, kvm,
+ &vgic_debug_fops);
}
-int vgic_debug_destroy(struct kvm *kvm)
+void vgic_debug_destroy(struct kvm *kvm)
{
- return 0;
}
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h
index 830e815748a0..3c38c5349953 100644
--- a/virt/kvm/arm/vgic/vgic.h
+++ b/virt/kvm/arm/vgic/vgic.h
@@ -229,8 +229,8 @@ void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
int vgic_lazy_init(struct kvm *kvm);
int vgic_init(struct kvm *kvm);
-int vgic_debug_init(struct kvm *kvm);
-int vgic_debug_destroy(struct kvm *kvm);
+void vgic_debug_init(struct kvm *kvm);
+void vgic_debug_destroy(struct kvm *kvm);
bool lock_all_vcpus(struct kvm *kvm);
void unlock_all_vcpus(struct kvm *kvm);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index c7b2e927f699..0ad400f353fc 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -572,10 +572,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
return 0;
snprintf(dir_name, sizeof(dir_name), "%d-%d", task_pid_nr(current), fd);
- kvm->debugfs_dentry = debugfs_create_dir(dir_name,
- kvm_debugfs_dir);
- if (!kvm->debugfs_dentry)
- return -ENOMEM;
+ kvm->debugfs_dentry = debugfs_create_dir(dir_name, kvm_debugfs_dir);
kvm->debugfs_stat_data = kcalloc(kvm_debugfs_num_entries,
sizeof(*kvm->debugfs_stat_data),
@@ -591,11 +588,8 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
stat_data->kvm = kvm;
stat_data->offset = p->offset;
kvm->debugfs_stat_data[p - debugfs_entries] = stat_data;
- if (!debugfs_create_file(p->name, 0644,
- kvm->debugfs_dentry,
- stat_data,
- stat_fops_per_vm[p->kind]))
- return -ENOMEM;
+ debugfs_create_file(p->name, 0644, kvm->debugfs_dentry,
+ stat_data, stat_fops_per_vm[p->kind]);
}
return 0;
}
@@ -3896,29 +3890,18 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm)
kfree(env);
}
-static int kvm_init_debug(void)
+static void kvm_init_debug(void)
{
- int r = -EEXIST;
struct kvm_stats_debugfs_item *p;
kvm_debugfs_dir = debugfs_create_dir("kvm", NULL);
- if (kvm_debugfs_dir == NULL)
- goto out;
kvm_debugfs_num_entries = 0;
for (p = debugfs_entries; p->name; ++p, kvm_debugfs_num_entries++) {
- if (!debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
- (void *)(long)p->offset,
- stat_fops[p->kind]))
- goto out_dir;
+ debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
+ (void *)(long)p->offset,
+ stat_fops[p->kind]);
}
-
- return 0;
-
-out_dir:
- debugfs_remove_recursive(kvm_debugfs_dir);
-out:
- return r;
}
static int kvm_suspend(void)
@@ -4046,20 +4029,13 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
kvm_preempt_ops.sched_in = kvm_sched_in;
kvm_preempt_ops.sched_out = kvm_sched_out;
- r = kvm_init_debug();
- if (r) {
- pr_err("kvm: create debugfs files failed\n");
- goto out_undebugfs;
- }
+ kvm_init_debug();
r = kvm_vfio_ops_init();
WARN_ON(r);
return 0;
-out_undebugfs:
- unregister_syscore_ops(&kvm_syscore_ops);
- misc_deregister(&kvm_dev);
out_unreg:
kvm_async_pf_deinit();
out_free:
--
2.17.0
^ permalink raw reply related
* [PATCH v3 3/3] powerpc/time: no steal_time if !CONFIG_PPC_SPLPAR
From: Christophe Leroy @ 2018-05-29 16:19 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <2e937890abac10677aae3c1e345dd934a6794c37.1527610536.git.christophe.leroy@c-s.fr>
If CONFIG_PPC_SPLPAR is not selected, steal_time will always
be NUL, so accounting it is pointless
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
New in v3
arch/powerpc/kernel/time.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7d6040233003..85d1b1ff45f3 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -346,7 +346,8 @@ void vtime_account_system(struct task_struct *tsk)
stime = vtime_delta(tsk, &stime_scaled, &steal_time);
stime -= min(stime, steal_time);
- acct->steal_time += steal_time;
+ if (IS_ENABLED(CONFIG_PPC_SPLPAR))
+ acct->steal_time += steal_time;
if ((tsk->flags & PF_VCPU) && !irq_count()) {
acct->gtime += stime;
@@ -401,7 +402,7 @@ void vtime_flush(struct task_struct *tsk)
if (acct->gtime)
account_guest_time(tsk, cputime_to_nsecs(acct->gtime));
- if (acct->steal_time)
+ if (IS_ENABLED(CONFIG_PPC_SPLPAR) && acct->steal_time)
account_steal_time(cputime_to_nsecs(acct->steal_time));
if (acct->idle_time)
@@ -425,7 +426,8 @@ void vtime_flush(struct task_struct *tsk)
acct->stime_scaled = 0;
#endif
acct->gtime = 0;
- acct->steal_time = 0;
+ if (IS_ENABLED(CONFIG_PPC_SPLPAR))
+ acct->steal_time = 0;
acct->idle_time = 0;
acct->stime = 0;
acct->hardirq_time = 0;
--
2.13.3
^ permalink raw reply related
* [PATCH v3 2/3] powerpc/time: Only set ARCH_HAS_SCALED_CPUTIME on PPC64
From: Christophe Leroy @ 2018-05-29 16:19 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
In-Reply-To: <2e937890abac10677aae3c1e345dd934a6794c37.1527610536.git.christophe.leroy@c-s.fr>
scaled cputime is only meaningfull when the processor has
SPURR and/or PURR, which means only on PPC64.
Removing it on PPC32 significantly reduces the size of
vtime_account_system() and vtime_account_idle() on an 8xx:
Before:
00000114 l F .text 000000a8 vtime_delta
000004c0 g F .text 00000100 vtime_account_system
000005c0 g F .text 00000048 vtime_account_idle
After:
(vtime_delta gets inlined in the two functions)
00000418 g F .text 000000a0 vtime_account_system
000004b8 g F .text 00000054 vtime_account_idle
In terms of performance, we also get approximatly 5% improvement on task switch:
The following small benchmark app is run with perf stat:
void *thread(void *arg)
{
int i;
for (i = 0; i < atoi((char*)arg); i++)
pthread_yield();
}
int main(int argc, char **argv)
{
pthread_t th1, th2;
pthread_create(&th1, NULL, thread, argv[1]);
pthread_create(&th2, NULL, thread, argv[1]);
pthread_join(th1, NULL);
pthread_join(th2, NULL);
return 0;
}
Before the patch:
~# perf stat chrt -f 98 ./sched 100000
Performance counter stats for 'chrt -f 98 ./sched 100000':
8622.166272 task-clock (msec) # 0.955 CPUs utilized
200027 context-switches # 0.023 M/sec
After the patch:
~# perf stat chrt -f 98 ./sched 100000
Performance counter stats for 'chrt -f 98 ./sched 100000':
8207.090048 task-clock (msec) # 0.958 CPUs utilized
200025 context-switches # 0.024 M/sec
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
v3: Rebased following modifications in xmon.c
v2: added ifdefs in xmon to fix compilation error
arch/powerpc/Kconfig | 2 +-
arch/powerpc/include/asm/accounting.h | 4 ++++
arch/powerpc/include/asm/cputime.h | 2 ++
arch/powerpc/kernel/time.c | 29 +++++++++++++++++++++++------
arch/powerpc/xmon/xmon.c | 4 ++++
5 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4a66d39addd4..87ebac147828 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -142,7 +142,7 @@ config PPC
select ARCH_HAS_PHYS_TO_DMA
select ARCH_HAS_PMEM_API if PPC64
select ARCH_HAS_MEMBARRIER_CALLBACKS
- select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE
+ select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC64
select ARCH_HAS_SG_CHAIN
select ARCH_HAS_STRICT_KERNEL_RWX if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION)
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
diff --git a/arch/powerpc/include/asm/accounting.h b/arch/powerpc/include/asm/accounting.h
index 3abcf98ed2e0..f1096d4cc658 100644
--- a/arch/powerpc/include/asm/accounting.h
+++ b/arch/powerpc/include/asm/accounting.h
@@ -15,8 +15,10 @@ struct cpu_accounting_data {
/* Accumulated cputime values to flush on ticks*/
unsigned long utime;
unsigned long stime;
+#ifdef ARCH_HAS_SCALED_CPUTIME
unsigned long utime_scaled;
unsigned long stime_scaled;
+#endif
unsigned long gtime;
unsigned long hardirq_time;
unsigned long softirq_time;
@@ -25,8 +27,10 @@ struct cpu_accounting_data {
/* Internal counters */
unsigned long starttime; /* TB value snapshot */
unsigned long starttime_user; /* TB value on exit to usermode */
+#ifdef ARCH_HAS_SCALED_CPUTIME
unsigned long startspurr; /* SPURR value snapshot */
unsigned long utime_sspurr; /* ->user_time when ->startspurr set */
+#endif
};
#endif
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index bc4903badb3f..8fd3c1338822 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -62,7 +62,9 @@ static inline void arch_vtime_task_switch(struct task_struct *prev)
struct cpu_accounting_data *acct0 = get_accounting(prev);
acct->starttime = acct0->starttime;
+#ifdef ARCH_HAS_SCALED_CPUTIME
acct->startspurr = acct0->startspurr;
+#endif
}
#endif
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index a3ed2eb99d88..7d6040233003 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -175,6 +175,7 @@ static void calc_cputime_factors(void)
* Read the SPURR on systems that have it, otherwise the PURR,
* or if that doesn't exist return the timebase value passed in.
*/
+#ifdef ARCH_HAS_SCALED_CPUTIME
static unsigned long read_spurr(unsigned long tb)
{
if (cpu_has_feature(CPU_FTR_SPURR))
@@ -183,6 +184,7 @@ static unsigned long read_spurr(unsigned long tb)
return mfspr(SPRN_PURR);
return tb;
}
+#endif
#ifdef CONFIG_PPC_SPLPAR
@@ -285,22 +287,28 @@ static unsigned long vtime_delta(struct task_struct *tsk,
unsigned long *stime_scaled,
unsigned long *steal_time)
{
- unsigned long now, nowscaled, deltascaled;
+ unsigned long now;
unsigned long stime;
+#ifdef ARCH_HAS_SCALED_CPUTIME
+ unsigned long nowscaled, deltascaled;
unsigned long utime, utime_scaled;
+#endif
struct cpu_accounting_data *acct = get_accounting(tsk);
WARN_ON_ONCE(!irqs_disabled());
now = mftb();
+#ifdef ARCH_HAS_SCALED_CPUTIME
nowscaled = read_spurr(now);
+#endif
stime = now - acct->starttime;
acct->starttime = now;
- deltascaled = nowscaled - acct->startspurr;
- acct->startspurr = nowscaled;
*steal_time = calculate_stolen_time(now);
+#ifdef ARCH_HAS_SCALED_CPUTIME
+ deltascaled = nowscaled - acct->startspurr;
+ acct->startspurr = nowscaled;
utime = acct->utime - acct->utime_sspurr;
acct->utime_sspurr = acct->utime;
@@ -325,6 +333,7 @@ static unsigned long vtime_delta(struct task_struct *tsk,
}
}
acct->utime_scaled += utime_scaled;
+#endif
return stime;
}
@@ -341,7 +350,9 @@ void vtime_account_system(struct task_struct *tsk)
if ((tsk->flags & PF_VCPU) && !irq_count()) {
acct->gtime += stime;
+#ifdef ARCH_HAS_SCALED_CPUTIME
acct->utime_scaled += stime_scaled;
+#endif
} else {
if (hardirq_count())
acct->hardirq_time += stime;
@@ -350,7 +361,9 @@ void vtime_account_system(struct task_struct *tsk)
else
acct->stime += stime;
+#ifdef ARCH_HAS_SCALED_CPUTIME
acct->stime_scaled += stime_scaled;
+#endif
}
}
EXPORT_SYMBOL_GPL(vtime_account_system);
@@ -378,8 +391,12 @@ void vtime_flush(struct task_struct *tsk)
if (acct->utime)
account_user_time(tsk, cputime_to_nsecs(acct->utime));
+#ifdef ARCH_HAS_SCALED_CPUTIME
if (acct->utime_scaled)
tsk->utimescaled += cputime_to_nsecs(acct->utime_scaled);
+ if (acct->stime_scaled)
+ tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled);
+#endif
if (acct->gtime)
account_guest_time(tsk, cputime_to_nsecs(acct->gtime));
@@ -393,8 +410,6 @@ void vtime_flush(struct task_struct *tsk)
if (acct->stime)
account_system_index_time(tsk, cputime_to_nsecs(acct->stime),
CPUTIME_SYSTEM);
- if (acct->stime_scaled)
- tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled);
if (acct->hardirq_time)
account_system_index_time(tsk, cputime_to_nsecs(acct->hardirq_time),
@@ -404,13 +419,15 @@ void vtime_flush(struct task_struct *tsk)
CPUTIME_SOFTIRQ);
acct->utime = 0;
+#ifdef ARCH_HAS_SCALED_CPUTIME
acct->utime_scaled = 0;
acct->utime_sspurr = 0;
+ acct->stime_scaled = 0;
+#endif
acct->gtime = 0;
acct->steal_time = 0;
acct->idle_time = 0;
acct->stime = 0;
- acct->stime_scaled = 0;
acct->hardirq_time = 0;
acct->softirq_time = 0;
}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index c2e9270728c7..8ccfb2ae3aca 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2439,11 +2439,15 @@ static void dump_one_paca(int cpu)
DUMP(p, accounting.utime, "%#-*lx");
DUMP(p, accounting.stime, "%#-*lx");
+#ifdef ARCH_HAS_SCALED_CPUTIME
DUMP(p, accounting.utime_scaled, "%#-*lx");
+#endif
DUMP(p, accounting.starttime, "%#-*lx");
DUMP(p, accounting.starttime_user, "%#-*lx");
+#ifdef ARCH_HAS_SCALED_CPUTIME
DUMP(p, accounting.startspurr, "%#-*lx");
DUMP(p, accounting.utime_sspurr, "%#-*lx");
+#endif
DUMP(p, accounting.steal_time, "%#-*lx");
#undef DUMP
--
2.13.3
^ permalink raw reply related
* [PATCH v3 1/3] powerpc/time: inline arch_vtime_task_switch()
From: Christophe Leroy @ 2018-05-29 16:19 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linux-kernel, linuxppc-dev
arch_vtime_task_switch() is a small function which is called
only from vtime_common_task_switch(), so it is worth inlining
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
v3: no change
v2: added a local pointer for get_accounting(prev) to avoid GCC to read it twice
arch/powerpc/include/asm/cputime.h | 16 +++++++++++++++-
arch/powerpc/kernel/time.c | 21 ---------------------
2 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 99b541865d8d..bc4903badb3f 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -47,9 +47,23 @@ static inline unsigned long cputime_to_usecs(const cputime_t ct)
* has to be populated in the new task
*/
#ifdef CONFIG_PPC64
+#define get_accounting(tsk) (&get_paca()->accounting)
static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
#else
-void arch_vtime_task_switch(struct task_struct *tsk);
+#define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
+/*
+ * Called from the context switch with interrupts disabled, to charge all
+ * accumulated times to the current process, and to prepare accounting on
+ * the next process.
+ */
+static inline void arch_vtime_task_switch(struct task_struct *prev)
+{
+ struct cpu_accounting_data *acct = get_accounting(current);
+ struct cpu_accounting_data *acct0 = get_accounting(prev);
+
+ acct->starttime = acct0->starttime;
+ acct->startspurr = acct0->startspurr;
+}
#endif
#endif /* __KERNEL__ */
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 360e71d455cc..a3ed2eb99d88 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -163,12 +163,6 @@ EXPORT_SYMBOL(__cputime_usec_factor);
void (*dtl_consumer)(struct dtl_entry *, u64);
#endif
-#ifdef CONFIG_PPC64
-#define get_accounting(tsk) (&get_paca()->accounting)
-#else
-#define get_accounting(tsk) (&task_thread_info(tsk)->accounting)
-#endif
-
static void calc_cputime_factors(void)
{
struct div_result res;
@@ -421,21 +415,6 @@ void vtime_flush(struct task_struct *tsk)
acct->softirq_time = 0;
}
-#ifdef CONFIG_PPC32
-/*
- * Called from the context switch with interrupts disabled, to charge all
- * accumulated times to the current process, and to prepare accounting on
- * the next process.
- */
-void arch_vtime_task_switch(struct task_struct *prev)
-{
- struct cpu_accounting_data *acct = get_accounting(current);
-
- acct->starttime = get_accounting(prev)->starttime;
- acct->startspurr = get_accounting(prev)->startspurr;
-}
-#endif /* CONFIG_PPC32 */
-
#else /* ! CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
#define calc_cputime_factors()
#endif
--
2.13.3
^ permalink raw reply related
* Re: [PATCH] powerpc/64s: Enhance the information in cpu_show_spectre_v1()
From: Joe Perches @ 2018-05-29 16:15 UTC (permalink / raw)
To: Christophe Leroy, Michal Suchánek
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Mauricio Faria de Oliveira, Nicholas Piggin, Michael Neuling,
linuxppc-dev, linux-kernel
In-Reply-To: <59492aa2-a12d-4f74-0a5a-14f89de64908@c-s.fr>
On Tue, 2018-05-29 at 15:24 +0000, Christophe Leroy wrote:
> On 05/29/2018 02:46 PM, Michal Suchánek wrote:
> > On Tue, 29 May 2018 16:13:49 +0200 Christophe LEROY <christophe.leroy@c-s.fr> wrote:
[]
> > diff --git a/arch/powerpc/kernel/security.c
> > > > b/arch/powerpc/kernel/security.c index 0239383c7e4d..a0c32d53980b
> > > > 100644 --- a/arch/powerpc/kernel/security.c
> > > > +++ b/arch/powerpc/kernel/security.c
> > > > @@ -120,7 +120,10 @@ ssize_t cpu_show_spectre_v1(struct device
> > > > *dev, struct device_attribute *attr, c if
> > > > (!security_ftr_enabled(SEC_FTR_BNDS_CHK_SPEC_BAR)) return
> > > > sprintf(buf, "Not affected\n");
> > > > - return sprintf(buf, "Vulnerable\n");
> > > > + if (barrier_nospec_enabled)
> > > > + return sprintf(buf, "Mitigation: __user pointer
> > > > sanitization\n");
> > > > + else
> > > > + return sprintf(buf, "Vulnerable\n");
> > >
> > > Checkpatch would tell you that an else is unneeded after a return. So
> > > just leave it as it was before.
> >
> > Where did you get your copy of checkpatch? The one in Linux tree does
> > not do that.
Correct as this particular style is a maintainer preference.
> Strange, it should, as checkpatch.pl includes the following code:
>
> # check indentation of any line with a bare else
> # (but not if it is a multiple line "if (foo) return bar; else return baz;")
Note this comment and also that this case is
if (foo)
return bar;
else
return baz;
so no warning is generated.
> # if the previous line is a break or return and is indented 1 tab more...
> if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) {
> my $tabs = length($1) + 1;
> if ($prevline =~ /^\+\t{$tabs,$tabs}break\b/ ||
> ($prevline =~ /^\+\t{$tabs,$tabs}return\b/ &&
> defined $lines[$linenr] &&
> $lines[$linenr] !~ /^[ \+]\t{$tabs,$tabs}return/)) {
> WARN("UNNECESSARY_ELSE",
> "else is not generally useful after a break or return\n" .
> $hereprev);
> }
> }
>
>
> Anyway, you should remove that 'else' in your patch.
> And the other sprintf line is over 80 characters.
>
> Christophe
>
> >
> > Thanks
> >
> > Michal
> >
^ permalink raw reply
* [PATCH v3] powerpc: fix build failure by disabling attribute-alias warning
From: Christophe Leroy @ 2018-05-29 16:06 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, segher
Cc: linux-kernel, linuxppc-dev
Latest GCC version emit the following warnings
As arch/powerpc code is built with -Werror, this breaks build with
GCC 8.1
This patch inhibits those warnings
CC arch/powerpc/kernel/syscalls.o
In file included from arch/powerpc/kernel/syscalls.c:24:
./include/linux/syscalls.h:233:18: error: 'sys_mmap2' alias between functions of incompatible types 'long int(long unsigned int, size_t, long unsigned int, long unsigned int, long unsigned int, long unsigned int)' {aka 'long int(long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int)'} and 'long int(long int, long int, long int, long int, long int, long int)' [-Werror=attribute-alias]
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/syscalls.c:65:1: note: in expansion of macro 'SYSCALL_DEFINE6'
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/syscalls.c:65:1: note: in expansion of macro 'SYSCALL_DEFINE6'
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:233:18: error: 'sys_mmap' alias between functions of incompatible types 'long int(long unsigned int, size_t, long unsigned int, long unsigned int, long unsigned int, off_t)' {aka 'long int(long unsigned int, long unsigned int, long unsigned int, long unsigned int, long unsigned int, long int)'} and 'long int(long int, long int, long int, long int, long int, long int)' [-Werror=attribute-alias]
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/syscalls.c:72:1: note: in expansion of macro 'SYSCALL_DEFINE6'
SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:216:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/syscalls.c:72:1: note: in expansion of macro 'SYSCALL_DEFINE6'
SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
^~~~~~~~~~~~~~~
CC arch/powerpc/kernel/signal_32.o
In file included from arch/powerpc/kernel/signal_32.c:31:
./include/linux/compat.h:74:18: error: 'compat_sys_swapcontext' alias between functions of incompatible types 'long int(struct ucontext32 *, struct ucontext32 *, int)' and 'long int(long int, long int, long int)' [-Werror=attribute-alias]
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~~~~~~~~
./include/linux/compat.h:58:2: note: in expansion of macro 'COMPAT_SYSCALL_DEFINEx'
COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/kernel/signal_32.c:1041:1: note: in expansion of macro 'COMPAT_SYSCALL_DEFINE3'
COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
^~~~~~~~~~~~~~~~~~~~~~
./include/linux/compat.h:79:18: note: aliased declaration here
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~~~~~~~~
./include/linux/compat.h:58:2: note: in expansion of macro 'COMPAT_SYSCALL_DEFINEx'
COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/kernel/signal_32.c:1041:1: note: in expansion of macro 'COMPAT_SYSCALL_DEFINE3'
COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
^~~~~~~~~~~~~~~~~~~~~~
CC arch/powerpc/kernel/signal_64.o
In file included from arch/powerpc/kernel/signal_64.c:27:
./include/linux/syscalls.h:233:18: error: 'sys_swapcontext' alias between functions of incompatible types 'long int(struct ucontext *, struct ucontext *, long int)' and 'long int(long int, long int, long int)' [-Werror=attribute-alias]
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/signal_64.c:628:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/signal_64.c:628:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
^~~~~~~~~~~~~~~
CC arch/powerpc/kernel/rtas.o
In file included from arch/powerpc/kernel/rtas.c:29:
./include/linux/syscalls.h:233:18: error: 'sys_rtas' alias between functions of incompatible types 'long int(struct rtas_args *)' and 'long int(long int)' [-Werror=attribute-alias]
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:211:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/rtas.c:1054:1: note: in expansion of macro 'SYSCALL_DEFINE1'
SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:211:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/rtas.c:1054:1: note: in expansion of macro 'SYSCALL_DEFINE1'
SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
^~~~~~~~~~~~~~~
CC arch/powerpc/kernel/pci_64.o
In file included from arch/powerpc/kernel/pci_64.c:23:
./include/linux/syscalls.h:233:18: error: 'sys_pciconfig_iobase' alias between functions of incompatible types 'long int(long int, long unsigned int, long unsigned int)' and 'long int(long int, long int, long int)' [-Werror=attribute-alias]
asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/pci_64.c:206:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
^~~~~~~~~~~~~~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^~~~~~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
arch/powerpc/kernel/pci_64.c:206:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
^~~~~~~~~~~~~~~
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
v3: added '#pragma GCC diagnostic ignored "-Wpragmas"' to avoid build failure on old GCC
arch/powerpc/kernel/pci_64.c | 4 ++++
arch/powerpc/kernel/rtas.c | 4 ++++
arch/powerpc/kernel/signal_32.c | 8 ++++++++
arch/powerpc/kernel/signal_64.c | 4 ++++
arch/powerpc/kernel/syscalls.c | 4 ++++
arch/powerpc/mm/subpage-prot.c | 4 ++++
6 files changed, 28 insertions(+)
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index dff28f903512..812171c09f42 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -203,6 +203,9 @@ void pcibios_setup_phb_io_space(struct pci_controller *hose)
#define IOBASE_ISA_IO 3
#define IOBASE_ISA_MEM 4
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
unsigned long, in_devfn)
{
@@ -256,6 +259,7 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
return -EOPNOTSUPP;
}
+#pragma GCC diagnostic pop
#ifdef CONFIG_NUMA
int pcibus_to_node(struct pci_bus *bus)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 8afd146bc9c7..7fb9f83dcde8 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1051,6 +1051,9 @@ struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
}
/* We assume to be passed big endian arguments */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
{
struct rtas_args args;
@@ -1137,6 +1140,7 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
return 0;
}
+#pragma GCC diagnostic pop
/*
* Call early during boot, before mem init, to retrieve the RTAS
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 9cf8a03d3bc7..342ac78f620f 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -1037,6 +1037,9 @@ static int do_setcontext_tm(struct ucontext __user *ucp,
}
#endif
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
#ifdef CONFIG_PPC64
COMPAT_SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
struct ucontext __user *, new_ctx, int, ctx_size)
@@ -1132,6 +1135,7 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
set_thread_flag(TIF_RESTOREALL);
return 0;
}
+#pragma GCC diagnostic pop
#ifdef CONFIG_PPC64
COMPAT_SYSCALL_DEFINE0(rt_sigreturn)
@@ -1228,6 +1232,9 @@ SYSCALL_DEFINE0(rt_sigreturn)
return 0;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
#ifdef CONFIG_PPC32
SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
int, ndbg, struct sig_dbg_op __user *, dbg)
@@ -1333,6 +1340,7 @@ SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx,
return 0;
}
#endif
+#pragma GCC diagnostic pop
/*
* OK, we're invoking a handler
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 83d51bf586c7..d42b60020389 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -625,6 +625,9 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
/*
* Handle {get,set,swap}_context operations
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
struct ucontext __user *, new_ctx, long, ctx_size)
{
@@ -690,6 +693,7 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
set_thread_flag(TIF_RESTOREALL);
return 0;
}
+#pragma GCC diagnostic pop
/*
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index 466216506eb2..083fa06962fd 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -62,6 +62,9 @@ static inline long do_mmap2(unsigned long addr, size_t len,
return ret;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
unsigned long, prot, unsigned long, flags,
unsigned long, fd, unsigned long, pgoff)
@@ -75,6 +78,7 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, size_t, len,
{
return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
}
+#pragma GCC diagnostic pop
#ifdef CONFIG_PPC32
/*
diff --git a/arch/powerpc/mm/subpage-prot.c b/arch/powerpc/mm/subpage-prot.c
index 9d16ee251fc0..75cb646a79c3 100644
--- a/arch/powerpc/mm/subpage-prot.c
+++ b/arch/powerpc/mm/subpage-prot.c
@@ -186,6 +186,9 @@ static void subpage_mark_vma_nohuge(struct mm_struct *mm, unsigned long addr,
* in a 2-bit field won't allow writes to a page that is otherwise
* write-protected.
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
unsigned long, len, u32 __user *, map)
{
@@ -269,3 +272,4 @@ SYSCALL_DEFINE3(subpage_prot, unsigned long, addr,
up_write(&mm->mmap_sem);
return err;
}
+#pragma GCC diagnostic pop
--
2.13.3
^ permalink raw reply related
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