x86/debug: Move activate_debugregs() into debug.c
PATCH 1/1 x86/debug: Move activate_debugregs() into debug.c
We have since gained a better location for it to live.
Fix up the includes while doing so. I don't recall why we had kernel.h but it's definitely stale now.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/debug.c | 35 ++++++++++++++++++++++++++++++++++- xen/arch/x86/traps.c | 32 -------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-)
xen/arch/x86/debug.c +34 -1
@@ -3,10 +3,11 @@* Copyright (C) 2023 XenServer. */ #include <xen/bug.h> -#include <xen/kernel.h> +#include <xen/sched.h> #include <xen/lib/x86/cpu-policy.h> +#include <asm/current.h> #include <asm/debugreg.h> /*
@@ -84,3 +85,35 @@ unsigned int x86_adj_dr7_rsvd(const struct cpu_policy *p, unsigned int dr7)return dr7; } + +void activate_debugregs (const struct vcpu *curr) +{ +ASSERT (curr == current); + +write_debugreg (0 , curr->arch.dr[0 ]); +write_debugreg (1 , curr->arch.dr[1 ]); +write_debugreg (2 , curr->arch.dr[2 ]); +write_debugreg (3 , curr->arch.dr[3 ]); +write_debugreg (6 , curr->arch.dr6); + +/* +* Avoid writing the subsequently getting replaced value when getting +* called from set_debugreg() below. Eventual future callers will need +* to take this into account. +*/ +if ( curr->arch.dr7 &DR7_ACTIVE_MASK ) +write_debugreg (7 , curr->arch.dr7); + +/* +* Both the PV and HVM paths leave stale DR_MASK values in hardware on +* context-switch-out. If we're activating %dr7 for the guest, we must +* sync the DR_MASKs too, whether or not the guest can see them. +*/ +if (boot_cpu_has (X86_FEATURE_DBEXT ) ) + { +wrmsrl (MSR_AMD64_DR0_ADDRESS_MASK , curr->arch.msrs->dr_mask[0 ]); +wrmsrl (MSR_AMD64_DR1_ADDRESS_MASK , curr->arch.msrs->dr_mask[1 ]); +wrmsrl (MSR_AMD64_DR2_ADDRESS_MASK , curr->arch.msrs->dr_mask[2 ]); +wrmsrl (MSR_AMD64_DR3_ADDRESS_MASK , curr->arch.msrs->dr_mask[3 ]); + } +}
xen/arch/x86/traps.c +0 -32
@@ -1942,38 +1942,6 @@ void __init trap_init(void)cpu_init (); } -void activate_debugregs (const struct vcpu *curr) -{ -ASSERT (curr == current); - -write_debugreg (0 , curr->arch.dr[0 ]); -write_debugreg (1 , curr->arch.dr[1 ]); -write_debugreg (2 , curr->arch.dr[2 ]); -write_debugreg (3 , curr->arch.dr[3 ]); -write_debugreg (6 , curr->arch.dr6); - -/* -* Avoid writing the subsequently getting replaced value when getting -* called from set_debugreg() below. Eventual future callers will need -* to take this into account. -*/ -if ( curr->arch.dr7 &DR7_ACTIVE_MASK ) -write_debugreg (7 , curr->arch.dr7); - -/* -* Both the PV and HVM paths leave stale DR_MASK values in hardware on -* context-switch-out. If we're activating %dr7 for the guest, we must -* sync the DR_MASKs too, whether or not the guest can see them. -*/ -if (boot_cpu_has (X86_FEATURE_DBEXT ) ) - { -wrmsrl (MSR_AMD64_DR0_ADDRESS_MASK , curr->arch.msrs->dr_mask[0 ]); -wrmsrl (MSR_AMD64_DR1_ADDRESS_MASK , curr->arch.msrs->dr_mask[1 ]); -wrmsrl (MSR_AMD64_DR2_ADDRESS_MASK , curr->arch.msrs->dr_mask[2 ]); -wrmsrl (MSR_AMD64_DR3_ADDRESS_MASK , curr->arch.msrs->dr_mask[3 ]); - } -} -void asm_domain_crash_synchronous (unsigned long addr) {/*
Signature · 1 line
2.39.5
Quoted 8 lines · Andrew Cooper
We have since gained a better location for it to live.
Fix up the includes while doing so. I don't recall why we had
kernel.hbut it's definitely stale now.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Reviewed-by Jan Beulich <[email protected]>