Skip to content

Commit 710f198

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move SPSR_EL1 to the system register array
SPSR_EL1 being a VNCR-capable register with ARMv8.4-NV, move it to the sysregs array and update the accessors. Reviewed-by: James Morse <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent fd85b66 commit 710f198

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static inline unsigned long vcpu_read_spsr(const struct kvm_vcpu *vcpu)
176176
if (vcpu->arch.sysregs_loaded_on_cpu)
177177
return read_sysreg_el1(SYS_SPSR);
178178
else
179-
return vcpu->arch.ctxt.spsr_el1;
179+
return __vcpu_sys_reg(vcpu, SPSR_EL1);
180180
}
181181

182182
static inline void vcpu_write_spsr(struct kvm_vcpu *vcpu, unsigned long v)
@@ -189,7 +189,7 @@ static inline void vcpu_write_spsr(struct kvm_vcpu *vcpu, unsigned long v)
189189
if (vcpu->arch.sysregs_loaded_on_cpu)
190190
write_sysreg_el1(v, SYS_SPSR);
191191
else
192-
vcpu->arch.ctxt.spsr_el1 = v;
192+
__vcpu_sys_reg(vcpu, SPSR_EL1) = v;
193193
}
194194

195195
/*

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ enum vcpu_sysreg {
187187

188188
ELR_EL1,
189189
SP_EL1,
190+
SPSR_EL1,
190191

191192
/* 32bit specific registers. Keep them at the end of the range */
192193
DACR32_EL2, /* Domain Access Control Register */
@@ -241,7 +242,6 @@ enum vcpu_sysreg {
241242
struct kvm_cpu_context {
242243
struct user_pt_regs regs; /* sp = sp_el0 */
243244

244-
u64 spsr_el1; /* aka spsr_svc */
245245
u64 spsr_abt;
246246
u64 spsr_und;
247247
u64 spsr_irq;

arch/arm64/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static void *core_reg_addr(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
135135
return __ctxt_sys_reg(&vcpu->arch.ctxt, ELR_EL1);
136136

137137
case KVM_REG_ARM_CORE_REG(spsr[KVM_SPSR_EL1]):
138-
return &vcpu->arch.ctxt.spsr_el1;
138+
return __ctxt_sys_reg(&vcpu->arch.ctxt, SPSR_EL1);
139139

140140
case KVM_REG_ARM_CORE_REG(spsr[KVM_SPSR_ABT]):
141141
return &vcpu->arch.ctxt.spsr_abt;

arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)
4848

4949
ctxt_sys_reg(ctxt, SP_EL1) = read_sysreg(sp_el1);
5050
ctxt_sys_reg(ctxt, ELR_EL1) = read_sysreg_el1(SYS_ELR);
51-
ctxt->spsr_el1 = read_sysreg_el1(SYS_SPSR);
51+
ctxt_sys_reg(ctxt, SPSR_EL1) = read_sysreg_el1(SYS_SPSR);
5252
}
5353

5454
static inline void __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt)
@@ -127,7 +127,7 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
127127

128128
write_sysreg(ctxt_sys_reg(ctxt, SP_EL1), sp_el1);
129129
write_sysreg_el1(ctxt_sys_reg(ctxt, ELR_EL1), SYS_ELR);
130-
write_sysreg_el1(ctxt->spsr_el1, SYS_SPSR);
130+
write_sysreg_el1(ctxt_sys_reg(ctxt, SPSR_EL1), SYS_SPSR);
131131
}
132132

133133
static inline void __sysreg_restore_el2_return_state(struct kvm_cpu_context *ctxt)

arch/arm64/kvm/regmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ unsigned long vcpu_read_spsr32(const struct kvm_vcpu *vcpu)
150150
if (!vcpu->arch.sysregs_loaded_on_cpu) {
151151
switch (spsr_idx) {
152152
case KVM_SPSR_SVC:
153-
return vcpu->arch.ctxt.spsr_el1;
153+
return __vcpu_sys_reg(vcpu, SPSR_EL1);
154154
case KVM_SPSR_ABT:
155155
return vcpu->arch.ctxt.spsr_abt;
156156
case KVM_SPSR_UND:
@@ -185,7 +185,7 @@ void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v)
185185
if (!vcpu->arch.sysregs_loaded_on_cpu) {
186186
switch (spsr_idx) {
187187
case KVM_SPSR_SVC:
188-
vcpu->arch.ctxt.spsr_el1 = v;
188+
__vcpu_sys_reg(vcpu, SPSR_EL1) = v;
189189
break;
190190
case KVM_SPSR_ABT:
191191
vcpu->arch.ctxt.spsr_abt = v;

0 commit comments

Comments
 (0)