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:
Gabe Black
2021-05-18 18:05:37 -07:00
parent d53c0a95ee
commit a0fa1e03b2

View File

@@ -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);