Skip to contentSkip to conversation

x86/entry: Remove UNTRAIN_RET from native_irq_return_ldt

PATCH In review Alexandre Chartre 2 participants 2 messages Jul 13, 2022 – Jul 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/entry: Remove UNTRAIN_RET from native_irq_return_ldt

UNTRAIN_RET is not needed in native_irq_return_ldt because ret untrain has already be done at this point. In addition, when the RETBleed mitigation is IBPB, UNTRAIN_RET clobbers several registers (AX, CX, DX) so here it trashes user values which are in these registers.

---
 arch/x86/entry/entry_64.S | 1 -
 1 file changed, 1 deletion(-)
arch/x86/entry/entry_64.S +0 -1
index 285e043a3e40..9953d966d124 100644
@@ -727,7 +727,6 @@ native_irq_return_ldt:
 	pushq	%rdi				/* Stash user RDI */
 	swapgs					/* to kernel GS */
 	SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi	/* to kernel CR3 */
-	UNTRAIN_RET
 
 	movq	PER_CPU_VAR(espfix_waddr), %rdi
 	movq	%rax, (0*8)(%rdi)		/* user RAX */
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Alexandre Chartre

UNTRAIN_RET is not needed in native_irq_return_ldt because ret untrain has already be done at this point. In addition, when the RETBleed mitigation is IBPB, UNTRAIN_RET clobbers several registers (AX, CX, DX) so here it trashes user values which are in these registers.

Quoted 19 lines
---
 arch/x86/entry/entry_64.S | 1 -
 1 file changed, 1 deletion(-)
arch/x86/entry/entry_64.S +0 -1
index 285e043a3e40..9953d966d124 100644
@@ -727,7 +727,6 @@ native_irq_return_ldt:
 	pushq	%rdi				/* Stash user RDI */
 	swapgs					/* to kernel GS */
 	SWITCH_TO_KERNEL_CR3 scratch_reg=%rdi	/* to kernel CR3 */
-	UNTRAIN_RET
 
 	movq	PER_CPU_VAR(espfix_waddr), %rdi
 	movq	%rax, (0*8)(%rdi)		/* user RAX */
Signature · 1 line
2.31.1