All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spapr: propagate LPCR to hot-plugged CPUs
@ 2021-05-24 11:41 Cédric Le Goater
  2021-05-25 15:12 ` Greg Kurz
  2021-05-27  4:26 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Cédric Le Goater @ 2021-05-24 11:41 UTC (permalink / raw)
  To: David Gibson, Greg Kurz, Nicholas Piggin
  Cc: qemu-ppc, qemu-devel, Cédric Le Goater

Distros have started using the 'scv' instructions (glibc 2.33) which
relies on the LPCR AIL bits. Unfortunately, the LPCR of hot-plugged
CPUs is not synchronized with the rest of machine and it breaks the
guest OS.

Fix that by using the first CPU to set the LPCR value of all hot-plugged
CPUs.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/spapr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index c23bcc449071..e463c2570c7a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3890,6 +3890,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
         for (i = 0; i < cc->nr_threads; i++) {
             ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr,
                            &error_abort);
+            ppc_store_lpcr(core->threads[i],
+                           POWERPC_CPU(first_cpu)->env.spr[SPR_LPCR]);
         }
     }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spapr: propagate LPCR to hot-plugged CPUs
  2021-05-24 11:41 [PATCH] spapr: propagate LPCR to hot-plugged CPUs Cédric Le Goater
@ 2021-05-25 15:12 ` Greg Kurz
  2021-05-27  4:26 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kurz @ 2021-05-25 15:12 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, qemu-devel, Nicholas Piggin, David Gibson

On Mon, 24 May 2021 13:41:32 +0200
Cédric Le Goater <clg@kaod.org> wrote:

> Distros have started using the 'scv' instructions (glibc 2.33) which
> relies on the LPCR AIL bits. Unfortunately, the LPCR of hot-plugged
> CPUs is not synchronized with the rest of machine and it breaks the
> guest OS.
> 
> Fix that by using the first CPU to set the LPCR value of all hot-plugged
> CPUs.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---

LGTM

Reviewed-by: Greg Kurz <groug@kaod.org>

>  hw/ppc/spapr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index c23bcc449071..e463c2570c7a 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3890,6 +3890,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
>          for (i = 0; i < cc->nr_threads; i++) {
>              ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr,
>                             &error_abort);
> +            ppc_store_lpcr(core->threads[i],
> +                           POWERPC_CPU(first_cpu)->env.spr[SPR_LPCR]);
>          }
>      }
>  



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spapr: propagate LPCR to hot-plugged CPUs
  2021-05-24 11:41 [PATCH] spapr: propagate LPCR to hot-plugged CPUs Cédric Le Goater
  2021-05-25 15:12 ` Greg Kurz
@ 2021-05-27  4:26 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2021-05-27  4:26 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: qemu-ppc, Greg Kurz, Nicholas Piggin, qemu-devel

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

On Mon, May 24, 2021 at 01:41:32PM +0200, Cédric Le Goater wrote:
> Distros have started using the 'scv' instructions (glibc 2.33) which
> relies on the LPCR AIL bits. Unfortunately, the LPCR of hot-plugged
> CPUs is not synchronized with the rest of machine and it breaks the
> guest OS.
> 
> Fix that by using the first CPU to set the LPCR value of all hot-plugged
> CPUs.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

I'm assuming this is obsoleted by Nick Piggin's rework of LPCR
initialization.  This patch does fix a real bug, but it leaves LPCR
initialization a bit of a mess.

> ---
>  hw/ppc/spapr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index c23bcc449071..e463c2570c7a 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3890,6 +3890,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
>          for (i = 0; i < cc->nr_threads; i++) {
>              ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compat_pvr,
>                             &error_abort);
> +            ppc_store_lpcr(core->threads[i],
> +                           POWERPC_CPU(first_cpu)->env.spr[SPR_LPCR]);
>          }
>      }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-27  7:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 11:41 [PATCH] spapr: propagate LPCR to hot-plugged CPUs Cédric Le Goater
2021-05-25 15:12 ` Greg Kurz
2021-05-27  4:26 ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.