LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] powerpc, pkey: make protection key 0 less special
From: Ram Pai @ 2018-04-06 18:01 UTC (permalink / raw)
  To: Thiago Jung Bauermann
  Cc: mpe, mingo, akpm, fweimer, shuah, msuchanek, linux-kernel, mhocko,
	dave.hansen, paulus, aneesh.kumar, tglx, linuxppc-dev
In-Reply-To: <876056645u.fsf@morokweng.localdomain>

On Wed, Apr 04, 2018 at 06:41:01PM -0300, Thiago Jung Bauermann wrote:
> 
> Hello Ram,
> 
> Ram Pai <linuxram@us.ibm.com> writes:
> 
> > Applications need the ability to associate an address-range with some
> > key and latter revert to its initial default key. Pkey-0 comes close to
> > providing this function but falls short, because the current
> > implementation disallows applications to explicitly associate pkey-0 to
> > the address range.
> >
> > Lets make pkey-0 less special and treat it almost like any other key.
> > Thus it can be explicitly associated with any address range, and can be
> > freed. This gives the application more flexibility and power.  The
> > ability to free pkey-0 must be used responsibily, since pkey-0 is
> > associated with almost all address-range by default.
> >
> > Even with this change pkey-0 continues to be slightly more special
> > from the following point of view.
> > (a) it is implicitly allocated.
> > (b) it is the default key assigned to any address-range.
> 
> It's also special in more ways (and if intentional, these should be part
> of the commit message as well):
> 
> (c) it's not possible to change permissions for key 0
> 
>   This has two causes: this patch explicitly forbids it in
>   arch_set_user_pkey_access(), and also because even if it's allocated,
>   the bits for key 0 in AMOR and UAMOR aren't set.

Yes. will have to capture that one aswell.

we cannot let userspace change permissions on key 0 because
doing so will hurt the kernel too. Unlike x86 where keys are effective
only in userspace, powerpc keys are effective even in the kernel.
So if the kernel tries to access something, it will get stuck forever.
Almost everything in the kernel is associated with key-0.

I ran a small test program which disabled access on key 0 from
userspace, and as expected ran into softlockups. It certainly
can lead to denial-of-service-attack. We can let apps
shoot-itself-in-its-foot but if the shot hurts someone else, we will
have to stop it.

The key-semantics discussed with the x86 folks did not 
explicitly say anything about changing permissions on key-0. We will
have to keep that part of the semantics open-ended.

> 
> (d) it can be freed, but can't be allocated again later.
> 
>   This is because mm_pkey_alloc() only calls __arch_activate_pkey(ret)
>   if ret > 0.
> 
> It looks like (d) is a bug. Either mm_pkey_free() should fail with key
> 0, or mm_pkey_alloc() should work with it.

Well, it can be allocated, just that we do not let userspace change the
permissions on the key.  __arch_activate_pkey(ret) does not get called
for pkey-0.


> 
> (c) could be a measure to prevent users from shooting themselves in
> their feet. But if that is the case, then mm_pkey_free() should forbid
> freeing key 0 too.
> 
> > Tested on powerpc.
> >
> > cc: Thomas Gleixner <tglx@linutronix.de>
> > cc: Dave Hansen <dave.hansen@intel.com>
> > cc: Michael Ellermen <mpe@ellerman.id.au>
> > cc: Ingo Molnar <mingo@kernel.org>
> > cc: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > ---
> > History:
> > 	v2: mm_pkey_is_allocated() continued to treat pkey-0 special.
> > 	    fixed it.
> >
> >  arch/powerpc/include/asm/pkeys.h | 20 ++++++++++++++++----
> >  arch/powerpc/mm/pkeys.c          | 20 ++++++++++++--------
> >  2 files changed, 28 insertions(+), 12 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h
> > index 0409c80..b598fa9 100644
> > --- a/arch/powerpc/include/asm/pkeys.h
> > +++ b/arch/powerpc/include/asm/pkeys.h
> > @@ -101,10 +101,14 @@ static inline u16 pte_to_pkey_bits(u64 pteflags)
> >
> >  static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
> >  {
> > -	/* A reserved key is never considered as 'explicitly allocated' */
> > -	return ((pkey < arch_max_pkey()) &&
> > -		!__mm_pkey_is_reserved(pkey) &&
> > -		__mm_pkey_is_allocated(mm, pkey));
> > +	if (pkey < 0 || pkey >= arch_max_pkey())
> > +		return false;
> > +
> > +	/* Reserved keys are never allocated. */
> > +	if (__mm_pkey_is_reserved(pkey))
> > +		return false;
> > +
> > +	return __mm_pkey_is_allocated(mm, pkey);
> >  }
> >
> >  extern void __arch_activate_pkey(int pkey);
> > @@ -200,6 +204,14 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
> >  {
> >  	if (static_branch_likely(&pkey_disabled))
> >  		return -EINVAL;
> > +
> > +	/*
> > +	 * userspace is discouraged from changing permissions of
> > +	 * pkey-0.
> 
> They're not discouraged. They're not allowed to. :-)

ok :-)

> 
> > +	 * powerpc hardware does not support it anyway.
> 
> It doesn't? I don't get that impression from reading the ISA, but
> perhaps I'm missing something.

Good Catch. I am wrongly blaming it on powerpc hardware.
Its a semantics enforced by our pkey code to block DOS attacks.

> 
> > +	 */
> > +	if (!pkey)
> > +		return init_val ? -EINVAL : 0;
> > +
> >  	return __arch_set_user_pkey_access(tsk, pkey, init_val);
> >  }
> >
> > diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
> > index ba71c54..e7a9e34 100644
> > --- a/arch/powerpc/mm/pkeys.c
> > +++ b/arch/powerpc/mm/pkeys.c
> > @@ -119,19 +119,21 @@ int pkey_initialize(void)
> >  #else
> >  	os_reserved = 0;
> >  #endif
> > -	/*
> > -	 * Bits are in LE format. NOTE: 1, 0 are reserved.
> > -	 * key 0 is the default key, which allows read/write/execute.
> > -	 * key 1 is recommended not to be used. PowerISA(3.0) page 1015,
> > -	 * programming note.
> > -	 */
> > +	/* Bits are in LE format. */
> >  	initial_allocation_mask = ~0x0;
> >
> >  	/* register mask is in BE format */
> >  	pkey_amr_uamor_mask = ~0x0ul;
> >  	pkey_iamr_mask = ~0x0ul;
> >
> > -	for (i = 2; i < (pkeys_total - os_reserved); i++) {
> > +	for (i = 0; i < (pkeys_total - os_reserved); i++) {
> > +	 	/*
> 
> There's a space between the tabs here.

ok. will fix.

> 
> > +		 * key 1 is recommended not to be used.
> > +		 * PowerISA(3.0) page 1015,
> > +		 */
> > +		if (i == 1)
> > +			continue;
> > +
> >  		initial_allocation_mask &= ~(0x1 << i);
> >  		pkey_amr_uamor_mask &= ~(0x3ul << pkeyshift(i));
> >  		pkey_iamr_mask &= ~(0x1ul << pkeyshift(i));
> > @@ -145,7 +147,9 @@ void pkey_mm_init(struct mm_struct *mm)
> >  {
> >  	if (static_branch_likely(&pkey_disabled))
> >  		return;
> > -	mm_pkey_allocation_map(mm) = initial_allocation_mask;
> > +
> > +	/* allocate key-0 by default */
> > +	mm_pkey_allocation_map(mm) = initial_allocation_mask | 0x1;
> >  	/* -1 means unallocated or invalid */
> >  	mm->context.execute_only_pkey = -1;
> >  }
> 
> I think we should also set the AMOR and UAMOR bits for key 0. Otherwise,
> key 0 will be in allocated-but-not-enabled state which is yet another
> subtle way in which it will be special.

No. as explained above, it will hurt to let userspace modify
permissions on key-0.

> 
> Also, pkey_access_permitted() has a special case for key 0. Should it?

we can delete that check. though it does not hurt to leave it in place.
Access/Write/Execute on pkey-0 is always permitted.

RP

^ permalink raw reply

* Re: [PATCH v3 1/4] libnvdimm: Add of_node to region and bus descriptors
From: Dan Williams @ 2018-04-06 18:28 UTC (permalink / raw)
  To: Oliver O'Halloran; +Cc: linuxppc-dev, linux-nvdimm
In-Reply-To: <20180406052116.31483-1-oohall@gmail.com>

On Thu, Apr 5, 2018 at 10:21 PM, Oliver O'Halloran <oohall@gmail.com> wrote:
> We want to be able to cross reference the region and bus devices
> with the device tree node that they were spawned from. libNVDIMM
> handles creating the actual devices for these internally, so we
> need to pass in a pointer to the relevant node in the descriptor.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> Acked-by: Dan Williams <dan.j.williams@intel.com>

These look good to me. I'll get them applied today and let them soak
over the weekend for a pull request on Monday.

If anyone wants to add Acks or Reviews I can append them to the merge
tag. If there are any NAKs please speak up now, but as far as I know
there are no pending device-tree design concerns.

^ permalink raw reply

* Re: [PATCH v4 03/19] powerpc: Mark variable `l` as unused, remove `path`
From: Mathieu Malaterre @ 2018-04-06 18:32 UTC (permalink / raw)
  To: LEROY Christophe
  Cc: LKML, linuxppc-dev, Paul Mackerras, Benjamin Herrenschmidt,
	Michael Ellerman
In-Reply-To: <20180406173335.Horde.Qgml03BtHOxSl6SzIPgQLA9@messagerie.si.c-s.fr>

On Fri, Apr 6, 2018 at 5:33 PM, LEROY Christophe
<christophe.leroy@c-s.fr> wrote:
> Mathieu Malaterre <malat@debian.org> a =C3=A9crit :
>
>> Add gcc attribute unused for `l` variable, replace `path` variable
>> directly
>> with prom_scratch. Fix warnings treated as errors with W=3D1:
>>
>>   arch/powerpc/kernel/prom_init.c:607:6: error: variable =E2=80=98l=E2=
=80=99 set but not
>> used [-Werror=3Dunused-but-set-variable]
>>   arch/powerpc/kernel/prom_init.c:1388:8: error: variable =E2=80=98path=
=E2=80=99 set but
>> not used [-Werror=3Dunused-but-set-variable]
>>
>> Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>> ---
>> v4: redo v3 since path variable can be avoided
>> v3: really move path within ifdef DEBUG_PROM
>> v2: move path within ifdef DEBUG_PROM
>>
>>  arch/powerpc/kernel/prom_init.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/prom_init.c
>> b/arch/powerpc/kernel/prom_init.c
>> index f8a9a50ff9b5..4b223a9470be 100644
>> --- a/arch/powerpc/kernel/prom_init.c
>> +++ b/arch/powerpc/kernel/prom_init.c
>> @@ -604,7 +604,7 @@ static void __init early_cmdline_parse(void)
>>         const char *opt;
>>
>>         char *p;
>> -       int l =3D 0;
>> +       int l __maybe_unused =3D 0;
>
>
> Instead of hiding the problem with __maybe_unused, I think we could repla=
ce
> the
> #ifdef CONFIG_CMDLINE
> by a
> if (IS_ENABLED(CONFIG_CMDLINE_BOOL))
>
> This is recommanded by Linux codying style

Neat. I was not aware of this trick. Does not work in this case though:

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_ini=
t.c
index 7925f64fefde..19634739b279 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -604,17 +604,16 @@ static void __init early_cmdline_parse(void)
        const char *opt;

        char *p;
-       int l __maybe_unused =3D 0;
+       int l =3D 0;

        prom_cmd_line[0] =3D 0;
        p =3D prom_cmd_line;
        if ((long)prom.chosen > 0)
                l =3D prom_getprop(prom.chosen, "bootargs", p,
COMMAND_LINE_SIZE-1);
-#ifdef CONFIG_CMDLINE
-       if (l <=3D 0 || p[0] =3D=3D '\0') /* dbl check */
-               strlcpy(prom_cmd_line,
-                       CONFIG_CMDLINE, sizeof(prom_cmd_line));
-#endif /* CONFIG_CMDLINE */
+       if (IS_ENABLED(CONFIG_CMDLINE_BOOL))
+               if (l <=3D 0 || p[0] =3D=3D '\0') /* dbl check */
+                       strlcpy(prom_cmd_line,
+                               CONFIG_CMDLINE, sizeof(prom_cmd_line));
        prom_printf("command line: %s\n", prom_cmd_line);

 #ifdef CONFIG_PPC64


leads to:

  CC      arch/powerpc/kernel/prom_init.o
../arch/powerpc/kernel/prom_init.c: In function =E2=80=98early_cmdline_pars=
e=E2=80=99:
../arch/powerpc/kernel/prom_init.c:616:5: error: =E2=80=98CONFIG_CMDLINE=E2=
=80=99
undeclared (first use in this function)
     CONFIG_CMDLINE, sizeof(prom_cmd_line));
     ^~~~~~~~~~~~~~
../arch/powerpc/kernel/prom_init.c:616:5: note: each undeclared
identifier is reported only once for each function it appears in
../scripts/Makefile.build:312: recipe for target
'arch/powerpc/kernel/prom_init.o' failed
make[6]: *** [arch/powerpc/kernel/prom_init.o] Error 1


> Christophe
>
>
>>
>>         prom_cmd_line[0] =3D 0;
>>         p =3D prom_cmd_line;
>> @@ -1386,7 +1386,7 @@ static void __init reserve_mem(u64 base, u64 size)
>>  static void __init prom_init_mem(void)
>>  {
>>         phandle node;
>> -       char *path, type[64];
>> +       char type[64];
>>         unsigned int plen;
>>         cell_t *p, *endp;
>>         __be32 val;
>> @@ -1407,7 +1407,6 @@ static void __init prom_init_mem(void)
>>         prom_debug("root_size_cells: %x\n", rsc);
>>
>>         prom_debug("scanning memory:\n");
>> -       path =3D prom_scratch;
>>
>>         for (node =3D 0; prom_next_node(&node); ) {
>>                 type[0] =3D 0;
>> @@ -1432,9 +1431,9 @@ static void __init prom_init_mem(void)
>>                 endp =3D p + (plen / sizeof(cell_t));
>>
>>  #ifdef DEBUG_PROM
>> -               memset(path, 0, PROM_SCRATCH_SIZE);
>> -               call_prom("package-to-path", 3, 1, node, path,
>> PROM_SCRATCH_SIZE-1);
>> -               prom_debug("  node %s :\n", path);
>> +               memset(prom_scratch, 0, PROM_SCRATCH_SIZE);
>> +               call_prom("package-to-path", 3, 1, node, prom_scratch,
>> PROM_SCRATCH_SIZE - 1);
>> +               prom_debug("  node %s :\n", prom_scratch);
>>  #endif /* DEBUG_PROM */
>>
>>                 while ((endp - p) >=3D (rac + rsc)) {
>> --
>> 2.11.0
>
>
>

^ permalink raw reply related

* [PATCH] powerpc: add __printf verification to prom_printf
From: Mathieu Malaterre @ 2018-04-06 20:12 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, linux-kernel

__printf is useful to verify format and arguments. Fix arg mismatch
reported by gcc, remove the following warnings (with W=1):

  arch/powerpc/kernel/prom_init.c:1467:31: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1471:31: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1504:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1505:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1506:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1507:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1508:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1509:33: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1975:39: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:1986:27: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:2567:38: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:2567:46: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:2569:38: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘long unsigned int’ [-Werror=format=]
  arch/powerpc/kernel/prom_init.c:2569:46: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=]

The patch also include arg mismatch fix for case with #define DEBUG_PROM
(warning not listed here).

This patch fix also the following warnings revealed by checkpatch:

  WARNING: Prefer using '"%s...", __func__' to using 'alloc_up', this function's name, in a string
  #101: FILE: arch/powerpc/kernel/prom_init.c:1235:
  + prom_debug("alloc_up(%lx, %lx)\n", size, align);

and

  WARNING: Prefer using '"%s...", __func__' to using 'alloc_down', this function's name, in a string
  #138: FILE: arch/powerpc/kernel/prom_init.c:1278:
  + prom_debug("alloc_down(%lx, %lx, %s)\n", size, align,

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 arch/powerpc/kernel/prom_init.c | 114 ++++++++++++++++++++--------------------
 1 file changed, 58 insertions(+), 56 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 051f6e7e3a3d..7925f64fefde 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -334,6 +334,7 @@ static void __init prom_print_dec(unsigned long val)
 	call_prom("write", 3, 1, prom.stdout, buf+i, size);
 }
 
+__printf(1, 2)
 static void __init prom_printf(const char *format, ...)
 {
 	const char *p, *q, *s;
@@ -1149,7 +1150,7 @@ static void __init prom_send_capabilities(void)
 		 */
 
 		cores = DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads());
-		prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n",
+		prom_printf("Max number of cores passed to firmware: %u (NR_CPUS = %d)\n",
 			    cores, NR_CPUS);
 
 		ibm_architecture_vec.vec5.max_cpus = cpu_to_be32(cores);
@@ -1231,7 +1232,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
 
 	if (align)
 		base = _ALIGN_UP(base, align);
-	prom_debug("alloc_up(%x, %x)\n", size, align);
+	prom_debug("%s(%lx, %lx)\n", __func__, size, align);
 	if (ram_top == 0)
 		prom_panic("alloc_up() called with mem not initialized\n");
 
@@ -1242,7 +1243,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
 
 	for(; (base + size) <= alloc_top; 
 	    base = _ALIGN_UP(base + 0x100000, align)) {
-		prom_debug("    trying: 0x%x\n\r", base);
+		prom_debug("    trying: 0x%lx\n\r", base);
 		addr = (unsigned long)prom_claim(base, size, 0);
 		if (addr != PROM_ERROR && addr != 0)
 			break;
@@ -1254,12 +1255,12 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align)
 		return 0;
 	alloc_bottom = addr + size;
 
-	prom_debug(" -> %x\n", addr);
-	prom_debug("  alloc_bottom : %x\n", alloc_bottom);
-	prom_debug("  alloc_top    : %x\n", alloc_top);
-	prom_debug("  alloc_top_hi : %x\n", alloc_top_high);
-	prom_debug("  rmo_top      : %x\n", rmo_top);
-	prom_debug("  ram_top      : %x\n", ram_top);
+	prom_debug(" -> %lx\n", addr);
+	prom_debug("  alloc_bottom : %lx\n", alloc_bottom);
+	prom_debug("  alloc_top    : %lx\n", alloc_top);
+	prom_debug("  alloc_top_hi : %lx\n", alloc_top_high);
+	prom_debug("  rmo_top      : %lx\n", rmo_top);
+	prom_debug("  ram_top      : %lx\n", ram_top);
 
 	return addr;
 }
@@ -1274,7 +1275,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
 {
 	unsigned long base, addr = 0;
 
-	prom_debug("alloc_down(%x, %x, %s)\n", size, align,
+	prom_debug("%s(%lx, %lx, %s)\n", __func__, size, align,
 		   highmem ? "(high)" : "(low)");
 	if (ram_top == 0)
 		prom_panic("alloc_down() called with mem not initialized\n");
@@ -1302,7 +1303,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
 	base = _ALIGN_DOWN(alloc_top - size, align);
 	for (; base > alloc_bottom;
 	     base = _ALIGN_DOWN(base - 0x100000, align))  {
-		prom_debug("    trying: 0x%x\n\r", base);
+		prom_debug("    trying: 0x%lx\n\r", base);
 		addr = (unsigned long)prom_claim(base, size, 0);
 		if (addr != PROM_ERROR && addr != 0)
 			break;
@@ -1313,12 +1314,12 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align,
 	alloc_top = addr;
 
  bail:
-	prom_debug(" -> %x\n", addr);
-	prom_debug("  alloc_bottom : %x\n", alloc_bottom);
-	prom_debug("  alloc_top    : %x\n", alloc_top);
-	prom_debug("  alloc_top_hi : %x\n", alloc_top_high);
-	prom_debug("  rmo_top      : %x\n", rmo_top);
-	prom_debug("  ram_top      : %x\n", ram_top);
+	prom_debug(" -> %lx\n", addr);
+	prom_debug("  alloc_bottom : %lx\n", alloc_bottom);
+	prom_debug("  alloc_top    : %lx\n", alloc_top);
+	prom_debug("  alloc_top_hi : %lx\n", alloc_top_high);
+	prom_debug("  rmo_top      : %lx\n", rmo_top);
+	prom_debug("  ram_top      : %lx\n", ram_top);
 
 	return addr;
 }
@@ -1443,7 +1444,7 @@ static void __init prom_init_mem(void)
 
 			if (size == 0)
 				continue;
-			prom_debug("    %x %x\n", base, size);
+			prom_debug("    %lx %lx\n", base, size);
 			if (base == 0 && (of_platform & PLATFORM_LPAR))
 				rmo_top = size;
 			if ((base + size) > ram_top)
@@ -1463,12 +1464,12 @@ static void __init prom_init_mem(void)
 
 	if (prom_memory_limit) {
 		if (prom_memory_limit <= alloc_bottom) {
-			prom_printf("Ignoring mem=%x <= alloc_bottom.\n",
-				prom_memory_limit);
+			prom_printf("Ignoring mem=%lx <= alloc_bottom.\n",
+				    prom_memory_limit);
 			prom_memory_limit = 0;
 		} else if (prom_memory_limit >= ram_top) {
-			prom_printf("Ignoring mem=%x >= ram_top.\n",
-				prom_memory_limit);
+			prom_printf("Ignoring mem=%lx >= ram_top.\n",
+				    prom_memory_limit);
 			prom_memory_limit = 0;
 		} else {
 			ram_top = prom_memory_limit;
@@ -1500,12 +1501,13 @@ static void __init prom_init_mem(void)
 		alloc_bottom = PAGE_ALIGN(prom_initrd_end);
 
 	prom_printf("memory layout at init:\n");
-	prom_printf("  memory_limit : %x (16 MB aligned)\n", prom_memory_limit);
-	prom_printf("  alloc_bottom : %x\n", alloc_bottom);
-	prom_printf("  alloc_top    : %x\n", alloc_top);
-	prom_printf("  alloc_top_hi : %x\n", alloc_top_high);
-	prom_printf("  rmo_top      : %x\n", rmo_top);
-	prom_printf("  ram_top      : %x\n", ram_top);
+	prom_printf("  memory_limit : %lx (16 MB aligned)\n",
+		    prom_memory_limit);
+	prom_printf("  alloc_bottom : %lx\n", alloc_bottom);
+	prom_printf("  alloc_top    : %lx\n", alloc_top);
+	prom_printf("  alloc_top_hi : %lx\n", alloc_top_high);
+	prom_printf("  rmo_top      : %lx\n", rmo_top);
+	prom_printf("  ram_top      : %lx\n", ram_top);
 }
 
 static void __init prom_close_stdin(void)
@@ -1566,7 +1568,7 @@ static void __init prom_instantiate_opal(void)
 		return;
 	}
 
-	prom_printf("instantiating opal at 0x%x...", base);
+	prom_printf("instantiating opal at 0x%llx...", base);
 
 	if (call_prom_ret("call-method", 4, 3, rets,
 			  ADDR("load-opal-runtime"),
@@ -1582,10 +1584,10 @@ static void __init prom_instantiate_opal(void)
 
 	reserve_mem(base, size);
 
-	prom_debug("opal base     = 0x%x\n", base);
-	prom_debug("opal align    = 0x%x\n", align);
-	prom_debug("opal entry    = 0x%x\n", entry);
-	prom_debug("opal size     = 0x%x\n", (long)size);
+	prom_debug("opal base     = 0x%llx\n", base);
+	prom_debug("opal align    = 0x%llx\n", align);
+	prom_debug("opal entry    = 0x%llx\n", entry);
+	prom_debug("opal size     = 0x%llx\n", size);
 
 	prom_setprop(opal_node, "/ibm,opal", "opal-base-address",
 		     &base, sizeof(base));
@@ -1662,7 +1664,7 @@ static void __init prom_instantiate_rtas(void)
 
 	prom_debug("rtas base     = 0x%x\n", base);
 	prom_debug("rtas entry    = 0x%x\n", entry);
-	prom_debug("rtas size     = 0x%x\n", (long)size);
+	prom_debug("rtas size     = 0x%x\n", size);
 
 	prom_debug("prom_instantiate_rtas: end...\n");
 }
@@ -1720,7 +1722,7 @@ static void __init prom_instantiate_sml(void)
 	if (base == 0)
 		prom_panic("Could not allocate memory for sml\n");
 
-	prom_printf("instantiating sml at 0x%x...", base);
+	prom_printf("instantiating sml at 0x%llx...", base);
 
 	memset((void *)base, 0, size);
 
@@ -1739,8 +1741,8 @@ static void __init prom_instantiate_sml(void)
 	prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size",
 		     &size, sizeof(size));
 
-	prom_debug("sml base     = 0x%x\n", base);
-	prom_debug("sml size     = 0x%x\n", (long)size);
+	prom_debug("sml base     = 0x%llx\n", base);
+	prom_debug("sml size     = 0x%x\n", size);
 
 	prom_debug("prom_instantiate_sml: end...\n");
 }
@@ -1841,7 +1843,7 @@ static void __init prom_initialize_tce_table(void)
 
 		prom_debug("TCE table: %s\n", path);
 		prom_debug("\tnode = 0x%x\n", node);
-		prom_debug("\tbase = 0x%x\n", base);
+		prom_debug("\tbase = 0x%llx\n", base);
 		prom_debug("\tsize = 0x%x\n", minsize);
 
 		/* Initialize the table to have a one-to-one mapping
@@ -1928,12 +1930,12 @@ static void __init prom_hold_cpus(void)
 	}
 
 	prom_debug("prom_hold_cpus: start...\n");
-	prom_debug("    1) spinloop       = 0x%x\n", (unsigned long)spinloop);
-	prom_debug("    1) *spinloop      = 0x%x\n", *spinloop);
-	prom_debug("    1) acknowledge    = 0x%x\n",
+	prom_debug("    1) spinloop       = 0x%lx\n", (unsigned long)spinloop);
+	prom_debug("    1) *spinloop      = 0x%lx\n", *spinloop);
+	prom_debug("    1) acknowledge    = 0x%lx\n",
 		   (unsigned long)acknowledge);
-	prom_debug("    1) *acknowledge   = 0x%x\n", *acknowledge);
-	prom_debug("    1) secondary_hold = 0x%x\n", secondary_hold);
+	prom_debug("    1) *acknowledge   = 0x%lx\n", *acknowledge);
+	prom_debug("    1) secondary_hold = 0x%lx\n", secondary_hold);
 
 	/* Set the common spinloop variable, so all of the secondary cpus
 	 * will block when they are awakened from their OF spinloop.
@@ -1961,7 +1963,7 @@ static void __init prom_hold_cpus(void)
 		prom_getprop(node, "reg", &reg, sizeof(reg));
 		cpu_no = be32_to_cpu(reg);
 
-		prom_debug("cpu hw idx   = %lu\n", cpu_no);
+		prom_debug("cpu hw idx   = %u\n", cpu_no);
 
 		/* Init the acknowledge var which will be reset by
 		 * the secondary cpu when it awakens from its OF
@@ -1971,7 +1973,7 @@ static void __init prom_hold_cpus(void)
 
 		if (cpu_no != prom.cpu) {
 			/* Primary Thread of non-boot cpu or any thread */
-			prom_printf("starting cpu hw idx %lu... ", cpu_no);
+			prom_printf("starting cpu hw idx %u... ", cpu_no);
 			call_prom("start-cpu", 3, 0, node,
 				  secondary_hold, cpu_no);
 
@@ -1982,11 +1984,11 @@ static void __init prom_hold_cpus(void)
 			if (*acknowledge == cpu_no)
 				prom_printf("done\n");
 			else
-				prom_printf("failed: %x\n", *acknowledge);
+				prom_printf("failed: %lx\n", *acknowledge);
 		}
 #ifdef CONFIG_SMP
 		else
-			prom_printf("boot cpu hw idx %lu\n", cpu_no);
+			prom_printf("boot cpu hw idx %u\n", cpu_no);
 #endif /* CONFIG_SMP */
 	}
 
@@ -2264,7 +2266,7 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
 	while ((*mem_start + needed) > *mem_end) {
 		unsigned long room, chunk;
 
-		prom_debug("Chunk exhausted, claiming more at %x...\n",
+		prom_debug("Chunk exhausted, claiming more at %lx...\n",
 			   alloc_bottom);
 		room = alloc_top - alloc_bottom;
 		if (room > DEVTREE_CHUNK_SIZE)
@@ -2490,7 +2492,7 @@ static void __init flatten_device_tree(void)
 	room = alloc_top - alloc_bottom - 0x4000;
 	if (room > DEVTREE_CHUNK_SIZE)
 		room = DEVTREE_CHUNK_SIZE;
-	prom_debug("starting device tree allocs at %x\n", alloc_bottom);
+	prom_debug("starting device tree allocs at %lx\n", alloc_bottom);
 
 	/* Now try to claim that */
 	mem_start = (unsigned long)alloc_up(room, PAGE_SIZE);
@@ -2553,7 +2555,7 @@ static void __init flatten_device_tree(void)
 		int i;
 		prom_printf("reserved memory map:\n");
 		for (i = 0; i < mem_reserve_cnt; i++)
-			prom_printf("  %x - %x\n",
+			prom_printf("  %llx - %llx\n",
 				    be64_to_cpu(mem_reserve_map[i].base),
 				    be64_to_cpu(mem_reserve_map[i].size));
 	}
@@ -2563,9 +2565,9 @@ static void __init flatten_device_tree(void)
 	 */
 	mem_reserve_cnt = MEM_RESERVE_MAP_SIZE;
 
-	prom_printf("Device tree strings 0x%x -> 0x%x\n",
+	prom_printf("Device tree strings 0x%lx -> 0x%lx\n",
 		    dt_string_start, dt_string_end);
-	prom_printf("Device tree struct  0x%x -> 0x%x\n",
+	prom_printf("Device tree struct  0x%lx -> 0x%lx\n",
 		    dt_struct_start, dt_struct_end);
 }
 
@@ -2997,7 +2999,7 @@ static void __init prom_find_boot_cpu(void)
 	prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
 	prom.cpu = be32_to_cpu(rval);
 
-	prom_debug("Booting CPU hw index = %lu\n", prom.cpu);
+	prom_debug("Booting CPU hw index = %d\n", prom.cpu);
 }
 
 static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
@@ -3019,8 +3021,8 @@ static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
 		reserve_mem(prom_initrd_start,
 			    prom_initrd_end - prom_initrd_start);
 
-		prom_debug("initrd_start=0x%x\n", prom_initrd_start);
-		prom_debug("initrd_end=0x%x\n", prom_initrd_end);
+		prom_debug("initrd_start=0x%lx\n", prom_initrd_start);
+		prom_debug("initrd_end=0x%lx\n", prom_initrd_end);
 	}
 #endif /* CONFIG_BLK_DEV_INITRD */
 }
@@ -3273,7 +3275,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
 	/* Don't print anything after quiesce under OPAL, it crashes OFW */
 	if (of_platform != PLATFORM_OPAL) {
 		prom_printf("Booting Linux via __start() @ 0x%lx ...\n", kbase);
-		prom_debug("->dt_header_start=0x%x\n", hdr);
+		prom_debug("->dt_header_start=0x%lx\n", hdr);
 	}
 
 #ifdef CONFIG_PPC32
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH v2] powerpc, pkey: make protection key 0 less special
From: Thiago Jung Bauermann @ 2018-04-06 20:44 UTC (permalink / raw)
  To: Ram Pai
  Cc: mpe, mingo, akpm, fweimer, shuah, msuchanek, linux-kernel, mhocko,
	dave.hansen, paulus, aneesh.kumar, tglx, linuxppc-dev
In-Reply-To: <20180406180126.GJ5743@ram.oc3035372033.ibm.com>


Ram Pai <linuxram@us.ibm.com> writes:

> On Wed, Apr 04, 2018 at 06:41:01PM -0300, Thiago Jung Bauermann wrote:
>>
>> Hello Ram,
>>
>> Ram Pai <linuxram@us.ibm.com> writes:
>>
>> > Applications need the ability to associate an address-range with some
>> > key and latter revert to its initial default key. Pkey-0 comes close to
>> > providing this function but falls short, because the current
>> > implementation disallows applications to explicitly associate pkey-0 to
>> > the address range.
>> >
>> > Lets make pkey-0 less special and treat it almost like any other key.
>> > Thus it can be explicitly associated with any address range, and can be
>> > freed. This gives the application more flexibility and power.  The
>> > ability to free pkey-0 must be used responsibily, since pkey-0 is
>> > associated with almost all address-range by default.
>> >
>> > Even with this change pkey-0 continues to be slightly more special
>> > from the following point of view.
>> > (a) it is implicitly allocated.
>> > (b) it is the default key assigned to any address-range.
>>
>> It's also special in more ways (and if intentional, these should be part
>> of the commit message as well):
>>
>> (c) it's not possible to change permissions for key 0
>>
>>   This has two causes: this patch explicitly forbids it in
>>   arch_set_user_pkey_access(), and also because even if it's allocated,
>>   the bits for key 0 in AMOR and UAMOR aren't set.
>
> Yes. will have to capture that one aswell.
>
> we cannot let userspace change permissions on key 0 because
> doing so will hurt the kernel too. Unlike x86 where keys are effective
> only in userspace, powerpc keys are effective even in the kernel.
> So if the kernel tries to access something, it will get stuck forever.
> Almost everything in the kernel is associated with key-0.
>
> I ran a small test program which disabled access on key 0 from
> userspace, and as expected ran into softlockups. It certainly
> can lead to denial-of-service-attack. We can let apps
> shoot-itself-in-its-foot but if the shot hurts someone else, we will
> have to stop it.

Ah, I wasn't aware of that. We definitely shouldn't let userspace change
key 0 permissions then. :-) It would be good to have this information in
a comment in the code somewhere, IMHO.

> The key-semantics discussed with the x86 folks did not
> explicitly say anything about changing permissions on key-0. We will
> have to keep that part of the semantics open-ended.
>
>>
>> (d) it can be freed, but can't be allocated again later.
>>
>>   This is because mm_pkey_alloc() only calls __arch_activate_pkey(ret)
>>   if ret > 0.
>>
>> It looks like (d) is a bug. Either mm_pkey_free() should fail with key
>> 0, or mm_pkey_alloc() should work with it.
>
> Well, it can be allocated, just that we do not let userspace change the
> permissions on the key.  __arch_activate_pkey(ret) does not get called
> for pkey-0.

Yes, now I see how the allocated-but-not-enabled state makes sense.
Considering that the kernel always uses key 0, it's unworkable on
powerpc for an app to free pkey 0. In that case I think we should reject
it in mm_pkey_free().

>> (c) could be a measure to prevent users from shooting themselves in
>> their feet. But if that is the case, then mm_pkey_free() should forbid
>> freeing key 0 too.
>>
>> > Tested on powerpc.
>> >
>> > cc: Thomas Gleixner <tglx@linutronix.de>
>> > cc: Dave Hansen <dave.hansen@intel.com>
>> > cc: Michael Ellermen <mpe@ellerman.id.au>
>> > cc: Ingo Molnar <mingo@kernel.org>
>> > cc: Andrew Morton <akpm@linux-foundation.org>
>> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
>> > ---
>> > History:
>> > 	v2: mm_pkey_is_allocated() continued to treat pkey-0 special.
>> > 	    fixed it.
>> >
>> >  arch/powerpc/include/asm/pkeys.h | 20 ++++++++++++++++----
>> >  arch/powerpc/mm/pkeys.c          | 20 ++++++++++++--------
>> >  2 files changed, 28 insertions(+), 12 deletions(-)
>> >
>> > diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h
>> > index 0409c80..b598fa9 100644
>> > --- a/arch/powerpc/include/asm/pkeys.h
>> > +++ b/arch/powerpc/include/asm/pkeys.h
>> > @@ -101,10 +101,14 @@ static inline u16 pte_to_pkey_bits(u64 pteflags)
>> >
>> >  static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)
>> >  {
>> > -	/* A reserved key is never considered as 'explicitly allocated' */
>> > -	return ((pkey < arch_max_pkey()) &&
>> > -		!__mm_pkey_is_reserved(pkey) &&
>> > -		__mm_pkey_is_allocated(mm, pkey));
>> > +	if (pkey < 0 || pkey >= arch_max_pkey())
>> > +		return false;
>> > +
>> > +	/* Reserved keys are never allocated. */
>> > +	if (__mm_pkey_is_reserved(pkey))
>> > +		return false;
>> > +
>> > +	return __mm_pkey_is_allocated(mm, pkey);
>> >  }
>> >
>> >  extern void __arch_activate_pkey(int pkey);
>> > @@ -200,6 +204,14 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
>> >  {
>> >  	if (static_branch_likely(&pkey_disabled))
>> >  		return -EINVAL;
>> > +
>> > +	/*
>> > +	 * userspace is discouraged from changing permissions of
>> > +	 * pkey-0.
>>
>> They're not discouraged. They're not allowed to. :-)
>
> ok :-)
>
>>
>> > +	 * powerpc hardware does not support it anyway.
>>
>> It doesn't? I don't get that impression from reading the ISA, but
>> perhaps I'm missing something.
>
> Good Catch. I am wrongly blaming it on powerpc hardware.
> Its a semantics enforced by our pkey code to block DOS attacks.

I think this would be a good place to explain why we can't allow
userspace to change permissions on key 0.

>
>>
>> > +	 */
>> > +	if (!pkey)
>> > +		return init_val ? -EINVAL : 0;
>> > +
>> >  	return __arch_set_user_pkey_access(tsk, pkey, init_val);
>> >  }
>> >
>> > diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c
>> > index ba71c54..e7a9e34 100644
>> > --- a/arch/powerpc/mm/pkeys.c
>> > +++ b/arch/powerpc/mm/pkeys.c
>> > @@ -119,19 +119,21 @@ int pkey_initialize(void)
>> >  #else
>> >  	os_reserved = 0;
>> >  #endif
>> > -	/*
>> > -	 * Bits are in LE format. NOTE: 1, 0 are reserved.
>> > -	 * key 0 is the default key, which allows read/write/execute.
>> > -	 * key 1 is recommended not to be used. PowerISA(3.0) page 1015,
>> > -	 * programming note.
>> > -	 */
>> > +	/* Bits are in LE format. */
>> >  	initial_allocation_mask = ~0x0;
>> >
>> >  	/* register mask is in BE format */
>> >  	pkey_amr_uamor_mask = ~0x0ul;
>> >  	pkey_iamr_mask = ~0x0ul;
>> >
>> > -	for (i = 2; i < (pkeys_total - os_reserved); i++) {
>> > +	for (i = 0; i < (pkeys_total - os_reserved); i++) {
>> > +	 	/*
>>
>> There's a space between the tabs here.
>
> ok. will fix.
>
>>
>> > +		 * key 1 is recommended not to be used.
>> > +		 * PowerISA(3.0) page 1015,
>> > +		 */
>> > +		if (i == 1)
>> > +			continue;
>> > +
>> >  		initial_allocation_mask &= ~(0x1 << i);
>> >  		pkey_amr_uamor_mask &= ~(0x3ul << pkeyshift(i));
>> >  		pkey_iamr_mask &= ~(0x1ul << pkeyshift(i));
>> > @@ -145,7 +147,9 @@ void pkey_mm_init(struct mm_struct *mm)
>> >  {
>> >  	if (static_branch_likely(&pkey_disabled))
>> >  		return;
>> > -	mm_pkey_allocation_map(mm) = initial_allocation_mask;
>> > +
>> > +	/* allocate key-0 by default */
>> > +	mm_pkey_allocation_map(mm) = initial_allocation_mask | 0x1;
>> >  	/* -1 means unallocated or invalid */
>> >  	mm->context.execute_only_pkey = -1;
>> >  }
>>
>> I think we should also set the AMOR and UAMOR bits for key 0. Otherwise,
>> key 0 will be in allocated-but-not-enabled state which is yet another
>> subtle way in which it will be special.
>
> No. as explained above, it will hurt to let userspace modify
> permissions on key-0.

Indeed. Thanks for explaining and even double-checking that it's indeed
the case.

>>
>> Also, pkey_access_permitted() has a special case for key 0. Should it?
>
> we can delete that check. though it does not hurt to leave it in place.
> Access/Write/Execute on pkey-0 is always permitted.

It doesn't hurt, but it's redundant since the is_pkey_enabled() call
right below will have the same effect.

Actually I just changed my mind because I see now that the early exit
prevents the need to read the UAMOR (which is done by
is_pkey_enabled()). Since this function is called by page table code
it's probably worth avoiding the additional SPR access.

--
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply

* [RFC linux v2] init: make all setup_arch() output string to boot_command_line[]
From: yuan linyu @ 2018-04-07  1:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-alpha, linux-snps-arc, linux-arm-kernel, linux-c6x-dev,
	uclinux-h8-devel, linux-hexagon, linux-ia64, linux-m68k,
	Michal Simek, linux-mips, Greentime Hu, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, user-mode-linux-devel, user-mode-linux-user,
	Guan Xuetao, linux-xtensa, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

then all arch boot parameter handled in the same way in start_kernel()

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
v2:
	fix kbuild issue of parisc

 arch/alpha/kernel/setup.c          |  4 +---
 arch/arc/kernel/setup.c            |  5 +----
 arch/arm/kernel/setup.c            |  7 +------
 arch/arm64/kernel/setup.c          |  4 +---
 arch/c6x/kernel/setup.c            |  5 +----
 arch/h8300/kernel/setup.c          |  3 +--
 arch/hexagon/kernel/setup.c        | 16 +---------------
 arch/ia64/kernel/setup.c           | 15 ++++++++-------
 arch/m68k/kernel/setup_mm.c        |  5 ++---
 arch/m68k/kernel/setup_no.c        |  3 +--
 arch/microblaze/kernel/setup.c     |  4 +---
 arch/mips/kernel/setup.c           | 11 +++--------
 arch/nds32/kernel/setup.c          |  3 +--
 arch/nios2/kernel/setup.c          |  5 +----
 arch/openrisc/kernel/setup.c       |  4 +---
 arch/parisc/kernel/setup.c         | 11 +++--------
 arch/powerpc/kernel/setup-common.c |  4 +---
 arch/riscv/kernel/setup.c          |  4 +---
 arch/s390/kernel/setup.c           |  6 +-----
 arch/sh/kernel/setup.c             |  7 ++++---
 arch/sparc/kernel/setup_32.c       |  9 +++++----
 arch/sparc/kernel/setup_64.c       |  8 ++++----
 arch/um/kernel/um_arch.c           |  3 +--
 arch/unicore32/kernel/setup.c      |  8 +-------
 arch/x86/kernel/setup.c            |  6 +-----
 arch/xtensa/kernel/setup.c         |  9 +++++----
 include/linux/init.h               |  2 +-
 init/main.c                        | 14 +++++++-------
 28 files changed, 60 insertions(+), 125 deletions(-)

diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 5576f7646fb6..c74675cf7129 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -505,8 +505,7 @@ register_cpus(void)
 
 arch_initcall(register_cpus);
 
-void __init
-setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	extern char _end[];
 
@@ -566,7 +565,6 @@ setup_arch(char **cmdline_p)
 		strlcpy(command_line, COMMAND_LINE, sizeof command_line);
 	}
 	strcpy(boot_command_line, command_line);
-	*cmdline_p = command_line;
 
 	/* 
 	 * Process command-line arguments.
diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c
index b2cae79a25d7..9cfdcf42bf28 100644
--- a/arch/arc/kernel/setup.c
+++ b/arch/arc/kernel/setup.c
@@ -456,7 +456,7 @@ static inline int is_kernel(unsigned long addr)
 	return 0;
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 #ifdef CONFIG_ARC_UBOOT_SUPPORT
 	/* make sure that uboot passed pointer to cmdline/dtb is valid */
@@ -487,9 +487,6 @@ void __init setup_arch(char **cmdline_p)
 		}
 	}
 
-	/* Save unparsed command line copy for /proc/cmdline */
-	*cmdline_p = boot_command_line;
-
 	/* To force early parsing of things like mem=xxx */
 	parse_early_param();
 
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index fc40a2b40595..1025e3a37689 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -153,7 +153,6 @@ EXPORT_SYMBOL(elf_platform);
 
 static const char *cpu_name;
 static const char *machine_name;
-static char __initdata cmd_line[COMMAND_LINE_SIZE];
 const struct machine_desc *machine_desc __initdata;
 
 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
@@ -1061,7 +1060,7 @@ void __init hyp_mode_check(void)
 #endif
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	const struct machine_desc *mdesc;
 
@@ -1091,10 +1090,6 @@ void __init setup_arch(char **cmdline_p)
 	init_mm.end_data   = (unsigned long) _edata;
 	init_mm.brk	   = (unsigned long) _end;
 
-	/* populate cmd_line too for later use, preserving boot_command_line */
-	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = cmd_line;
-
 	early_fixmap_init();
 	early_ioremap_init();
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 30ad2f085d1f..c7ba4d32e7f7 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -243,15 +243,13 @@ static void __init request_standard_resources(void)
 
 u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	init_mm.start_code = (unsigned long) _text;
 	init_mm.end_code   = (unsigned long) _etext;
 	init_mm.end_data   = (unsigned long) _edata;
 	init_mm.brk	   = (unsigned long) _end;
 
-	*cmdline_p = boot_command_line;
-
 	early_fixmap_init();
 	early_ioremap_init();
 
diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c
index 786e36e2f61d..012c8e746889 100644
--- a/arch/c6x/kernel/setup.c
+++ b/arch/c6x/kernel/setup.c
@@ -294,16 +294,13 @@ notrace void __init machine_init(unsigned long dt_ptr)
 	parse_early_param();
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	int bootmap_size;
 	struct memblock_region *reg;
 
 	printk(KERN_INFO "Initializing kernel\n");
 
-	/* Initialize command line */
-	*cmdline_p = boot_command_line;
-
 	memory_end = ram_end;
 	memory_end &= ~(PAGE_SIZE - 1);
 
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index a4d0470c10a9..bb54c2087f13 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -117,7 +117,7 @@ static void __init bootmem_init(void)
 	}
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	unflatten_and_copy_device_tree();
 
@@ -131,7 +131,6 @@ void __init setup_arch(char **cmdline_p)
 
 	if (*command_line)
 		strcpy(boot_command_line, command_line);
-	*cmdline_p = boot_command_line;
 
 	parse_early_param();
 
diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c
index 6981949f5df3..a0348dfad265 100644
--- a/arch/hexagon/kernel/setup.c
+++ b/arch/hexagon/kernel/setup.c
@@ -34,7 +34,6 @@
 #include <asm/vm_mmu.h>
 #include <asm/time.h>
 
-char cmd_line[COMMAND_LINE_SIZE];
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 
 int on_simulator;
@@ -44,12 +43,7 @@ void calibrate_delay(void)
 	loops_per_jiffy = thread_freq_mhz * 1000000 / HZ;
 }
 
-/*
- * setup_arch -  high level architectural setup routine
- * @cmdline_p: pointer to pointer to command-line arguments
- */
-
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	char *p = &external_cmdline_buffer;
 
@@ -84,14 +78,6 @@ void __init setup_arch(char **cmdline_p)
 		strlcpy(boot_command_line, default_command_line,
 			COMMAND_LINE_SIZE);
 
-	/*
-	 * boot_command_line and the value set up by setup_arch
-	 * are both picked up by the init code. If no reason to
-	 * make them different, pass the same pointer back.
-	 */
-	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = cmd_line;
-
 	parse_early_param();
 
 	setup_arch_memory();
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index dee56bcb993d..75196264dd4e 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -527,15 +527,16 @@ int __init reserve_elfcorehdr(u64 *start, u64 *end)
 
 #endif /* CONFIG_PROC_VMCORE */
 
-void __init
-setup_arch (char **cmdline_p)
+void __init setup_arch (void)
 {
+	char *cmdline_p;
+
 	unw_init();
 
 	ia64_patch_vtop((u64) __start___vtop_patchlist, (u64) __end___vtop_patchlist);
 
-	*cmdline_p = __va(ia64_boot_param->command_line);
-	strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
+	cmdline_p = __va(ia64_boot_param->command_line);
+	strlcpy(boot_command_line, cmdline_p, COMMAND_LINE_SIZE);
 
 	efi_init();
 	io_port_init();
@@ -546,12 +547,12 @@ setup_arch (char **cmdline_p)
 	 * that ia64_mv is initialised before any command line
 	 * settings may cause console setup to occur
 	 */
-	machvec_init_from_cmdline(*cmdline_p);
+	machvec_init_from_cmdline(cmdline_p);
 #endif
 
 	parse_early_param();
 
-	if (early_console_setup(*cmdline_p) == 0)
+	if (early_console_setup(cmdline_p) == 0)
 		mark_bsp_online();
 
 #ifdef CONFIG_ACPI
@@ -618,7 +619,7 @@ setup_arch (char **cmdline_p)
 	if (!nomca)
 		ia64_mca_init();
 
-	platform_setup(cmdline_p);
+	platform_setup(&cmdline_p);
 #ifndef CONFIG_IA64_HP_SIM
 	check_sal_cache_flush();
 #endif
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index dd25bfc22fb4..38ccaf3e0274 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -222,7 +222,7 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
 #endif
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 #ifndef CONFIG_SUN3
 	int i;
@@ -272,8 +272,7 @@ void __init setup_arch(char **cmdline_p)
 	m68k_command_line[CL_SIZE - 1] = 0;
 #endif /* CONFIG_BOOTPARAM */
 	process_uboot_commandline(&m68k_command_line[0], CL_SIZE);
-	*cmdline_p = m68k_command_line;
-	memcpy(boot_command_line, *cmdline_p, CL_SIZE);
+	memcpy(boot_command_line, m68k_command_line, CL_SIZE);
 
 	parse_early_param();
 
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index a98af1018201..8b244d4ea603 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -84,7 +84,7 @@ void (*mach_power_off)(void);
 #define	CPU_INSTR_PER_JIFFY	16
 #endif
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	int bootmap_size;
 
@@ -143,7 +143,6 @@ void __init setup_arch(char **cmdline_p)
 		 __bss_stop, memory_start, memory_start, memory_end);
 
 	/* Keep a copy of command line */
