|
@@ -110,16 +110,13 @@ static void __hyp_text __debug_restore_spe_nvhe(u64 pmscr_el1)
|
|
|
write_sysreg_s(pmscr_el1, SYS_PMSCR_EL1);
|
|
|
}
|
|
|
|
|
|
-void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu,
|
|
|
- struct kvm_guest_debug_arch *dbg,
|
|
|
- struct kvm_cpu_context *ctxt)
|
|
|
+static void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu,
|
|
|
+ struct kvm_guest_debug_arch *dbg,
|
|
|
+ struct kvm_cpu_context *ctxt)
|
|
|
{
|
|
|
u64 aa64dfr0;
|
|
|
int brps, wrps;
|
|
|
|
|
|
- if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
|
|
|
- return;
|
|
|
-
|
|
|
aa64dfr0 = read_sysreg(id_aa64dfr0_el1);
|
|
|
brps = (aa64dfr0 >> 12) & 0xf;
|
|
|
wrps = (aa64dfr0 >> 20) & 0xf;
|
|
@@ -132,16 +129,13 @@ void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu,
|
|
|
ctxt->sys_regs[MDCCINT_EL1] = read_sysreg(mdccint_el1);
|
|
|
}
|
|
|
|
|
|
-void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu,
|
|
|
- struct kvm_guest_debug_arch *dbg,
|
|
|
- struct kvm_cpu_context *ctxt)
|
|
|
+static void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu,
|
|
|
+ struct kvm_guest_debug_arch *dbg,
|
|
|
+ struct kvm_cpu_context *ctxt)
|
|
|
{
|
|
|
u64 aa64dfr0;
|
|
|
int brps, wrps;
|
|
|
|
|
|
- if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
|
|
|
- return;
|
|
|
-
|
|
|
aa64dfr0 = read_sysreg(id_aa64dfr0_el1);
|
|
|
|
|
|
brps = (aa64dfr0 >> 12) & 0xf;
|
|
@@ -155,10 +149,12 @@ void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu,
|
|
|
write_sysreg(ctxt->sys_regs[MDCCINT_EL1], mdccint_el1);
|
|
|
}
|
|
|
|
|
|
-void __hyp_text __debug_cond_save_host_state(struct kvm_vcpu *vcpu)
|
|
|
+void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
- __debug_save_state(vcpu, &vcpu->arch.host_debug_state.regs,
|
|
|
- kern_hyp_va(vcpu->arch.host_cpu_context));
|
|
|
+ struct kvm_cpu_context *host_ctxt;
|
|
|
+ struct kvm_cpu_context *guest_ctxt;
|
|
|
+ struct kvm_guest_debug_arch *host_dbg;
|
|
|
+ struct kvm_guest_debug_arch *guest_dbg;
|
|
|
|
|
|
/*
|
|
|
* Non-VHE: Disable and flush SPE data generation
|
|
@@ -166,15 +162,39 @@ void __hyp_text __debug_cond_save_host_state(struct kvm_vcpu *vcpu)
|
|
|
*/
|
|
|
if (!has_vhe())
|
|
|
__debug_save_spe_nvhe(&vcpu->arch.host_debug_state.pmscr_el1);
|
|
|
+
|
|
|
+ if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
|
|
|
+ return;
|
|
|
+
|
|
|
+ host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
|
|
|
+ guest_ctxt = &vcpu->arch.ctxt;
|
|
|
+ host_dbg = &vcpu->arch.host_debug_state.regs;
|
|
|
+ guest_dbg = kern_hyp_va(vcpu->arch.debug_ptr);
|
|
|
+
|
|
|
+ __debug_save_state(vcpu, host_dbg, host_ctxt);
|
|
|
+ __debug_restore_state(vcpu, guest_dbg, guest_ctxt);
|
|
|
}
|
|
|
|
|
|
-void __hyp_text __debug_cond_restore_host_state(struct kvm_vcpu *vcpu)
|
|
|
+void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
+ struct kvm_cpu_context *host_ctxt;
|
|
|
+ struct kvm_cpu_context *guest_ctxt;
|
|
|
+ struct kvm_guest_debug_arch *host_dbg;
|
|
|
+ struct kvm_guest_debug_arch *guest_dbg;
|
|
|
+
|
|
|
if (!has_vhe())
|
|
|
__debug_restore_spe_nvhe(vcpu->arch.host_debug_state.pmscr_el1);
|
|
|
|
|
|
- __debug_restore_state(vcpu, &vcpu->arch.host_debug_state.regs,
|
|
|
- kern_hyp_va(vcpu->arch.host_cpu_context));
|
|
|
+ if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
|
|
|
+ return;
|
|
|
+
|
|
|
+ host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
|
|
|
+ guest_ctxt = &vcpu->arch.ctxt;
|
|
|
+ host_dbg = &vcpu->arch.host_debug_state.regs;
|
|
|
+ guest_dbg = kern_hyp_va(vcpu->arch.debug_ptr);
|
|
|
+
|
|
|
+ __debug_save_state(vcpu, guest_dbg, guest_ctxt);
|
|
|
+ __debug_restore_state(vcpu, host_dbg, host_ctxt);
|
|
|
|
|
|
vcpu->arch.debug_flags &= ~KVM_ARM64_DEBUG_DIRTY;
|
|
|
}
|