From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: kvmarm@lists.cs.columbia.edu, patches@linaro.org
Subject: [Qemu-devel] [PATCH v9 01/11] target-arm: Provide mechanism for getting KVM constants even if not CONFIG_KVM
Date: Fri, 22 Nov 2013 17:17:08 +0000 [thread overview]
Message-ID: <1385140638-10444-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1385140638-10444-1-git-send-email-peter.maydell@linaro.org>
There are a number of places where it would be convenient for ARM
code to have working definitions of KVM constants even in code
which is compiled with CONFIG_KVM not set. In this situation we
can't simply include the kernel KVM headers (which might conflict
with host header definitions or not even compile on the compiler
we're using) so we have to redefine equivalent constants.
Provide a mechanism for doing this and checking that the values
match, and use it for the constants we're currently exposing
via an ad-hoc mechanism.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target-arm/cpu.h | 13 ++-----------
target-arm/kvm-consts.h | 41 +++++++++++++++++++++++++++++++++++++++++
target-arm/kvm.c | 9 ---------
3 files changed, 43 insertions(+), 20 deletions(-)
create mode 100644 target-arm/kvm-consts.h
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 9f110f1..c3f007f 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -21,6 +21,8 @@
#include "config.h"
+#include "kvm-consts.h"
+
#if defined(TARGET_AARCH64)
/* AArch64 definitions */
# define TARGET_LONG_BITS 64
@@ -497,17 +499,6 @@ void armv7m_nvic_complete_irq(void *opaque, int irq);
(((cp) << 16) | ((is64) << 15) | ((crn) << 11) | \
((crm) << 7) | ((opc1) << 3) | (opc2))
-/* Note that these must line up with the KVM/ARM register
- * ID field definitions (kvm.c will check this, but we
- * can't just use the KVM defines here as the kvm headers
- * are unavailable to non-KVM-specific files)
- */
-#define CP_REG_SIZE_SHIFT 52
-#define CP_REG_SIZE_MASK 0x00f0000000000000ULL
-#define CP_REG_SIZE_U32 0x0020000000000000ULL
-#define CP_REG_SIZE_U64 0x0030000000000000ULL
-#define CP_REG_ARM 0x4000000000000000ULL
-
/* Convert a full 64 bit KVM register ID to the truncated 32 bit
* version used as a key for the coprocessor register hashtable
*/
diff --git a/target-arm/kvm-consts.h b/target-arm/kvm-consts.h
new file mode 100644
index 0000000..6f56f72
--- /dev/null
+++ b/target-arm/kvm-consts.h
@@ -0,0 +1,41 @@
+/*
+ * KVM ARM ABI constant definitions
+ *
+ * Copyright (c) 2013 Linaro Limited
+ *
+ * Provide versions of KVM constant defines that can be used even
+ * when CONFIG_KVM is not set and we don't have access to the
+ * KVM headers. If CONFIG_KVM is set, we do a compile-time check
+ * that we haven't got out of sync somehow.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef ARM_KVM_CONSTS_H
+#define ARM_KVM_CONSTS_H
+
+#ifdef CONFIG_KVM
+#include "qemu/compiler.h"
+#include <linux/kvm.h>
+
+#define MISMATCH_CHECK(X, Y) QEMU_BUILD_BUG_ON(X != Y)
+
+#else
+#define MISMATCH_CHECK(X, Y)
+#endif
+
+#define CP_REG_SIZE_SHIFT 52
+#define CP_REG_SIZE_MASK 0x00f0000000000000ULL
+#define CP_REG_SIZE_U32 0x0020000000000000ULL
+#define CP_REG_SIZE_U64 0x0030000000000000ULL
+#define CP_REG_ARM 0x4000000000000000ULL
+
+MISMATCH_CHECK(CP_REG_SIZE_SHIFT, KVM_REG_SIZE_SHIFT)
+MISMATCH_CHECK(CP_REG_SIZE_MASK, KVM_REG_SIZE_MASK)
+MISMATCH_CHECK(CP_REG_SIZE_U32, KVM_REG_SIZE_U32)
+MISMATCH_CHECK(CP_REG_SIZE_U64, KVM_REG_SIZE_U64)
+MISMATCH_CHECK(CP_REG_ARM, KVM_REG_ARM)
+
+#undef MISMATCH_CHECK
+
+#endif
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 6e5cd36..3098456 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -23,15 +23,6 @@
#include "cpu.h"
#include "hw/arm/arm.h"
-/* Check that cpu.h's idea of coprocessor fields matches KVM's */
-#if (CP_REG_SIZE_SHIFT != KVM_REG_SIZE_SHIFT) || \
- (CP_REG_SIZE_MASK != KVM_REG_SIZE_MASK) || \
- (CP_REG_SIZE_U32 != KVM_REG_SIZE_U32) || \
- (CP_REG_SIZE_U64 != KVM_REG_SIZE_U64) || \
- (CP_REG_ARM != KVM_REG_ARM)
-#error mismatch between cpu.h and KVM header definitions
-#endif
-
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_LAST_INFO
};
--
1.7.9.5
next prev parent reply other threads:[~2013-11-22 17:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 17:17 [Qemu-devel] [PATCH v9 00/11] target-arm: mach virt and -cpu host support Peter Maydell
2013-11-22 17:17 ` Peter Maydell [this message]
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 02/11] device_tree.c: Terminate the empty reservemap in create_device_tree() Peter Maydell
2013-11-24 8:04 ` Peter Crosthwaite
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 03/11] hw/arm/boot: Allow boards to provide an fdt blob Peter Maydell
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 04/11] target-arm: Provide PSCI constants to generic QEMU code Peter Maydell
2013-11-22 17:52 ` Christoffer Dall
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 05/11] target-arm: Add ARMCPU field for Linux device-tree 'compatible' string Peter Maydell
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 06/11] target-arm: Allow secondary KVM CPUs to be booted via PSCI Peter Maydell
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 07/11] hw/arm: Add 'virt' platform Peter Maydell
2013-11-22 18:11 ` Christoffer Dall
2013-11-22 18:17 ` Peter Maydell
2013-11-22 18:24 ` Christoffer Dall
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 08/11] linux-headers: Update from mainline Peter Maydell
2013-12-02 13:35 ` Peter Maydell
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 09/11] target-arm: Don't hardcode KVM target CPU to be A15 Peter Maydell
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 10/11] target-arm: Provide '-cpu host' when running KVM Peter Maydell
2013-11-22 18:25 ` Christoffer Dall
2013-11-22 18:50 ` Peter Maydell
2013-11-22 19:00 ` Christoffer Dall
2013-11-22 17:17 ` [Qemu-devel] [PATCH v9 11/11] hw/arm/virt: Support -cpu host Peter Maydell
2013-11-22 18:26 ` [Qemu-devel] [PATCH v9 00/11] target-arm: mach virt and -cpu host support Christoffer Dall
2013-12-02 13:46 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385140638-10444-2-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).