qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Gleb Natapov <gleb@redhat.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org, patches@linaro.org
Subject: Re: [Qemu-devel] [RFC] target-arm: Provide mechanism for getting KVM constants even if not CONFIG_KVM
Date: Fri, 15 Nov 2013 11:54:41 +0100	[thread overview]
Message-ID: <5285FD71.60707@redhat.com> (raw)
In-Reply-To: <1384456020-12251-1-git-send-email-peter.maydell@linaro.org>

Il 14/11/2013 20:07, Peter Maydell ha scritto:
> 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 <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
> 

It's okay.  There are indeed advantages to putting this together with
the definitions, instead of splitting it between target-arm/cpu.h and
target-arm/kvm.c.

The patch is missing the removal of the check from kvm.c though.

Paolo

  reply	other threads:[~2013-11-15 10:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 19:07 [Qemu-devel] [RFC] target-arm: Provide mechanism for getting KVM constants even if not CONFIG_KVM Peter Maydell
2013-11-15 10:54 ` Paolo Bonzini [this message]
2013-11-15 11:26   ` Peter Maydell
2013-11-15 11:33     ` Paolo Bonzini
2013-11-15 11:58       ` 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=5285FD71.60707@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=peter.maydell@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).