|
|
d740ea |
From 53c0d0dcad838ef8b9b0faf0c8066d47380f2cf1 Mon Sep 17 00:00:00 2001
|
|
|
d740ea |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
d740ea |
Date: Thu, 13 Dec 2018 21:55:04 +0100
|
|
|
d740ea |
Subject: [PATCH 3/5] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
|
|
|
d740ea |
|
|
|
d740ea |
RH-Author: Alex Williamson <alex.williamson@redhat.com>
|
|
|
d740ea |
Message-id: <154473810399.22725.17809569801460658619.stgit@gimli.home>
|
|
|
d740ea |
Patchwork-id: 83495
|
|
|
d740ea |
O-Subject: [RHEL-7.7 qemu-kvm PATCH 3/5] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
|
|
|
d740ea |
Bugzilla: 1659229
|
|
|
d740ea |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
d740ea |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
d740ea |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
d740ea |
|
|
|
d740ea |
From: Greg Kurz <groug@kaod.org>
|
|
|
d740ea |
|
|
|
d740ea |
Bugzilla: 1659229
|
|
|
d740ea |
Notes: We don't have kvm_vm_check_extension() but we can still
|
|
|
d740ea |
cache the result, which gives us the same hook to trigger
|
|
|
d740ea |
the balloon inhibitor here.
|
|
|
d740ea |
|
|
|
d740ea |
On a server-class ppc host, this capability depends on the KVM type,
|
|
|
d740ea |
ie, HV or PR. If both KVM are present in the kernel, we will always
|
|
|
d740ea |
get the HV specific value, even if we explicitely requested PR on
|
|
|
d740ea |
the command line.
|
|
|
d740ea |
|
|
|
d740ea |
This can have an impact if we're using hugepages or a balloon device.
|
|
|
d740ea |
|
|
|
d740ea |
Since we've already created the VM at the time any user calls
|
|
|
d740ea |
kvm_has_sync_mmu(), switching to kvm_vm_check_extension() is
|
|
|
d740ea |
enough to fix any potential issue.
|
|
|
d740ea |
|
|
|
d740ea |
It is okay for the other archs that also implement KVM_CAP_SYNC_MMU,
|
|
|
d740ea |
ie, mips, s390, x86 and arm, because they don't depend on the VM being
|
|
|
d740ea |
created or not.
|
|
|
d740ea |
|
|
|
d740ea |
While here, let's cache the state of this extension in a bool variable,
|
|
|
d740ea |
since it has several users in the code, as suggested by Thomas Huth.
|
|
|
d740ea |
|
|
|
d740ea |
Signed-off-by: Greg Kurz <groug@kaod.org>
|
|
|
d740ea |
Message-Id: <150600965332.30533.14702405809647835716.stgit@bahia.lan>
|
|
|
d740ea |
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
d740ea |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
d740ea |
(cherry picked from commit 62dd4edaaf859b60f74a51f2a526d4d3d85d0248)
|
|
|
d740ea |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
d740ea |
---
|
|
|
d740ea |
include/sysemu/kvm.h | 2 +-
|
|
|
d740ea |
kvm-all.c | 7 +++++--
|
|
|
d740ea |
kvm-stub.c | 4 ++--
|
|
|
d740ea |
3 files changed, 8 insertions(+), 5 deletions(-)
|
|
|
d740ea |
|
|
|
d740ea |
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
|
|
|
d740ea |
index 49cfc42..e4403be 100644
|
|
|
d740ea |
--- a/include/sysemu/kvm.h
|
|
|
d740ea |
+++ b/include/sysemu/kvm.h
|
|
|
d740ea |
@@ -135,7 +135,7 @@ extern KVMState *kvm_state;
|
|
|
d740ea |
|
|
|
d740ea |
int kvm_init(void);
|
|
|
d740ea |
|
|
|
d740ea |
-int kvm_has_sync_mmu(void);
|
|
|
d740ea |
+bool kvm_has_sync_mmu(void);
|
|
|
d740ea |
int kvm_has_vcpu_events(void);
|
|
|
d740ea |
int kvm_has_robust_singlestep(void);
|
|
|
d740ea |
int kvm_has_debugregs(void);
|
|
|
d740ea |
diff --git a/kvm-all.c b/kvm-all.c
|
|
|
d740ea |
index 9486b9a..f5b7958 100644
|
|
|
d740ea |
--- a/kvm-all.c
|
|
|
d740ea |
+++ b/kvm-all.c
|
|
|
d740ea |
@@ -92,6 +92,7 @@ struct KVMState
|
|
|
d740ea |
int xsave, xcrs;
|
|
|
d740ea |
int many_ioeventfds;
|
|
|
d740ea |
int intx_set_mask;
|
|
|
d740ea |
+ bool sync_mmu;
|
|
|
d740ea |
/* The man page (and posix) say ioctl numbers are signed int, but
|
|
|
d740ea |
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
|
|
|
d740ea |
* unsigned, and treating them as signed here can break things */
|
|
|
d740ea |
@@ -1479,6 +1480,8 @@ int kvm_init(void)
|
|
|
d740ea |
|
|
|
d740ea |
cpu_interrupt_handler = kvm_handle_interrupt;
|
|
|
d740ea |
|
|
|
d740ea |
+ s->sync_mmu = !!kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
|
|
|
d740ea |
+
|
|
|
d740ea |
return 0;
|
|
|
d740ea |
|
|
|
d740ea |
err:
|
|
|
d740ea |
@@ -1775,9 +1778,9 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)
|
|
|
d740ea |
return ret;
|
|
|
d740ea |
}
|
|
|
d740ea |
|
|
|
d740ea |
-int kvm_has_sync_mmu(void)
|
|
|
d740ea |
+bool kvm_has_sync_mmu(void)
|
|
|
d740ea |
{
|
|
|
d740ea |
- return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
|
|
|
d740ea |
+ return kvm_state->sync_mmu;
|
|
|
d740ea |
}
|
|
|
d740ea |
|
|
|
d740ea |
int kvm_has_vcpu_events(void)
|
|
|
d740ea |
diff --git a/kvm-stub.c b/kvm-stub.c
|
|
|
d740ea |
index 22eaff0..ca6ddd7 100644
|
|
|
d740ea |
--- a/kvm-stub.c
|
|
|
d740ea |
+++ b/kvm-stub.c
|
|
|
d740ea |
@@ -59,9 +59,9 @@ int kvm_cpu_exec(CPUArchState *env)
|
|
|
d740ea |
abort ();
|
|
|
d740ea |
}
|
|
|
d740ea |
|
|
|
d740ea |
-int kvm_has_sync_mmu(void)
|
|
|
d740ea |
+bool kvm_has_sync_mmu(void)
|
|
|
d740ea |
{
|
|
|
d740ea |
- return 0;
|
|
|
d740ea |
+ return false;
|
|
|
d740ea |
}
|
|
|
d740ea |
|
|
|
d740ea |
int kvm_has_many_ioeventfds(void)
|
|
|
d740ea |
--
|
|
|
d740ea |
1.8.3.1
|
|
|
d740ea |
|