Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/40877 )
Change subject: KVM fixup
......................................................................
KVM fixup
Change-Id: I7edbec46dc5c8de02276f55efea8d538bc9ea98e
---
M SConstruct
M src/arch/arm/kvm/SConscript
M src/cpu/kvm/SConscript
M src/cpu/kvm/SConsopts
4 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/SConstruct b/SConstruct
index c281174..a73894f 100755
--- a/SConstruct
+++ b/SConstruct
@@ -811,6 +811,9 @@
if env['USE_EFENCE']:
env.Append(LIBS=['efence'])
+ if env['KVM_ISA'] != env['TARGET_ISA']:
+ env['USE_KVM'] = False
+
# Save sticky variable settings back to current variables file
sticky_vars.Save(current_vars_file, env)
diff --git a/src/arch/arm/kvm/SConscript b/src/arch/arm/kvm/SConscript
index d999505..b078f06 100644
--- a/src/arch/arm/kvm/SConscript
+++ b/src/arch/arm/kvm/SConscript
@@ -41,7 +41,7 @@
host_isa = platform.machine()
if not (env['USE_KVM'] and env['TARGET_ISA'] == 'arm' and
- host_isa in ('armv71', 'aarch64')):
+ env['KVM_ISA'] == 'arm'):
Return()
SimObject('KvmGic.py')
diff --git a/src/cpu/kvm/SConscript b/src/cpu/kvm/SConscript
index 397d96a..0e79501 100644
--- a/src/cpu/kvm/SConscript
+++ b/src/cpu/kvm/SConscript
@@ -37,7 +37,7 @@
Import('*')
-if not env['USE_KVM']:
+if not env['USE_KVM'] or env['TARGET_ISA'] != env['KVM_ISA']:
Return()
SimObject('KvmVM.py')
@@ -49,10 +49,7 @@
Source('perfevent.cc')
Source('timer.cc')
-import platform
-host_isa = platform.machine()
-
-if env['TARGET_ISA'] == 'x86' and host_isa == 'x86_64':
+if env['TARGET_ISA'] == 'x86':
SimObject('X86KvmCPU.py')
Source('x86_cpu.cc')
diff --git a/src/cpu/kvm/SConsopts b/src/cpu/kvm/SConsopts
index 655786f..7b08d87 100644
--- a/src/cpu/kvm/SConsopts
+++ b/src/cpu/kvm/SConsopts
@@ -28,7 +28,12 @@
from gem5_scons import warning
import gem5_scons
-import platform
+host_isa = None
+try:
+ import platform
+ host_isa = platform.machine()
+except:
+ pass
conf = gem5_scons.Configure(main)
@@ -36,21 +41,24 @@
# we rely on exists since version 2.6.36 of the kernel, but somehow
# the KVM_API_VERSION does not reflect the change. We test for one of
# the types as a fall back.
-have_kvm = True
+main['KVM_ISA'] = None
if not conf.CheckHeader('linux/kvm.h', '<>'):
print("Info: Compatible header file <linux/kvm.h> not found, "
"disabling KVM support.")
- have_kvm = False
elif not conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h'
], 'C',
'timer_create(CLOCK_MONOTONIC, NULL,
NULL);'):
warning("Cannot enable KVM, host seems to lack support for POSIX
timers")
- have_kvm = False
-elif platform.machine() == 'x86' and not \
- conf.CheckTypeSize('struct kvm_xsave', '#include <linux/kvm.h>')
== 0:
- warning("KVM on x86 requires xsave support in kernel headers.")
- have_kvm = False
+elif host_isa == 'x86_64':
+ if conf.CheckTypeSize('struct kvm_xsave', '#include <linux/kvm.h>') !=
0:
+ main['KVM_ISA'] = 'x86'
+ else:
+ warning("KVM on x86 requires xsave support in kernel headers.")
+elif host_isa in ('armv71', 'aarch64'):
+ main['KVM_ISA'] = 'arm'
+else:
+ warning("Failed to determine host ISA.")
-if have_kvm:
+if main['KVM_ISA']:
# Check if the exclude_host attribute is available. We want this to
# get accurate instruction counts in KVM.
main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
@@ -65,7 +73,7 @@
main = conf.Finish()
-if have_kvm:
+if main['KVM_ISA']:
sticky_vars.Add(BoolVariable('USE_KVM',
'Enable hardware virtualized (KVM) CPU models', True))
else:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40877
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7edbec46dc5c8de02276f55efea8d538bc9ea98e
Gerrit-Change-Number: 40877
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s