cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 11f30b4e8f2e939fe2cb061e8ae70d77ef582b63 Mon Sep 17 00:00:00 2001
0a122b
From: Laszlo Ersek <lersek@redhat.com>
0a122b
Date: Sat, 11 Jan 2014 17:59:56 +0100
0a122b
Subject: [PATCH 06/22] kvm: add kvm_readonly_mem_enabled
0a122b
0a122b
RH-Author: Laszlo Ersek <lersek@redhat.com>
0a122b
Message-id: <1389463208-6278-7-git-send-email-lersek@redhat.com>
0a122b
Patchwork-id: 56620
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH 06/18] kvm: add kvm_readonly_mem_enabled
0a122b
Bugzilla: 1032346
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Andrew Jones <drjones@redhat.com>
0a122b
0a122b
From: Jordan Justen <jordan.l.justen@intel.com>
0a122b
0a122b
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
0a122b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: 1369816047-16384-3-git-send-email-jordan.l.justen@intel.com
0a122b
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
0a122b
(cherry picked from commit df9c8b758a04825e23f82427001028342b92d0cf)
0a122b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
0a122b
---
0a122b
 include/sysemu/kvm.h | 10 ++++++++++
0a122b
 kvm-all.c            |  6 ++++++
0a122b
 kvm-stub.c           |  1 +
0a122b
 3 files changed, 17 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 include/sysemu/kvm.h |   10 ++++++++++
0a122b
 kvm-all.c            |    6 ++++++
0a122b
 kvm-stub.c           |    1 +
0a122b
 3 files changed, 17 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
0a122b
index 7fc3844..e722027 100644
0a122b
--- a/include/sysemu/kvm.h
0a122b
+++ b/include/sysemu/kvm.h
0a122b
@@ -45,6 +45,7 @@ extern bool kvm_async_interrupts_allowed;
0a122b
 extern bool kvm_irqfds_allowed;
0a122b
 extern bool kvm_msi_via_irqfd_allowed;
0a122b
 extern bool kvm_gsi_routing_allowed;
0a122b
+extern bool kvm_readonly_mem_allowed;
0a122b
 
0a122b
 #if defined CONFIG_KVM || !defined NEED_CPU_H
0a122b
 #define kvm_enabled()           (kvm_allowed)
0a122b
@@ -97,6 +98,14 @@ extern bool kvm_gsi_routing_allowed;
0a122b
  */
0a122b
 #define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed)
0a122b
 
0a122b
+/**
0a122b
+ * kvm_readonly_mem_enabled:
0a122b
+ *
0a122b
+ * Returns: true if KVM readonly memory is enabled (ie the kernel
0a122b
+ * supports it and we're running in a configuration that permits it).
0a122b
+ */
0a122b
+#define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed)
0a122b
+
0a122b
 #else
0a122b
 #define kvm_enabled()           (0)
0a122b
 #define kvm_irqchip_in_kernel() (false)
0a122b
@@ -104,6 +113,7 @@ extern bool kvm_gsi_routing_allowed;
0a122b
 #define kvm_irqfds_enabled() (false)
0a122b
 #define kvm_msi_via_irqfd_enabled() (false)
0a122b
 #define kvm_gsi_routing_allowed() (false)
0a122b
+#define kvm_readonly_mem_enabled() (false)
0a122b
 #endif
0a122b
 
0a122b
 struct kvm_run;
0a122b
diff --git a/kvm-all.c b/kvm-all.c
0a122b
index 603bd4b..0a70ca1 100644
0a122b
--- a/kvm-all.c
0a122b
+++ b/kvm-all.c
0a122b
@@ -113,6 +113,7 @@ bool kvm_irqfds_allowed;
0a122b
 bool kvm_msi_via_irqfd_allowed;
0a122b
 bool kvm_gsi_routing_allowed;
0a122b
 bool kvm_allowed;
0a122b
+bool kvm_readonly_mem_allowed;
0a122b
 
0a122b
 static const KVMCapabilityInfo kvm_required_capabilites[] = {
0a122b
     KVM_CAP_INFO(USER_MEMORY),
0a122b
@@ -1435,6 +1436,11 @@ int kvm_init(void)
0a122b
         s->irq_set_ioctl = KVM_IRQ_LINE_STATUS;
0a122b
     }
0a122b
 
0a122b
+#ifdef KVM_CAP_READONLY_MEM
0a122b
+    kvm_readonly_mem_allowed =
0a122b
+        (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
0a122b
+#endif
0a122b
+
0a122b
     ret = kvm_arch_init(s);
0a122b
     if (ret < 0) {
0a122b
         goto err;
0a122b
diff --git a/kvm-stub.c b/kvm-stub.c
0a122b
index b2c8f9b..22eaff0 100644
0a122b
--- a/kvm-stub.c
0a122b
+++ b/kvm-stub.c
0a122b
@@ -26,6 +26,7 @@ bool kvm_irqfds_allowed;
0a122b
 bool kvm_msi_via_irqfd_allowed;
0a122b
 bool kvm_gsi_routing_allowed;
0a122b
 bool kvm_allowed;
0a122b
+bool kvm_readonly_mem_allowed;
0a122b
 
0a122b
 int kvm_init_vcpu(CPUState *cpu)
0a122b
 {
0a122b
-- 
0a122b
1.7.1
0a122b