changeset 0c0506575409 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=0c0506575409
description:
        kvm, x86: Guard x86-specific APIs in KvmVM

        Protect x86-specific APIs in KvmVM with compile-time guards to avoid
        breaking ARM builds.

diffstat:

 src/cpu/kvm/vm.cc |  13 +++++--------
 src/cpu/kvm/vm.hh |  30 +++++++++++++++++++++---------
 2 files changed, 26 insertions(+), 17 deletions(-)

diffs (115 lines):

diff -r 38af38f1f307 -r 0c0506575409 src/cpu/kvm/vm.cc
--- a/src/cpu/kvm/vm.cc Sat May 23 13:37:18 2015 +0100
+++ b/src/cpu/kvm/vm.cc Sat May 23 13:37:20 2015 +0100
@@ -191,10 +191,11 @@
 #endif
 }
 
+
+#if defined(__i386__) || defined(__x86_64__)
 bool
 Kvm::getSupportedCPUID(struct kvm_cpuid2 &cpuid) const
 {
-#if defined(__i386__) || defined(__x86_64__)
     if (ioctl(KVM_GET_SUPPORTED_CPUID, (void *)&cpuid) == -1) {
         if (errno == E2BIG)
             return false;
@@ -202,9 +203,6 @@
             panic("KVM: Failed to get supported CPUID (errno: %i)\n", errno);
     } else
         return true;
-#else
-    panic("KVM: getSupportedCPUID is unsupported on this platform.\n");
-#endif
 }
 
 const Kvm::CPUIDVector &
@@ -230,7 +228,6 @@
 bool
 Kvm::getSupportedMSRs(struct kvm_msr_list &msrs) const
 {
-#if defined(__i386__) || defined(__x86_64__)
     if (ioctl(KVM_GET_MSR_INDEX_LIST, (void *)&msrs) == -1) {
         if (errno == E2BIG)
             return false;
@@ -238,9 +235,6 @@
             panic("KVM: Failed to get supported CPUID (errno: %i)\n", errno);
     } else
         return true;
-#else
-    panic("KVM: getSupportedCPUID is unsupported on this platform.\n");
-#endif
 }
 
 const Kvm::MSRIndexVector &
@@ -262,6 +256,9 @@
     return supportedMSRCache;
 }
 
+#endif // x86-specific
+
+
 int
 Kvm::checkExtension(int extension) const
 {
diff -r 38af38f1f307 -r 0c0506575409 src/cpu/kvm/vm.hh
--- a/src/cpu/kvm/vm.hh Sat May 23 13:37:18 2015 +0100
+++ b/src/cpu/kvm/vm.hh Sat May 23 13:37:20 2015 +0100
@@ -75,9 +75,6 @@
     friend class KvmVM;
 
   public:
-    typedef std::vector<struct kvm_cpuid_entry2> CPUIDVector;
-    typedef std::vector<uint32_t> MSRIndexVector;
-
     virtual ~Kvm();
 
     Kvm *create();
@@ -143,6 +140,16 @@
     bool capXSave() const;
     /** @} */
 
+#if defined(__i386__) || defined(__x86_64__)
+  public: // x86-specific
+    /**
+     * @{
+     * @name X86-specific APIs
+     */
+
+    typedef std::vector<struct kvm_cpuid_entry2> CPUIDVector;
+    typedef std::vector<uint32_t> MSRIndexVector;
+
     /**
      * Get the CPUID features supported by the hardware and Kvm.
      *
@@ -181,6 +188,17 @@
      */
     const MSRIndexVector &getSupportedMSRs() const;
 
+  private: // x86-specific
+    /** Cached vector of supported CPUID entries. */
+    mutable CPUIDVector supportedCPUIDCache;
+
+    /** Cached vector of supported MSRs. */
+    mutable MSRIndexVector supportedMSRCache;
+
+
+    /** @} */
+#endif
+
   protected:
     /**
      * Check for the presence of an extension to the KVM API.
@@ -239,12 +257,6 @@
     /** Size of the MMAPed vCPU parameter area. */
     int vcpuMMapSize;
 
-    /** Cached vector of supported CPUID entries. */
-    mutable CPUIDVector supportedCPUIDCache;
-
-    /** Cached vector of supported MSRs. */
-    mutable MSRIndexVector supportedMSRCache;
-
     /** Singleton instance */
     static Kvm *instance;
 };
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to