Skip to content

Ensure stack is aligned for kernel entries

Dave Martin kvmarm linux-arm-kernel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest0 of 7 patches 0 repliesNew

Patches in v1 No applies recorded yet

None of the 7 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/7] Ensure stack is aligned for kernel entries
Quoted 39 lines · Ramana Radhakrishnan
Quoted 38 lines · Dave Martin
Quoted 37 lines · Ramana Radhakrishnan
Quoted 23 lines · Ard Biesheuvel

(+ Ramana)

Quoted 20 lines · Julien Thierry
Quoted 16 lines · Ard Biesheuvel
Quoted 6 lines · Julien Thierry

Hi,

Having SCTLR_ELx.SA enabled requires the SP to be 16-bytes aligned before using it to access memory. When taking an exception, it is possible that the context during which the exception occured had SP mis-aligned.

How is this possible? GCC clearly only manipulates the stack pointer in 16 byte multiples, and so if we do the same in our asm code (which I think we already do, given the lack of reports about this issue), is this handling really necessary?

Quoted 8 lines
Quoted 4 lines

Is there anything that actually gives us that guarantee from GCC? I agree that currently it looks like aarch64-<...>-gcc only manipulates SP aligned to 16 bytes, but I don't know whether that is certain.

I think we should get that clarified then. I don't think it makes sense for GCC to have to reason about whether SP currently has a value that permits dereferencing.

The ABI gives that guarantee.

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

<quote>

Surely This only applies at public interfaces?

I don't think this has anything to do with public interfaces. If there is a trap with a 16byte misaligned access of the SP then it doesn't matter whether it's a public interface or not.

We're not talking about SP alignment faults here particluarly.

We're talking about any exception that may be taken from EL1h to EL1h, which may happen on random instructions inside a function, for random reasons.

There was talk about running the kernel mostly in EL1t but I don't think we currently do this (somebody please put me right if I'm wrong here!)

Cheers
---Dave