All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix for compat mode in P9 < 2.2
@ 2021-05-05  0:11 Fabiano Rosas
  2021-05-05  0:11 ` [PATCH 1/2] hw/ppc/spapr.c: Extract MMU mode error reporting into a function Fabiano Rosas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Fabiano Rosas @ 2021-05-05  0:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david

We dropped support in KVM for mixing MMU modes in machines that have
old POWER9 processors which don't support mixing. As usual I forgot
that compat mode exists:

  $ lscpu | grep pvr
  Model:               2.1 (pvr 004e 1201)

  $ ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
  error: kvm run failed Invalid argument
  NIP 0000000000000100   LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#0
  MSR 8000000000001000 HID0 0000000000000000  HF 8000000000000000 iidx 3 didx 3
  TB 00000000 00000000 DECR 0
  GPR00 0000000000000000 0000000000000000 0000000000000000 000000007ff00000
  GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  CR 00000000  [ -  -  -  -  -  -  -  -  ]             RES ffffffffffffffff
   SRR0 0000000000000000  SRR1 0000000000000000    PVR 00000000004e1201 VRSAVE 0000000000000000
  SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
  SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
  HSRR0 0000000000000000 HSRR1 0000000000000000
   CFAR 0000000000000000
   LPCR 000000000004f01f
   PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000

This series reuses some code we already have to abort and print a
proper message if the chosen MMU mode is not supported by the host.

Fabiano Rosas (2):
  hw/ppc/spapr.c: Extract MMU mode error reporting into a function
  hw/ppc/spapr.c: Make sure the host supports the selected MMU mode

 hw/ppc/spapr.c         | 17 +++++++++++++++++
 hw/ppc/spapr_hcall.c   | 14 ++------------
 include/hw/ppc/spapr.h |  1 +
 3 files changed, 20 insertions(+), 12 deletions(-)

--
2.29.2


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

* [PATCH 1/2] hw/ppc/spapr.c: Extract MMU mode error reporting into a function
  2021-05-05  0:11 [PATCH 0/2] Fix for compat mode in P9 < 2.2 Fabiano Rosas
@ 2021-05-05  0:11 ` Fabiano Rosas
  2021-05-05  0:11 ` [PATCH 2/2] hw/ppc/spapr.c: Make sure the host supports the selected MMU mode Fabiano Rosas
  2021-05-05  3:29 ` [PATCH 0/2] Fix for compat mode in P9 < 2.2 David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: Fabiano Rosas @ 2021-05-05  0:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david

A following patch will make use of it.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
 hw/ppc/spapr.c         | 16 ++++++++++++++++
 hw/ppc/spapr_hcall.c   | 14 ++------------
 include/hw/ppc/spapr.h |  1 +
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 529ff056dd..4fd226b15b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1558,6 +1558,22 @@ void spapr_setup_hpt(SpaprMachineState *spapr)
     }
 }
 
+void spapr_check_mmu_mode(bool guest_radix)
+{
+    if (guest_radix) {
+        if (kvm_enabled() && !kvmppc_has_cap_mmu_radix()) {
+            error_report("Guest requested unavailable MMU mode (radix).");
+            exit(EXIT_FAILURE);
+        }
+    } else {
+        if (kvm_enabled() && kvmppc_has_cap_mmu_radix()
+            && !kvmppc_has_cap_mmu_hash_v3()) {
+            error_report("Guest requested unavailable MMU mode (hash).");
+            exit(EXIT_FAILURE);
+        }
+    }
+}
+
 static void spapr_machine_reset(MachineState *machine)
 {
     SpaprMachineState *spapr = SPAPR_MACHINE(machine);
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 7b5cd3553c..32b7100125 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1755,18 +1755,8 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
     spapr_ovec_intersect(spapr->ov5_cas, spapr->ov5, ov5_guest);
     spapr_ovec_cleanup(ov5_guest);
 
-    if (guest_radix) {
-        if (kvm_enabled() && !kvmppc_has_cap_mmu_radix()) {
-            error_report("Guest requested unavailable MMU mode (radix).");
-            exit(EXIT_FAILURE);
-        }
-    } else {
-        if (kvm_enabled() && kvmppc_has_cap_mmu_radix()
-            && !kvmppc_has_cap_mmu_hash_v3()) {
-            error_report("Guest requested unavailable MMU mode (hash).");
-            exit(EXIT_FAILURE);
-        }
-    }
+    spapr_check_mmu_mode(guest_radix);
+
     spapr->cas_pre_isa3_guest = !spapr_ovec_test(ov1_guest, OV1_PPC_3_00);
     spapr_ovec_cleanup(ov1_guest);
 
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index bf7cab7a2c..52b68b2d92 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -820,6 +820,7 @@ void spapr_dt_events(SpaprMachineState *sm, void *fdt);
 void close_htab_fd(SpaprMachineState *spapr);
 void spapr_setup_hpt(SpaprMachineState *spapr);
 void spapr_free_hpt(SpaprMachineState *spapr);
+void spapr_check_mmu_mode(bool guest_radix);
 SpaprTceTable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn);
 void spapr_tce_table_enable(SpaprTceTable *tcet,
                             uint32_t page_shift, uint64_t bus_offset,
-- 
2.29.2



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

* [PATCH 2/2] hw/ppc/spapr.c: Make sure the host supports the selected MMU mode
  2021-05-05  0:11 [PATCH 0/2] Fix for compat mode in P9 < 2.2 Fabiano Rosas
  2021-05-05  0:11 ` [PATCH 1/2] hw/ppc/spapr.c: Extract MMU mode error reporting into a function Fabiano Rosas
@ 2021-05-05  0:11 ` Fabiano Rosas
  2021-05-05  3:29 ` [PATCH 0/2] Fix for compat mode in P9 < 2.2 David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: Fabiano Rosas @ 2021-05-05  0:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, david

Starting with Linux kernel v5.12 we dropped support[1] in KVM for
hosts that can't have their threads running in different MMU modes
(POWER9 < DD2.2). In these hosts, KVM will no longer report the
KVM_CAP_PPC_MMU_HASH_V3 capability[2] when the host is running Radix.

For guests that support both MMU modes, the negotiation during CAS
will make sure it selects the correct one.

For guests that only support Hash, such as P8 compat mode guests, the
following error is currently thrown:

  $ ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
  error: kvm run failed Invalid argument
  NIP 0000000000000100   LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#0
  MSR 8000000000001000 HID0 0000000000000000  HF 8000000000000000 iidx 3 didx 3
  TB 00000000 00000000 DECR 0
  GPR00 0000000000000000 0000000000000000 0000000000000000 000000007ff00000
  GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  CR 00000000  [ -  -  -  -  -  -  -  -  ]             RES ffffffffffffffff
   SRR0 0000000000000000  SRR1 0000000000000000    PVR 00000000004e1201 VRSAVE 0000000000000000
  SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
  SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
  HSRR0 0000000000000000 HSRR1 0000000000000000
   CFAR 0000000000000000
   LPCR 000000000004f01f
   PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000

This patch adds a verification during the writing of the platform
support vector so that we error out as soon as we determine this guest
only supports Hash and the host doesn't.

  ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
  qemu-system-ppc64: Guest requested unavailable MMU mode (hash).

1- https://git.kernel.org/torvalds/p/b1b1697ae0cc8
2- https://git.kernel.org/torvalds/p/a722076e94702

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
---
 hw/ppc/spapr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4fd226b15b..69201399eb 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -981,6 +981,7 @@ static void spapr_dt_ov5_platform_support(SpaprMachineState *spapr, void *fdt,
          */
         val[1] = SPAPR_OV5_XIVE_LEGACY; /* XICS */
         val[3] = 0x00; /* Hash */
+        spapr_check_mmu_mode(false);
     } else if (kvm_enabled()) {
         if (kvmppc_has_cap_mmu_radix() && kvmppc_has_cap_mmu_hash_v3()) {
             val[3] = 0x80; /* OV5_MMU_BOTH */
-- 
2.29.2



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

* Re: [PATCH 0/2] Fix for compat mode in P9 < 2.2
  2021-05-05  0:11 [PATCH 0/2] Fix for compat mode in P9 < 2.2 Fabiano Rosas
  2021-05-05  0:11 ` [PATCH 1/2] hw/ppc/spapr.c: Extract MMU mode error reporting into a function Fabiano Rosas
  2021-05-05  0:11 ` [PATCH 2/2] hw/ppc/spapr.c: Make sure the host supports the selected MMU mode Fabiano Rosas
@ 2021-05-05  3:29 ` David Gibson
  2 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2021-05-05  3:29 UTC (permalink / raw)
  To: Fabiano Rosas; +Cc: qemu-ppc, qemu-devel

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

On Tue, May 04, 2021 at 09:11:28PM -0300, Fabiano Rosas wrote:
> We dropped support in KVM for mixing MMU modes in machines that have
> old POWER9 processors which don't support mixing. As usual I forgot
> that compat mode exists:
> 
>   $ lscpu | grep pvr
>   Model:               2.1 (pvr 004e 1201)
> 
>   $ ~/qemu-system-ppc64 -machine pseries,accel=kvm,max-cpu-compat=power8 ...
>   error: kvm run failed Invalid argument
>   NIP 0000000000000100   LR 0000000000000000 CTR 0000000000000000 XER 0000000000000000 CPU#0
>   MSR 8000000000001000 HID0 0000000000000000  HF 8000000000000000 iidx 3 didx 3
>   TB 00000000 00000000 DECR 0
>   GPR00 0000000000000000 0000000000000000 0000000000000000 000000007ff00000
>   GPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>   CR 00000000  [ -  -  -  -  -  -  -  -  ]             RES ffffffffffffffff
>    SRR0 0000000000000000  SRR1 0000000000000000    PVR 00000000004e1201 VRSAVE 0000000000000000
>   SPRG0 0000000000000000 SPRG1 0000000000000000  SPRG2 0000000000000000  SPRG3 0000000000000000
>   SPRG4 0000000000000000 SPRG5 0000000000000000  SPRG6 0000000000000000  SPRG7 0000000000000000
>   HSRR0 0000000000000000 HSRR1 0000000000000000
>    CFAR 0000000000000000
>    LPCR 000000000004f01f
>    PTCR 0000000000000000   DAR 0000000000000000  DSISR 0000000000000000
> 
> This series reuses some code we already have to abort and print a
> proper message if the chosen MMU mode is not supported by the host.

Applied to ppc-for-6.1, thanks.

> 
> Fabiano Rosas (2):
>   hw/ppc/spapr.c: Extract MMU mode error reporting into a function
>   hw/ppc/spapr.c: Make sure the host supports the selected MMU mode
> 
>  hw/ppc/spapr.c         | 17 +++++++++++++++++
>  hw/ppc/spapr_hcall.c   | 14 ++------------
>  include/hw/ppc/spapr.h |  1 +
>  3 files changed, 20 insertions(+), 12 deletions(-)
> 

-- 
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] 4+ messages in thread

end of thread, other threads:[~2021-05-05  4:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05  0:11 [PATCH 0/2] Fix for compat mode in P9 < 2.2 Fabiano Rosas
2021-05-05  0:11 ` [PATCH 1/2] hw/ppc/spapr.c: Extract MMU mode error reporting into a function Fabiano Rosas
2021-05-05  0:11 ` [PATCH 2/2] hw/ppc/spapr.c: Make sure the host supports the selected MMU mode Fabiano Rosas
2021-05-05  3:29 ` [PATCH 0/2] Fix for compat mode in P9 < 2.2 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.