]> xenbits.xensource.com Git - xen.git/commitdiff
xen/x86: Implement enable_nmis() in C
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 15 Mar 2018 16:15:45 +0000 (16:15 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 15 Mar 2018 17:40:41 +0000 (17:40 +0000)
I don't recall why I chose to implement this in assembly to begin with, but
it can happily live in a static inline instead, and only has two callers.

Doing so reduces the quantity of code in .text.entry.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/x86_64/entry.S
xen/include/asm-x86/processor.h

index f4e1b805fbdfa5d306a5ae7e34328497e0ae547a..f6ba31c4e20b70872fe4be012b359c90ad07b5d5 100644 (file)
@@ -854,22 +854,6 @@ ENTRY(machine_check)
         movl  $TRAP_machine_check,4(%rsp)
         jmp   handle_ist_exception
 
-/* Enable NMIs.  No special register assumptions. Only %rax is not preserved. */
-ENTRY(enable_nmis)
-        movq  %rsp, %rax /* Grab RSP before pushing */
-
-        /* Set up stack frame */
-        pushq $0               /* SS */
-        pushq %rax             /* RSP */
-        pushfq                 /* RFLAGS */
-        pushq $__HYPERVISOR_CS /* CS */
-        leaq  1f(%rip),%rax
-        pushq %rax             /* RIP */
-
-        iretq /* Disable the hardware NMI latch */
-1:
-        retq
-
 /* No op trap handler.  Required for kexec crash path. */
 GLOBAL(trap_nop)
         iretq
index 01bc89f46c7badb354db2e5ed417fff2b3cbf198..db9988ab335c1565fafb6dd40fea93b35b039b84 100644 (file)
@@ -498,7 +498,23 @@ DECLARE_TRAP_HANDLER(entry_int82);
 #undef DECLARE_TRAP_HANDLER
 
 void trap_nop(void);
-void enable_nmis(void);
+
+static inline void enable_nmis(void)
+{
+    unsigned long tmp;
+
+    asm volatile ( "mov %%rsp, %[tmp]     \n\t"
+                   "push %[ss]            \n\t"
+                   "push %[tmp]           \n\t"
+                   "pushf                 \n\t"
+                   "push %[cs]            \n\t"
+                   "lea 1f(%%rip), %[tmp] \n\t"
+                   "push %[tmp]           \n\t"
+                   "iretq; 1:             \n\t"
+                   : [tmp] "=&r" (tmp)
+                   : [ss] "i" (__HYPERVISOR_DS),
+                     [cs] "i" (__HYPERVISOR_CS) );
+}
 
 void sysenter_entry(void);
 void sysenter_eflags_saved(void);