Blame SOURCES/kvm-BZ1513294-spapr-Include-pre-plugged-DIMMS-in-ram-siz.patch

4a2fec
From 35dcc0b1cf6cf7e031f5e4f9bfd3eab9e98044dc Mon Sep 17 00:00:00 2001
4a2fec
From: David Gibson <dgibson@redhat.com>
4a2fec
Date: Tue, 5 Dec 2017 04:18:21 +0100
4a2fec
Subject: [PATCH 15/21] BZ1513294: spapr: Include "pre-plugged" DIMMS in ram
4a2fec
 size calculation at reset
4a2fec
4a2fec
RH-Author: David Gibson <dgibson@redhat.com>
4a2fec
Message-id: <20171205041821.28985-1-dgibson@redhat.com>
4a2fec
Patchwork-id: 78132
4a2fec
O-Subject: [RHL-7.5 qemu-kvm-rhev PATCH] BZ1513294: spapr: Include "pre-plugged" DIMMS in ram size calculation at reset
4a2fec
Bugzilla: 1513294
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
4a2fec
4a2fec
From: David Gibson <david@gibson.dropbear.id.au>
4a2fec
4a2fec
At guest reset time, we allocate a hash page table (HPT) for the guest
4a2fec
based on the guest's RAM size.  If dynamic HPT resizing is not available we
4a2fec
use the maximum RAM size, if it is we use the current RAM size.
4a2fec
4a2fec
But the "current RAM size" calculation is incorrect - we just use the
4a2fec
"base" ram_size from the machine structure.  This doesn't include any
4a2fec
pluggable DIMMs that are already plugged at reset time.
4a2fec
4a2fec
This means that if you try to start a 'pseries' machine with a DIMM
4a2fec
specified on the command line that's much larger than the "base" RAM size,
4a2fec
then the guest will get a woefully inadequate HPT.  This can lead to a
4a2fec
guest freeze during boot as it runs out of HPT space during initial MMU
4a2fec
setup.
4a2fec
4a2fec
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
4a2fec
Reviewed-by: Greg Kurz <groug@kaod.org>
4a2fec
Tested-by: Greg Kurz <groug@kaod.org>
4a2fec
(cherry picked from commit 768a20f3a491ed4afce73ebb65347d55251c0ebd)
4a2fec
4a2fec
Slightly modified logic downstream because we don't have the
4a2fec
get_plugged_memory_size() helper.
4a2fec
4a2fec
Signed-off-by: David Gibson <dgibson@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 hw/ppc/spapr.c | 6 +++++-
4a2fec
 1 file changed, 5 insertions(+), 1 deletion(-)
4a2fec
4a2fec
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
4a2fec
index e3dce84..af7a3bb 100644
4a2fec
--- a/hw/ppc/spapr.c
4a2fec
+++ b/hw/ppc/spapr.c
4a2fec
@@ -1369,7 +1369,11 @@ void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr)
4a2fec
             && !spapr_ovec_test(spapr->ov5_cas, OV5_HPT_RESIZE))) {
4a2fec
         hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->maxram_size);
4a2fec
     } else {
4a2fec
-        hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->ram_size);
4a2fec
+        uint64_t current_ram_size;
4a2fec
+
4a2fec
+        current_ram_size = MACHINE(spapr)->ram_size +
4a2fec
+            pc_existing_dimms_capacity(&error_fatal);
4a2fec
+        hpt_shift = spapr_hpt_shift_for_ramsize(current_ram_size);
4a2fec
     }
4a2fec
     spapr_reallocate_hpt(spapr, hpt_shift, &error_fatal);
4a2fec
 
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec