On 7/26/23 01:17, Ard Biesheuvel wrote:
While working on some EFI boot changes for Linux/x86, I noticed that TCG
deviates from
bare metal when it comes to how it handles the value of the stack pointer
register RSP
when dropping out of long mode.
On bare metal, RSP is truncated to 32 bits, even if the code that runs in 32-bit
protected mode never uses the stack at all (and uses a long jump rather than
long
return to switch back to long mode). This means 64-bit code cannot rely on RSP
surviving any excursions into 32-bit protected mode (with paging disabled).
Let's align TCG with this behavior, so that code that relies on RSP retaining
its value
does not inadvertently work while bare metal does not.
Observed on Intel Ice Lake cores.
Cc: Paolo Bonzini<pbonz...@redhat.com> Cc: Richard
Henderson<richard.hender...@linaro.org> Cc: Eduardo Habkost<edua...@habkost.net>
Link:https://lore.kernel.org/all/20230711091453.2543622-11-a...@kernel.org/
Signed-off-by: Ard Biesheuvel<a...@kernel.org> --- I used this patch locally to
reproduce an issue that was reported on Ice Lake but didn't trigger in my QEMU
testing.
Hints welcome on where the architectural behavior is specified, and in
particular,
whether or not other 64-bit GPRs can be relied upon to preserve their full
64-bit
length values.
No idea about chapter and verse, but it has the feel of being part and parcel
with the
truncation of eip. While esp is always special, I suspect that none of the GPRs can be
relied on carrying all bits.
I'm happy with the change though, since similar behaviour can be observed on hw.
Acked-by: Richard Henderson <richard.hender...@linaro.org>
r~