Skip to contentSkip to conversation

x86/boot: enable NMIs during cpu_init()

PATCH In review Sergey Dyasli 2 participants 2 messages Oct 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: enable NMIs during cpu_init()

In certain scenarios, NMIs might be disabled during Xen boot process. Such situation will cause alternative_instructions() to:

    panic("Timed out waiting for alternatives self-NMI to hit");

This bug was originally seen when using tboot to boot Xen. To prevent this from happening, enable NMIs during cpu_init().

---
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/cpu/common.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/cpu/common.c +2 -0
index 057859ab14..09fbd98764 100644
@@ -819,6 +819,8 @@ void cpu_init(void)
 #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
+
+	enable_nmis();
 }
 
 void cpu_uninit(unsigned int cpu)
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 22 lines · Sergey Dyasli

In certain scenarios, NMIs might be disabled during Xen boot process. Such situation will cause alternative_instructions() to:

    panic("Timed out waiting for alternatives self-NMI to hit");

This bug was originally seen when using tboot to boot Xen. To prevent this from happening, enable NMIs during cpu_init().

---
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/cpu/common.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/cpu/common.c +0 -0
index 057859ab14..09fbd98764 100644

xen/arch/x86/cpu/common.c void cpu_init(void) · line 822

Quoted 4 lines
xen/arch/x86/cpu/common.c +1 -0
@@ -819,6 +819,8 @@ void cpu_init(void)
 #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
+

I'd add

/* Re-enable NMIs in case our loader (e.g. Tboot) has left them disabled. */

or there is a chance people might try and take these out again.

xen/arch/x86/cpu/common.c void cpu_init(void) · line 826

Quoted 4 lines
xen/arch/x86/cpu/common.c +1 -0
+	enable_nmis();
 }
 
 void cpu_uninit(unsigned int cpu)

This is actually very late in the BSP path.  I'd insert another one immediately after /* Full exception support from here on in. */ in __start_xen()

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel