x86/entry/64: Use TASK_SIZE_MAX for canonical RIP test
authorBrian Gerst <brgerst@gmail.com>
Wed, 11 Oct 2023 22:43:50 +0000 (18:43 -0400)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Oct 2023 11:05:28 +0000 (13:05 +0200)
commit58978b44df7276f7c75a2c6aad6c201421cd4daa
tree226adbd1966b01907d4ccf5c2aebc1181a50d253
parentca282b486a570a0bfda5c1a4595ace7fa14243bf
x86/entry/64: Use TASK_SIZE_MAX for canonical RIP test

Using shifts to determine if an address is canonical is difficult for
the compiler to optimize when the virtual address width is variable
(LA57 feature) without using inline assembly.  Instead, compare RIP
against TASK_SIZE_MAX.  The only user executable address outside of that
range is the deprecated vsyscall page, which can fall back to using IRET.

Signed-off-by: Brian Gerst <brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Uros Bizjak <ubizjak@gmail.com>
Link: https://lore.kernel.org/r/20231011224351.130935-3-brgerst@gmail.com
arch/x86/entry/common.c