Skip to content

Commit b029628

Browse files
ebiedermkees
authored andcommitted
alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support
Richard Henderson <richard.henderson@linaro.org> writes[1]: > There was a Spec benchmark (I forget which) which was memory bound and ran > twice as fast with 32-bit pointers. > > I copied the idea from DEC to the ELF abi, but never did all the other work > to allow the toolchain to take advantage. > > Amusingly, a later Spec changed the benchmark data sets to not fit into a > 32-bit address space, specifically because of this. > > I expect one could delete the ELF bit and personality and no one would > notice. Not even the 10 remaining Alpha users. In [2] it was pointed out that parts of setarch weren't working properly on alpha because it has it's own SET_PERSONALITY implementation. In the discussion that followed Richard Henderson pointed out that the 32bit pointer support for alpha was never completed. Fix this by removing alpha's 32bit pointer support. As a bit of paranoia refuse to execute any alpha binaries that have the EF_ALPHA_32BIT flag set. Just in case someone somewhere has binaries that try to use alpha's 32bit pointer support. Link: https://lkml.kernel.org/r/CAFXwXrkgu=4Qn-v1PjnOR4SG0oUb9LSa0g6QXpBq4ttm52pJOQ@mail.gmail.com [1] Link: https://lkml.kernel.org/r/20250103140148.370368-1-glaubitz@physik.fu-berlin.de [2] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Link: https://lore.kernel.org/r/87y0zfs26i.fsf_-_@email.froward.int.ebiederm.org Signed-off-by: Kees Cook <kees@kernel.org>
1 parent 55cf2f4 commit b029628

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

arch/alpha/include/asm/elf.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
7474
/*
7575
* This is used to ensure we don't load something for the wrong architecture.
7676
*/
77-
#define elf_check_arch(x) ((x)->e_machine == EM_ALPHA)
77+
#define elf_check_arch(x) (((x)->e_machine == EM_ALPHA) && !((x)->e_flags & EF_ALPHA_32BIT))
7878

7979
/*
8080
* These are used to set parameters in the core dumps.
@@ -137,10 +137,6 @@ extern int dump_elf_task(elf_greg_t *dest, struct task_struct *task);
137137
: amask (AMASK_CIX) ? "ev6" : "ev67"); \
138138
})
139139

140-
#define SET_PERSONALITY(EX) \
141-
set_personality(((EX).e_flags & EF_ALPHA_32BIT) \
142-
? PER_LINUX_32BIT : PER_LINUX)
143-
144140
extern int alpha_l1i_cacheshape;
145141
extern int alpha_l1d_cacheshape;
146142
extern int alpha_l2_cacheshape;

arch/alpha/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
360360

361361
extern void paging_init(void);
362362

363-
/* We have our own get_unmapped_area to cope with ADDR_LIMIT_32BIT. */
363+
/* We have our own get_unmapped_area */
364364
#define HAVE_ARCH_UNMAPPED_AREA
365365

366366
#endif /* _ALPHA_PGTABLE_H */

arch/alpha/include/asm/processor.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@
88
#ifndef __ASM_ALPHA_PROCESSOR_H
99
#define __ASM_ALPHA_PROCESSOR_H
1010

11-
#include <linux/personality.h> /* for ADDR_LIMIT_32BIT */
12-
1311
/*
1412
* We have a 42-bit user address space: 4TB user VM...
1513
*/
1614
#define TASK_SIZE (0x40000000000UL)
1715

18-
#define STACK_TOP \
19-
(current->personality & ADDR_LIMIT_32BIT ? 0x80000000 : 0x00120000000UL)
16+
#define STACK_TOP (0x00120000000UL)
2017

2118
#define STACK_TOP_MAX 0x00120000000UL
2219

2320
/* This decides where the kernel will search for a free chunk of vm
2421
* space during mmap's.
2522
*/
26-
#define TASK_UNMAPPED_BASE \
27-
((current->personality & ADDR_LIMIT_32BIT) ? 0x40000000 : TASK_SIZE / 2)
23+
#define TASK_UNMAPPED_BASE (TASK_SIZE / 2)
2824

2925
/* This is dead. Everything has been moved to thread_info. */
3026
struct thread_struct { };

arch/alpha/kernel/osf_sys.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,7 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
12111211
return ret;
12121212
}
12131213

1214-
/* Get an address range which is currently unmapped. Similar to the
1215-
generic version except that we know how to honor ADDR_LIMIT_32BIT. */
1214+
/* Get an address range which is currently unmapped. */
12161215

12171216
static unsigned long
12181217
arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
@@ -1231,13 +1230,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
12311230
unsigned long len, unsigned long pgoff,
12321231
unsigned long flags, vm_flags_t vm_flags)
12331232
{
1234-
unsigned long limit;
1235-
1236-
/* "32 bit" actually means 31 bit, since pointers sign extend. */
1237-
if (current->personality & ADDR_LIMIT_32BIT)
1238-
limit = 0x80000000;
1239-
else
1240-
limit = TASK_SIZE;
1233+
unsigned long limit = TASK_SIZE;
12411234

12421235
if (len > limit)
12431236
return -ENOMEM;

0 commit comments

Comments
 (0)