xen/arm64: head: misc cleanup
cover xen/arm64: head: misc cleanup
Some cleanup and improvements for the assembly boot code to make the behavior more consistent between arm32 and arm64.
Michal Orzel (3):
xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str xen/arm64: Move print_reg macro to asm/arm64/macros.h xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
xen/arch/arm/arm64/head.S | 37 ++++--------------------- xen/arch/arm/arm64/mmu/head.S | 8 +++--- xen/arch/arm/include/asm/arm64/macros.h | 15 ++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use 'adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.
--- xen/arch/arm/arm64/head.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/arch/arm/arm64/head.S +2 -3
@@ -498,7 +498,7 @@ ENDPROC(asm_puts) * Clobbers x0-x3 */ putn: - adr x1, hex + adr_l x1, hex mov x3, #16 1: early_uart_ready x23, 2
@@ -512,8 +512,7 @@ putn: ret ENDPROC(putn) -hex: .ascii "0123456789abcdef" - .align 2 +RODATA_STR(hex, "0123456789abcdef") #else /* CONFIG_EARLY_PRINTK */
Signature · 1 line
2.25.1
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Quoted 12 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.Signed-off-by Michal Orzel <[email protected]>
Hi Michal,
I’ve also tested on FVP
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
In reply to Michal OrzelHi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.
This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
So I would consider to drop this patch for now.
Cheers,
Quoted 20 lines
Signed-off-by Michal Orzel <[email protected]>--- xen/arch/arm/arm64/head.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)xen/arch/arm/arm64/head.S +1
-1@@ -498,7 +498,7 @@ ENDPROC(asm_puts) * Clobbers x0-x3 */ putn: - adr x1, hex + adr_l x1, hex mov x3, #16 1: early_uart_ready x23, 2
xen/arch/arm/arm64/head.S putn: · line 518
Quoted 9 lines
xen/arch/arm/arm64/head.S +1
-2@@ -512,8 +512,7 @@ putn: ret ENDPROC(putn) -hex: .ascii "0123456789abcdef" - .align 2 +RODATA_STR(hex, "0123456789abcdef") #else /* CONFIG_EARLY_PRINTK */
[1] https://lore.kernel.org/[email protected]
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Hi Julien,
Quoted 12 lines · Julien Grall
Hi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.
Quoted 3 lines
This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
So you are planning on extending your series to also cover arm64? If that is the case, then I'm ok on postponing/dropping this patch.
~Michal
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Quoted 1 line · Michal Orzel
Hi Julien,
Hi,
Quoted 13 lines · Julien Grall
Quoted 12 lines
Hi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.
Quoted 4 lines
Quoted 3 lines
This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
So you are planning on extending your series to also cover arm64?
It is not in my soonish plan. But you are arguing that this patch is for consistency with arm32. This will not be after my series.
And I would not change arm64 just for consistency because I don't view it as necessary. The boot code is already not the same.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Quoted 20 lines · Julien Grall
Quoted 1 line · Michal Orzel
Hi Julien,
Hi,
Quoted 13 lines · Julien Grall
Quoted 12 lines
Hi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
So you are planning on extending your series to also cover arm64?
It is not in my soonish plan. But you are arguing that this patch is for consistency with arm32. This will not be after my series.
Hmm, consistency was not the only reason for sending this patch. It's a beneficial side effect given that putn implementations are very similar on arm32/arm64. Are you saying that moving a string that is const from .text to .rodata is not a good change?
Quoted 3 lines
And I would not change arm64 just for consistency because I don't view it as necessary. The boot code is already not the same.
I don't recall trying to make the entire boot code consistent. But if there are parts that are almost identical, I think symmetry is welcomed. It helps reading the code, at least for me.
~Michal
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Hi Michal,
Quoted 26 lines · Michal Orzel
Quoted 23 lines · Julien Grall
Quoted 1 line · Michal Orzel
Hi Julien,
Hi,
Quoted 16 lines · Julien Grall
Quoted 15 lines
Hi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So you are planning on extending your series to also cover arm64?
It is not in my soonish plan. But you are arguing that this patch is for consistency with arm32. This will not be after my series.
Hmm, consistency was not the only reason for sending this patch. It's a beneficial side effect given that putn implementations are very similar on arm32/arm64. Are you saying that moving a string that is const from .text to .rodata is not a good change?
.rodata is better but I would rather prefer if this is moved to .rodata.idmap directly.
Quoted 6 lines
Quoted 4 lines
And I would not change arm64 just for consistency because I don't view it as necessary. The boot code is already not the same.
I don't recall trying to make the entire boot code consistent. But if there are parts that are almost identical, I think symmetry is welcomed. It helps reading the code, at least for me.
If you want symmetry, then I am happy to switch to .rodata.idmap. But I would rather not first move to .rodata and then in a month time switch to .rodata.idmap.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm64: head: Move earlyprintk 'hex' string to .rodata.str
Hi,
Quoted 45 lines · Julien Grall
Hi Michal,
Quoted 26 lines · Michal Orzel
Quoted 23 lines · Julien Grall
Quoted 1 line · Michal Orzel
Hi Julien,
Hi,
Quoted 16 lines · Julien Grall
Quoted 15 lines
Hi Michal,
Quoted 6 lines · Michal Orzel
At the moment, the 'hex' string is placed right after the 'putn' function in the .text section. This is because of the limited range (+/- 1MB) of PC relative 'adr' instruction 'putn' uses. Modify it to use '
adr_l' instead (range extended to +/- 4GB) and move the string to .rodata.str. This way all the earlyprintk messages will be part of .rodata and the behavior will be consistent with what we already do on arm32.This will be correct today, but I am actually thinking to move 'hex' to .rodata.idmap so it can be used while we are on the 1:1 mapping and/or temporary mapping.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
So you are planning on extending your series to also cover arm64?
It is not in my soonish plan. But you are arguing that this patch is for consistency with arm32. This will not be after my series.
Hmm, consistency was not the only reason for sending this patch. It's a beneficial side effect given that putn implementations are very similar on arm32/arm64.
Are you saying that
moving a string that is const from .text to .rodata is not a good change?.rodata is better but I would rather prefer if this is moved to .rodata.idmap directly.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
And I would not change arm64 just for consistency because I don't view it as necessary. The boot code is already not the same.
I don't recall trying to make the entire boot code consistent. But if there are parts that are almost identical, I think symmetry is welcomed. It helps reading the code, at least for me.
If you want symmetry, then I am happy to switch to .rodata.idmap. But I would rather not first move to .rodata and then in a month time switch to .rodata.idmap.
Ok, fair enough.
~Michal
PATCH 2/3 xen/arm64: Move print_reg macro to asm/arm64/macros.h
In reply to Michal OrzelMacro print_reg is used to print a value of a register passed as an argument. While today it is only used from within the common head.S, in the future we might want to make use of it from other files, just like PRINT(). It also serves as a great aid when debugging.
Expose print_reg macro by moving it to asm/arm64/macros.h and:
- rename putn to asm_putn to denote the usage from assembly only,
- use ENTRY() for asm_putn to make it globally visible,
- get rid of unneeded stubs for early_puts, init_uart and putn since the calls to them are already protected by #ifdef CONFIG_EARLY_PRINTK.
This way the behavior will be consistent with what we already do on arm32.
--- xen/arch/arm/arm64/head.S | 32 ++++--------------------- xen/arch/arm/include/asm/arm64/macros.h | 15 ++++++++++++ 2 files changed, 19 insertions(+), 28 deletions(-)
xen/arch/arm/arm64/head.S +4 -28
@@ -74,25 +74,6 @@ * x30 - lr */ - #ifdef CONFIG_EARLY_PRINTK -/* - * Macro to print the value of register \xb - * - * Clobbers x0 - x4 - */ -.macro print_reg xb - mov x0, \xb - mov x4, lr - bl putn - mov lr, x4 -.endm - -#else /* CONFIG_EARLY_PRINTK */ -.macro print_reg xb -.endm - -#endif /* !CONFIG_EARLY_PRINTK */ - .section .text.header, "ax", %progbits /*.aarch64*/
@@ -493,11 +474,12 @@ ENDPROC(asm_puts) /* * Print a 64-bit number in hex. + * Note: This function must be called from assembly. * x0: Number to print. * x23: Early UART base address * Clobbers x0-x3 */ -putn: +ENTRY(asm_putn) adr_l x1, hex mov x3, #16 1:
@@ -510,17 +492,11 @@ putn: subs x3, x3, #1 b.ne 1b ret -ENDPROC(putn) +ENDPROC(asm_putn) RODATA_STR(hex, "0123456789abcdef") -#else /* CONFIG_EARLY_PRINTK */ - -ENTRY(early_puts) -init_uart: -putn: ret - -#endif /* !CONFIG_EARLY_PRINTK */ +#endif /* CONFIG_EARLY_PRINTK */ /* This provides a C-API version of __lookup_processor_type * TODO: For now, the implementation return NULL every time
xen/arch/arm/include/asm/arm64/macros.h +15 -0
@@ -45,9 +45,24 @@mov lr, x3 ; \RODATA_STR (98 , _s) +/* +* Macro to print the value of register \xb +* +* Clobbers x0 - x4 +*/ +.macro print_reg xb + mov x0, \xb + mov x4, lr + bl asm_putn + mov lr, x4 +.endm + #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) +.macro print_reg xb +.endm +#endif /* !CONFIG_EARLY_PRINTK */ /*
Signature · 1 line
2.25.1
Re: [PATCH 2/3] xen/arm64: Move print_reg macro to asm/arm64/macros.h
Quoted 15 lines · Michal Orzel
Macro
print_regis used to print a value of a register passed as an argument. While today it is only used from within the commonhead.S, in the future we might want to make use of it from other files, just likePRINT(). It also serves as a great aid when debugging.Expose
print_regmacro by moving it toasm/arm64/macros.hand:
- rename putn toasm_putnto denote the usage from assembly only,
- useENTRY()forasm_putnto make it globally visible,
- get rid of unneeded stubs forearly_puts,init_uartand putn since the calls to them are already protected by #ifdefCONFIG_EARLY_PRINTK.
Quoted 3 lines
This way the behavior will be consistent with what we already do on arm32.
Signed-off-by Michal Orzel <[email protected]>
Hi Michal,
I’ve also tested on FVP
Re: [PATCH 2/3] xen/arm64: Move print_reg macro to asm/arm64/macros.h
In reply to Michal OrzelQuoted 10 lines · Michal Orzel
Macro
print_regis used to print a value of a register passed as an argument. While today it is only used from within the commonhead.S, in the future we might want to make use of it from other files, just likePRINT(). It also serves as a great aid when debugging.Expose
print_regmacro by moving it toasm/arm64/macros.hand:
- rename putn toasm_putnto denote the usage from assembly only,
- useENTRY()forasm_putnto make it globally visible,
- get rid of unneeded stubs forearly_puts,init_uartand putn since the calls to them are already protected by #ifdefCONFIG_EARLY_PRINTK.
NIT: The last one read as this is necessary to move print_reg() to asm/arm64/macros. But really, this is just a clean-up. So I would add something like "Take the opportunity to..." or similar to make it clearer.
Other than that:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 2/3] xen/arm64: Move print_reg macro to asm/arm64/macros.h
Hi Julien,
Quoted 14 lines · Julien Grall
Quoted 10 lines · Michal Orzel
Macro
print_regis used to print a value of a register passed as an argument. While today it is only used from within the commonhead.S, in the future we might want to make use of it from other files, just likePRINT(). It also serves as a great aid when debugging.Expose
print_regmacro by moving it toasm/arm64/macros.hand:
- rename putn toasm_putnto denote the usage from assembly only,
- useENTRY()forasm_putnto make it globally visible,
- get rid of unneeded stubs forearly_puts,init_uartand putn since the calls to them are already protected by #ifdefCONFIG_EARLY_PRINTK.
Quoted 3 lines
NIT: The last one read as this is necessary to move
print_reg()to asm/arm64/macros. But really, this is just a clean-up. So I would add something like "Take the opportunity to..." or similar to make it clearer.
Ok, I can do that.
~Michal
PATCH 3/3 xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
In reply to Michal OrzelMacros load_paddr and adr_l are equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances of load_paddr with adr_l, except in create_table_entry macro. Even though there is currently no use of load_paddr after MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.
This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Take the opportunity to fix a comment with incorrect function name.
--- xen/arch/arm/arm64/mmu/head.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/arm64/mmu/head.S +4 -4
@@ -146,10 +146,10 @@ create_page_tables: /* * We need to use a stash register because - * create_table_entry_paddr() will clobber the register storing + * create_table_entry_from_paddr() will clobber the register storing * the physical address of the table to point to. */ - load_paddr x4, boot_third + adr_l x4, boot_third ldr x1, =XEN_VIRT_START .rept XEN_NR_ENTRIES(2) mov x0, x4 /* x0 := paddr(l3 table) */
@@ -311,7 +311,7 @@ ENDPROC(enable_mmu) ENTRY(enable_secondary_cpu_mm) mov x6, lr - load_paddr x0, init_ttbr + adr_l x0, init_ttbr ldr x0, [x0] mov x1, #SCTLR_Axx_ELx_WXN /* Enable WxN from the start */
@@ -336,7 +336,7 @@ ENTRY(enable_boot_cpu_mm) mov x6, lr bl create_page_tables - load_paddr x0, boot_pgtable + adr_l x0, boot_pgtable mov x1, #0 /* No extra SCTLR flags */ bl enable_mmu
Signature · 1 line
2.25.1
Re: [PATCH 3/3] xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
Hi Michal,
Quoted 5 lines · Michal Orzel
Macros
load_paddrandadr_lare equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances ofload_paddrwithadr_l, except
I don't buy this argument. The advantage with using "load_paddr" is that it is pretty clear what you get from the call. With "adr_l" you will need to check whether the MMU is on or off.
Quoted 7 lines
in
create_table_entrymacro. Even though there is currently no use ofload_paddrafter MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Not really. See above. But there is also no documentation stating that "load_paddr" should not be used before the MMU is on. And as I said above, I find it easier to work with compare to "adr_l".
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 3/3] xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
Hi Julien,
Quoted 19 lines · Julien Grall
Hi Michal,
Quoted 5 lines · Michal Orzel
Macros
load_paddrandadr_lare equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances ofload_paddrwithadr_l, exceptI don't buy this argument. The advantage with using "
load_paddr" is that it is pretty clear what you get from the call. With "adr_l" you will need to check whether the MMU is on or off.Quoted 4 lines
in
create_table_entrymacro. Even though there is currently no use ofload_paddrafter MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.
Quoted 7 lines
Quoted 3 lines
This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Not really. See above. But there is also no documentation stating that "
load_paddr" should not be used before the MMU is on. And as I said above, I find it easier to work with compare to "adr_l".
I guess it is a matter of taste. load_paddr requires adding a physical offset to calculate an address, where in fact we have no places in the code where this is truly needed. Seeing an instance of this macro makes me think that this piece of code runs with MMU enabled. We could in fact remove it completely and the only reason I did not is because you told me [1] that one day we might want to use it.
[1] https://lore.kernel.org/xen-devel/[email protected]/
~Michal
Re: [PATCH 3/3] xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
Hi,
Quoted 20 lines · Michal Orzel
Quoted 19 lines · Julien Grall
Hi Michal,
Quoted 5 lines · Michal Orzel
Macros
load_paddrandadr_lare equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances ofload_paddrwithadr_l, exceptI don't buy this argument. The advantage with using "
load_paddr" is that it is pretty clear what you get from the call. With "adr_l" you will need to check whether the MMU is on or off.Quoted 4 lines
in
create_table_entrymacro. Even though there is currently no use ofload_paddrafter MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Not really. See above. But there is also no documentation stating that "
load_paddr" should not be used before the MMU is on. And as I said above, I find it easier to work with compare to "adr_l".I guess it is a matter of taste.
load_paddrrequires adding a physical offset to
I agree this is a matter of taste.
Quoted 1 line
calculate an address, where in fact we have no places in the code where this is truly needed.
I added adr_l only recently (2019). Before hand, we were using open-coded adrp and load_paddr (which was introduced in 2017).
Quoted 1 line
Seeing an instance of this macro makes me think that this piece of code runs with MMU enabled.
Fair enough. But how do you know when 'adr_l' effectively returns a physical address or virtual address? You could go through the functions call but that's fairly cumbersome.
This is why I don't particularly like this change and I am afraid, I will not ack it.
Quoted 2 lines
We could in fact remove it completely and the only reason I did not is because you told me [1] that one day we might want to use it.
Yes I still have plan to use it.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 3/3] xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
Hi,
Quoted 38 lines · Julien Grall
Hi,
Quoted 20 lines · Michal Orzel
Quoted 19 lines · Julien Grall
Hi Michal,
Quoted 5 lines · Michal Orzel
Macros
load_paddrandadr_lare equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances ofload_paddrwithadr_l, exceptI don't buy this argument. The advantage with using "
load_paddr" is that it is pretty clear what you get from the call. With "adr_l" you will need to check whether the MMU is on or off.Quoted 4 lines
in
create_table_entrymacro. Even though there is currently no use ofload_paddrafter MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Not really. See above. But there is also no documentation stating that "
load_paddr" should not be used before the MMU is on. And as I said above, I find it easier to work with compare to "adr_l".I guess it is a matter of taste.
load_paddrrequires adding a physical offset toI agree this is a matter of taste.
Quoted 1 line
calculate an address, where in fact we have no places in the code where this is truly needed.
Quoted 8 lines
I added
adr_lonly recently (2019). Before hand, we were using open-coded adrp andload_paddr(which was introduced in 2017).Quoted 1 line
Seeing an instance of this macro makes me think that this piece of code runs with MMU enabled.
Fair enough. But how do you know when '
adr_l' effectively returns a physical address or virtual address? You could go through the functions call but that's fairly cumbersome.
I see your point but we already use adr_l in MMU code. Also, recently we accepted a patch from Ayan
for arm32 that does exactly the same - load_paddr is used only in one place in MMU head.S where it is required (I thought we are aligned on this subject + I shared my plan some weeks ago). Ayan's change together with my patch would make it obvious that we use load_paddr only in MMU enabled context. That is why I struggle to understand why nacking this patch if you let the other one go. IMO this can create confusion for a future developer \wrt which one to use.
~Michal
Re: [PATCH 3/3] xen/arm64/mmu: head: Replace load_paddr with adr_l where appropriate
In reply to Michal OrzelQuoted 13 lines · Michal Orzel
Macros
load_paddrandadr_lare equivalent when used before the MMU is enabled, resulting in obtaining physical address of a symbol. The former requires to know the physical offset (PA - VA) and can be used both before and after the MMU is enabled. In the spirit of using something only when truly necessary, replace all instances ofload_paddrwithadr_l, except increate_table_entrymacro. Even though there is currently no use ofload_paddrafter MMU is enabled, this macro used to be call in such a context and we can't rule out that it won't happen again.
Quoted 8 lines
This way, the logic behind using load_paddr/adr_l is consistent between arm32 and arm64, making it easier for developers to determine which one to use and when.
Take the opportunity to fix a comment with incorrect function name.
Signed-off-by Michal Orzel <[email protected]>---
Hi Michal,
I’ve also tested on FVP