qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] target-arm: kvm: use KVM_SET_SREGS to set target to


From: Rusty Russell
Subject: [Qemu-devel] [PATCH] target-arm: kvm: use KVM_SET_SREGS to set target to Cortex A15
Date: Fri, 13 Jul 2012 13:07:44 +0930
User-agent: Notmuch/0.12 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu)

Recent kernels use this to set the cpu and features (currently, only
the A15 is supported).

Note that this causes the registers in the CPU to be initialized, so
it's important that all CPUs are created first (they are, as it turns
out).

This code ignores errors, for backwards compatibility with older
kernels.

Signed-off-by: Rusty Russell <address@hidden>

diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h
index 38ff1d6..988890a 100644
--- a/linux-headers/asm-arm/kvm.h
+++ b/linux-headers/asm-arm/kvm.h
@@ -66,7 +66,13 @@ struct kvm_regs {
 
 };
 
+/* Supported Processor Types */
+#define KVM_ARM_TARGET_CORTEX_A15      (0xC0F)
+
 struct kvm_sregs {
+       __u32 target;
+       __u32 num_features;
+       __u32 features[14];
 };
 
 struct kvm_fpu {
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 29bb51f..67d005f 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -34,7 +34,13 @@ int kvm_arch_init(KVMState *s)
 
 int kvm_arch_init_vcpu(CPUARMState *env)
 {
-    return 0;
+    struct kvm_sregs sregs;
+
+    sregs.target = KVM_ARM_TARGET_CORTEX_A15;
+    sregs.num_features = 0;
+
+    /* Ignore failure for compatibility with old kvm versions. */
+    return kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs) ? 0 : 0;
 }
 
 int kvm_arch_put_registers(CPUARMState *env, int level)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]