Re: [PATCHv9 11/16] x86/traps: Communicate a LASS violation in #GP message
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2025-07-09 09:43:24
Also in:
linux-efi, linux-mm, lkml
Hi Kirill, On Wed, 9 Jul 2025 at 11:31, Kirill A. Shutemov [off-list ref] wrote:
On Tue, Jul 08, 2025 at 07:40:35PM -0700, Sohil Mehta wrote:quoted
quoted
@@ -664,14 +673,23 @@ static enum kernel_gp_hint get_kernel_gp_address(struct pt_regs *regs, return GP_NO_HINT; #ifdef CONFIG_X86_64Might as well get rid of the #ifdef in C code, if possible. if (!IS_ENABLED(CONFIG_X86_64) return GP_CANONICAL; or combine it with the next check.I tried this before. It triggers compiler error on 32-bit: arch/x86/kernel/traps.c:673:16: error: shift count >= width of type [-Werror,-Wshift-count-overflow] 673 | if (*addr >= ~__VIRTUAL_MASK) | ^~~~~~~~~~~~~~ __VIRTUAL_MASK is not usable on 32-bit configs.
arch/x86/include/asm/page_32_types.h:#define __VIRTUAL_MASK_SHIFT 32
arch/x86/include/asm/page_32_types.h:#define __VIRTUAL_MASK_SHIFT 32
arch/x86/include/asm/page_64_types.h:#define __VIRTUAL_MASK_SHIFT
(pgtable_l5_enabled() ? 56 : 47)
arch/x86/include/asm/page_types.h:#define __VIRTUAL_MASK
((1UL << __VIRTUAL_MASK_SHIFT) - 1)
Given __VIRTUAL_MASK_SHIFT is 32 on 32-bit platforms, perhaps
__VIRTUAL_MASK should just be changed to shift 1ULL instead?
Or better, use GENMASK(__VIRTUAL_MASK_SHIFT - 1, 0), so the
resulting type is still unsigned long.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds