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 <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2025-03-17 16:08:34 +00:00
1 parent 3c0745196c
commit 90ebf9905b
2 files changed
+34 -33

No files matched your search

+34 -1
View File
@@ -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]);
}
}
-32
View File
@@ -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)
{
/*
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.