KVM: arm64: introduce vcpu->arch.debug_ptr
This introduces a level of indirection for the debug registers. Instead of using the sys_regs[] directly we store registers in a structure in the vcpu. The new kvm_arm_reset_debug_ptr() sets the debug ptr to the guest context. Because we no longer give the sys_regs offset for the sys_reg_desc->reg field, but instead the index into a debug-specific struct we need to add a number of additional trap functions for each register. Also as the generic generic user-space access code no longer works we have introduced a new pair of function pointers to the sys_reg_desc structure to override the generic code when needed. Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
This commit is contained in:

committed by
Marc Zyngier

parent
e0a1b9a937
commit
84e690bfbe
@@ -596,6 +596,7 @@ __restore_sysregs:
|
||||
/* Save debug state */
|
||||
__save_debug:
|
||||
// x2: ptr to CPU context
|
||||
// x3: ptr to debug reg struct
|
||||
// x4/x5/x6-22/x24-26: trashed
|
||||
|
||||
mrs x26, id_aa64dfr0_el1
|
||||
@@ -606,15 +607,15 @@ __save_debug:
|
||||
sub w25, w26, w25 // How many WPs to skip
|
||||
|
||||
mov x5, x24
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGBCR0_EL1)
|
||||
add x4, x3, #DEBUG_BCR
|
||||
save_debug dbgbcr
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGBVR0_EL1)
|
||||
add x4, x3, #DEBUG_BVR
|
||||
save_debug dbgbvr
|
||||
|
||||
mov x5, x25
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGWCR0_EL1)
|
||||
add x4, x3, #DEBUG_WCR
|
||||
save_debug dbgwcr
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGWVR0_EL1)
|
||||
add x4, x3, #DEBUG_WVR
|
||||
save_debug dbgwvr
|
||||
|
||||
mrs x21, mdccint_el1
|
||||
@@ -624,6 +625,7 @@ __save_debug:
|
||||
/* Restore debug state */
|
||||
__restore_debug:
|
||||
// x2: ptr to CPU context
|
||||
// x3: ptr to debug reg struct
|
||||
// x4/x5/x6-22/x24-26: trashed
|
||||
|
||||
mrs x26, id_aa64dfr0_el1
|
||||
@@ -634,15 +636,15 @@ __restore_debug:
|
||||
sub w25, w26, w25 // How many WPs to skip
|
||||
|
||||
mov x5, x24
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGBCR0_EL1)
|
||||
add x4, x3, #DEBUG_BCR
|
||||
restore_debug dbgbcr
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGBVR0_EL1)
|
||||
add x4, x3, #DEBUG_BVR
|
||||
restore_debug dbgbvr
|
||||
|
||||
mov x5, x25
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGWCR0_EL1)
|
||||
add x4, x3, #DEBUG_WCR
|
||||
restore_debug dbgwcr
|
||||
add x4, x2, #CPU_SYSREG_OFFSET(DBGWVR0_EL1)
|
||||
add x4, x3, #DEBUG_WVR
|
||||
restore_debug dbgwvr
|
||||
|
||||
ldr x21, [x2, #CPU_SYSREG_OFFSET(MDCCINT_EL1)]
|
||||
@@ -682,6 +684,7 @@ ENTRY(__kvm_vcpu_run)
|
||||
bl __save_sysregs
|
||||
|
||||
compute_debug_state 1f
|
||||
add x3, x0, #VCPU_HOST_DEBUG_STATE
|
||||
bl __save_debug
|
||||
1:
|
||||
activate_traps
|
||||
@@ -697,6 +700,8 @@ ENTRY(__kvm_vcpu_run)
|
||||
bl __restore_fpsimd
|
||||
|
||||
skip_debug_state x3, 1f
|
||||
ldr x3, [x0, #VCPU_DEBUG_PTR]
|
||||
kern_hyp_va x3
|
||||
bl __restore_debug
|
||||
1:
|
||||
restore_guest_32bit_state
|
||||
@@ -717,6 +722,8 @@ __kvm_vcpu_return:
|
||||
bl __save_sysregs
|
||||
|
||||
skip_debug_state x3, 1f
|
||||
ldr x3, [x0, #VCPU_DEBUG_PTR]
|
||||
kern_hyp_va x3
|
||||
bl __save_debug
|
||||
1:
|
||||
save_guest_32bit_state
|
||||
@@ -739,6 +746,7 @@ __kvm_vcpu_return:
|
||||
// already been saved. Note that we nuke the whole 64bit word.
|
||||
// If we ever add more flags, we'll have to be more careful...
|
||||
str xzr, [x0, #VCPU_DEBUG_FLAGS]
|
||||
add x3, x0, #VCPU_HOST_DEBUG_STATE
|
||||
bl __restore_debug
|
||||
1:
|
||||
restore_host_regs
|
||||
|
Reference in New Issue
Block a user