diff mbox series

[2/6] arm64: head: remove __PHYS_OFFSET

Message ID 20220518031725.3128044-3-anshuman.khandual@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64/head: Cleanups for __create_page_tables() | expand

Commit Message

Anshuman Khandual May 18, 2022, 3:17 a.m. UTC
From: Mark Rutland <mark.rutland@arm.com>

It's very easy to confuse __PHYS_OFFSET and PHYS_OFFSET. To clarify
things, let's remove __PHYS_OFFSET and use KERNEL_START directly, with
comments to show that we're using physical address, as we do for other
objects.

At the same time, update the comment regarding the kernel entry address
to mention __pa(KERNEL_START) rather than __pa(PAGE_OFFSET).

There should be no functional change as a result of this patch.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm64/kernel/head.S | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Ard Biesheuvel May 18, 2022, 6:45 a.m. UTC | #1
On Wed, 18 May 2022 at 05:17, Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
>
> From: Mark Rutland <mark.rutland@arm.com>
>
> It's very easy to confuse __PHYS_OFFSET and PHYS_OFFSET. To clarify
> things, let's remove __PHYS_OFFSET and use KERNEL_START directly, with
> comments to show that we're using physical address, as we do for other
> objects.
>
> At the same time, update the comment regarding the kernel entry address
> to mention __pa(KERNEL_START) rather than __pa(PAGE_OFFSET).
>
> There should be no functional change as a result of this patch.
>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

Acked-by: Ard Biesheuvel <ardb@kernel.org>

Again, this conflicts with

https://lore.kernel.org/linux-arm-kernel/20220411094824.4176877-1-ardb@kernel.org/

but the conflict can be resolved in a straight-forward manner.

> ---
>  arch/arm64/kernel/head.S | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index 6a98f1a38c29..aaad76680495 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -37,8 +37,6 @@
>
>  #include "efi-header.S"
>
> -#define __PHYS_OFFSET  KERNEL_START
> -
>  #if (PAGE_OFFSET & 0x1fffff) != 0
>  #error PAGE_OFFSET must be at least 2MB aligned
>  #endif
> @@ -52,7 +50,7 @@
>   *   x0 = physical address to the FDT blob.
>   *
>   * This code is mostly position independent so you call this at
> - * __pa(PAGE_OFFSET).
> + * __pa(KERNEL_START).
>   *
>   * Note that the callee-saved registers are used for storing variables
>   * that are useful before the MMU is enabled. The allocations are described
> @@ -91,7 +89,7 @@
>  SYM_CODE_START(primary_entry)
>         bl      preserve_boot_args
>         bl      init_kernel_el                  // w0=cpu_boot_mode
> -       adrp    x23, __PHYS_OFFSET
> +       adrp    x23, KERNEL_START               // __pa(KERNEL_START)
>         and     x23, x23, MIN_KIMG_ALIGN - 1    // KASLR offset, defaults to 0
>         bl      set_cpu_boot_mode_flag
>         bl      __create_page_tables
> @@ -420,7 +418,7 @@ SYM_FUNC_END(__create_page_tables)
>  /*
>   * The following fragment of code is executed with the MMU enabled.
>   *
> - *   x0 = __PHYS_OFFSET
> + *   x0 = __pa(KERNEL_START)
>   */
>  SYM_FUNC_START_LOCAL(__primary_switched)
>         adr_l   x4, init_task
> @@ -870,7 +868,7 @@ SYM_FUNC_START_LOCAL(__primary_switch)
>         bl      __relocate_kernel
>  #ifdef CONFIG_RANDOMIZE_BASE
>         ldr     x8, =__primary_switched
> -       adrp    x0, __PHYS_OFFSET
> +       adrp    x0, KERNEL_START                // __pa(KERNEL_START)
>         blr     x8
>
>         /*
> @@ -893,6 +891,6 @@ SYM_FUNC_START_LOCAL(__primary_switch)
>  #endif
>  #endif
>         ldr     x8, =__primary_switched
> -       adrp    x0, __PHYS_OFFSET
> +       adrp    x0, KERNEL_START                // __pa(KERNEL_START)
>         br      x8
>  SYM_FUNC_END(__primary_switch)
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 6a98f1a38c29..aaad76680495 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -37,8 +37,6 @@ 
 
 #include "efi-header.S"
 
-#define __PHYS_OFFSET	KERNEL_START
-
 #if (PAGE_OFFSET & 0x1fffff) != 0
 #error PAGE_OFFSET must be at least 2MB aligned
 #endif
@@ -52,7 +50,7 @@ 
  *   x0 = physical address to the FDT blob.
  *
  * This code is mostly position independent so you call this at
- * __pa(PAGE_OFFSET).
+ * __pa(KERNEL_START).
  *
  * Note that the callee-saved registers are used for storing variables
  * that are useful before the MMU is enabled. The allocations are described
@@ -91,7 +89,7 @@ 
 SYM_CODE_START(primary_entry)
 	bl	preserve_boot_args
 	bl	init_kernel_el			// w0=cpu_boot_mode
-	adrp	x23, __PHYS_OFFSET
+	adrp	x23, KERNEL_START		// __pa(KERNEL_START)
 	and	x23, x23, MIN_KIMG_ALIGN - 1	// KASLR offset, defaults to 0
 	bl	set_cpu_boot_mode_flag
 	bl	__create_page_tables
@@ -420,7 +418,7 @@  SYM_FUNC_END(__create_page_tables)
 /*
  * The following fragment of code is executed with the MMU enabled.
  *
- *   x0 = __PHYS_OFFSET
+ *   x0 = __pa(KERNEL_START)
  */
 SYM_FUNC_START_LOCAL(__primary_switched)
 	adr_l	x4, init_task
@@ -870,7 +868,7 @@  SYM_FUNC_START_LOCAL(__primary_switch)
 	bl	__relocate_kernel
 #ifdef CONFIG_RANDOMIZE_BASE
 	ldr	x8, =__primary_switched
-	adrp	x0, __PHYS_OFFSET
+	adrp	x0, KERNEL_START		// __pa(KERNEL_START)
 	blr	x8
 
 	/*
@@ -893,6 +891,6 @@  SYM_FUNC_START_LOCAL(__primary_switch)
 #endif
 #endif
 	ldr	x8, =__primary_switched
-	adrp	x0, __PHYS_OFFSET
+	adrp	x0, KERNEL_START		// __pa(KERNEL_START)
 	br	x8
 SYM_FUNC_END(__primary_switch)