]> xenbits.xensource.com Git - xen.git/commitdiff
x86/debug: Move activate_debugregs() into debug.c
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Jan 2025 15:19:49 +0000 (15:19 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Mar 2025 16:08:34 +0000 (16:08 +0000)
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>
xen/arch/x86/debug.c
xen/arch/x86/traps.c

index e99e663ba5b98280c3b58c3d97797036f4a38e5d..71755dea6ff2a0822481a30221623f44741def01 100644 (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]);
+    }
+}
index 5addb1f903d3adc5a1b53204a43f8b267f41432e..df1155bfb67311716cc7a2609baae06ce8378760 100644 (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)
 {
     /*