|
|
9bac43 |
From 61cace627e7140a63e27c7b1f949fc3b44ec120c Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: Serhii Popovych <spopovyc@redhat.com>
|
|
|
9bac43 |
Date: Wed, 22 Nov 2017 13:35:31 +0100
|
|
|
9bac43 |
Subject: [PATCH 1/7] spapr: Correct RAM size calculation for HPT resizing
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: Serhii Popovych <spopovyc@redhat.com>
|
|
|
9bac43 |
Message-id: <1511357731-4779-1-git-send-email-spopovyc@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77778
|
|
|
9bac43 |
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH v2] spapr: Correct RAM size calculation for HPT resizing
|
|
|
9bac43 |
Bugzilla: 1499647
|
|
|
9bac43 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: David Gibson <david@gibson.dropbear.id.au>
|
|
|
9bac43 |
|
|
|
9bac43 |
The only thing making this change distinct from one in
|
|
|
9bac43 |
upstream is get_plugged_memory_size() function which
|
|
|
9bac43 |
isn't present in 2.10.x branch and it is a part of new
|
|
|
9bac43 |
QMP interface command which we do not want to introduce
|
|
|
9bac43 |
in downstream.
|
|
|
9bac43 |
|
|
|
9bac43 |
So assuming that we replace get_plugged_memory_size()
|
|
|
9bac43 |
with direct call to pc_existing_dimms_capacity().
|
|
|
9bac43 |
|
|
|
9bac43 |
commit db50f280cf5f714e64ff2b134aae138908f07502
|
|
|
9bac43 |
Author: David Gibson <david@gibson.dropbear.id.au>
|
|
|
9bac43 |
Date: Wed Oct 11 00:16:57 2017 +1100
|
|
|
9bac43 |
|
|
|
9bac43 |
spapr: Correct RAM size calculation for HPT resizing
|
|
|
9bac43 |
|
|
|
9bac43 |
In order to prevent the guest from forcing the allocation of large amounts
|
|
|
9bac43 |
of qemu memory (or host kernel memory, in the case of KVM HV), we limit
|
|
|
9bac43 |
the size of Hashed Page Table (HPT) it is allowed to allocated, based on
|
|
|
9bac43 |
its RAM size.
|
|
|
9bac43 |
|
|
|
9bac43 |
However, the current calculation is not correct: it only adds up the size
|
|
|
9bac43 |
of plugged memory, ignoring the base memory size. This patch corrects it.
|
|
|
9bac43 |
|
|
|
9bac43 |
While we're there, use get_plugged_memory_size() instead of directly
|
|
|
9bac43 |
calling pc_existing_dimms_capacity(). The only difference is that it
|
|
|
9bac43 |
will abort on failure, which is right: a failure here indicates something
|
|
|
9bac43 |
wrong within qemu.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
9bac43 |
Reviewed-by: Greg Kurz <groug@kaod.org>
|
|
|
9bac43 |
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Serhii Popovych <spopovyc@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
hw/ppc/spapr_hcall.c | 5 +++--
|
|
|
9bac43 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
|
|
|
9bac43 |
index b503299..217358d 100644
|
|
|
9bac43 |
--- a/hw/ppc/spapr_hcall.c
|
|
|
9bac43 |
+++ b/hw/ppc/spapr_hcall.c
|
|
|
9bac43 |
@@ -472,7 +472,7 @@ static target_ulong h_resize_hpt_prepare(PowerPCCPU *cpu,
|
|
|
9bac43 |
target_ulong flags = args[0];
|
|
|
9bac43 |
int shift = args[1];
|
|
|
9bac43 |
sPAPRPendingHPT *pending = spapr->pending_hpt;
|
|
|
9bac43 |
- uint64_t current_ram_size = MACHINE(spapr)->ram_size;
|
|
|
9bac43 |
+ uint64_t current_ram_size;
|
|
|
9bac43 |
int rc;
|
|
|
9bac43 |
|
|
|
9bac43 |
if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) {
|
|
|
9bac43 |
@@ -494,7 +494,8 @@ static target_ulong h_resize_hpt_prepare(PowerPCCPU *cpu,
|
|
|
9bac43 |
return H_PARAMETER;
|
|
|
9bac43 |
}
|
|
|
9bac43 |
|
|
|
9bac43 |
- current_ram_size = pc_existing_dimms_capacity(&error_fatal);
|
|
|
9bac43 |
+ current_ram_size = MACHINE(spapr)->ram_size +
|
|
|
9bac43 |
+ pc_existing_dimms_capacity(&error_fatal);
|
|
|
9bac43 |
|
|
|
9bac43 |
/* We only allow the guest to allocate an HPT one order above what
|
|
|
9bac43 |
* we'd normally give them (to stop a small guest claiming a huge
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|