Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22dae6cb authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Sami Tolvanen
Browse files

UPSTREAM: arm64: remove __calc_phys_offset



This removes the function __calc_phys_offset and all open coded
virtual to physical address translations using the offset kept
in x28.

Instead, just use absolute or PC-relative symbol references as
appropriate when referring to virtual or physical addresses,
respectively.

Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>

Bug: 31432001
Change-Id: I2b838e4c9f0a35960a055ccc31123de80929ecc1
(cherry picked from commit 6f4d57fa7021efbf135cfa068d56bc5035edffa1)
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent cb6afcca
Loading
Loading
Loading
Loading
+11 −36
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
#include <asm/page.h>
#include <asm/virt.h>

#define KERNEL_RAM_VADDR	(PAGE_OFFSET + TEXT_OFFSET)
#define __PHYS_OFFSET	(KERNEL_START - TEXT_OFFSET)

#if (TEXT_OFFSET & 0xfff) != 0
#error TEXT_OFFSET must be at least 4KB aligned
@@ -46,13 +46,6 @@
#error TEXT_OFFSET must be less than 2MB
#endif

	.macro	pgtbl, ttb0, ttb1, virt_to_phys
	ldr	\ttb1, =swapper_pg_dir
	ldr	\ttb0, =idmap_pg_dir
	add	\ttb1, \ttb1, \virt_to_phys
	add	\ttb0, \ttb0, \virt_to_phys
	.endm

#ifdef CONFIG_ARM64_64K_PAGES
#define BLOCK_SHIFT	PAGE_SHIFT
#define BLOCK_SIZE	PAGE_SIZE
@@ -63,7 +56,7 @@
#define TABLE_SHIFT	PUD_SHIFT
#endif

#define KERNEL_START	KERNEL_RAM_VADDR
#define KERNEL_START	_text
#define KERNEL_END	_end

/*
@@ -237,7 +230,7 @@ section_table:
ENTRY(stext)
	mov	x21, x0				// x21=FDT
	bl	el2_setup			// Drop to EL1, w20=cpu_boot_mode
	bl	__calc_phys_offset		// x24=PHYS_OFFSET, x28=PHYS_OFFSET-PAGE_OFFSET
	adrp	x24, __PHYS_OFFSET
	bl	set_cpu_boot_mode_flag

	bl	__vet_fdt
@@ -337,7 +330,8 @@ ENDPROC(__vet_fdt)
 *   - pgd entry for fixed mappings (TTBR1)
 */
__create_page_tables:
	pgtbl	x25, x26, x28			// idmap_pg_dir and swapper_pg_dir addresses
	adrp	x25, idmap_pg_dir
	adrp	x26, swapper_pg_dir
	mov	x27, lr

	/*
@@ -366,12 +360,10 @@ __create_page_tables:
	 * Create the identity mapping.
	 */
	mov	x0, x25				// idmap_pg_dir
	ldr	x3, =KERNEL_START
	add	x3, x3, x28			// __pa(KERNEL_START)
	adrp	x3, KERNEL_START		// __pa(KERNEL_START)
	create_pgd_entry x0, x3, x5, x6
	ldr	x6, =KERNEL_END
	mov	x5, x3				// __pa(KERNEL_START)
	add	x6, x6, x28			// __pa(KERNEL_END)
	adr_l	x6, KERNEL_END			// __pa(KERNEL_END)
	create_block_map x0, x7, x3, x5, x6

	/*
@@ -380,7 +372,7 @@ __create_page_tables:
	mov	x0, x26				// swapper_pg_dir
	mov	x5, #PAGE_OFFSET
	create_pgd_entry x0, x5, x3, x6
	ldr	x6, =KERNEL_END
	ldr	x6, =KERNEL_END			// __va(KERNEL_END)
	mov	x3, x24				// phys offset
	create_block_map x0, x7, x3, x5, x6

@@ -532,8 +524,7 @@ ENDPROC(el2_setup)
 * in x20. See arch/arm64/include/asm/virt.h for more info.
 */
ENTRY(set_cpu_boot_mode_flag)
	ldr	x1, =__boot_cpu_mode		// Compute __boot_cpu_mode
	add	x1, x1, x28
	adr_l	x1, __boot_cpu_mode
	cmp	w20, #BOOT_CPU_MODE_EL2
	b.ne	1f
	add	x1, x1, #4
@@ -567,7 +558,6 @@ ENTRY(__boot_cpu_mode)
	 */
ENTRY(secondary_holding_pen)
	bl	el2_setup			// Drop to EL1, w20=cpu_boot_mode
	bl	__calc_phys_offset		// x24=PHYS_OFFSET, x28=PHYS_OFFSET-PAGE_OFFSET
	bl	set_cpu_boot_mode_flag
	mrs	x0, mpidr_el1
	ldr     x1, =MPIDR_HWID_BITMASK
@@ -586,7 +576,6 @@ ENDPROC(secondary_holding_pen)
	 */
ENTRY(secondary_entry)
	bl	el2_setup			// Drop to EL1
	bl	__calc_phys_offset		// x24=PHYS_OFFSET, x28=PHYS_OFFSET-PAGE_OFFSET
	bl	set_cpu_boot_mode_flag
	b	secondary_startup
ENDPROC(secondary_entry)
@@ -595,7 +584,8 @@ ENTRY(secondary_startup)
	/*
	 * Common entry point for secondary CPUs.
	 */
	pgtbl	x25, x26, x28			// x25=TTBR0, x26=TTBR1
	adrp	x25, idmap_pg_dir
	adrp	x26, swapper_pg_dir
	bl	__cpu_setup			// initialise processor

	ldr	x21, =secondary_data
@@ -636,18 +626,3 @@ __enable_mmu:
	isb
	br	x27
ENDPROC(__enable_mmu)

/*
 * Calculate the start of physical memory.
 */
__calc_phys_offset:
	adr	x0, 1f
	ldp	x1, x2, [x0]
	sub	x28, x0, x1			// x28 = PHYS_OFFSET - PAGE_OFFSET
	add	x24, x2, x28			// x24 = PHYS_OFFSET
	ret
ENDPROC(__calc_phys_offset)

	.align 3
1:	.quad	.
	.quad	PAGE_OFFSET