From patchwork Thu Nov 14 19:07:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 21514 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 862FE23FDD for ; Thu, 14 Nov 2013 19:07:06 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id f73sf4604723yha.6 for ; Thu, 14 Nov 2013 11:07:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=zMoXhGu4oeUGqxPGSUU0/lEQbdZccccV+M/kabOjioA=; b=WyJmzwmfFT7N8KIfKhTkml0U5OeUOD/HiO6cBCM1FKltRnXfZxQ5btMl7JlJmzK2PR bHgmJscdtif0kDH4RRIMmilB6dmPaW759D16yrovVq5XTPGf5zRQdDoadceBFOEATEst sC3gcjNttAGZH5Q2p2eS/H63YkC//YJm1RC3KEJye5CznEIkVhmW1bPqIkyB6xm4elb1 yAwGaxT/WNgFgiN0OUuS9OKR+/ZJhr9JS/4Z2HPFZRSXXBIHXUZrag3yaKZHSGxXcjoy URSqLNkMUcLdVoH9fFLb1fbSkXNX4cqWEXocskPBl/iDP1pa2O+lGQIOXmEjnLyipgGc B2KA== X-Gm-Message-State: ALoCoQmVlUZC1btRzIdElOdYfD0tyLqw+xpeYoJY3GVmNMF7Wxy30CV0WHlHaB6mrQ7soEx1KROJ X-Received: by 10.58.54.97 with SMTP id i1mr1276247vep.40.1384456025445; Thu, 14 Nov 2013 11:07:05 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.1.11 with SMTP id 11ls1034685qei.74.gmail; Thu, 14 Nov 2013 11:07:05 -0800 (PST) X-Received: by 10.220.147.20 with SMTP id j20mr1727554vcv.21.1384456025318; Thu, 14 Nov 2013 11:07:05 -0800 (PST) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id tq4si17663613vdc.77.2013.11.14.11.07.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Nov 2013 11:07:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id jx11so2238395veb.12 for ; Thu, 14 Nov 2013 11:07:05 -0800 (PST) X-Received: by 10.58.217.130 with SMTP id oy2mr1708763vec.24.1384456025191; Thu, 14 Nov 2013 11:07:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp339739vcz; Thu, 14 Nov 2013 11:07:04 -0800 (PST) X-Received: by 10.180.94.100 with SMTP id db4mr4264126wib.14.1384456024167; Thu, 14 Nov 2013 11:07:04 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id t6si11676151wjz.5.2013.11.14.11.07.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 14 Nov 2013 11:07:03 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Vh2Fo-0003C4-Cn; Thu, 14 Nov 2013 19:07:00 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvm@vger.kernel.org, Gleb Natapov , Paolo Bonzini Subject: [RFC] target-arm: Provide mechanism for getting KVM constants even if not CONFIG_KVM Date: Thu, 14 Nov 2013 19:07:00 +0000 Message-Id: <1384456020-12251-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- A series I'm currently working on wants another couple of KVM constants outside CONFIG_KVM code (in that case it's the KVM_ARM_TARGET_* values), and hw/arm/virt.c will want KVM_PSCI_* constants. This is my attempt at at least putting all of our redefinitions of things in one header file. Does anybody think this is horribly ugly or have a better idea? target-arm/cpu.h | 13 ++----------- target-arm/kvm-consts.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 11 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..42ffb50 --- /dev/null +++ b/target-arm/kvm-consts.h @@ -0,0 +1,34 @@ +/* + * 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. + */ +#ifndef ARM_KVM_CONSTS_H +#define ARM_KVM_CONSTS_H + +#ifdef CONFIG_KVM +#include "qemu/compiler.h" +#include + +#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