From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>
Subject: [Qemu-devel] [PULL 4/6] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
Date: Tue, 3 Oct 2017 12:28:39 +0200 [thread overview]
Message-ID: <1507026521-19230-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1507026521-19230-1-git-send-email-pbonzini@redhat.com>
From: Greg Kurz <groug@kaod.org>
On a server-class ppc host, this capability depends on the KVM type,
ie, HV or PR. If both KVM are present in the kernel, we will always
get the HV specific value, even if we explicitely requested PR on
the command line.
This can have an impact if we're using hugepages or a balloon device.
Since we've already created the VM at the time any user calls
kvm_has_sync_mmu(), switching to kvm_vm_check_extension() is
enough to fix any potential issue.
It is okay for the other archs that also implement KVM_CAP_SYNC_MMU,
ie, mips, s390, x86 and arm, because they don't depend on the VM being
created or not.
While here, let's cache the state of this extension in a bool variable,
since it has several users in the code, as suggested by Thomas Huth.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <150600965332.30533.14702405809647835716.stgit@bahia.lan>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
accel/kvm/kvm-all.c | 8 +++++---
accel/stubs/kvm-stub.c | 4 ++--
include/sysemu/kvm.h | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4f1997d..f54a337 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -87,6 +87,7 @@ struct KVMState
#endif
int many_ioeventfds;
int intx_set_mask;
+ bool sync_mmu;
/* The man page (and posix) say ioctl numbers are signed int, but
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
* unsigned, and treating them as signed here can break things */
@@ -1664,6 +1665,8 @@ static int kvm_init(MachineState *ms)
s->many_ioeventfds = kvm_check_many_ioeventfds();
+ s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
+
return 0;
err:
@@ -2130,10 +2133,9 @@ int kvm_device_access(int fd, int group, uint64_t attr,
return err;
}
-/* Return 1 on success, 0 on failure */
-int kvm_has_sync_mmu(void)
+bool kvm_has_sync_mmu(void)
{
- return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
+ return kvm_state->sync_mmu;
}
int kvm_has_vcpu_events(void)
diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
index 3965c52..c964af3 100644
--- a/accel/stubs/kvm-stub.c
+++ b/accel/stubs/kvm-stub.c
@@ -64,9 +64,9 @@ int kvm_cpu_exec(CPUState *cpu)
abort();
}
-int kvm_has_sync_mmu(void)
+bool kvm_has_sync_mmu(void)
{
- return 0;
+ return false;
}
int kvm_has_many_ioeventfds(void)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 3a458f5..bbf12a1 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -207,7 +207,7 @@ extern KVMState *kvm_state;
/* external API */
bool kvm_has_free_slot(MachineState *ms);
-int kvm_has_sync_mmu(void);
+bool kvm_has_sync_mmu(void);
int kvm_has_vcpu_events(void);
int kvm_has_robust_singlestep(void);
int kvm_has_debugregs(void);
--
1.8.3.1
next prev parent reply other threads:[~2017-10-03 10:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 10:28 [Qemu-devel] [PULL 0/6] Misc patches for 2017-10-03 Paolo Bonzini
2017-10-03 10:28 ` [Qemu-devel] [PULL 1/6] scsi: Ignore executable for in-tree builds Paolo Bonzini
2017-10-03 10:28 ` [Qemu-devel] [PULL 2/6] iothread: Make iothread_stop() idempotent Paolo Bonzini
2017-10-03 10:28 ` [Qemu-devel] [PULL 3/6] linux-headers: sync against v4.14-rc1 Paolo Bonzini
2017-10-03 10:28 ` Paolo Bonzini [this message]
2017-10-03 10:28 ` [Qemu-devel] [PULL 5/6] kvm: check KVM_CAP_NR_VCPUS with kvm_vm_check_extension() Paolo Bonzini
2017-10-03 10:28 ` [Qemu-devel] [PULL 6/6] kvmclock: use the updated system_timer_msr Paolo Bonzini
2017-10-03 16:42 ` [Qemu-devel] [PULL 0/6] Misc patches for 2017-10-03 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=1507026521-19230-5-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/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).