[PATCH] arm: kvm: Update kvm/arm headers.

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

 



The offsets for the registers have changed, so this patch updates the
headers and fixes the offsets and the compilation in one.

Signed-off-by: Christoffer Dall <c.dall@xxxxxxxxxxxxxxxxxxxxxx>
---
 linux-headers/asm-arm/kvm.h |   15 ++++-----------
 linux-headers/linux/kvm.h   |    5 +++++
 target-arm/kvm.c            |   37 +++++++++++++++++++------------------
 3 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h
index 8101812..5142cab 100644
--- a/linux-headers/asm-arm/kvm.h
+++ b/linux-headers/asm-arm/kvm.h
@@ -20,6 +20,7 @@
 #define __ARM_KVM_H__
 
 #include <asm/types.h>
+#include <asm/ptrace.h>
 
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
@@ -28,19 +29,17 @@
 	(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
 
 struct kvm_regs {
-	__u32 usr_regs[15];	/* R0_usr - R14_usr */
+	struct pt_regs usr_regs;/* R0_usr - R14_usr, PC, CPSR */
 	__u32 svc_regs[3];	/* SP_svc, LR_svc, SPSR_svc */
 	__u32 abt_regs[3];	/* SP_abt, LR_abt, SPSR_abt */
 	__u32 und_regs[3];	/* SP_und, LR_und, SPSR_und */
 	__u32 irq_regs[3];	/* SP_irq, LR_irq, SPSR_irq */
 	__u32 fiq_regs[8];	/* R8_fiq - R14_fiq, SPSR_fiq */
-	__u32 pc;		/* The program counter (r15) */
-	__u32 cpsr;		/* The guest CPSR */
 };
 
 /* Supported Processor Types */
-#define KVM_ARM_TARGET_CORTEX_A15 0
-#define KVM_ARM_NUM_TARGETS 1
+#define KVM_ARM_TARGET_CORTEX_A15	0
+#define KVM_ARM_NUM_TARGETS		1
 
 struct kvm_vcpu_init {
 	__u32 target;
@@ -65,12 +64,6 @@ struct kvm_sync_regs {
 struct kvm_arch_memory_slot {
 };
 
-/* For KVM_VCPU_GET_REG_LIST. */
-struct kvm_reg_list {
-	__u64 n; /* number of regs */
-	__u64 reg[0];
-};
-
 /* If you need to interpret the index values, here is the key: */
 #define KVM_REG_ARM_COPROC_MASK		0x000000000FFF0000
 #define KVM_REG_ARM_COPROC_SHIFT	16
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 7a02d73..0030863 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -746,6 +746,11 @@ struct kvm_dirty_tlb {
 #define KVM_REG_SIZE_U512	0x0060000000000000ULL
 #define KVM_REG_SIZE_U1024	0x0070000000000000ULL
 
+struct kvm_reg_list {
+	__u64 n; /* number of regs */
+	__u64 reg[0];
+};
+
 struct kvm_one_reg {
 	__u64 id;
 	__u64 addr;
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index fee60e1..622c82e 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -14,6 +14,7 @@
 #include <sys/mman.h>
 
 #include <linux/kvm.h>
+#include <linux/ptrace.h>
 
 #include "qemu-common.h"
 #include "qemu-timer.h"
@@ -70,21 +71,21 @@ struct reg {
 
 const struct reg regs[] = {
     /* R0_usr .. R14_usr */
-    COREREG(usr_regs[0], regs[0]),
-    COREREG(usr_regs[1], regs[1]),
-    COREREG(usr_regs[2], regs[2]),
-    COREREG(usr_regs[3], regs[3]),
-    COREREG(usr_regs[4], regs[4]),
-    COREREG(usr_regs[5], regs[5]),
-    COREREG(usr_regs[6], regs[6]),
-    COREREG(usr_regs[7], regs[7]),
-    COREREG(usr_regs[8], usr_regs[0]),
-    COREREG(usr_regs[9], usr_regs[1]),
-    COREREG(usr_regs[10], usr_regs[2]),
-    COREREG(usr_regs[11], usr_regs[3]),
-    COREREG(usr_regs[12], usr_regs[4]),
-    COREREG(usr_regs[13], banked_r13[0]),
-    COREREG(usr_regs[14], banked_r14[0]),
+    COREREG(usr_regs.ARM_r0, regs[0]),
+    COREREG(usr_regs.ARM_r1, regs[1]),
+    COREREG(usr_regs.ARM_r2, regs[2]),
+    COREREG(usr_regs.ARM_r3, regs[3]),
+    COREREG(usr_regs.ARM_r4, regs[4]),
+    COREREG(usr_regs.ARM_r5, regs[5]),
+    COREREG(usr_regs.ARM_r6, regs[6]),
+    COREREG(usr_regs.ARM_r7, regs[7]),
+    COREREG(usr_regs.ARM_r8, usr_regs[0]),
+    COREREG(usr_regs.ARM_r9, usr_regs[1]),
+    COREREG(usr_regs.ARM_r10, usr_regs[2]),
+    COREREG(usr_regs.ARM_fp, usr_regs[3]),
+    COREREG(usr_regs.ARM_ip, usr_regs[4]),
+    COREREG(usr_regs.ARM_sp, banked_r13[0]),
+    COREREG(usr_regs.ARM_lr, banked_r14[0]),
     /* R13, R14, SPSR for SVC, ABT, UND, IRQ banks */
     COREREG(svc_regs[0], banked_r13[1]),
     COREREG(svc_regs[1], banked_r14[1]),
@@ -108,7 +109,7 @@ const struct reg regs[] = {
     COREREG(fiq_regs[1], banked_r14[5]),
     COREREG(fiq_regs[2], banked_spsr[5]),
     /* R15 */
-    COREREG(pc, regs[15]),
+    COREREG(usr_regs.ARM_pc, regs[15]),
     /* A non-comprehensive set of cp15 registers.
      * TODO: drive this from the cp_regs hashtable instead.
      */
@@ -150,7 +151,7 @@ int kvm_arch_put_registers(CPUARMState *env, int level)
     /* Special cases which aren't a single CPUARMState field */
     cpsr = cpsr_read(env);
     r.id = KVM_REG_ARM | KVM_REG_SIZE_U32 |
-        KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(cpsr);
+        KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(usr_regs.ARM_cpsr);
     r.addr = (uintptr_t)(&cpsr);
     ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, &r);
     if (ret) {
@@ -196,7 +197,7 @@ int kvm_arch_get_registers(CPUARMState *env)
 
     /* Special cases which aren't a single CPUARMState field */
     r.id = KVM_REG_ARM | KVM_REG_SIZE_U32 |
-        KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(cpsr);
+        KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(usr_regs.ARM_cpsr);
     r.addr = (uintptr_t)(&cpsr);
     ret = kvm_vcpu_ioctl(env, KVM_GET_ONE_REG, &r);
     if (ret) {
-- 
1.7.9.5

_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux