cpu: Check the KVM API version with a static_assert instead of macros.
Change-Id: Id8d52e25c4582ad802ee59facad5a1c31c2aa216 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45743 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -53,11 +53,14 @@
|
||||
#include "params/KvmVM.hh"
|
||||
#include "sim/system.hh"
|
||||
|
||||
#define EXPECTED_KVM_API_VERSION 12
|
||||
namespace
|
||||
{
|
||||
|
||||
#if EXPECTED_KVM_API_VERSION != KVM_API_VERSION
|
||||
#error Unsupported KVM version
|
||||
#endif
|
||||
constexpr int ExpectedKvmApiVersion = 12;
|
||||
static_assert(KVM_API_VERSION == ExpectedKvmApiVersion,
|
||||
"Unsupported KVM version");
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Kvm *Kvm::instance = NULL;
|
||||
|
||||
@@ -75,7 +78,7 @@ Kvm::Kvm()
|
||||
fatal("KVM: Failed to open /dev/kvm\n");
|
||||
|
||||
apiVersion = ioctl(KVM_GET_API_VERSION);
|
||||
if (apiVersion != EXPECTED_KVM_API_VERSION)
|
||||
if (apiVersion != ExpectedKvmApiVersion)
|
||||
fatal("KVM: Incompatible API version\n");
|
||||
|
||||
vcpuMMapSize = ioctl(KVM_GET_VCPU_MMAP_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user