]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/boot: Initialise the debug registers correctly
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Nov 2018 14:02:59 +0000 (15:02 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 5 Nov 2018 14:02:59 +0000 (15:02 +0100)
In particular, initialising %dr6 with the value 0 is buggy, because on
hardware supporting Transactional Memory, it will cause the sticky RTM bit to
be asserted, even though a debug exception from a transaction hasn't actually
been observed.

Move X86_DR6_DEFAULT into x86-defns.h along with the other architectural
register constants, and introduce a new X86_DR7_DEFAULT.  Use the existing
write_debugreg() helper, rather than opencoded inline assembly.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: 721da6d41a70fe08b3fcd9c31a62f6709a54c6ba
master date: 2018-10-24 14:43:05 +0100

xen/arch/x86/cpu/common.c
xen/include/asm-x86/debugreg.h
xen/include/asm-x86/x86-defns.h

index 72e65b6e1a6eb09383a46f52980904d31ebab330..1d21ff9467e72c17dbf92da241df891bd5d0a128 100644 (file)
@@ -3,6 +3,7 @@
 #include <xen/delay.h>
 #include <xen/smp.h>
 #include <asm/current.h>
+#include <asm/debugreg.h>
 #include <asm/processor.h>
 #include <asm/xstate.h>
 #include <asm/msr.h>
@@ -827,10 +828,13 @@ void cpu_init(void)
        /* Ensure FPU gets initialised for each domain. */
        stts();
 
-       /* Clear all 6 debug registers: */
-#define CD(register) asm volatile ( "mov %0,%%db" #register : : "r"(0UL) );
-       CD(0); CD(1); CD(2); CD(3); /* no db4 and db5 */; CD(6); CD(7);
-#undef CD
+       /* Reset debug registers: */
+       write_debugreg(0, 0);
+       write_debugreg(1, 0);
+       write_debugreg(2, 0);
+       write_debugreg(3, 0);
+       write_debugreg(6, X86_DR6_DEFAULT);
+       write_debugreg(7, X86_DR7_DEFAULT);
 
        /* Enable NMIs.  Our loader (e.g. Tboot) may have left them disabled. */
        enable_nmis();
index b3b10eaf40c10716f3f79f80858ab1be44c1bea5..c57914efc6e81eac5f6c948cf26f374c68a930ca 100644 (file)
@@ -24,8 +24,6 @@
 #define DR_STATUS_RESERVED_ZERO (~0xffffeffful) /* Reserved, read as zero */
 #define DR_STATUS_RESERVED_ONE  0xffff0ff0ul /* Reserved, read as one */
 
-#define X86_DR6_DEFAULT 0xffff0ff0ul    /* Default %dr6 value. */
-
 /* Now define a bunch of things for manipulating the control register.
    The top two bytes of the control register consist of 4 fields of 4
    bits - each field corresponds to one of the four debug registers,
index 904041e1ab60e21967d502ad2c7fe37701f6c51f..b80bbd80ad5dcf6e772098d30fdd37c8ff56bdb3 100644 (file)
 #define X86_XCR0_LWP_POS          62
 #define X86_XCR0_LWP              (1ULL << X86_XCR0_LWP_POS)
 
+/*
+ * Debug status flags in DR6.
+ */
+#define X86_DR6_DEFAULT         0xffff0ff0  /* Default %dr6 value. */
+
+/*
+ * Debug control flags in DR7.
+ */
+#define X86_DR7_DEFAULT         0x00000400  /* Default %dr7 value. */
+
 #endif /* __XEN_X86_DEFNS_H__ */