From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: kvmarm@lists.cs.columbia.edu, "Andreas Färber" <afaerber@suse.de>,
patches@linaro.org
Subject: [Qemu-devel] [RFC 1/2] target-arm: Don't hardcode KVM target CPU to be A15
Date: Tue, 13 Aug 2013 19:03:02 +0100 [thread overview]
Message-ID: <1376416983-30838-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1376416983-30838-1-git-send-email-peter.maydell@linaro.org>
Instead of assuming that a KVM target CPU must always be a
Cortex-A15 and hardcoding this in kvm_arch_init_vcpu(), look
up the KVM_ARM_TARGET_* value based on the ARMCPU object
type. This is slightly overengineered for a single supported
CPU but provides a place to put support for future CPUs
and for "-cpu host".
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target-arm/kvm.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index b92e00d..0e33efc 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -70,6 +70,32 @@ static int compare_u64(const void *a, const void *b)
return *(uint64_t *)a - *(uint64_t *)b;
}
+static bool kvm_arm_get_init_args(ARMCPU *cpu, struct kvm_vcpu_init *init)
+{
+ /* Fill in the kvm_vcpu_init struct appropriately for this CPU.
+ * Return true on success, false on failure (ie unsupported CPU).
+ */
+ Object *obj = OBJECT(cpu);
+ int i;
+ static const struct {
+ const char *name;
+ uint32_t target;
+ } kvm_cpus[] = {
+ { "cortex-a15-" TYPE_ARM_CPU, KVM_ARM_TARGET_CORTEX_A15 },
+ };
+
+ memset(init->features, 0, sizeof(init->features));
+
+ for (i = 0; i < ARRAY_SIZE(kvm_cpus); i++) {
+ if (object_dynamic_cast(obj, kvm_cpus[i].name)) {
+ init->target = kvm_cpus[i].target;
+ return true;
+ }
+ }
+
+ return false;
+}
+
int kvm_arch_init_vcpu(CPUState *cs)
{
struct kvm_vcpu_init init;
@@ -80,8 +106,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
struct kvm_reg_list *rlp;
ARMCPU *cpu = ARM_CPU(cs);
- init.target = KVM_ARM_TARGET_CORTEX_A15;
- memset(init.features, 0, sizeof(init.features));
+ if (!kvm_arm_get_init_args(cpu, &init)) {
+ fprintf(stderr, "KVM is not supported for this guest CPU type\n");
+ return -EINVAL;
+ }
ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
if (ret) {
return ret;
--
1.7.9.5
next prev parent reply other threads:[~2013-08-13 18:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 18:03 [Qemu-devel] [RFC 0/2] target-arm: Provide '-cpu host' when running KVM Peter Maydell
2013-08-13 18:03 ` Peter Maydell [this message]
2013-08-13 18:03 ` [Qemu-devel] [RFC 2/2] " Peter Maydell
2013-08-14 6:32 ` [Qemu-devel] [RFC 0/2] " Alexander Graf
2013-08-14 8:11 ` Marc Zyngier
2013-08-14 8:16 ` Alexander Graf
2013-08-14 8:27 ` Marc Zyngier
2013-08-14 8:46 ` Alexander Graf
2013-08-14 9:07 ` Peter Maydell
2013-08-14 9:11 ` Alexander Graf
2013-08-14 9:23 ` Peter Maydell
2013-08-14 9:30 ` Alexander Graf
2013-08-14 17:26 ` Christoffer Dall
2013-08-14 17:31 ` Alexander Graf
2013-08-14 17:39 ` Christoffer Dall
2013-08-14 17:44 ` Alexander Graf
2013-08-14 18:18 ` Christoffer Dall
2013-08-14 18:21 ` Alexander Graf
2013-08-14 18:27 ` Peter Maydell
2013-08-14 19:23 ` Alexander Graf
2013-08-14 18:28 ` Christoffer Dall
2013-08-14 19:28 ` Alexander Graf
2013-08-14 20:33 ` Christoffer Dall
2013-08-14 20:47 ` Alexander Graf
2013-08-14 20:56 ` Christoffer Dall
2013-08-14 21:00 ` Alexander Graf
2013-08-25 14:42 ` Gleb Natapov
2013-08-25 15:11 ` Peter Maydell
2013-08-26 11:18 ` Gleb Natapov
2013-08-26 12:17 ` Peter Maydell
2013-08-14 18:11 ` Peter Maydell
2013-08-14 18:15 ` Alexander Graf
2013-08-14 18:24 ` Peter Maydell
2013-08-14 9:06 ` 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=1376416983-30838-2-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=afaerber@suse.de \
--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).