All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] target/ppc: correct htab shift for hash on radix
@ 2017-11-06  3:14 Sam Bobroff
  2017-11-13  4:23 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Bobroff @ 2017-11-06  3:14 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc; +Cc: david

KVM HV will soon support running a guest in hash mode on a POWER9 host
running in radix mode (see [1]), however the guest currently fails to
boot.

This is because the "htab_shift" value (the size of the MMU's hash
table) is added to the device tree before KVM has had a chance to
change it. If the host is in hash mode, KVM does not need to change it
and so the problem is not seen, but when the host is in radix mode a
change is required and we see a problem.

To fix this, move the call spapr_setup_hpt_and_vrma() (where
htab_shift could be changed) up a little so that it's called before
spapr_h_cas_compose_response() (where htab_shift is added to the
device tree).

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>

[1] See http://www.spinics.net/lists/kvm-ppc/msg13057.html
---
I tested this patch using a kernel based on Paul's kvm-ppc-next branch from his
powerpc tree:
https://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/

 hw/ppc/spapr_hcall.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 0d59d1534d..be22a6b289 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1636,6 +1636,12 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
     spapr->cas_legacy_guest_workaround = !spapr_ovec_test(ov1_guest,
                                                           OV1_PPC_3_00);
     if (!spapr->cas_reboot) {
+        /* If ppc_spapr_reset() did not set up a HPT but one is necessary
+         * (because the guest isn't going to use radix) then set it up here. */
+        if ((spapr->patb_entry & PATBE1_GR) && !guest_radix) {
+            /* legacy hash or new hash: */
+            spapr_setup_hpt_and_vrma(spapr);
+        }
         spapr->cas_reboot =
             (spapr_h_cas_compose_response(spapr, args[1], args[2],
                                           ov5_updates) != 0);
@@ -1644,13 +1650,6 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
 
     if (spapr->cas_reboot) {
         qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
-    } else {
-        /* If ppc_spapr_reset() did not set up a HPT but one is necessary
-         * (because the guest isn't going to use radix) then set it up here. */
-        if ((spapr->patb_entry & PATBE1_GR) && !guest_radix) {
-            /* legacy hash or new hash: */
-            spapr_setup_hpt_and_vrma(spapr);
-        }
     }
 
     return H_SUCCESS;
-- 
2.14.1.4.g334a7be4f

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

* Re: [Qemu-devel] [PATCH 1/1] target/ppc: correct htab shift for hash on radix
  2017-11-06  3:14 [Qemu-devel] [PATCH 1/1] target/ppc: correct htab shift for hash on radix Sam Bobroff
@ 2017-11-13  4:23 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2017-11-13  4:23 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc

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

On Mon, Nov 06, 2017 at 02:14:35PM +1100, Sam Bobroff wrote:
> KVM HV will soon support running a guest in hash mode on a POWER9 host
> running in radix mode (see [1]), however the guest currently fails to
> boot.
> 
> This is because the "htab_shift" value (the size of the MMU's hash
> table) is added to the device tree before KVM has had a chance to
> change it. If the host is in hash mode, KVM does not need to change it
> and so the problem is not seen, but when the host is in radix mode a
> change is required and we see a problem.
> 
> To fix this, move the call spapr_setup_hpt_and_vrma() (where
> htab_shift could be changed) up a little so that it's called before
> spapr_h_cas_compose_response() (where htab_shift is added to the
> device tree).
> 
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>

Applied to ppc-for-2.11.

> 
> [1] See http://www.spinics.net/lists/kvm-ppc/msg13057.html
> ---
> I tested this patch using a kernel based on Paul's kvm-ppc-next branch from his
> powerpc tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc.git/
> 
>  hw/ppc/spapr_hcall.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 0d59d1534d..be22a6b289 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -1636,6 +1636,12 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
>      spapr->cas_legacy_guest_workaround = !spapr_ovec_test(ov1_guest,
>                                                            OV1_PPC_3_00);
>      if (!spapr->cas_reboot) {
> +        /* If ppc_spapr_reset() did not set up a HPT but one is necessary
> +         * (because the guest isn't going to use radix) then set it up here. */
> +        if ((spapr->patb_entry & PATBE1_GR) && !guest_radix) {
> +            /* legacy hash or new hash: */
> +            spapr_setup_hpt_and_vrma(spapr);
> +        }
>          spapr->cas_reboot =
>              (spapr_h_cas_compose_response(spapr, args[1], args[2],
>                                            ov5_updates) != 0);
> @@ -1644,13 +1650,6 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
>  
>      if (spapr->cas_reboot) {
>          qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
> -    } else {
> -        /* If ppc_spapr_reset() did not set up a HPT but one is necessary
> -         * (because the guest isn't going to use radix) then set it up here. */
> -        if ((spapr->patb_entry & PATBE1_GR) && !guest_radix) {
> -            /* legacy hash or new hash: */
> -            spapr_setup_hpt_and_vrma(spapr);
> -        }
>      }
>  
>      return H_SUCCESS;

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

end of thread, other threads:[~2017-11-13  4:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06  3:14 [Qemu-devel] [PATCH 1/1] target/ppc: correct htab shift for hash on radix Sam Bobroff
2017-11-13  4:23 ` 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.