Skip to content

Commit

Permalink
x86/ia32: State that IA32 emulation is disabled
Browse files Browse the repository at this point in the history
Issue a short message once, on the first try to load a 32-bit process to
save people time when wondering why it won't load and trying to execute
it, would say:

  -bash: ./strsep32: cannot execute binary file: Exec format error

Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Reviewed-by: Nikolay Borisov <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
bp3tk0v committed Dec 11, 2023
1 parent 79c603e commit f789383
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/x86/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ do { \
((x)->e_machine == EM_X86_64)

#define compat_elf_check_arch(x) \
((elf_check_arch_ia32(x) && ia32_enabled()) || \
((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \
(IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64))

static inline void elf_common_init(struct thread_struct *t,
Expand Down
11 changes: 10 additions & 1 deletion arch/x86/include/asm/ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#ifndef _ASM_X86_IA32_H
#define _ASM_X86_IA32_H


#ifdef CONFIG_IA32_EMULATION

#include <linux/compat.h>
Expand Down Expand Up @@ -84,4 +83,14 @@ static inline bool ia32_enabled(void)

#endif

static inline bool ia32_enabled_verbose(void)
{
bool enabled = ia32_enabled();

if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled)
pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n");

return enabled;
}

#endif /* _ASM_X86_IA32_H */

0 comments on commit f789383

Please sign in to comment.