diff mbox

[RFC,5/9] spapr: Only setup HTP if necessary.

Message ID f04bb6a57aa50c7c75762e3479252f2ee3fa385a.1486436186.git.sam.bobroff@au1.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sam Bobroff Feb. 7, 2017, 2:56 a.m. UTC
Because KVM cannot support radix and hash modes concurrently, QEMU can
avoid allocating a hash page table if KVM supports radix mode.

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
---
 hw/ppc/spapr.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

David Gibson Feb. 9, 2017, 2:24 a.m. UTC | #1
On Tue, Feb 07, 2017 at 01:56:48PM +1100, Sam Bobroff wrote:
> Because KVM cannot support radix and hash modes concurrently, QEMU can
> avoid allocating a hash page table if KVM supports radix mode.
> 
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>

This isn't quite right, it's doing the HPT handling based on whether
or not we *can* do RPT rather than whether we *are* doing RPT.

It'll mostly work for now, while only radix-on-radix and hash-on-hash
are supported, but that won't be true forever.

It will already be wrong if, for example, you tried to run a POWER8
TCG guest on a host that happened to be a POWER9 in radix mode.

> ---
>  hw/ppc/spapr.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index d629e2630c..1411e470c0 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1150,15 +1150,17 @@ static void ppc_spapr_reset(void)
>      /* Check for unknown sysbus devices */
>      foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
>  
> -    /* Allocate and/or reset the hash page table */
> -    spapr_reallocate_hpt(spapr,
> +    if (!kvmppc_has_cap_mmu_radix()) {
> +        /* Allocate and/or reset the hash page table */
> +        spapr_reallocate_hpt(spapr,
>                           spapr_hpt_shift_for_ramsize(machine->maxram_size),
>                           &error_fatal);
>  
> -    /* Update the RMA size if necessary */
> -    if (spapr->vrma_adjust) {
> -        spapr->rma_size = kvmppc_rma_size(spapr_node0_size(),
> -                                          spapr->htab_shift);
> +        /* Update the RMA size if necessary */
> +        if (spapr->vrma_adjust) {
> +            spapr->rma_size = kvmppc_rma_size(spapr_node0_size(),
> +                                              spapr->htab_shift);
> +        }
>      }
>  
>      qemu_devices_reset();
diff mbox

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d629e2630c..1411e470c0 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1150,15 +1150,17 @@  static void ppc_spapr_reset(void)
     /* Check for unknown sysbus devices */
     foreach_dynamic_sysbus_device(find_unknown_sysbus_device, NULL);
 
-    /* Allocate and/or reset the hash page table */
-    spapr_reallocate_hpt(spapr,
+    if (!kvmppc_has_cap_mmu_radix()) {
+        /* Allocate and/or reset the hash page table */
+        spapr_reallocate_hpt(spapr,
                          spapr_hpt_shift_for_ramsize(machine->maxram_size),
                          &error_fatal);
 
-    /* Update the RMA size if necessary */
-    if (spapr->vrma_adjust) {
-        spapr->rma_size = kvmppc_rma_size(spapr_node0_size(),
-                                          spapr->htab_shift);
+        /* Update the RMA size if necessary */
+        if (spapr->vrma_adjust) {
+            spapr->rma_size = kvmppc_rma_size(spapr_node0_size(),
+                                              spapr->htab_shift);
+        }
     }
 
     qemu_devices_reset();