All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: head: remove __PHYS_OFFSET
@ 2022-06-28  4:57 Anshuman Khandual
  2022-06-28  7:25 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2022-06-28  4:57 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Mark Rutland, Ard Biesheuvel, Catalin Marinas, Will Deacon,
	Anshuman Khandual

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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on latest arm64 kernel (for-next/boot).

 arch/arm64/kernel/head.S | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 6bf685f988f1..763f11a394a7 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
@@ -409,7 +407,7 @@ SYM_FUNC_END(create_kernel_mapping)
 /*
  * 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
@@ -793,7 +791,7 @@ SYM_FUNC_START_LOCAL(__primary_switch)
 	adrp	x2, init_idmap_pg_dir
 	bl	__enable_mmu
 #ifdef CONFIG_RELOCATABLE
-	adrp	x23, __PHYS_OFFSET
+	adrp	x23, KERNEL_START
 	and	x23, x23, MIN_KIMG_ALIGN - 1
 #ifdef CONFIG_RANDOMIZE_BASE
 	mov	x0, x22
@@ -815,6 +813,6 @@ SYM_FUNC_START_LOCAL(__primary_switch)
 	bl	__relocate_kernel
 #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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: head: remove __PHYS_OFFSET
  2022-06-28  4:57 [PATCH] arm64: head: remove __PHYS_OFFSET Anshuman Khandual
@ 2022-06-28  7:25 ` Ard Biesheuvel
  2022-06-28  7:43   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2022-06-28  7:25 UTC (permalink / raw)
  To: Anshuman Khandual; +Cc: Linux ARM, Mark Rutland, Catalin Marinas, Will Deacon

On Tue, 28 Jun 2022 at 06:57, 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>
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This applies on latest arm64 kernel (for-next/boot).
>
>  arch/arm64/kernel/head.S | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index 6bf685f988f1..763f11a394a7 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).
>   *

I'm now wondering whether we should just drop this comment - it is no
longer accurate, and of dubious value even when it was.


>   * Note that the callee-saved registers are used for storing variables
>   * that are useful before the MMU is enabled. The allocations are described
> @@ -409,7 +407,7 @@ SYM_FUNC_END(create_kernel_mapping)
>  /*
>   * 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
> @@ -793,7 +791,7 @@ SYM_FUNC_START_LOCAL(__primary_switch)
>         adrp    x2, init_idmap_pg_dir
>         bl      __enable_mmu
>  #ifdef CONFIG_RELOCATABLE
> -       adrp    x23, __PHYS_OFFSET
> +       adrp    x23, KERNEL_START
>         and     x23, x23, MIN_KIMG_ALIGN - 1
>  #ifdef CONFIG_RANDOMIZE_BASE
>         mov     x0, x22
> @@ -815,6 +813,6 @@ SYM_FUNC_START_LOCAL(__primary_switch)
>         bl      __relocate_kernel
>  #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
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: head: remove __PHYS_OFFSET
  2022-06-28  7:25 ` Ard Biesheuvel
@ 2022-06-28  7:43   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2022-06-28  7:43 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Linux ARM, Mark Rutland, Catalin Marinas, Will Deacon



On 6/28/22 12:55, Ard Biesheuvel wrote:
> On Tue, 28 Jun 2022 at 06:57, 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>
>> Acked-by: Ard Biesheuvel <ardb@kernel.org>
>> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> This applies on latest arm64 kernel (for-next/boot).
>>
>>  arch/arm64/kernel/head.S | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
>> index 6bf685f988f1..763f11a394a7 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).
>>   *
> I'm now wondering whether we should just drop this comment - it is no
> longer accurate, and of dubious value even when it was.

Sure, will drop those two comment lines.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-28  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28  4:57 [PATCH] arm64: head: remove __PHYS_OFFSET Anshuman Khandual
2022-06-28  7:25 ` Ard Biesheuvel
2022-06-28  7:43   ` Anshuman Khandual

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.