Skip to content

Commit 82c211e

Browse files
jgross1gregkh
authored andcommitted
x86/xen: don't do PV iret hypercall through hypercall page
commit a2796df upstream. Instead of jumping to the Xen hypercall page for doing the iret hypercall, directly code the required sequence in xen-asm.S. This is done in preparation of no longer using hypercall page at all, as it has shown to cause problems with speculation mitigations. This is part of XSA-466 / CVE-2024-53241. Reported-by: Andrew Cooper <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Jan Beulich <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cd95149 commit 82c211e

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

arch/x86/xen/xen-asm.S

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ SYM_CODE_START(xen_early_idt_handler_array)
176176
SYM_CODE_END(xen_early_idt_handler_array)
177177
__FINIT
178178

179-
hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
180179
/*
181180
* Xen64 iret frame:
182181
*
@@ -186,17 +185,28 @@ hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
186185
* cs
187186
* rip <-- standard iret frame
188187
*
189-
* flags
188+
* flags <-- xen_iret must push from here on
190189
*
191-
* rcx }
192-
* r11 }<-- pushed by hypercall page
193-
* rsp->rax }
190+
* rcx
191+
* r11
192+
* rsp->rax
194193
*/
194+
.macro xen_hypercall_iret
195+
pushq $0 /* Flags */
196+
push %rcx
197+
push %r11
198+
push %rax
199+
mov $__HYPERVISOR_iret, %eax
200+
syscall /* Do the IRET. */
201+
#ifdef CONFIG_MITIGATION_SLS
202+
int3
203+
#endif
204+
.endm
205+
195206
SYM_CODE_START(xen_iret)
196207
UNWIND_HINT_UNDEFINED
197208
ANNOTATE_NOENDBR
198-
pushq $0
199-
jmp hypercall_iret
209+
xen_hypercall_iret
200210
SYM_CODE_END(xen_iret)
201211

202212
/*
@@ -301,8 +311,7 @@ SYM_CODE_START(xen_entry_SYSENTER_compat)
301311
ENDBR
302312
lea 16(%rsp), %rsp /* strip %rcx, %r11 */
303313
mov $-ENOSYS, %rax
304-
pushq $0
305-
jmp hypercall_iret
314+
xen_hypercall_iret
306315
SYM_CODE_END(xen_entry_SYSENTER_compat)
307316
SYM_CODE_END(xen_entry_SYSCALL_compat)
308317

0 commit comments

Comments
 (0)