kvm: Separate host frequency from simulated CPU frequency
[gem5.git] / SConstruct
index 6354bf0ca468633f8b2f59a111adaff8af2f2435..559692de000f46843c40c983eee8de1d10419717 100755 (executable)
@@ -724,9 +724,9 @@ if compareVersions(swig_version[2], min_swig_version) < 0:
     print '       Installed version:', swig_version[2]
     Exit(1)
 
-if swig_version[2] == "2.0.9":
+if swig_version[2] in ["2.0.9", "2.0.10"]:
     print '\n' + termcap.Yellow + termcap.Bold + \
-        'Warning: SWIG version 2.0.9 sometimes generates broken code.\n' + \
+        'Warning: SWIG version 2.0.9/10 sometimes generates broken code.\n' + \
         termcap.Normal + \
         'This problem only affects some platforms and some Python\n' + \
         'versions. See the following SWIG bug report for details:\n' + \
@@ -944,6 +944,27 @@ if not have_fenv:
     print "Warning: Header file <fenv.h> not found."
     print "         This host has no IEEE FP rounding mode control."
 
+# Check if we should enable KVM-based hardware virtualization
+have_kvm = conf.CheckHeader('linux/kvm.h', '<>')
+if not have_kvm:
+    print "Info: Header file <linux/kvm.h> not found, " \
+        "disabling KVM support."
+
+# Check if the requested target ISA is compatible with the host
+def is_isa_kvm_compatible(isa):
+    isa_comp_table = {
+        "arm" : ( "armv7l" ),
+        }
+    try:
+        import platform
+        host_isa = platform.machine()
+    except:
+        print "Warning: Failed to determine host ISA."
+        return False
+
+    return host_isa in isa_comp_table.get(isa, [])
+
+
 ######################################################################
 #
 # Finish the configuration
@@ -1038,6 +1059,7 @@ sticky_vars.AddVariables(
     BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
     BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
     BoolVariable('CP_ANNOTATE', 'Enable critical path annotation capability', False),
+    BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models', have_kvm),
     EnumVariable('PROTOCOL', 'Coherence protocol for Ruby', 'None',
                   all_protocols),
     )
@@ -1205,6 +1227,15 @@ for variant_path in variant_paths:
     if env['EFENCE']:
         env.Append(LIBS=['efence'])
 
+    if env['USE_KVM']:
+        if not have_kvm:
+            print "Warning: Can not enable KVM, host seems to lack KVM support"
+            env['USE_KVM'] = False
+        elif not is_isa_kvm_compatible(env['TARGET_ISA']):
+            print "Info: KVM support disabled due to unsupported host and " \
+                "target ISA combination"
+            env['USE_KVM'] = False
+
     # Save sticky variable settings back to current variables file
     sticky_vars.Save(current_vars_file, env)