-	*cmdline_p = &command_line[0];
 	memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
 	boot_command_line[COMMAND_LINE_SIZE-1] = 0;
 
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index be98ffe28ca8..632b7546effc 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -50,10 +50,8 @@ unsigned int boot_cpuid;
  */
 char cmd_line[COMMAND_LINE_SIZE] __attribute__ ((section(".data")));
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
-	*cmdline_p = boot_command_line;
-
 	console_verbose();
 
 	unflatten_device_tree();
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 5f8b0a9e30b3..2bff67be95d6 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -64,7 +64,6 @@ EXPORT_SYMBOL(mips_machtype);
 
 struct boot_mem_map boot_mem_map;
 
-static char __initdata command_line[COMMAND_LINE_SIZE];
 char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
 
 #ifdef CONFIG_CMDLINE_BOOL
@@ -829,7 +828,7 @@ static void __init request_crashkernel(struct resource *res)
 #define BUILTIN_EXTEND_WITH_PROM	\
 	IS_ENABLED(CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND)
 
-static void __init arch_mem_init(char **cmdline_p)
+static void __init arch_mem_init(void)
 {
 	struct memblock_region *reg;
 	extern void plat_mem_setup(void);
@@ -881,10 +880,6 @@ static void __init arch_mem_init(char **cmdline_p)
 	pr_info("Determined physical RAM map:\n");
 	print_memory_map();
 
-	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
-
-	*cmdline_p = command_line;
-
 	parse_early_param();
 
 	if (usermem) {
@@ -1002,7 +997,7 @@ static void __init prefill_possible_map(void)
 static inline void prefill_possible_map(void) {}
 #endif
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	cpu_probe();
 	mips_cm_probe();
@@ -1023,7 +1018,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #endif
 
-	arch_mem_init(cmdline_p);
+	arch_mem_init();
 
 	resource_init();
 	plat_smp_setup();
diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c
index ba910e9e4ecb..7df72753dd9a 100644
--- a/arch/nds32/kernel/setup.c
+++ b/arch/nds32/kernel/setup.c
@@ -276,7 +276,7 @@ static void __init setup_memory(void)
 	memblock_dump_all();
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	early_init_devtree( __dtb_start);
 
@@ -303,7 +303,6 @@ void __init setup_arch(char **cmdline_p)
 			conswitchp = &dummy_con;
 	}
 
-	*cmdline_p = boot_command_line;
 	early_trap_init();
 }
 
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
index 926a02b17b31..e8d140f1d40c 100644
--- a/arch/nios2/kernel/setup.c
+++ b/arch/nios2/kernel/setup.c
@@ -141,7 +141,7 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
 	parse_early_param();
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	int bootmap_size;
 
@@ -156,9 +156,6 @@ void __init setup_arch(char **cmdline_p)
 	init_mm.brk = (unsigned long) _end;
 	init_task.thread.kregs = &fake_regs;
 
-	/* Keep a copy of command line */
-	*cmdline_p = boot_command_line;
-
 	min_low_pfn = PFN_UP(memory_start);
 	max_low_pfn = PFN_DOWN(memory_end);
 	max_mapnr = max_low_pfn;
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index 9d28ab14d139..d73e1faa88d1 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -283,7 +283,7 @@ void calibrate_delay(void)
 		(loops_per_jiffy / (5000 / HZ)) % 100, loops_per_jiffy);
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	unflatten_and_copy_device_tree();
 
@@ -320,8 +320,6 @@ void __init setup_arch(char **cmdline_p)
 		conswitchp = &dummy_con;
 #endif
 
-	*cmdline_p = boot_command_line;
-
 	printk(KERN_INFO "OpenRISC Linux -- http://openrisc.io\n");
 }
 
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 0e9675f857a5..0a78a897959a 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -51,8 +51,6 @@
 #include <asm/unwind.h>
 #include <asm/smp.h>
 
-static char __initdata command_line[COMMAND_LINE_SIZE];
-
 /* Intended for ccio/sba/cpu statistics under /proc/bus/{runway|gsc} */
 struct proc_dir_entry * proc_runway_root __read_mostly = NULL;
 struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
@@ -63,7 +61,7 @@ int parisc_bus_is_phys __read_mostly = 1;	/* Assume no IOMMU is present */
 EXPORT_SYMBOL(parisc_bus_is_phys);
 #endif
 
-void __init setup_cmdline(char **cmdline_p)
+void __init setup_cmdline(void)
 {
 	extern unsigned int boot_args[];
 
@@ -85,9 +83,6 @@ void __init setup_cmdline(char **cmdline_p)
 		}
 #endif
 	}
-
-	strcpy(command_line, boot_command_line);
-	*cmdline_p = command_line;
 }
 
 #ifdef CONFIG_PA11
@@ -119,7 +114,7 @@ void __init dma_ops_init(void)
 
 extern void collect_boot_cpu_data(void);
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 #ifdef CONFIG_64BIT
 	extern int parisc_narrow_firmware;
@@ -160,7 +155,7 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	setup_pdc();
-	setup_cmdline(cmdline_p);
+	setup_cmdline();
 	collect_boot_cpu_data();
 	do_memory_inventory();  /* probe for physical memory */
 	parisc_cache_init();
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index d73ec518ef80..b88ce4afaafd 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -839,10 +839,8 @@ static __init void print_system_info(void)
  * Called into from start_kernel this initializes memblock, which is used
  * to manage page allocation until mem_init is called.
  */
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
-	*cmdline_p = boot_command_line;
-
 	/* Set a half-reasonable default so udelay does something sensible */
 	loops_per_jiffy = 500000000 / HZ;
 
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index c11f40c1b2a8..dee21fd2f5c2 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -192,10 +192,8 @@ static void __init setup_bootmem(void)
 	}
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
-	*cmdline_p = boot_command_line;
-
 	parse_early_param();
 
 	init_mm.start_code = (unsigned long) _stext;
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index a6a91f01a17a..6addb5afc59e 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -867,7 +867,7 @@ static void __init setup_task_size(void)
  * was printed.
  */
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
         /*
          * print what head.S has found out about the machine
@@ -880,10 +880,6 @@ void __init setup_arch(char **cmdline_p)
 	else if (MACHINE_IS_LPAR)
 		pr_info("Linux is running natively in 64-bit mode\n");
 
-	/* Have one command line that is parsed and saved in /proc/cmdline */
-	/* boot_command_line has been already set up in early.c */
-	*cmdline_p = boot_command_line;
-
         ROOT_DEV = Root_RAM0;
 
 	/* Is init_mm really needed? */
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index b95c411d0333..c46646f0c3c5 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -270,8 +270,10 @@ void __ref sh_fdt_init(phys_addr_t dt_phys)
 }
 #endif
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
+	char *cmdline_p = command_line;
+
 	enable_mmu();
 
 	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
@@ -319,7 +321,6 @@ void __init setup_arch(char **cmdline_p)
 
 	/* Save unparsed command line copy for /proc/cmdline */
 	memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = command_line;
 
 	parse_early_param();
 
@@ -338,7 +339,7 @@ void __init setup_arch(char **cmdline_p)
 
 	/* Perform the machine specific initialisation */
 	if (likely(sh_mv.mv_setup))
-		sh_mv.mv_setup(cmdline_p);
+		sh_mv.mv_setup(&cmdline_p);
 
 	plat_smp_setup();
 }
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 13664c377196..5bced97cc5f8 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -294,19 +294,20 @@ void __init sparc32_start_kernel(struct linux_romvec *rp)
 	start_kernel();
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	int i;
+	char *cmdline_p;
 	unsigned long highest_paddr;
 
 	sparc_ttable = &trapbase;
 
 	/* Initialize PROM console and command line. */
-	*cmdline_p = prom_getbootargs();
-	strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
+	cmdline_p = prom_getbootargs();
+	strlcpy(boot_command_line, cmdline_p, COMMAND_LINE_SIZE);
 	parse_early_param();
 
-	boot_flags_init(*cmdline_p);
+	boot_flags_init(cmdline_p);
 
 	register_console(&prom_early_console);
 
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 7944b3ca216a..9f6edffa6a4b 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -630,14 +630,14 @@ void __init alloc_irqstack_bootmem(void)
 	}
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	/* Initialize PROM console and command line. */
-	*cmdline_p = prom_getbootargs();
-	strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
+	char *cmdline_p = prom_getbootargs();
+	strlcpy(boot_command_line, cmdline_p, COMMAND_LINE_SIZE);
 	parse_early_param();
 
-	boot_flags_init(*cmdline_p);
+	boot_flags_init(cmdline_p);
 #ifdef CONFIG_EARLYFB
 	if (btext_find_display())
 #endif
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index a818ccef30ca..73d62cf96149 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -339,7 +339,7 @@ int __init __weak read_initrd(void)
 	return 0;
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	stack_protections((unsigned long) &init_thread_info);
 	setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
@@ -348,7 +348,6 @@ void __init setup_arch(char **cmdline_p)
 
 	paging_init();
 	strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = command_line;
 	setup_hostinfo(host_info, sizeof host_info);
 }
 
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c
index c2bffa5614a4..c13a07eeed0b 100644
--- a/arch/unicore32/kernel/setup.c
+++ b/arch/unicore32/kernel/setup.c
@@ -60,8 +60,6 @@ struct screen_info screen_info;
 char elf_platform[ELF_PLATFORM_SIZE];
 EXPORT_SYMBOL(elf_platform);
 
-static char __initdata cmd_line[COMMAND_LINE_SIZE];
-
 static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
 
 /*
@@ -235,7 +233,7 @@ static int __init customize_machine(void)
 }
 arch_initcall(customize_machine);
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	char *from = default_command_line;
 
@@ -249,10 +247,6 @@ void __init setup_arch(char **cmdline_p)
 	/* parse_early_param needs a boot_command_line */
 	strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
 
-	/* populate cmd_line too for later use, preserving boot_command_line */
-	strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = cmd_line;
-
 	parse_early_param();
 
 	uc32_memblock_init(&meminfo);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 6285697b6e56..6e3347dde550 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -219,7 +219,6 @@ unsigned long saved_video_mode;
 #define RAMDISK_PROMPT_FLAG		0x8000
 #define RAMDISK_LOAD_FLAG		0x4000
 
-static char __initdata command_line[COMMAND_LINE_SIZE];
 #ifdef CONFIG_CMDLINE_BOOL
 static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 #endif
@@ -812,7 +811,7 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
  * Note: On x86_64, fixmaps are ready for use even before this is called.
  */
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
 	memblock_reserve(__pa_symbol(_text),
 			 (unsigned long)__bss_stop - (unsigned long)_text);
@@ -933,9 +932,6 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #endif
 
-	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
-	*cmdline_p = command_line;
-
 	/*
 	 * x86_configure_nx() is called before parse_early_param() to detect
 	 * whether hardware doesn't support NX (so that the early EHCI debug
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 686a27444bba..0409fa85bfdd 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -309,8 +309,10 @@ static inline int mem_reserve(unsigned long start, unsigned long end)
 	return memblock_reserve(start, end - start);
 }
 
-void __init setup_arch(char **cmdline_p)
+void __init setup_arch(void)
 {
+	char *cmdline_p = command_line;
+
 	pr_info("config ID: %08x:%08x\n",
 		get_sr(SREG_EPC), get_sr(SREG_EXCSAVE));
 	if (get_sr(SREG_EPC) != XCHAL_HW_CONFIGID0 ||
@@ -318,9 +320,8 @@ void __init setup_arch(char **cmdline_p)
 		pr_info("built for config ID: %08x:%08x\n",
 			XCHAL_HW_CONFIGID0, XCHAL_HW_CONFIGID1);
 
-	*cmdline_p = command_line;
-	platform_setup(cmdline_p);
-	strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
+	platform_setup(&cmdline_p);
+	strlcpy(boot_command_line, cmdline_p, COMMAND_LINE_SIZE);
 
 	/* Reserve some memory regions */
 
diff --git a/include/linux/init.h b/include/linux/init.h
index bc27cf03c41e..206b98d77cb4 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -129,7 +129,7 @@ extern char *saved_command_line;
 extern unsigned int reset_devices;
 
 /* used by init/main.c */
-void setup_arch(char **);
+void setup_arch(void);
 void prepare_namespace(void);
 void __init load_default_modules(void);
 int __init init_rootfs(void);
diff --git a/init/main.c b/init/main.c
index e4a3160991ea..8df5917867b1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -367,15 +367,16 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
  * parsing is performed in place, and we should allow a component to
  * store reference of name/value for future reference.
  */
-static void __init setup_command_line(char *command_line)
+static void __init setup_command_line(void)
 {
 	saved_command_line =
 		memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
 	initcall_command_line =
 		memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
-	static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0);
+	static_command_line =
+		memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
 	strcpy(saved_command_line, boot_command_line);
-	strcpy(static_command_line, command_line);
+	strcpy(static_command_line, boot_command_line);
 }
 
 /*
@@ -514,7 +515,6 @@ static void __init mm_init(void)
 
 asmlinkage __visible void __init start_kernel(void)
 {
-	char *command_line;
 	char *after_dashes;
 
 	set_task_stack_end_magic(&init_task);
@@ -533,16 +533,16 @@ asmlinkage __visible void __init start_kernel(void)
 	boot_cpu_init();
 	page_address_init();
 	pr_notice("%s", linux_banner);
-	setup_arch(&command_line);
+	setup_arch();
 	/*
 	 * Set up the the initial canary and entropy after arch
 	 * and after adding latent and command line entropy.
 	 */
 	add_latent_entropy();
-	add_device_randomness(command_line, strlen(command_line));
+	add_device_randomness(boot_command_line, strlen(boot_command_line));
 	boot_init_stack_canary();
 	mm_init_cpumask(&init_mm);
-	setup_command_line(command_line);
+	setup_command_line();
 	setup_nr_cpu_ids();
 	setup_per_cpu_areas();
 	boot_cpu_state_init();
-- 
2.14.1

^ permalink raw reply related

* Re: [PATCH v3 1/4] libnvdimm: Add of_node to region and bus descriptors
From: Balbir Singh @ 2018-04-07  8:08 UTC (permalink / raw)
  To: Dan Williams; +Cc: Oliver O'Halloran, linuxppc-dev, linux-nvdimm
In-Reply-To: <CAPcyv4hRut3MjihCStXkO6QGXYQf6gmoPPmv_=9K-Z8qoVLL0Q@mail.gmail.com>

On Sat, Apr 7, 2018 at 4:28 AM, Dan Williams <dan.j.williams@intel.com> wrote:
> On Thu, Apr 5, 2018 at 10:21 PM, Oliver O'Halloran <oohall@gmail.com> wrote:
>> We want to be able to cross reference the region and bus devices
>> with the device tree node that they were spawned from. libNVDIMM
>> handles creating the actual devices for these internally, so we
>> need to pass in a pointer to the relevant node in the descriptor.
>>
>> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>> Acked-by: Dan Williams <dan.j.williams@intel.com>
>
> These look good to me. I'll get them applied today and let them soak
> over the weekend for a pull request on Monday.
>
> If anyone wants to add Acks or Reviews I can append them to the merge
> tag. If there are any NAKs please speak up now, but as far as I know
> there are no pending device-tree design concerns.

Hi, Dan

I can ack Oliver's work, will do so in each patch

Overall

Acked-by: Balbir Singh <bsingharora@gmail.com>

Balbir Singh

^ permalink raw reply

* Re: [PATCH v3 3/4] doc/devicetree: Persistent memory region bindings
From: Michael Ellerman @ 2018-04-07 10:58 UTC (permalink / raw)
  To: Oliver O'Halloran, linuxppc-dev
  Cc: devicetree, Oliver O'Halloran, linux-nvdimm
In-Reply-To: <20180406052116.31483-3-oohall@gmail.com>

Oliver O'Halloran <oohall@gmail.com> writes:
> Add device-tree binding documentation for the nvdimm region driver.
>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
> v2: Changed name from nvdimm-region to pmem-region.
>     Cleaned up the example binding and fixed the overlapping regions.
>     Added support for multiple regions in a single reg.
> v3: Removed platform bus boilerplate from the example.
>     Changed description of the volatile and reg properties
>     to make them more clear.

Thanks.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

^ permalink raw reply

* [GIT PULL] Please pull powerpc/linux.git powerpc-4.17-1 tag
From: Michael Ellerman @ 2018-04-07 13:23 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Larry.Finger, aaro.koskinen, agust, aik, alexandre.belloni,
	alistair, ananth, andrew.donnellan, aneesh.kumar, aneesh.kumar,
	bauerman, bsingharora, christophe.leroy, clombard, elfring,
	fbarrat, felix, fthain, gromero, j.neuschaefer, khandual, ldufour,
	linux-kernel, linuxppc-dev, linuxram, logang, maddy, malat, matt,
	matthew.brown.dev, mauricfo, mgreer, mhairgrove, mikey,
	naveen.n.rao, npiggin, paulus, robh, sam.bobroff, segher,
	sjitindarsingh, stewart, sukadev, vaibhav, wei.guo.simon,
	weiyongjun1

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Linus,

Please pull powerpc updates for 4.17.

A bit late unfortunately, not due to anything terrible, but just a
trickle of small fixes through the week.

There's one minor merge conflict in the lib/raid6/test/Makefile, between
our changes and the removal of the tilegx implementation.

Other than that the only other out-of-area change is a minor change to
memblock.[ch], to export a function, which was OK'ed by Andrew.

cheers


The following changes since commit 661e50bc853209e41a5c14a290ca4decc43cbfd1:

  Linux 4.16-rc4 (2018-03-04 14:54:11 -0800)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/po=
werpc-4.17-1

for you to fetch changes up to c1b25a17d24925b0961c319cfc3fd7e1dc778914:

  powerpc/64s/idle: Fix restore of AMOR on POWER9 after deep sleep (2018-04=
-05 16:48:52 +1000)

=2D ----------------------------------------------------------------
powerpc updates for 4.17

Notable changes:

 - Support for 4PB user address space on 64-bit, opt-in via mmap().

 - Removal of POWER4 support, which was accidentally broken in 2016 and no =
one
   noticed, and blocked use of some modern instructions.

 - Workarounds so that the hypervisor can enable Transactional Memory on Po=
wer9.

 - A series to disable the DAWR (Data Address Watchpoint Register) on Power=
9.

 - More information displayed in the meltdown/spectre_v1/v2 sysfs files.

 - A vpermxor (Power8 Altivec) implementation for the raid6 Q Syndrome.

 - A big series to make the allocation of our pacas (per cpu area), kernel =
page
   tables, and per-cpu stacks NUMA aware when using the Radix MMU on Power9.

And as usual many fixes, reworks and cleanups.

Thanks to:
  Aaro Koskinen, Alexandre Belloni, Alexey Kardashevskiy, Alistair Popple, =
Andy
  Shevchenko, Aneesh Kumar K.V, Anshuman Khandual, Balbir Singh, Benjamin
  Herrenschmidt, Christophe Leroy, Christophe Lombard, Cyril Bur, Daniel Ax=
tens,
  Dave Young, Finn Thain, Frederic Barrat, Gustavo Romero, Horia Geant=C4=
=83,
  Jonathan Neusch=C3=A4fer, Kees Cook, Larry Finger, Laurent Dufour, Lauren=
t Vivier,
  Logan Gunthorpe, Madhavan Srinivasan, Mark Greer, Mark Hairgrove, Markus
  Elfring, Mathieu Malaterre, Matt Brown, Matt Evans, Mauricio Faria de
  Oliveira, Michael Neuling, Naveen N. Rao, Nicholas Piggin, Paul Mackerras,
  Philippe Bergheaud, Ram Pai, Rob Herring, Sam Bobroff, Segher Boessenkool,
  Simon Guo, Simon Horman, Stewart Smith, Sukadev Bhattiprolu, Suraj Jitind=
ar
  Singh, Thiago Jung Bauermann, Vaibhav Jain, Vaidyanathan Srinivasan, Vasa=
nt
  Hegde, Wei Yongjun.

=2D ----------------------------------------------------------------
Aaro Koskinen (1):
      drivers: macintosh: rack-meter: really fix bogus memsets

Alexandre Belloni (2):
      powerpc/time: stop validating rtc_time in .read_time
      powerpc/5200: dts: digsy_mtc.dts: fix rv3029 compatible

Alexey Kardashevskiy (4):
      powerpc/init: Do not advertise radix during client-architecture-suppo=
rt
      powerpc/lpar/debug: Initialize flags before printing debug message
      powerpc/mm: Fix typo in comments
      powerpc/powernv/npu: Do not try invalidating 32bit table when 64bit t=
able is enabled

Alistair Popple (1):
      powerpc/powernv/npu: Fix deadlock in mmio_invalidate()

Aneesh Kumar K.V (12):
      powerpc/mm/keys: Move pte bits to correct headers
      powerpc/mm/slice: Consolidate return path in slice_get_unmapped_area()
      powerpc/mm: Add support for handling > 512TB address in SLB miss
      powerpc/mm/hash64: Increase the VA range
      powerpc/mm/hash: Don't memset pgd table if not needed
      powerpc/kvm: Fix guest boot failure on Power9 since DAWR changes
      powerpc: Fix oops due to bad access of lppaca on bare metal
      powerpc/mm/keys: Update documentation and remove unnecessary check
      powerpc/mm/radix: Update pte fragment count from 16 to 256 on radix
      powerpc/mm/hugetlb: initialize the pagetable cache correctly for huge=
tlb
      powerpc/mm/radix: Parse disable_radix commandline correctly.
      powerpc/mm/radix: Update command line parsing for disable_radix

Anshuman Khandual (1):
      powerpc/mm: Drop the function native_register_proc_table()

Balbir Singh (1):
      powerpc/powernv/mce: Don't silently restart the machine

Christophe Leroy (7):
      powerpc/mm/slice: Remove intermediate bitmap copy
      powerpc/mm/slice: create header files dedicated to slices
      powerpc/mm/slice: Enhance for supporting PPC32
      powerpc/mm/slice: Fix hugepage allocation at hint address on 8xx
      powerpc/mm/slice: Allow up to 64 low slices
      powerpc/8xx: Increase number of slices to 64
      powerpc/8xx: fix cpm_cascade() dual end of interrupt

Christophe Lombard (1):
      cxl: Fix timebase synchronization status on P9

Finn Thain (1):
      macintosh/adb: Use C99 initializers for struct adb_driver instances

Frederic Barrat (2):
      powerpc/xive: Fix wrong xmon output caused by typo
      cxl: Fix possible deadlock when processing page faults from cxllib

Gustavo Romero (1):
      selftests/powerpc: Skip tm-unavailable if TM is not enabled

Jonathan Neusch=C3=A4fer (10):
      powerpc/wii: Probe the whole devicetree
      powerpc/wii: Explicitly configure GPIO owner for poweroff pin
      powerpc/wii.dts: Add ngpios property
      powerpc/wii.dts: Add GPIO line names
      powerpc/wii.dts: Add drive slot LED
      powerpc/mm: Simplify page_is_ram by using memblock_is_memory
      powerpc/mm: Use memblock API for PPC32 page_is_ram
      powerpc/mm/32: Use page_is_ram to check for RAM
      powerpc/wii: Don't rely on the reserved memory hack
      powerpc/mm/32: Remove the reserved memory hack

Larry Finger (1):
      macintosh: Add module license to ans-lcd

Laurent Dufour (1):
      selftest/powerpc: Add test for sigreturn in transaction

Logan Gunthorpe (2):
      powerpc: io.h: move iomap.h include so that it can use readq/writeq d=
efs
      powerpc: iomap.c: introduce io{read|write}64_{lo_hi|hi_lo}

Madhavan Srinivasan (5):
      powerpc/perf: Prevent kernel address leak to userspace via BHRB buffer
      powerpc/perf: Prevent kernel address leak via perf_get_data_addr()
      powerpc/perf: Infrastructure to support addition of blacklisted events
      powerpc/perf: Add blacklisted events for Power9 DD2.1
      powerpc/perf: Add blacklisted events for Power9 DD2.2

Mark Greer (1):
      powerpc/boot: Remove duplicate typedefs from libfdt_env.h

Mark Hairgrove (1):
      powerpc/npu-dma.c: Fix crash after __mmu_notifier_register failure

Markus Elfring (1):
      powerpc: Use sizeof(*foo) rather than sizeof(struct foo)

Mathieu Malaterre (22):
      powerpc/via-pmu: Fix section mismatch warning
      powerpc/epapr: Move register keyword at the beginning of declaration
      powerpc/32: Move the inline keyword at the beginning of function decl=
aration
      powerpc/32: Mark both tmp variables as unused
      powerpc/embedded6xx: Make functions flipper_pic_init() & ug_udbg_putc=
() static
      powerpc/kernel: Make function __giveup_fpu() static
      powerpc: Add missing prototype for slb_miss_bad_addr()
      powerpc: Add missing prototype for hdec_interrupt
      powerpc: Add missing prototype for time_init()
      powerpc: Add missing prototype for arch_dup_task_struct()
      powerpc: Add missing prototype for arch_irq_work_raise()
      powerpc: Add missing prototype for init_IRQ()
      powerpc: Add missing prototype for sys_debug_setcontext()
      powerpc: Add missing prototypes for sys_sigreturn() & sys_rt_sigretur=
n()
      powerpc: Add missing prototypes for hw_breakpoint_handler() & arch_un=
register_hw_breakpoint()
      powerpc: Add missing prototypes for ppc_select() & ppc_fadvise64_64()
      powerpc/prom: Remove warning on array size when empty
      powerpc: Avoid comparison of unsigned long >=3D 0 in pfn_valid()
      powerpc: Avoid comparison of unsigned long >=3D 0 in __access_ok()
      powerpc/32: Make some functions static
      powerpc/32: Add missing prototypes for (early|machine)_init()
      powerpc/mm/radix: Fix always false comparison against MMU_NO_CONTEXT

Matt Brown (3):
      lib/raid6/altivec: Add vpermxor implementation for raid6 Q syndrome
      lib/raid6: Build proper raid6test files on powerpc
      powerpc: Remove unused flush_dcache_phys_range()

Matt Evans (1):
      powerpc: Clear branch trap (MSR.BE) before delivering SIGTRAP

Mauricio Faria de Oliveira (5):
      powerpc/rfi-flush: Differentiate enabled and patched flush types
      powerpc/mm: Fix section mismatch warning in stop_machine_change_mappi=
ng()
      powerpc/pseries: Fix clearing of security feature flags
      powerpc: Move default security feature flags
      powerpc/pseries: Restore default security feature flags on setup

Michael Ellerman (29):
      Merge two commits from 'kvm-ppc-fixes' into next
      powerpc/pseries: Move smp_query_cpu_stopped() etc. out of plpar_wrapp=
ers.h
      powerpc/pseries: Make plpar_wrappers.h safe to include when PSERIES=
=3Dn
      powerpc: Rename plapr routines to plpar
      powerpc/xmon: Move empty plpar_set_ciabr() into plpar_wrappers.h
      Merge branch 'topic/ppc-kvm' into next
      powerpc/perf: Fix kernel address leak via sampling registers
      powerpc/rfi-flush: Move the logic to avoid a redo into the debugfs co=
de
      powerpc/rfi-flush: Make it possible to call setup_rfi_flush() again
      powerpc/rfi-flush: Always enable fallback flush on pseries
      powerpc/rfi-flush: Call setup_rfi_flush() after LPM migration
      powerpc/pseries: Add new H_GET_CPU_CHARACTERISTICS flags
      powerpc: Add security feature flags for Spectre/Meltdown
      powerpc/pseries: Set or clear security feature flags
      powerpc/powernv: Set or clear security feature flags
      powerpc/64s: Move cpu_show_meltdown()
      powerpc/64s: Enhance the information in cpu_show_meltdown()
      powerpc/powernv: Use the security flags in pnv_setup_rfi_flush()
      powerpc/pseries: Use the security flags in pseries_setup_rfi_flush()
      powerpc/64s: Wire up cpu_show_spectre_v1()
      powerpc/64s: Wire up cpu_show_spectre_v2()
      Merge branch 'topic/ppc-kvm' into next
      Merge branch 'fixes' into next
      powerpc/mpic: Check if cpu_possible() in mpic_physmask()
      Merge branch 'topic/paca' into next
      powerpc/64e: Fix oops due to deferral of paca allocation
      selftests/powerpc: Fix copyloops build since Power4 assembler change
      powerpc/64s/idle: Consolidate power9_offline_stop()/power9_idle_stop()
      Revert "powerpc/64s/idle: POWER9 ESL=3D0 stop avoid save/restore over=
head"

Michael Neuling (9):
      powerpc: Add ppc_breakpoint_available()
      powerpc: Update ptrace to use ppc_breakpoint_available()
      powerpc: Update xmon to use ppc_breakpoint_available()
      KVM: PPC: Book3S HV: Return error from h_set_mode(SET_DAWR) on POWER9
      KVM: PPC: Book3S HV: Return error from h_set_dabr() on POWER9
      KVM: PPC: Book3S HV: Handle migration with POWER9 disabled DAWR
      powerpc: Disable DAWR on POWER9 via CPU feature quirk
      powerpc: Disable DAWR in the base POWER9 CPU features
      powerpc/eeh: Fix race with driver un/bind

Naveen N. Rao (2):
      powerpc/kprobes: Fix call trace due to incorrect preempt count
      powerpc/hw_breakpoint: Only disable hw breakpoint if cpu supports it

Nicholas Piggin (50):
      powerpc/mm/slice: Simplify and optimise slice context initialisation
      powerpc/mm/slice: tidy lpsizes and hpsizes update loops
      powerpc/mm/slice: pass pointers to struct slice_mask where possible
      powerpc/mm/slice: implement a slice mask cache
      powerpc/mm/slice: implement slice_check_range_fits
      powerpc/mm/slice: Switch to 3-operand slice bitops helpers
      powerpc/mm/slice: remove dead code
      powerpc/mm/slice: Use const pointers to cached slice masks where poss=
ible
      powerpc/mm/slice: remove radix calls to the slice code
      selftests/powerpc: Add process creation benchmark
      powerpc/64s: Do not allocate lppaca if we are not virtualized
      powerpc/64: Use array of paca pointers and allocate pacas individually
      powerpc/64s: Allocate LPPACAs individually
      powerpc/64s: Allocate slb_shadow structures individually
      mm: make memblock_alloc_base_nid() non-static
      powerpc/mm/numa: move numa topology discovery earlier
      powerpc/64: move default SPR recording
      powerpc/setup: Add cpu_to_phys_id array
      powerpc/64: Defer paca allocation until memory topology is discovered
      powerpc/64: Allocate pacas per node
      powerpc/64: Allocate per-cpu stacks node-local if possible
      powerpc/64s/radix: Split early page table mapping to its own function
      powerpc/64s/radix: Allocate kernel page tables node-local if possible
      powerpc/mm: Pass node id into create_section_mapping
      powerpc/powernv: Handle unknown OPAL errors in opal_nvram_write()
      powerpc/64: Fix smp_wmb barrier definition use use lwsync consistently
      powerpc/64s: return more carefully from sreset NMI
      powerpc/64s: sreset panic if there is no debugger or crash dump handl=
ers
      powerpc/64s/idle: POWER9 implement a separate idle stop function for =
hotplug
      powerpc/64s/idle: avoid sync for KVM state when waking from idle
      powerpc/64s: Add all POWER9 features to CPU_FTRS_ALWAYS
      powerpc/64s: Explicitly add vector features to CPU_FTRS_POSSIBLE
      powerpc/64s: Set assembler machine type to POWER4
      powerpc/64s: Fix POWER9 DD2.2 and above in DT CPU features
      powerpc: Remove unused CPU_FTR_ARCH_201
      powerpc/64s: Remove POWER4 support
      powerpc/64: Add GENERIC_CPU support for little endian
      powerpc/64s: Refine feature sets for little endian builds
      powerpc/64s: Add POWER9 CPU type selection
      KVM: PPC: Book3S HV: Fix ppc_breakpoint_available compile error
      powerpc: Don't write to DABR on >=3D Power8 if DAWR is disabled
      powerpc/powernv: Fix SMT4 forcing idle code
      powerpc: use NMI IPI for smp_send_stop
      powerpc: hard disable irqs in smp_send_stop loop
      powerpc/powernv: Always stop secondaries before reboot/shutdown
      powerpc/64s/idle: POWER9 ESL=3D0 stop avoid save/restore overhead
      powerpc/64s: Fix dt_cpu_ftrs to have restore_cpu clear unwanted LPCR =
bits
      powerpc/64s: Fix pkey support in dt_cpu_ftrs, add CPU_FTR_PKEY bit
      powerpc/64s: Fix POWER9 DD2.2 and above in cputable features
      powerpc/64s/idle: Fix restore of AMOR on POWER9 after deep sleep

Paul Mackerras (8):
      powerpc: Use feature bit for RTC presence rather than timebase presen=
ce
      powerpc: Book E: Remove unused CPU_FTR_L2CSR bit
      powerpc: Free up CPU feature bits on 64-bit machines
      powerpc: Add CPU feature bits for TM bug workarounds on POWER9 v2.2
      powerpc/powernv: Provide a way to force a core into SMT4 mode
      KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9
      KVM: PPC: Book3S HV: Work around TEXASR bug in fake suspend state
      powerpc/64: Call H_REGISTER_PROC_TBL when running as a HPT guest on P=
OWER9

Philippe Bergheaud (2):
      powerpc/powernv: Enable tunneled operations
      cxl: read PHB indications from the device tree

Ram Pai (1):
      powerpc/mm: Fix thread_pkey_regs_init()

Rob Herring (1):
      powerpc: dts: replace 'linux,stdout-path' with 'stdout-path'

Sam Bobroff (9):
      powerpc/eeh: Remove eeh_handle_event()
      powerpc/eeh: Manage EEH_PE_RECOVERING inside eeh_handle_normal_event()
      powerpc/eeh: Fix misleading comment in __eeh_addr_cache_get_device()
      powerpc/eeh: Remove misleading test in eeh_handle_normal_event()
      powerpc/eeh: Rename frozen_bus to bus in eeh_handle_normal_event()
      powerpc/eeh: Clarify arguments to eeh_reset_device()
      powerpc/eeh: Remove always-true tests in eeh_reset_device()
      powerpc/eeh: Factor out common code eeh_reset_device()
      powerpc/eeh: Add eeh_state_active() helper

Segher Boessenkool (1):
      powerpc: Keep const vars out of writable .sdata

Simon Guo (1):
      PCI/hotplug: ppc: correct a php_slot usage after free

Sukadev Bhattiprolu (4):
      powerpc/powernv/vas: Remove a stray line in Makefile
      powerpc/powernv/vas: Fix order of cleanup in vas_window_init_dbgdir()
      powerpc/vas: Fix cleanup when VAS is not configured
      powerpc/vas: Add a couple of trace points

Suraj Jitindar Singh (1):
      KVM: PPC: Book3S HV: Work around XER[SO] bug in fake suspend mode

Thiago Jung Bauermann (1):
      powerpc/kexec_file: Fix error code when trying to load kdump kernel

Vaibhav Jain (5):
      powerpc/xmon: Setup debugger hooks when first break-point is set
      powerpc/xmon: Clear all breakpoints when xmon is disabled via debugfs
      cxl: Enable NORST bit in PSL_DEBUG register for PSL9
      cxl: Remove function write_timebase_ctrl_psl9() for PSL9
      cxl: Check if PSL data-cache is available before issue flush request

Wei Yongjun (1):
      powerpc/4xx: Fix error return code in ppc4xx_msi_probe()

 arch/powerpc/Makefile                              |  14 +-
 arch/powerpc/boot/dts/acadia.dts                   |   2 +-
 arch/powerpc/boot/dts/adder875-redboot.dts         |   2 +-
 arch/powerpc/boot/dts/adder875-uboot.dts           |   2 +-
 arch/powerpc/boot/dts/akebono.dts                  |   2 +-
 arch/powerpc/boot/dts/amigaone.dts                 |   2 +-
 arch/powerpc/boot/dts/asp834x-redboot.dts          |   2 +-
 arch/powerpc/boot/dts/bamboo.dts                   |   2 +-
 arch/powerpc/boot/dts/c2k.dts                      |   2 +-
 arch/powerpc/boot/dts/currituck.dts                |   2 +-
 arch/powerpc/boot/dts/digsy_mtc.dts                |   2 +-
 arch/powerpc/boot/dts/ebony.dts                    |   2 +-
 arch/powerpc/boot/dts/eiger.dts                    |   2 +-
 arch/powerpc/boot/dts/ep405.dts                    |   2 +-
 arch/powerpc/boot/dts/fsl/mvme7100.dts             |   2 +-
 arch/powerpc/boot/dts/fsp2.dts                     |   2 +-
 arch/powerpc/boot/dts/holly.dts                    |   2 +-
 arch/powerpc/boot/dts/hotfoot.dts                  |   2 +-
 arch/powerpc/boot/dts/icon.dts                     |   2 +-
 arch/powerpc/boot/dts/iss4xx-mpic.dts              |   2 +-
 arch/powerpc/boot/dts/iss4xx.dts                   |   2 +-
 arch/powerpc/boot/dts/katmai.dts                   |   2 +-
 arch/powerpc/boot/dts/klondike.dts                 |   2 +-
 arch/powerpc/boot/dts/ksi8560.dts                  |   2 +-
 arch/powerpc/boot/dts/media5200.dts                |   2 +-
 arch/powerpc/boot/dts/mpc8272ads.dts               |   2 +-
 arch/powerpc/boot/dts/mpc866ads.dts                |   2 +-
 arch/powerpc/boot/dts/mpc885ads.dts                |   2 +-
 arch/powerpc/boot/dts/mvme5100.dts                 |   2 +-
 arch/powerpc/boot/dts/obs600.dts                   |   2 +-
 arch/powerpc/boot/dts/pq2fads.dts                  |   2 +-
 arch/powerpc/boot/dts/rainier.dts                  |   2 +-
 arch/powerpc/boot/dts/redwood.dts                  |   2 +-
 arch/powerpc/boot/dts/sam440ep.dts                 |   2 +-
 arch/powerpc/boot/dts/sequoia.dts                  |   2 +-
 arch/powerpc/boot/dts/storcenter.dts               |   2 +-
 arch/powerpc/boot/dts/taishan.dts                  |   2 +-
 arch/powerpc/boot/dts/virtex440-ml507.dts          |   2 +-
 arch/powerpc/boot/dts/virtex440-ml510.dts          |   2 +-
 arch/powerpc/boot/dts/walnut.dts                   |   2 +-
 arch/powerpc/boot/dts/warp.dts                     |   2 +-
 arch/powerpc/boot/dts/wii.dts                      |  21 +
 arch/powerpc/boot/dts/xpedite5200_xmon.dts         |   2 +-
 arch/powerpc/boot/dts/yosemite.dts                 |   2 +-
 arch/powerpc/boot/libfdt_env.h                     |   2 -
 arch/powerpc/include/asm/asm-prototypes.h          |  15 +
 arch/powerpc/include/asm/barrier.h                 |   3 +-
 arch/powerpc/include/asm/book3s/64/hash-4k.h       |  14 +
 arch/powerpc/include/asm/book3s/64/hash-64k.h      |  25 +-
 arch/powerpc/include/asm/book3s/64/hash.h          |   2 +-
 arch/powerpc/include/asm/book3s/64/mmu.h           |  54 +-
 arch/powerpc/include/asm/book3s/64/pgalloc.h       |  12 +-
 arch/powerpc/include/asm/book3s/64/pgtable.h       |  19 -
 arch/powerpc/include/asm/book3s/64/radix-4k.h      |   5 +
 arch/powerpc/include/asm/book3s/64/radix-64k.h     |   6 +
 arch/powerpc/include/asm/book3s/64/radix.h         |   2 +-
 arch/powerpc/include/asm/book3s/64/slice.h         |  27 +
 arch/powerpc/include/asm/cacheflush.h              |   1 -
 arch/powerpc/include/asm/cputable.h                | 263 +++++----
 arch/powerpc/include/asm/debug.h                   |   1 +
 arch/powerpc/include/asm/eeh.h                     |   6 +
 arch/powerpc/include/asm/eeh_event.h               |   3 +-
 arch/powerpc/include/asm/epapr_hcalls.h            |  22 +-
 arch/powerpc/include/asm/hugetlb.h                 |   8 +-
 arch/powerpc/include/asm/hvcall.h                  |   4 +
 arch/powerpc/include/asm/hw_breakpoint.h           |   5 +-
 arch/powerpc/include/asm/io.h                      |   4 +-
 arch/powerpc/include/asm/irq.h                     |   1 +
 arch/powerpc/include/asm/irq_work.h                |   1 +
 arch/powerpc/include/asm/kvm_asm.h                 |   2 +
 arch/powerpc/include/asm/kvm_book3s.h              |   4 +
 arch/powerpc/include/asm/kvm_book3s_64.h           |  43 ++
 arch/powerpc/include/asm/kvm_book3s_asm.h          |   1 +
 arch/powerpc/include/asm/kvm_host.h                |   1 +
 arch/powerpc/include/asm/kvm_ppc.h                 |   8 +-
 arch/powerpc/include/asm/lppaca.h                  |  29 +-
 arch/powerpc/include/asm/mmu-8xx.h                 |  21 +
 arch/powerpc/include/asm/mmu.h                     |   6 +-
 arch/powerpc/include/asm/mmu_context.h             |  39 ++
 arch/powerpc/include/asm/nohash/32/slice.h         |  18 +
 arch/powerpc/include/asm/nohash/64/slice.h         |  12 +
 arch/powerpc/include/asm/opal-api.h                |   4 +-
 arch/powerpc/include/asm/opal.h                    |   4 +-
 arch/powerpc/include/asm/paca.h                    |  27 +-
 arch/powerpc/include/asm/page.h                    |  11 +-
 arch/powerpc/include/asm/page_64.h                 |  59 --
 arch/powerpc/include/asm/perf_event_server.h       |   2 +
 arch/powerpc/include/asm/plpar_wrappers.h          |  24 +-
 arch/powerpc/include/asm/pmc.h                     |  13 +-
 arch/powerpc/include/asm/pnv-pci.h                 |   6 +
 arch/powerpc/include/asm/powernv.h                 |   1 +
 arch/powerpc/include/asm/ppc-opcode.h              |  10 +
 arch/powerpc/include/asm/ppc_asm.h                 |  11 +-
 arch/powerpc/include/asm/processor.h               |  16 +-
 arch/powerpc/include/asm/reg.h                     |   7 +
 arch/powerpc/include/asm/security_features.h       |  74 +++
 arch/powerpc/include/asm/setup.h                   |   3 +-
 arch/powerpc/include/asm/slice.h                   |  40 ++
 arch/powerpc/include/asm/smp.h                     |   5 +-
 arch/powerpc/include/asm/sparsemem.h               |   2 +-
 arch/powerpc/include/asm/spinlock.h                |   2 +
 arch/powerpc/include/asm/switch_to.h               |   1 -
 arch/powerpc/include/asm/synch.h                   |   4 -
 arch/powerpc/include/asm/thread_info.h             |   1 +
 arch/powerpc/include/asm/time.h                    |   4 +-
 arch/powerpc/include/asm/uaccess.h                 |  10 +-
 arch/powerpc/kernel/Makefile                       |   2 +-
 arch/powerpc/kernel/asm-offsets.c                  |   8 +
 arch/powerpc/kernel/cpu_setup_6xx.S                |   2 +-
 arch/powerpc/kernel/cpu_setup_fsl_booke.S          |   2 +-
 arch/powerpc/kernel/cputable.c                     |  59 +-
 arch/powerpc/kernel/crash.c                        |   2 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c                  |  36 +-
 arch/powerpc/kernel/eeh.c                          |  19 +-
 arch/powerpc/kernel/eeh_cache.c                    |   3 +-
 arch/powerpc/kernel/eeh_driver.c                   | 205 ++++---
 arch/powerpc/kernel/eeh_event.c                    |   6 +-
 arch/powerpc/kernel/entry_64.S                     |   2 +-
 arch/powerpc/kernel/exceptions-64s.S               |  86 ++-
 arch/powerpc/kernel/head_64.S                      |  19 +-
 arch/powerpc/kernel/hw_breakpoint.c                |   3 +
 arch/powerpc/kernel/idle_book3s.S                  |  50 +-
 arch/powerpc/kernel/iomap.c                        |  40 ++
 arch/powerpc/kernel/kprobes.c                      |  30 +-
 arch/powerpc/kernel/machine_kexec_64.c             |  37 +-
 arch/powerpc/kernel/machine_kexec_file_64.c        |   2 +-
 arch/powerpc/kernel/misc_64.S                      |  38 --
 arch/powerpc/kernel/nvram_64.c                     |   9 +-
 arch/powerpc/kernel/paca.c                         | 242 ++++----
 arch/powerpc/kernel/process.c                      |  26 +-
 arch/powerpc/kernel/prom.c                         |  19 +-
 arch/powerpc/kernel/prom_init.c                    |  29 +-
 arch/powerpc/kernel/prom_init_check.sh             |   2 +-
 arch/powerpc/kernel/ptrace.c                       |  16 +-
 arch/powerpc/kernel/security.c                     |  88 +++
 arch/powerpc/kernel/setup-common.c                 |  37 +-
 arch/powerpc/kernel/setup.h                        |   9 +-
 arch/powerpc/kernel/setup_32.c                     |   8 +-
 arch/powerpc/kernel/setup_64.c                     | 113 ++--
 arch/powerpc/kernel/signal.h                       |   5 +
 arch/powerpc/kernel/signal_32.c                    |   4 +-
 arch/powerpc/kernel/smp.c                          |  23 +-
 arch/powerpc/kernel/sysfs.c                        |  20 +-
 arch/powerpc/kernel/time.c                         |   5 +-
 arch/powerpc/kernel/traps.c                        |  31 +-
 arch/powerpc/kernel/vdso.c                         |  12 +-
 arch/powerpc/kvm/Makefile                          |   7 +
 arch/powerpc/kvm/book3s_hv.c                       |  55 +-
 arch/powerpc/kvm/book3s_hv_builtin.c               |   2 +-
 arch/powerpc/kvm/book3s_hv_interrupts.S            |   3 +-
 arch/powerpc/kvm/book3s_hv_rmhandlers.S            | 187 ++++++-
 arch/powerpc/kvm/book3s_hv_tm.c                    | 216 +++++++
 arch/powerpc/kvm/book3s_hv_tm_builtin.c            | 109 ++++
 arch/powerpc/kvm/emulate.c                         |   6 -
 arch/powerpc/kvm/powerpc.c                         |   5 +-
 arch/powerpc/lib/Makefile                          |   6 +-
 arch/powerpc/lib/copypage_64.S                     |   2 +
 arch/powerpc/lib/copypage_power7.S                 |   3 -
 arch/powerpc/lib/copyuser_64.S                     |   2 +
 arch/powerpc/lib/copyuser_power7.S                 |   3 -
 arch/powerpc/lib/feature-fixups.c                  |   9 +-
 arch/powerpc/lib/memcpy_64.S                       |   2 +
 arch/powerpc/lib/memcpy_power7.S                   |   3 -
 arch/powerpc/lib/sstep.c                           |   4 +-
 arch/powerpc/mm/8xx_mmu.c                          |   2 +-
 arch/powerpc/mm/copro_fault.c                      |   2 +-
 arch/powerpc/mm/fault.c                            |  28 +-
 arch/powerpc/mm/hash_native_64.c                   |  15 -
 arch/powerpc/mm/hash_utils_64.c                    |  34 +-
 arch/powerpc/mm/hugetlbpage.c                      |  26 +-
 arch/powerpc/mm/init_32.c                          |   7 +-
 arch/powerpc/mm/init_64.c                          |   8 +-
 arch/powerpc/mm/mem.c                              |  25 +-
 arch/powerpc/mm/mmu_context_book3s64.c             |  24 +-
 arch/powerpc/mm/mmu_context_nohash.c               |  15 +-
 arch/powerpc/mm/mmu_decl.h                         |   1 -
 arch/powerpc/mm/numa.c                             |  36 +-
 arch/powerpc/mm/pgtable-book3s64.c                 |   8 +-
 arch/powerpc/mm/pgtable-hash64.c                   |   6 +-
 arch/powerpc/mm/pgtable-radix.c                    | 218 +++++---
 arch/powerpc/mm/pgtable_32.c                       |   2 +-
 arch/powerpc/mm/pgtable_64.c                       |   5 -
 arch/powerpc/mm/pkeys.c                            |  17 +-
 arch/powerpc/mm/slb.c                              | 108 ++++
 arch/powerpc/mm/slb_low.S                          |  19 +-
 arch/powerpc/mm/slice.c                            | 485 ++++++++--------
 arch/powerpc/mm/tlb-radix.c                        |  14 +-
 arch/powerpc/mm/tlb_hash64.c                       |   2 +-
 arch/powerpc/oprofile/cell/spu_task_sync.c         |   2 +-
 arch/powerpc/oprofile/cell/vma_map.c               |   4 +-
 arch/powerpc/perf/Makefile                         |   2 +-
 arch/powerpc/perf/core-book3s.c                    |  50 ++
 arch/powerpc/perf/power4-pmu.c                     | 622 -----------------=
