Commit efe1691a authored by Rohan McLure's avatar Rohan McLure Committed by Michael Ellerman
Browse files

powerpc/64e: Clear gprs on interrupt routine entry on Book3E



Zero GPRS r14-r31 on entry into the kernel for interrupt sources to
limit influence of user-space values in potential speculation gadgets.
Prior to this commit, all other GPRS are reassigned during the common
prologue to interrupt handlers and so need not be zeroised explicitly.

This may be done safely, without loss of register state prior to the
interrupt, as the common prologue saves the initial values of
non-volatiles, which are unconditionally restored in interrupt_64.S.
Mitigation defaults to enabled by INTERRUPT_SANITIZE_REGISTERS.

Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarRohan McLure <rmclure@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221201071019.1953023-6-rmclure@linux.ibm.com
parent 1df45d78
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -358,7 +358,6 @@ ret_from_mc_except:
	std	r14,PACA_EXMC+EX_R14(r13);				    \
	std	r15,PACA_EXMC+EX_R15(r13)


/* Core exception code for all exceptions except TLB misses. */
#define EXCEPTION_COMMON_LVL(n, scratch, excf)				    \
exc_##n##_common:							    \
@@ -394,7 +393,8 @@ exc_##n##_common: \
	std	r12,STACK_INT_FRAME_MARKER(r1); /* mark the frame */	    \
	std	r3,_TRAP(r1);		/* set trap number		*/  \
	std	r0,RESULT(r1);		/* clear regs->result */	    \
	SAVE_NVGPRS(r1);
	SAVE_NVGPRS(r1);						    \
	SANITIZE_NVGPRS();		/* minimise speculation influence */

#define EXCEPTION_COMMON(n) \
	EXCEPTION_COMMON_LVL(n, SPRN_SPRG_GEN_SCRATCH, PACA_EXGEN)