0095-xen-x86-entry-64-Add-xen-NMI-trap-entry.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. From 47b64e9de8bba4e6ccd0976bce6cf99446daf82e Mon Sep 17 00:00:00 2001
  2. From: Juergen Gross <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:59:07 -0700
  4. Subject: [PATCH 095/242] xen, x86/entry/64: Add xen NMI trap entry
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Instead of trying to execute any NMI via the bare metal's NMI trap
  10. handler use a Xen specific one for PV domains, like we do for e.g.
  11. debug traps. As in a PV domain the NMI is handled via the normal
  12. kernel stack this is the correct thing to do.
  13. This will enable us to get rid of the very fragile and questionable
  14. dependencies between the bare metal NMI handler and Xen assumptions
  15. believed to be broken anyway.
  16. Signed-off-by: Juergen Gross <[email protected]>
  17. Signed-off-by: Andy Lutomirski <[email protected]>
  18. Cc: Borislav Petkov <[email protected]>
  19. Cc: Brian Gerst <[email protected]>
  20. Cc: Dave Hansen <[email protected]>
  21. Cc: Linus Torvalds <[email protected]>
  22. Cc: Peter Zijlstra <[email protected]>
  23. Cc: Thomas Gleixner <[email protected]>
  24. Link: http://lkml.kernel.org/r/5baf5c0528d58402441550c5770b98e7961e7680.1509609304.git.luto@kernel.org
  25. Signed-off-by: Ingo Molnar <[email protected]>
  26. (cherry picked from commit 43e4111086a70c78bedb6ad990bee97f17b27a6e)
  27. Signed-off-by: Andy Whitcroft <[email protected]>
  28. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  29. (cherry picked from commit 20c970e03b42141abf6c45938ce6d4fdc3555921)
  30. Signed-off-by: Fabian Grünbichler <[email protected]>
  31. ---
  32. arch/x86/include/asm/traps.h | 2 +-
  33. arch/x86/xen/enlighten_pv.c | 2 +-
  34. arch/x86/entry/entry_64.S | 2 +-
  35. arch/x86/xen/xen-asm_64.S | 2 +-
  36. 4 files changed, 4 insertions(+), 4 deletions(-)
  37. diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
  38. index 8e5bf86f87e5..b052a7621ca1 100644
  39. --- a/arch/x86/include/asm/traps.h
  40. +++ b/arch/x86/include/asm/traps.h
  41. @@ -55,9 +55,9 @@ asmlinkage void simd_coprocessor_error(void);
  42. #if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
  43. asmlinkage void xen_divide_error(void);
  44. +asmlinkage void xen_xennmi(void);
  45. asmlinkage void xen_xendebug(void);
  46. asmlinkage void xen_xenint3(void);
  47. -asmlinkage void xen_nmi(void);
  48. asmlinkage void xen_overflow(void);
  49. asmlinkage void xen_bounds(void);
  50. asmlinkage void xen_invalid_op(void);
  51. diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
  52. index 69b9deff7e5c..8da4eff19c2a 100644
  53. --- a/arch/x86/xen/enlighten_pv.c
  54. +++ b/arch/x86/xen/enlighten_pv.c
  55. @@ -600,7 +600,7 @@ static struct trap_array_entry trap_array[] = {
  56. #ifdef CONFIG_X86_MCE
  57. { machine_check, xen_machine_check, true },
  58. #endif
  59. - { nmi, xen_nmi, true },
  60. + { nmi, xen_xennmi, true },
  61. { overflow, xen_overflow, false },
  62. #ifdef CONFIG_IA32_EMULATION
  63. { entry_INT80_compat, xen_entry_INT80_compat, false },
  64. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  65. index 4eff3aca54ed..5a6aba7cf3bd 100644
  66. --- a/arch/x86/entry/entry_64.S
  67. +++ b/arch/x86/entry/entry_64.S
  68. @@ -1091,6 +1091,7 @@ idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
  69. idtentry stack_segment do_stack_segment has_error_code=1
  70. #ifdef CONFIG_XEN
  71. +idtentry xennmi do_nmi has_error_code=0
  72. idtentry xendebug do_debug has_error_code=0
  73. idtentry xenint3 do_int3 has_error_code=0
  74. #endif
  75. @@ -1253,7 +1254,6 @@ ENTRY(error_exit)
  76. END(error_exit)
  77. /* Runs on exception stack */
  78. -/* XXX: broken on Xen PV */
  79. ENTRY(nmi)
  80. UNWIND_HINT_IRET_REGS
  81. /*
  82. diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
  83. index dae2cc33afb5..286ecc198562 100644
  84. --- a/arch/x86/xen/xen-asm_64.S
  85. +++ b/arch/x86/xen/xen-asm_64.S
  86. @@ -29,7 +29,7 @@ xen_pv_trap debug
  87. xen_pv_trap xendebug
  88. xen_pv_trap int3
  89. xen_pv_trap xenint3
  90. -xen_pv_trap nmi
  91. +xen_pv_trap xennmi
  92. xen_pv_trap overflow
  93. xen_pv_trap bounds
  94. xen_pv_trap invalid_op
  95. --
  96. 2.14.2