----
 arch/powerpc/perf/power9-events-list.h             |  28 +
 arch/powerpc/perf/power9-pmu.c                     |  48 ++
 arch/powerpc/platforms/4xx/msi.c                   |   5 +-
 arch/powerpc/platforms/4xx/ocm.c                   |   2 +-
 arch/powerpc/platforms/85xx/smp.c                  |   8 +-
 arch/powerpc/platforms/8xx/m8xx_setup.c            |   8 +-
 arch/powerpc/platforms/Kconfig.cputype             |  20 +-
 arch/powerpc/platforms/cell/axon_msi.c             |   2 +-
 arch/powerpc/platforms/cell/smp.c                  |   4 +-
 arch/powerpc/platforms/cell/spider-pci.c           |   2 +-
 arch/powerpc/platforms/cell/spufs/lscsa_alloc.c    |   2 +-
 arch/powerpc/platforms/embedded6xx/flipper-pic.c   |   2 +-
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   2 +-
 arch/powerpc/platforms/embedded6xx/wii.c           |  23 +-
 arch/powerpc/platforms/powermac/low_i2c.c          |   2 +-
 arch/powerpc/platforms/powermac/pfunc_core.c       |   4 +-
 arch/powerpc/platforms/powernv/Makefile            |   1 -
 arch/powerpc/platforms/powernv/eeh-powernv.c       |   9 +-
 arch/powerpc/platforms/powernv/idle.c              |  88 ++-
 arch/powerpc/platforms/powernv/npu-dma.c           | 261 +++++----
 arch/powerpc/platforms/powernv/opal-flash.c        |  32 +-
 arch/powerpc/platforms/powernv/opal-hmi.c          |   2 +-
 arch/powerpc/platforms/powernv/opal-imc.c          |  10 +-
 .../powerpc/platforms/powernv/opal-memory-errors.c |   2 +-
 arch/powerpc/platforms/powernv/opal-nvram.c        |   4 +
 arch/powerpc/platforms/powernv/opal-psr.c          |   2 +-
 .../powerpc/platforms/powernv/opal-sensor-groups.c |   4 +-
 arch/powerpc/platforms/powernv/opal-wrappers.S     |   2 +
 arch/powerpc/platforms/powernv/opal-xscom.c        |   2 +-
 arch/powerpc/platforms/powernv/opal.c              |   5 +-
 arch/powerpc/platforms/powernv/pci-cxl.c           |   8 -
 arch/powerpc/platforms/powernv/pci-ioda.c          |  29 +-
 arch/powerpc/platforms/powernv/pci.c               | 135 +++++
 arch/powerpc/platforms/powernv/setup.c             | 114 ++--
 arch/powerpc/platforms/powernv/smp.c               |   2 +-
 arch/powerpc/platforms/powernv/subcore.c           |   2 +-
 arch/powerpc/platforms/powernv/vas-debug.c         |  19 +-
 arch/powerpc/platforms/powernv/vas-trace.h         | 113 ++++
 arch/powerpc/platforms/powernv/vas-window.c        |   9 +
 arch/powerpc/platforms/powernv/vas.c               |   6 +-
 arch/powerpc/platforms/ps3/mm.c                    |   6 +-
 arch/powerpc/platforms/pseries/hotplug-cpu.c       |   2 +-
 arch/powerpc/platforms/pseries/kexec.c             |   7 +-
 arch/powerpc/platforms/pseries/lpar.c              |  18 +-
 arch/powerpc/platforms/pseries/mobility.c          |   3 +
 arch/powerpc/platforms/pseries/pseries.h           |  10 +
 arch/powerpc/platforms/pseries/setup.c             |  85 ++-
 arch/powerpc/platforms/pseries/smp.c               |   6 +-
 arch/powerpc/sysdev/mpic.c                         |   2 +-
 arch/powerpc/sysdev/xics/icp-native.c              |   2 +-
 arch/powerpc/sysdev/xive/common.c                  |   2 +-
 arch/powerpc/xmon/xmon.c                           |  56 +-
 drivers/macintosh/adb-iop.c                        |  14 +-
 drivers/macintosh/ans-lcd.c                        |   1 +
 drivers/macintosh/macio-adb.c                      |  15 +-
 drivers/macintosh/rack-meter.c                     |   6 +-
 drivers/macintosh/via-macii.c                      |  14 +-
 drivers/macintosh/via-pmu.c                        |  16 +-
 drivers/macintosh/via-pmu68k.c                     |  14 +-
 drivers/misc/cxl/cxl.h                             |   6 +-
 drivers/misc/cxl/cxllib.c                          |  87 ++-
 drivers/misc/cxl/native.c                          |  11 +-
 drivers/misc/cxl/pci.c                             | 102 ++--
 drivers/misc/cxl/sysfs.c                           |  12 +
 drivers/pci/hotplug/pnv_php.c                      |   2 +-
 include/linux/memblock.h                           |   3 +
 include/linux/raid/pq.h                            |   4 +
 lib/raid6/.gitignore                               |   1 +
 lib/raid6/Makefile                                 |  27 +-
 lib/raid6/algos.c                                  |   4 +
 lib/raid6/altivec.uc                               |   3 +
 lib/raid6/test/Makefile                            |  25 +-
 lib/raid6/vpermxor.uc                              | 105 ++++
 mm/memblock.c                                      |   2 +-
 .../selftests/powerpc/benchmarks/.gitignore        |   2 +
 .../testing/selftests/powerpc/benchmarks/Makefile  |   7 +-
 .../selftests/powerpc/benchmarks/exec_target.c     |  13 +
 tools/testing/selftests/powerpc/benchmarks/fork.c  | 325 +++++++++++
 tools/testing/selftests/powerpc/copyloops/Makefile |   4 +-
 tools/testing/selftests/powerpc/tm/Makefile        |   2 +-
 tools/testing/selftests/powerpc/tm/tm-sigreturn.c  |  92 +++
 .../testing/selftests/powerpc/tm/tm-unavailable.c  |  24 +-
 275 files changed, 4647 insertions(+), 2427 deletions(-)
 create mode 100644 arch/powerpc/include/asm/book3s/64/slice.h
 create mode 100644 arch/powerpc/include/asm/nohash/32/slice.h
 create mode 100644 arch/powerpc/include/asm/nohash/64/slice.h
 create mode 100644 arch/powerpc/include/asm/security_features.h
 create mode 100644 arch/powerpc/include/asm/slice.h
 create mode 100644 arch/powerpc/kernel/security.c
 create mode 100644 arch/powerpc/kvm/book3s_hv_tm.c
 create mode 100644 arch/powerpc/kvm/book3s_hv_tm_builtin.c
 delete mode 100644 arch/powerpc/perf/power4-pmu.c
 create mode 100644 arch/powerpc/platforms/powernv/vas-trace.h
 create mode 100644 lib/raid6/vpermxor.uc
 create mode 100644 tools/testing/selftests/powerpc/benchmarks/exec_target.c
 create mode 100644 tools/testing/selftests/powerpc/benchmarks/fork.c
 create mode 100644 tools/testing/selftests/powerpc/tm/tm-sigreturn.c
=2D----BEGIN PGP SIGNATURE-----

iQIcBAEBCAAGBQJayMZIAAoJEFHr6jzI4aWA5N8P/2Ld4s0Olg6bCPR+s49cY6AT
kPphjS90QWYXEV7ZmU5zJtms8n5PCEIzAJ1fZyCvMN2bltzv0Y+GeHmL3VaPPehT
c7T/v0AVs/9j1P3+AwDm3oTZZSnxAW3ruZr62Pn9+9DtNqLuUvvpqqKszGjjWIKe
W7G2pVqF8DDSMoVLWvtgXJbYMbDDsCmKy5ZGX0kenctFZX5hLWGxAURYfymeh/Tx
j3anKXMaeSypAQNQcapHmdqeyMc531niSk5VbN8o/7Tr59igA7Eokzv2+0IIKs37
t5E6Tw99r/qchQiUx3gpy7yf9m+QNEHkwHRa8R6HB2fHIanpg10y7rD7gyQcomFQ
K0Zppm++yms541pll9CMN7RLWa4BhqGoDeDJIv8s/MGIl8ETQIHVfG30doxaFaIN
ivY0u1C9KXAGdUOwjaVT82C7RuGZTKjAjSQ2U2riNGI8iKV7usSioJrwT5ZRxys/
6XATnbugpM4usmbupqs652Ver6o2b7kz2Ek1voYbTF18L0UY5Ez/7ECaZNiTvqKa
R+2VlaUx4B8ei7NYFX+GXP8VN4jecaHUSyPoBLLvyUwXSmvBqwyD0r0yhVHrUGfr
ogneuLDkqVSbG1e2yFWuxe0AKZifmZoTXv/7I6qBlStMtXA/crKSbpd6NUkBUpXH
U4aL/5JjSTR3Zqv3g5BM
=3Dw2Q5
=2D----END PGP SIGNATURE-----

^ permalink raw reply

* Re: [PATCH 1/5] powerpc/embedded6xx: Remove C2K board support
From: kbuild test robot @ 2018-04-07 14:18 UTC (permalink / raw)
  To: Mark Greer
  Cc: kbuild-all, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Remi Machet, Dale Farnsworth, linuxppc-dev,
	linux-kernel, Mark Greer
In-Reply-To: <20180406011720.7728-2-mgreer@animalcreek.com>

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

Hi Mark,

I love your patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[cannot apply to v4.16 next-20180406]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Mark-Greer/powerpc-Remove-support-for-Marvell-mv64x60-hostbridges/20180406-204320
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-amigaone_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All warnings (new ones prefixed by >>):

warning: (AMIGAONE) selects NOT_COHERENT_CACHE which has unmet direct dependencies (4xx || PPC_8xx || E200 || PPC_MPC512x || GAMECUBE_COMMON)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 17537 bytes --]

^ permalink raw reply

* [PATCH] ASoC: fsl_ssi: Fix mode setting when changing channel number
From: Nicolin Chen @ 2018-04-08  4:40 UTC (permalink / raw)
  To: broonie, mika.penttila
  Cc: linux-kernel, linuxppc-dev, alsa-devel, tiwai, perex, lgirdwood,
	fabio.estevam, timur

This is a partial revert (in a cleaner way) of commit ebf08ae3bc90
("ASoC: fsl_ssi: Keep ssi->i2s_net updated") to fix a regression
at test cases when switching between mono and stereo audio.

The problem is that ssi->i2s_net is initialized in set_dai_fmt()
only, while this set_dai_fmt() is only called during the dai-link
probe(). The original patch assumed set_dai_fmt() would be called
during every playback instance, so it failed at the overriding use
cases.

This patch adds the local variable i2s_net back to let regular use
cases still follow the mode settings from the set_dai_fmt().

Meanwhile, the original commit of keeping ssi->i2s_net updated was
to make set_tdm_slot() clean by checking the ssi->i2s_net directly
instead of reading SCR register. However, the change itself is not
necessary (or even harmful) because the set_tdm_slot() might fail
to check the slot number for Normal-Mode-None-Net settings while
mono audio cases still need 2 slots. So this patch can also fix it.
And it adds an extra line of comments to declare ssi->i2s_net does
not reflect the register value but merely the initial setting from
the set_dai_fmt().

Reported-by: Mika Penttilä <mika.penttila@nextfour.com>
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Mika Penttilä <mika.penttila@nextfour.com>
---
 sound/soc/fsl/fsl_ssi.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0823b08..89df2d9 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -217,6 +217,7 @@ struct fsl_ssi_soc_data {
  * @dai_fmt: DAI configuration this device is currently used with
  * @streams: Mask of current active streams: BIT(TX) and BIT(RX)
  * @i2s_net: I2S and Network mode configurations of SCR register
+ *           (this is the initial settings based on the DAI format)
  * @synchronous: Use synchronous mode - both of TX and RX use STCK and SFCK
  * @use_dma: DMA is used or FIQ with stream filter
  * @use_dual_fifo: DMA with support for dual FIFO mode
@@ -829,16 +830,23 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	if (!fsl_ssi_is_ac97(ssi)) {
+		/*
+		 * Keep the ssi->i2s_net intact while having a local variable
+		 * to override settings for special use cases. Otherwise, the
+		 * ssi->i2s_net will lose the settings for regular use cases.
+		 */
+		u8 i2s_net = ssi->i2s_net;
+
 		/* Normal + Network mode to send 16-bit data in 32-bit frames */
 		if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16)
-			ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
+			i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET;
 
 		/* Use Normal mode to send mono data at 1st slot of 2 slots */
 		if (channels == 1)
-			ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL;
+			i2s_net = SSI_SCR_I2S_MODE_NORMAL;
 
 		regmap_update_bits(regs, REG_SSI_SCR,
-				   SSI_SCR_I2S_NET_MASK, ssi->i2s_net);
+				   SSI_SCR_I2S_NET_MASK, i2s_net);
 	}
 
 	/* In synchronous mode, the SSI uses STCCR for capture */
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH 1/2] KVM: PPC: Book3S HV: trace_tlbie must not be called in realmode
From: Balbir Singh @ 2018-04-08 10:17 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: open list:KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC,
	open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Paul Mackerras
In-Reply-To: <20180405175631.31381-2-npiggin@gmail.com>

On Fri, Apr 6, 2018 at 3:56 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> This crashes with a "Bad real address for load" attempting to load
> from the vmalloc region in realmode (faulting address is in DAR).
>
>   Oops: Bad interrupt in KVM entry/exit code, sig: 6 [#1]
>   LE SMP NR_CPUS=2048 NUMA PowerNV
>   CPU: 53 PID: 6582 Comm: qemu-system-ppc Not tainted 4.16.0-01530-g43d1859f0994
>   NIP:  c0000000000155ac LR: c0000000000c2430 CTR: c000000000015580
>   REGS: c000000fff76dd80 TRAP: 0200   Not tainted  (4.16.0-01530-g43d1859f0994)
>   MSR:  9000000000201003 <SF,HV,ME,RI,LE>  CR: 48082222  XER: 00000000
>   CFAR: 0000000102900ef0 DAR: d00017fffd941a28 DSISR: 00000040 SOFTE: 3
>   NIP [c0000000000155ac] perf_trace_tlbie+0x2c/0x1a0
>   LR [c0000000000c2430] do_tlbies+0x230/0x2f0
>
> I suspect the reason is the per-cpu data is not in the linear chunk.
> This could be restored if that was able to be fixed, but for now,
> just remove the tracepoints.

Could you share the stack trace as well? I've not observed this in my testing.
May be I don't have as many cpus. I presume your talking about the per cpu
data offsets for per cpu trace data?

Balbir Singh.

^ permalink raw reply

* Re: [PATCH 1/2] KVM: PPC: Book3S HV: trace_tlbie must not be called in realmode
From: Nicholas Piggin @ 2018-04-08 13:41 UTC (permalink / raw)
  To: Balbir Singh
  Cc: open list:KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC,
	open list:LINUX FOR POWERPC (32-BIT AND 64-BIT), Paul Mackerras
In-Reply-To: <CAKTCnzn119+T_jkWAxPXoor_bpMezdRoQ9VqN+TYTUhxvQq4Fw@mail.gmail.com>

On Sun, 8 Apr 2018 20:17:47 +1000
Balbir Singh <bsingharora@gmail.com> wrote:

> On Fri, Apr 6, 2018 at 3:56 AM, Nicholas Piggin <npiggin@gmail.com> wrote:
> > This crashes with a "Bad real address for load" attempting to load
> > from the vmalloc region in realmode (faulting address is in DAR).
> >
> >   Oops: Bad interrupt in KVM entry/exit code, sig: 6 [#1]
> >   LE SMP NR_CPUS=2048 NUMA PowerNV
> >   CPU: 53 PID: 6582 Comm: qemu-system-ppc Not tainted 4.16.0-01530-g43d1859f0994
> >   NIP:  c0000000000155ac LR: c0000000000c2430 CTR: c000000000015580
> >   REGS: c000000fff76dd80 TRAP: 0200   Not tainted  (4.16.0-01530-g43d1859f0994)
> >   MSR:  9000000000201003 <SF,HV,ME,RI,LE>  CR: 48082222  XER: 00000000
> >   CFAR: 0000000102900ef0 DAR: d00017fffd941a28 DSISR: 00000040 SOFTE: 3
> >   NIP [c0000000000155ac] perf_trace_tlbie+0x2c/0x1a0
> >   LR [c0000000000c2430] do_tlbies+0x230/0x2f0
> >
> > I suspect the reason is the per-cpu data is not in the linear chunk.
> > This could be restored if that was able to be fixed, but for now,
> > just remove the tracepoints.  
> 
> Could you share the stack trace as well? I've not observed this in my testing.

I can't seem to find it, I can try reproduce tomorrow. It was coming
from h_remove hcall from the guest. It's 176 logical CPUs.

> May be I don't have as many cpus. I presume your talking about the per cpu
> data offsets for per cpu trace data?

It looked like it was dereferencing virtually mapped per-cpu data, yes.
Probably the perf_events deref.

Thanks,
Nick

^ permalink raw reply

* [PATCH] powerpc/32: Make some functions static
From: Mathieu Malaterre @ 2018-04-08 19:43 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, linux-kernel

In commit 4aea909eeba3 ("powerpc: Add missing prototypes in setup_32.c")
prototypes for

- ppc_setup_l2cr
- ppc_setup_l3cr
- ppc_init

were added but at the same time in commit d15a261d876d ("powerpc/32: Make
some functions static") those same functions were made static. Fix
conflicting changes by removing the prototypes and leave the function as
static. Fix the following warnings, treated as errors with W=1:

  arch/powerpc/kernel/setup_32.c:127:19: error: static declaration of ‘ppc_setup_l2cr’ follows non-static declaration
  arch/powerpc/kernel/setup_32.c:140:19: error: static declaration of ‘ppc_setup_l3cr’ follows non-static declaration
  arch/powerpc/kernel/setup_32.c:186:19: error: static declaration of ‘ppc_init’ follows non-static declaration

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 arch/powerpc/kernel/setup_32.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 9827b6b3aaaa..9e79be13b937 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -124,7 +124,7 @@ notrace void __init machine_init(u64 dt_ptr)
 }
 
 /* Checks "l2cr=xxxx" command-line option */
-static int __init ppc_setup_l2cr(char *str)
+int __init ppc_setup_l2cr(char *str)
 {
 	if (cpu_has_feature(CPU_FTR_L2CR)) {
 		unsigned long val = simple_strtoul(str, NULL, 0);
@@ -137,7 +137,7 @@ static int __init ppc_setup_l2cr(char *str)
 __setup("l2cr=", ppc_setup_l2cr);
 
 /* Checks "l3cr=xxxx" command-line option */
-static int __init ppc_setup_l3cr(char *str)
+int __init ppc_setup_l3cr(char *str)
 {
 	if (cpu_has_feature(CPU_FTR_L3CR)) {
 		unsigned long val = simple_strtoul(str, NULL, 0);
@@ -183,7 +183,7 @@ EXPORT_SYMBOL(nvram_sync);
 
 #endif /* CONFIG_NVRAM */
 
-static int __init ppc_init(void)
+int __init ppc_init(void)
 {
 	/* clear the progress line */
 	if (ppc_md.progress)
-- 
2.11.0

^ permalink raw reply related

* [PATCH] powerpc/mm/radix: add missing braces for single statement block
From: Mathieu Malaterre @ 2018-04-08 19:44 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, linux-kernel

In commit 7a22d6321c3d ("powerpc/mm/radix: Update command line parsing for
disable_radix") an `if` statement was added for a possible empty body
(prom_debug).

Fix the following warning, treated as error with W=1:

  arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 arch/powerpc/kernel/prom_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 5ae153b97d0a..f0e802495530 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void)
 		} else
 			prom_radix_disable = true;
 	}
-	if (prom_radix_disable)
+	if (prom_radix_disable) {
 		prom_debug("Radix disabled from cmdline\n");
+	}
 }
 
 #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
-- 
2.11.0

^ permalink raw reply related

* [PATCH v2] powerpc/32: Make some functions static
From: Mathieu Malaterre @ 2018-04-08 19:48 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, linux-kernel
In-Reply-To: <20180408194318.8062-1-malat@debian.org>

In commit 4aea909eeba3 ("powerpc: Add missing prototypes in setup_32.c")
prototypes for

- ppc_setup_l2cr
- ppc_setup_l3cr
- ppc_init

were added but at the same time in commit d15a261d876d ("powerpc/32: Make
some functions static") those same functions were made static. Fix
conflicting changes by removing the prototypes and leave the function as
static. Fix the following warnings, treated as errors with W=1:

  arch/powerpc/kernel/setup_32.c:127:19: error: static declaration of ‘ppc_setup_l2cr’ follows non-static declaration
  arch/powerpc/kernel/setup_32.c:140:19: error: static declaration of ‘ppc_setup_l3cr’ follows non-static declaration
  arch/powerpc/kernel/setup_32.c:186:19: error: static declaration of ‘ppc_init’ follows non-static declaration

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
v2: Previous version contained the reverted patch, correct that.

 arch/powerpc/kernel/setup.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/powerpc/kernel/setup.h b/arch/powerpc/kernel/setup.h
index 35ca309848d7..829ed66f0a40 100644
--- a/arch/powerpc/kernel/setup.h
+++ b/arch/powerpc/kernel/setup.h
@@ -19,9 +19,6 @@ void irqstack_early_init(void);
 void setup_power_save(void);
 unsigned long __init early_init(unsigned long dt_ptr);
 void __init machine_init(u64 dt_ptr);
-int __init ppc_setup_l2cr(char *str);
-int __init ppc_setup_l3cr(char *str);
-int __init ppc_init(void);
 #else
 static inline void setup_power_save(void) { };
 #endif
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH] powerpc/mm/radix: add missing braces for single statement block
From: Randy Dunlap @ 2018-04-08 20:34 UTC (permalink / raw)
  To: Mathieu Malaterre, Michael Ellerman
  Cc: Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev,
	linux-kernel
In-Reply-To: <20180408194424.8719-1-malat@debian.org>

On 04/08/2018 12:44 PM, Mathieu Malaterre wrote:
> In commit 7a22d6321c3d ("powerpc/mm/radix: Update command line parsing for
> disable_radix") an `if` statement was added for a possible empty body
> (prom_debug).
> 
> Fix the following warning, treated as error with W=1:
> 
>   arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
>  arch/powerpc/kernel/prom_init.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> index 5ae153b97d0a..f0e802495530 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void)
>  		} else
>  			prom_radix_disable = true;
>  	}
> -	if (prom_radix_disable)
> +	if (prom_radix_disable) {
>  		prom_debug("Radix disabled from cmdline\n");

Looks like the macro for #prom_debug() should be fixed instead.

> +	}
>  }
>  
>  #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
> 


-- 
~Randy

^ permalink raw reply

* [PATCH] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio
From: Nicolin Chen @ 2018-04-08 23:57 UTC (permalink / raw)
  To: broonie, marex
  Cc: linux-kernel, linuxppc-dev, alsa-devel, tiwai, perex, lgirdwood,
	fabio.estevam

When the desired ratio is less than 256, the savesub (tolerance)
in the calculation would become 0. This will then fail the loop-
search immediately without reporting any errors.

But if the ratio is smaller enough, there is no need to calculate
the tolerance because PM divisor alone is enough to get the ratio.

So a simple fix could be just to set PM directly instead of going
into the loop-search.

Reported-by: Marek Vasut <marex@denx.de>
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Marek Vasut <marex@denx.de>
---
 sound/soc/fsl/fsl_esai.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 40a7004..da8fd98 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -144,6 +144,13 @@ static int fsl_esai_divisor_cal(struct snd_soc_dai *dai, bool tx, u32 ratio,
 
 	psr = ratio <= 256 * maxfp ? ESAI_xCCR_xPSR_BYPASS : ESAI_xCCR_xPSR_DIV8;
 
+	/* Do not loop-search if PM (1 ~ 256) alone can serve the ratio */
+	if (ratio <= 256) {
+		pm = ratio;
+		fp = 1;
+		goto out;
+	}
+
 	/* Set the max fluctuation -- 0.1% of the max devisor */
 	savesub = (psr ? 1 : 8)  * 256 * maxfp / 1000;
 
-- 
2.7.4

^ permalink raw reply related

* [PATCH] ASoC: fsl_esai: Add freq check in set_dai_sysclk()
From: Nicolin Chen @ 2018-04-09  0:33 UTC (permalink / raw)
  To: broonie
  Cc: linux-kernel, linuxppc-dev, alsa-devel, tiwai, perex, lgirdwood,
	fabio.estevam

The freq parameter indicates the physical frequency of an actual
input clock or a desired frequency of an output clock for HCKT/R.
It should never be passed 0. This might cause Division-by-zero.

So this patch adds a check to fix it.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
 sound/soc/fsl/fsl_esai.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index da8fd98..d79e99e 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
 	unsigned long clk_rate;
 	int ret;
 
+	if (freq == 0) {
+		dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n",
+			in ? "in" : "out", tx ? 'T' : 'R');
+		return -EINVAL;
+	}
+
 	/* Bypass divider settings if the requirement doesn't change */
 	if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx])
 		return 0;
-- 
2.7.4

^ permalink raw reply related

* Re: [alsa-devel] [PATCH] ASoC: fsl_esai: Add freq check in set_dai_sysclk()
From: Fabio Estevam @ 2018-04-09  1:31 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: Mark Brown, alsa-devel, linux-kernel, Takashi Iwai, Liam Girdwood,
	Fabio Estevam, linuxppc-dev
In-Reply-To: <1523234034-33018-1-git-send-email-nicoleotsuka@gmail.com>

On Sun, Apr 8, 2018 at 9:33 PM, Nicolin Chen <nicoleotsuka@gmail.com> wrote:
> The freq parameter indicates the physical frequency of an actual
> input clock or a desired frequency of an output clock for HCKT/R.
> It should never be passed 0. This might cause Division-by-zero.
>
> So this patch adds a check to fix it.
>
> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

^ permalink raw reply

* Re: [alsa-devel] [PATCH] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio
From: Fabio Estevam @ 2018-04-09  1:34 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: Mark Brown, Marek Vasut, alsa-devel, linux-kernel, Takashi Iwai,
	Liam Girdwood, Fabio Estevam, linuxppc-dev
In-Reply-To: <1523231855-7854-1-git-send-email-nicoleotsuka@gmail.com>

Hi Nicolin,

On Sun, Apr 8, 2018 at 8:57 PM, Nicolin Chen <nicoleotsuka@gmail.com> wrote:
> When the desired ratio is less than 256, the savesub (tolerance)
> in the calculation would become 0. This will then fail the loop-
> search immediately without reporting any errors.
>
> But if the ratio is smaller enough, there is no need to calculate
> the tolerance because PM divisor alone is enough to get the ratio.
>
> So a simple fix could be just to set PM directly instead of going
> into the loop-search.
>
> Reported-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
> Cc: Marek Vasut <marex@denx.de>

If this fixes Marek's usecase then I think we should also add:

Cc: <stable@vger.kernel.org>

Thanks

^ permalink raw reply

* [PATCH v2 0/9] first step of standardising OPAL_BUSY handling
From: Nicholas Piggin @ 2018-04-09  5:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Since v1:
- Added console and opal-kmsg
- Fix a missing case in opal_shutdown that would delay even if
  OPAL_SUCCESS was returned.

Thanks,
Nick

Nicholas Piggin (9):
  powerpc/powernv: define a standard delay for OPAL_BUSY type retry
    loops
  powerpc/powernv: OPAL RTC driver standardise OPAL_BUSY loops
  powerpc/powernv: opal_put_chars partial write fix
  powerpc/powernv: OPAL console standardise OPAL_BUSY loops
  powerpc/powernv: OPAL platform standardise OPAL_BUSY loops
  powerpc/powernv: OPAL NVRAM driver standardise OPAL_BUSY delays
  powerpc/powernv: OPAL dump support standardise OPAL_BUSY delays
  powerpc/xive: standardise OPAL_BUSY delays
  powerpc/powernv: opal-kmsg standardise OPAL_BUSY handling

 arch/powerpc/include/asm/opal.h             |   3 +
 arch/powerpc/platforms/powernv/opal-dump.c  |   6 +-
 arch/powerpc/platforms/powernv/opal-kmsg.c  |  24 ++-
 arch/powerpc/platforms/powernv/opal-nvram.c |   7 +-
 arch/powerpc/platforms/powernv/opal-rtc.c   |   6 +-
 arch/powerpc/platforms/powernv/opal.c       |  46 +++--
 arch/powerpc/platforms/powernv/setup.c      |  16 +-
 arch/powerpc/sysdev/xive/native.c           | 193 +++++++++++---------
 drivers/rtc/rtc-opal.c                      |  33 ++--
 9 files changed, 203 insertions(+), 131 deletions(-)

-- 
2.17.0

^ permalink raw reply

* [PATCH v2 1/9] powerpc/powernv: define a standard delay for OPAL_BUSY type retry loops
From: Nicholas Piggin @ 2018-04-09  5:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20180409052431.26405-1-npiggin@gmail.com>

This is the start of an effort to tidy up and standardise all the
delays. Existing loops have a range of delay/sleep periods from 1ms
to 20ms, and some have no delay. They all loop forever except rtc,
which times out after 10 retries, and that uses 10ms delays. So use
10ms as our standard delay. The OPAL maintainer agrees 10ms is a
reasonable starting point.

The idea is to use the same recipe everywhere, once this is proven to
work then it will be documented as an OPAL API standard. Then both
firmware and OS can agree, and if a particular call needs something
else, then that can be documented with reasoning.

This is not the end-all of this effort, it's just a relatively easy
change that fixes some existing high latency delays. There should be
provision for standardising timeouts and/or interruptible loops where
possible, so non-fatal firmware errors don't cause hangs.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/opal.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 7159e1a6a61a..03e1a920491e 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -21,6 +21,9 @@
 /* We calculate number of sg entries based on PAGE_SIZE */
 #define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry))
 
+/* Default time to sleep or delay between OPAL_BUSY/OPAL_BUSY_EVENT loops */
+#define OPAL_BUSY_DELAY_MS	10
+
 /* /sys/firmware/opal */
 extern struct kobject *opal_kobj;
 
-- 
2.17.0

^ permalink raw reply related

* [PATCH v2 2/9] powerpc/powernv: OPAL RTC driver standardise OPAL_BUSY loops
From: Nicholas Piggin @ 2018-04-09  5:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, linux-rtc
In-Reply-To: <20180409052431.26405-1-npiggin@gmail.com>

Convert to using the standard delay poll/delay form.

The OPAL RTC driver:

- Did not previously delay or sleep in the OPAL_BUSY_EVENT case.
  There have been scheduling delays of up to 50 seconds observed here
  (BMC reboot can do it), which this should fix.

Cc: linux-rtc@vger.kernel.org
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/platforms/powernv/opal-rtc.c |  6 +++--
 drivers/rtc/rtc-opal.c                    | 33 ++++++++++++++---------
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c b/arch/powerpc/platforms/powernv/opal-rtc.c
index f8868864f373..f530cf62594d 100644
--- a/arch/powerpc/platforms/powernv/opal-rtc.c
+++ b/arch/powerpc/platforms/powernv/opal-rtc.c
@@ -48,10 +48,12 @@ unsigned long __init opal_get_boot_time(void)
 
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			mdelay(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (rc == OPAL_BUSY)
+		} else if (rc == OPAL_BUSY) {
 			mdelay(10);
+		}
 	}
 	if (rc != OPAL_SUCCESS)
 		return 0;
diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c
index 304e891e35fc..cddcc4749d39 100644
--- a/drivers/rtc/rtc-opal.c
+++ b/drivers/rtc/rtc-opal.c
@@ -57,7 +57,7 @@ static void tm_to_opal(struct rtc_time *tm, u32 *y_m_d, u64 *h_m_s_ms)
 
 static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
 {
-	long rc = OPAL_BUSY;
+	s64 rc = OPAL_BUSY;
 	int retries = 10;
 	u32 y_m_d;
 	u64 h_m_s_ms;
@@ -66,13 +66,17 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
 
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			msleep(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (retries-- && (rc == OPAL_HARDWARE
-				       || rc == OPAL_INTERNAL_ERROR))
+		} else if (rc == OPAL_BUSY) {
 			msleep(10);
-		else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
-			break;
+		} else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
+			if (retries--) {
+				msleep(10); /* Wait 10ms before retry */
+				rc = OPAL_BUSY; /* go around again */
+			}
+		}
 	}
 
 	if (rc != OPAL_SUCCESS)
@@ -87,21 +91,26 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
 
 static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
 {
-	long rc = OPAL_BUSY;
+	s64 rc = OPAL_BUSY;
 	int retries = 10;
 	u32 y_m_d = 0;
 	u64 h_m_s_ms = 0;
 
 	tm_to_opal(tm, &y_m_d, &h_m_s_ms);
+
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_write(y_m_d, h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			msleep(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (retries-- && (rc == OPAL_HARDWARE
-				       || rc == OPAL_INTERNAL_ERROR))
+		} else if (rc == OPAL_BUSY) {
 			msleep(10);
-		else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
-			break;
+		} else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
+			if (retries--) {
+				msleep(10); /* Wait 10ms before retry */
+				rc = OPAL_BUSY; /* go around again */
+			}
+		}
 	}
 
 	return rc == OPAL_SUCCESS ? 0 : -EIO;
-- 
2.17.0

^ permalink raw reply related

* [PATCH v2 3/9] powerpc/powernv: opal_put_chars partial write fix
From: Nicholas Piggin @ 2018-04-09  5:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Benjamin Herrenschmidt
In-Reply-To: <20180409052431.26405-1-npiggin@gmail.com>

The intention here is to consume and discard the remaining buffer
upon error. This works if there has not been a previous partial write.
If there has been, then total_len is no longer total number of bytes
to copy. total_len is always "bytes left to copy", so it should be
added to written bytes.

This code may not be exercised any more if partial writes will not be
hit, but this is a small bugfix before a larger change.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/platforms/powernv/opal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 516e23de5a3d..87d4c0aa7f64 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -388,7 +388,7 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
 		/* Closed or other error drop */
 		if (rc != OPAL_SUCCESS && rc != OPAL_BUSY &&
 		    rc != OPAL_BUSY_EVENT) {
-			written = total_len;
+			written += total_len;
 			break;
 		}
 		if (rc == OPAL_SUCCESS) {
-- 
2.17.0

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox