Skip to content

Commit 120dc60

Browse files
ardbiesheuvelwilldeacon
authored andcommitted
arm64: get rid of TEXT_OFFSET
TEXT_OFFSET serves no purpose, and for this reason, it was redefined as 0x0 in the v5.8 timeframe. Since this does not appear to have caused any issues that require us to revisit that decision, let's get rid of the macro entirely, along with any references to it. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20200825135440.11288-1-ardb@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent b4c9712 commit 120dc60

10 files changed

Lines changed: 14 additions & 29 deletions

File tree

arch/arm64/Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# Copyright (C) 1995-2001 by Russell King
1212

1313
LDFLAGS_vmlinux :=--no-undefined -X
14-
CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
1514

1615
ifeq ($(CONFIG_RELOCATABLE), y)
1716
# Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
@@ -132,9 +131,6 @@ endif
132131
# Default value
133132
head-y := arch/arm64/kernel/head.o
134133

135-
# The byte offset of the kernel image in RAM from the start of RAM.
136-
TEXT_OFFSET := 0x0
137-
138134
ifeq ($(CONFIG_KASAN_SW_TAGS), y)
139135
KASAN_SHADOW_SCALE_SHIFT := 4
140136
else
@@ -145,8 +141,6 @@ KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
145141
KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
146142
KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
147143

148-
export TEXT_OFFSET
149-
150144
core-y += arch/arm64/
151145
libs-y := arch/arm64/lib/ $(libs-y)
152146
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a

arch/arm64/include/asm/boot.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#define MAX_FDT_SIZE SZ_2M
1414

1515
/*
16-
* arm64 requires the kernel image to placed
17-
* TEXT_OFFSET bytes beyond a 2 MB aligned base
16+
* arm64 requires the kernel image to placed at a 2 MB aligned base address
1817
*/
1918
#define MIN_KIMG_ALIGN SZ_2M
2019

arch/arm64/include/asm/kernel-pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
+ EARLY_PGDS((vstart), (vend)) /* each PGDIR needs a next level page table */ \
8787
+ EARLY_PUDS((vstart), (vend)) /* each PUD needs a next level page table */ \
8888
+ EARLY_PMDS((vstart), (vend))) /* each PMD needs a next level page table */
89-
#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR + TEXT_OFFSET, _end))
89+
#define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end))
9090
#define IDMAP_DIR_SIZE (IDMAP_PGTABLE_LEVELS * PAGE_SIZE)
9191

9292
#ifdef CONFIG_ARM64_SW_TTBR0_PAN

arch/arm64/include/asm/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern s64 memstart_addr;
169169
/* PHYS_OFFSET - the physical address of the start of memory. */
170170
#define PHYS_OFFSET ({ VM_BUG_ON(memstart_addr & 1); memstart_addr; })
171171

172-
/* the virtual base of the kernel image (minus TEXT_OFFSET) */
172+
/* the virtual base of the kernel image */
173173
extern u64 kimage_vaddr;
174174

175175
/* the offset between the kernel virtual and physical mappings */

arch/arm64/kernel/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# Makefile for the linux kernel.
44
#
55

6-
CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET)
7-
AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
86
CFLAGS_armv8_deprecated.o := -I$(src)
97

108
CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)

arch/arm64/kernel/head.S

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@
3636

3737
#include "efi-header.S"
3838

39-
#define __PHYS_OFFSET (KERNEL_START - TEXT_OFFSET)
39+
#define __PHYS_OFFSET KERNEL_START
4040

41-
#if (TEXT_OFFSET & 0xfff) != 0
42-
#error TEXT_OFFSET must be at least 4KB aligned
43-
#elif (PAGE_OFFSET & 0x1fffff) != 0
41+
#if (PAGE_OFFSET & 0x1fffff) != 0
4442
#error PAGE_OFFSET must be at least 2MB aligned
45-
#elif TEXT_OFFSET > 0x1fffff
46-
#error TEXT_OFFSET must be less than 2MB
4743
#endif
4844

4945
/*
@@ -55,7 +51,7 @@
5551
* x0 = physical address to the FDT blob.
5652
*
5753
* This code is mostly position independent so you call this at
58-
* __pa(PAGE_OFFSET + TEXT_OFFSET).
54+
* __pa(PAGE_OFFSET).
5955
*
6056
* Note that the callee-saved registers are used for storing variables
6157
* that are useful before the MMU is enabled. The allocations are described
@@ -77,7 +73,7 @@ _head:
7773
b primary_entry // branch to kernel start, magic
7874
.long 0 // reserved
7975
#endif
80-
le64sym _kernel_offset_le // Image load offset from start of RAM, little-endian
76+
.quad 0 // Image load offset from start of RAM, little-endian
8177
le64sym _kernel_size_le // Effective size of kernel image, little-endian
8278
le64sym _kernel_flags_le // Informative flags, little-endian
8379
.quad 0 // reserved
@@ -382,7 +378,7 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
382378
* Map the kernel image (starting with PHYS_OFFSET).
383379
*/
384380
adrp x0, init_pg_dir
385-
mov_q x5, KIMAGE_VADDR + TEXT_OFFSET // compile time __va(_text)
381+
mov_q x5, KIMAGE_VADDR // compile time __va(_text)
386382
add x5, x5, x23 // add KASLR displacement
387383
mov x4, PTRS_PER_PGD
388384
adrp x6, _end // runtime __pa(_end)
@@ -474,7 +470,7 @@ SYM_FUNC_END(__primary_switched)
474470

475471
.pushsection ".rodata", "a"
476472
SYM_DATA_START(kimage_vaddr)
477-
.quad _text - TEXT_OFFSET
473+
.quad _text
478474
SYM_DATA_END(kimage_vaddr)
479475
EXPORT_SYMBOL(kimage_vaddr)
480476
.popsection

arch/arm64/kernel/image.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
*/
6363
#define HEAD_SYMBOLS \
6464
DEFINE_IMAGE_LE64(_kernel_size_le, _end - _text); \
65-
DEFINE_IMAGE_LE64(_kernel_offset_le, TEXT_OFFSET); \
6665
DEFINE_IMAGE_LE64(_kernel_flags_le, __HEAD_FLAGS);
6766

6867
#endif /* __ARM64_KERNEL_IMAGE_H */

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SECTIONS
105105
*(.eh_frame)
106106
}
107107

108-
. = KIMAGE_VADDR + TEXT_OFFSET;
108+
. = KIMAGE_VADDR;
109109

110110
.head.text : {
111111
_text = .;
@@ -274,4 +274,4 @@ ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE,
274274
/*
275275
* If padding is applied before .head.text, virt<->phys conversions will fail.
276276
*/
277-
ASSERT(_text == (KIMAGE_VADDR + TEXT_OFFSET), "HEAD is misaligned")
277+
ASSERT(_text == KIMAGE_VADDR, "HEAD is misaligned")

drivers/firmware/efi/libstub/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ lib-$(CONFIG_ARM) += arm32-stub.o
6464
lib-$(CONFIG_ARM64) += arm64-stub.o
6565
lib-$(CONFIG_X86) += x86-stub.o
6666
CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
67-
CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
6867

6968
#
7069
# For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the

drivers/firmware/efi/libstub/arm64-stub.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
7777

7878
kernel_size = _edata - _text;
7979
kernel_memsize = kernel_size + (_end - _edata);
80-
*reserve_size = kernel_memsize + TEXT_OFFSET % min_kimg_align();
80+
*reserve_size = kernel_memsize;
8181

8282
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && phys_seed != 0) {
8383
/*
@@ -91,7 +91,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
9191
}
9292

9393
if (status != EFI_SUCCESS) {
94-
if (IS_ALIGNED((u64)_text - TEXT_OFFSET, min_kimg_align())) {
94+
if (IS_ALIGNED((u64)_text, min_kimg_align())) {
9595
/*
9696
* Just execute from wherever we were loaded by the
9797
* UEFI PE/COFF loader if the alignment is suitable.
@@ -111,7 +111,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
111111
}
112112
}
113113

114-
*image_addr = *reserve_addr + TEXT_OFFSET % min_kimg_align();
114+
*image_addr = *reserve_addr;
115115
memcpy((void *)*image_addr, _text, kernel_size);
116116

117117
return EFI_SUCCESS;

0 commit comments

Comments
 (0)