aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2012-10-03 06:17:02 -0400
committerChristoffer Dall <cdall@cs.columbia.edu>2013-03-06 18:48:42 -0500
commitdb730d8d623a0826f7fb6b74e890d3eb97a1b7a3 (patch)
treef70fd526d947afd6c3d43fc36e4ededef78e9788
parent0b5e3bac30c545720f7e6b026241b5f8dd832df2 (diff)
ARM: KVM: convert GP registers from u32 to unsigned long
On 32bit ARM, unsigned long is guaranteed to be a 32bit quantity. On 64bit ARM, it is a 64bit quantity. In order to be able to share code between the two architectures, convert the registers to be unsigned long, so the core code can be oblivious of the change. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm/include/asm/kvm_emulate.h12
-rw-r--r--arch/arm/include/uapi/asm/kvm.h12
-rw-r--r--arch/arm/kvm/coproc.c4
-rw-r--r--arch/arm/kvm/coproc.h4
-rw-r--r--arch/arm/kvm/emulate.c22
-rw-r--r--arch/arm/kvm/mmio.c2
6 files changed, 28 insertions, 28 deletions
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index fd611996bfb5..510488ad30bd 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -23,8 +23,8 @@
23#include <asm/kvm_asm.h> 23#include <asm/kvm_asm.h>
24#include <asm/kvm_mmio.h> 24#include <asm/kvm_mmio.h>
25 25
26u32 *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); 26unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num);
27u32 *vcpu_spsr(struct kvm_vcpu *vcpu); 27unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu);
28 28
29int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run); 29int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run);
30void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr); 30void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr);
@@ -37,14 +37,14 @@ static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu)
37 return 1; 37 return 1;
38} 38}
39 39
40static inline u32 *vcpu_pc(struct kvm_vcpu *vcpu) 40static inline unsigned long *vcpu_pc(struct kvm_vcpu *vcpu)
41{ 41{
42 return (u32 *)&vcpu->arch.regs.usr_regs.ARM_pc; 42 return &vcpu->arch.regs.usr_regs.ARM_pc;
43} 43}
44 44
45static inline u32 *vcpu_cpsr(struct kvm_vcpu *vcpu) 45static inline unsigned long *vcpu_cpsr(struct kvm_vcpu *vcpu)
46{ 46{
47 return (u32 *)&vcpu->arch.regs.usr_regs.ARM_cpsr; 47 return &vcpu->arch.regs.usr_regs.ARM_cpsr;
48} 48}
49 49
50static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu) 50static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu)
diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 023bfeb367bf..c1ee007523d7 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -53,12 +53,12 @@
53#define KVM_ARM_FIQ_spsr fiq_regs[7] 53#define KVM_ARM_FIQ_spsr fiq_regs[7]
54 54
55struct kvm_regs { 55struct kvm_regs {
56 struct pt_regs usr_regs;/* R0_usr - R14_usr, PC, CPSR */ 56 struct pt_regs usr_regs; /* R0_usr - R14_usr, PC, CPSR */
57 __u32 svc_regs[3]; /* SP_svc, LR_svc, SPSR_svc */ 57 unsigned long svc_regs[3]; /* SP_svc, LR_svc, SPSR_svc */
58 __u32 abt_regs[3]; /* SP_abt, LR_abt, SPSR_abt */ 58 unsigned long abt_regs[3]; /* SP_abt, LR_abt, SPSR_abt */
59 __u32 und_regs[3]; /* SP_und, LR_und, SPSR_und */ 59 unsigned long und_regs[3]; /* SP_und, LR_und, SPSR_und */
60 __u32 irq_regs[3]; /* SP_irq, LR_irq, SPSR_irq */ 60 unsigned long irq_regs[3]; /* SP_irq, LR_irq, SPSR_irq */
61 __u32 fiq_regs[8]; /* R8_fiq - R14_fiq, SPSR_fiq */ 61 unsigned long fiq_regs[8]; /* R8_fiq - R14_fiq, SPSR_fiq */
62}; 62};
63 63
64/* Supported Processor Types */ 64/* Supported Processor Types */
diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
index 4ea9a982269c..38e76bcb52a4 100644
--- a/arch/arm/kvm/coproc.c
+++ b/arch/arm/kvm/coproc.c
@@ -76,7 +76,7 @@ static bool access_dcsw(struct kvm_vcpu *vcpu,
76 const struct coproc_params *p, 76 const struct coproc_params *p,
77 const struct coproc_reg *r) 77 const struct coproc_reg *r)
78{ 78{
79 u32 val; 79 unsigned long val;
80 int cpu; 80 int cpu;
81 81
82 cpu = get_cpu(); 82 cpu = get_cpu();
@@ -298,7 +298,7 @@ static int emulate_cp15(struct kvm_vcpu *vcpu,
298 } 298 }
299 /* If access function fails, it should complain. */ 299 /* If access function fails, it should complain. */
300 } else { 300 } else {
301 kvm_err("Unsupported guest CP15 access at: %08x\n", 301 kvm_err("Unsupported guest CP15 access at: %08lx\n",
302 *vcpu_pc(vcpu)); 302 *vcpu_pc(vcpu));
303 print_cp_instr(params); 303 print_cp_instr(params);
304 } 304 }
diff --git a/arch/arm/kvm/coproc.h b/arch/arm/kvm/coproc.h
index 992adfafa2ff..b7301d3e4799 100644
--- a/arch/arm/kvm/coproc.h
+++ b/arch/arm/kvm/coproc.h
@@ -84,7 +84,7 @@ static inline bool read_zero(struct kvm_vcpu *vcpu,
84static inline bool write_to_read_only(struct kvm_vcpu *vcpu, 84static inline bool write_to_read_only(struct kvm_vcpu *vcpu,
85 const struct coproc_params *params) 85 const struct coproc_params *params)
86{ 86{
87 kvm_debug("CP15 write to read-only register at: %08x\n", 87 kvm_debug("CP15 write to read-only register at: %08lx\n",
88 *vcpu_pc(vcpu)); 88 *vcpu_pc(vcpu));
89 print_cp_instr(params); 89 print_cp_instr(params);
90 return false; 90 return false;
@@ -93,7 +93,7 @@ static inline bool write_to_read_only(struct kvm_vcpu *vcpu,
93static inline bool read_from_write_only(struct kvm_vcpu *vcpu, 93static inline bool read_from_write_only(struct kvm_vcpu *vcpu,
94 const struct coproc_params *params) 94 const struct coproc_params *params)
95{ 95{
96 kvm_debug("CP15 read to write-only register at: %08x\n", 96 kvm_debug("CP15 read to write-only register at: %08lx\n",
97 *vcpu_pc(vcpu)); 97 *vcpu_pc(vcpu));
98 print_cp_instr(params); 98 print_cp_instr(params);
99 return false; 99 return false;
diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
index d61450ac6665..d3094eb4ade6 100644
--- a/arch/arm/kvm/emulate.c
+++ b/arch/arm/kvm/emulate.c
@@ -109,10 +109,10 @@ static const unsigned long vcpu_reg_offsets[VCPU_NR_MODES][15] = {
109 * Return a pointer to the register number valid in the current mode of 109 * Return a pointer to the register number valid in the current mode of
110 * the virtual CPU. 110 * the virtual CPU.
111 */ 111 */
112u32 *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num) 112unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num)
113{ 113{
114 u32 *reg_array = (u32 *)&vcpu->arch.regs; 114 unsigned long *reg_array = (unsigned long *)&vcpu->arch.regs;
115 u32 mode = *vcpu_cpsr(vcpu) & MODE_MASK; 115 unsigned long mode = *vcpu_cpsr(vcpu) & MODE_MASK;
116 116
117 switch (mode) { 117 switch (mode) {
118 case USR_MODE...SVC_MODE: 118 case USR_MODE...SVC_MODE:
@@ -141,9 +141,9 @@ u32 *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num)
141/* 141/*
142 * Return the SPSR for the current mode of the virtual CPU. 142 * Return the SPSR for the current mode of the virtual CPU.
143 */ 143 */
144u32 *vcpu_spsr(struct kvm_vcpu *vcpu) 144unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu)
145{ 145{
146 u32 mode = *vcpu_cpsr(vcpu) & MODE_MASK; 146 unsigned long mode = *vcpu_cpsr(vcpu) & MODE_MASK;
147 switch (mode) { 147 switch (mode) {
148 case SVC_MODE: 148 case SVC_MODE:
149 return &vcpu->arch.regs.KVM_ARM_SVC_spsr; 149 return &vcpu->arch.regs.KVM_ARM_SVC_spsr;
@@ -257,9 +257,9 @@ static u32 exc_vector_base(struct kvm_vcpu *vcpu)
257 */ 257 */
258void kvm_inject_undefined(struct kvm_vcpu *vcpu) 258void kvm_inject_undefined(struct kvm_vcpu *vcpu)
259{ 259{
260 u32 new_lr_value; 260 unsigned long new_lr_value;
261 u32 new_spsr_value; 261 unsigned long new_spsr_value;
262 u32 cpsr = *vcpu_cpsr(vcpu); 262 unsigned long cpsr = *vcpu_cpsr(vcpu);
263 u32 sctlr = vcpu->arch.cp15[c1_SCTLR]; 263 u32 sctlr = vcpu->arch.cp15[c1_SCTLR];
264 bool is_thumb = (cpsr & PSR_T_BIT); 264 bool is_thumb = (cpsr & PSR_T_BIT);
265 u32 vect_offset = 4; 265 u32 vect_offset = 4;
@@ -291,9 +291,9 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu)
291 */ 291 */
292static void inject_abt(struct kvm_vcpu *vcpu, bool is_pabt, unsigned long addr) 292static void inject_abt(struct kvm_vcpu *vcpu, bool is_pabt, unsigned long addr)
293{ 293{
294 u32 new_lr_value; 294 unsigned long new_lr_value;
295 u32 new_spsr_value; 295 unsigned long new_spsr_value;
296 u32 cpsr = *vcpu_cpsr(vcpu); 296 unsigned long cpsr = *vcpu_cpsr(vcpu);
297 u32 sctlr = vcpu->arch.cp15[c1_SCTLR]; 297 u32 sctlr = vcpu->arch.cp15[c1_SCTLR];
298 bool is_thumb = (cpsr & PSR_T_BIT); 298 bool is_thumb = (cpsr & PSR_T_BIT);
299 u32 vect_offset; 299 u32 vect_offset;
diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
index 98a870ff1a5c..c186bc910715 100644
--- a/arch/arm/kvm/mmio.c
+++ b/arch/arm/kvm/mmio.c
@@ -33,7 +33,7 @@
33 */ 33 */
34int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) 34int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
35{ 35{
36 __u32 *dest; 36 unsigned long *dest;
37 unsigned int len; 37 unsigned int len;
38 int mask; 38 int mask;
39 39