From: Cornelia Huck <cohuck@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Alexander Graf <agraf@suse.de>,
Richard Henderson <rth@twiddle.net>,
David Hildenbrand <david@redhat.com>,
Thomas Huth <thuth@redhat.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Janosch Frank <frankja@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>
Subject: [Qemu-devel] [PULL 7/7] s390x: Enable KVM huge page backing support
Date: Mon, 20 Aug 2018 14:53:41 +0200 [thread overview]
Message-ID: <20180820125341.5882-8-cohuck@redhat.com> (raw)
In-Reply-To: <20180820125341.5882-1-cohuck@redhat.com>
From: Janosch Frank <frankja@linux.ibm.com>
QEMU has had huge page support for a longer time already, but KVM
memory management under s390x needed some changes to work with huge
backings.
Now that we have support, let's enable it if requested and
available. Otherwise we now properly tell the user if there is no
support and back out instead of failing to run the VM later on.
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180802070201.257406-1-frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
target/s390x/kvm.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index af83955e5f..348e8cc546 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -34,6 +34,8 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
+#include "qemu/units.h"
+#include "qemu/mmap-alloc.h"
#include "sysemu/sysemu.h"
#include "sysemu/hw_accel.h"
#include "hw/hw.h"
@@ -139,6 +141,7 @@ static int cap_mem_op;
static int cap_s390_irq;
static int cap_ri;
static int cap_gs;
+static int cap_hpage_1m;
static int active_cmma;
@@ -220,9 +223,9 @@ static void kvm_s390_enable_cmma(void)
.attr = KVM_S390_VM_MEM_ENABLE_CMMA,
};
- if (mem_path) {
+ if (cap_hpage_1m) {
warn_report("CMM will not be enabled because it is not "
- "compatible with hugetlbfs.");
+ "compatible with huge memory backings.");
return;
}
rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
@@ -281,10 +284,38 @@ void kvm_s390_crypto_reset(void)
}
}
+static int kvm_s390_configure_mempath_backing(KVMState *s)
+{
+ size_t path_psize = qemu_mempath_getpagesize(mem_path);
+
+ if (path_psize == 4 * KiB) {
+ return 0;
+ }
+
+ if (path_psize != 1 * MiB) {
+ error_report("Memory backing with 2G pages was specified, "
+ "but KVM does not support this memory backing");
+ return -EINVAL;
+ }
+
+ if (kvm_vm_enable_cap(s, KVM_CAP_S390_HPAGE_1M, 0)) {
+ error_report("Memory backing with 1M pages was specified, "
+ "but KVM does not support this memory backing");
+ return -EINVAL;
+ }
+
+ cap_hpage_1m = 1;
+ return 0;
+}
+
int kvm_arch_init(MachineState *ms, KVMState *s)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
+ if (mem_path && kvm_s390_configure_mempath_backing(s)) {
+ return -EINVAL;
+ }
+
mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
--
2.14.4
next prev parent reply other threads:[~2018-08-20 12:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 12:53 [Qemu-devel] [PULL 0/7] s390x patches for 3.1 Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 1/7] s390x: introduce 3.1 compat machine Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 2/7] s390x/cpumodel: enum type S390FeatGroup now gets generated Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 3/7] s390x: remove 's390-squash-mcss' option Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 4/7] s390x/cpumodel: Add "-cpu max" support Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 5/7] linux-headers: update Cornelia Huck
2018-08-20 12:53 ` [Qemu-devel] [PULL 6/7] s390x/kvm: add etoken facility Cornelia Huck
2018-08-20 12:53 ` Cornelia Huck [this message]
2018-08-20 17:18 ` [Qemu-devel] [PULL 0/7] s390x patches for 3.1 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180820125341.5882-8-cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).