Skip to content

Commit f5e3068

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move __adjust_pc out of line
In order to make it easy to call __adjust_pc() from the EL1 code (in the case of nVHE), rename it to __kvm_adjust_pc() and move it out of line. No expected functional change. Reviewed-by: Alexandru Elisei <[email protected]> Reviewed-by: Zenghui Yu <[email protected]> Tested-by: Zenghui Yu <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] # 5.11
1 parent 3fdc15f commit f5e3068

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

arch/arm64/include/asm/kvm_asm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ extern void __kvm_timer_set_cntvoff(u64 cntvoff);
201201

202202
extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
203203

204+
extern void __kvm_adjust_pc(struct kvm_vcpu *vcpu);
205+
204206
extern u64 __vgic_v3_get_gic_config(void);
205207
extern u64 __vgic_v3_read_vmcr(void);
206208
extern void __vgic_v3_write_vmcr(u32 vmcr);

arch/arm64/kvm/hyp/exception.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static void enter_exception32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
296296
*vcpu_pc(vcpu) = vect_offset;
297297
}
298298

299-
void kvm_inject_exception(struct kvm_vcpu *vcpu)
299+
static void kvm_inject_exception(struct kvm_vcpu *vcpu)
300300
{
301301
if (vcpu_el1_is_32bit(vcpu)) {
302302
switch (vcpu->arch.flags & KVM_ARM64_EXCEPT_MASK) {
@@ -329,3 +329,19 @@ void kvm_inject_exception(struct kvm_vcpu *vcpu)
329329
}
330330
}
331331
}
332+
333+
/*
334+
* Adjust the guest PC on entry, depending on flags provided by EL1
335+
* for the purpose of emulation (MMIO, sysreg) or exception injection.
336+
*/
337+
void __kvm_adjust_pc(struct kvm_vcpu *vcpu)
338+
{
339+
if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) {
340+
kvm_inject_exception(vcpu);
341+
vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION |
342+
KVM_ARM64_EXCEPT_MASK);
343+
} else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) {
344+
kvm_skip_instr(vcpu);
345+
vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC;
346+
}
347+
}

arch/arm64/kvm/hyp/include/hyp/adjust_pc.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <asm/kvm_emulate.h>
1414
#include <asm/kvm_host.h>
1515

16-
void kvm_inject_exception(struct kvm_vcpu *vcpu);
17-
1816
static inline void kvm_skip_instr(struct kvm_vcpu *vcpu)
1917
{
2018
if (vcpu_mode_is_32bit(vcpu)) {
@@ -43,22 +41,6 @@ static inline void __kvm_skip_instr(struct kvm_vcpu *vcpu)
4341
write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR);
4442
}
4543

46-
/*
47-
* Adjust the guest PC on entry, depending on flags provided by EL1
48-
* for the purpose of emulation (MMIO, sysreg) or exception injection.
49-
*/
50-
static inline void __adjust_pc(struct kvm_vcpu *vcpu)
51-
{
52-
if (vcpu->arch.flags & KVM_ARM64_PENDING_EXCEPTION) {
53-
kvm_inject_exception(vcpu);
54-
vcpu->arch.flags &= ~(KVM_ARM64_PENDING_EXCEPTION |
55-
KVM_ARM64_EXCEPT_MASK);
56-
} else if (vcpu->arch.flags & KVM_ARM64_INCREMENT_PC) {
57-
kvm_skip_instr(vcpu);
58-
vcpu->arch.flags &= ~KVM_ARM64_INCREMENT_PC;
59-
}
60-
}
61-
6244
/*
6345
* Skip an instruction while host sysregs are live.
6446
* Assumes host is always 64-bit.

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* Author: Marc Zyngier <[email protected]>
55
*/
66

7-
#include <hyp/adjust_pc.h>
87
#include <hyp/switch.h>
98
#include <hyp/sysreg-sr.h>
109

@@ -201,7 +200,7 @@ int __kvm_vcpu_run(struct kvm_vcpu *vcpu)
201200
*/
202201
__debug_save_host_buffers_nvhe(vcpu);
203202

204-
__adjust_pc(vcpu);
203+
__kvm_adjust_pc(vcpu);
205204

206205
/*
207206
* We must restore the 32-bit state before the sysregs, thanks

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* Author: Marc Zyngier <[email protected]>
55
*/
66

7-
#include <hyp/adjust_pc.h>
87
#include <hyp/switch.h>
98

109
#include <linux/arm-smccc.h>
@@ -132,7 +131,7 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
132131
__load_guest_stage2(vcpu->arch.hw_mmu);
133132
__activate_traps(vcpu);
134133

135-
__adjust_pc(vcpu);
134+
__kvm_adjust_pc(vcpu);
136135

137136
sysreg_restore_guest_state_vhe(guest_ctxt);
138137
__debug_switch_to_guest(vcpu);

0 commit comments

Comments
 (0)