[PATCH] arm: kprobes: Align stack to 8-bytes in test code

Jon Medhurst (Tixy) tixy at linaro.org
Fri Mar 17 10:50:49 PDT 2017


On Fri, 2017-03-17 at 15:05 +0000, Russell King - ARM Linux wrote
[...]
> I suspect we're into compiler behavioural differences, which can't be
> relied upon, so I guess we do need to do something in
> __kprobes_test_case_start() to work around it.
> 
> I'd do:
> 
> 	mov	ip, sp
> 	tst	sp, #4
> 	subeq	sp, sp, #4		@ need to mis-align as we don't save
> 	stmfd	sp!, {r4 - r11, ip}	@ an even number of registers to end
> 	sub	sp, sp, #size		@ up with an aligned stack here
> 
> and when restoring:
> 
> 	add	ip, sp, #size
> 	ldmfd	ip, {r4 - r11, sp}
> 	bx	r0

Thumb doesn't allow a lot of operations with SP (like that 'tst sp, #4'
or having SP in the reg list for LDM) which is why I ended up producing
slightly convoluted code. Some of these are deprecated for ARM too,
which means they might not be supported on newer architecture versions,
oh joy.

-- 
Tixy



More information about the linux-arm-kernel mailing list