Skip to content

Conversation

@carlocaione
Copy link
Contributor

@carlocaione carlocaione commented Mar 9, 2021

small fix suggested by @jharris-intel.

Please note that if this is merged before #32854 we will have to fix the userspace PR because get_cpu now needs 3 registers to be clobbered.

@npitre
Copy link

npitre commented Mar 9, 2021

You could save one insn by combining the symbol with an offset:

diff --git a/arch/arm/core/aarch64/macro_priv.inc b/arch/arm/core/aarch64/macro_priv.inc
index 298fc18216..a85ff2ef1e 100644
--- a/arch/arm/core/aarch64/macro_priv.inc
+++ b/arch/arm/core/aarch64/macro_priv.inc
@@ -27,8 +27,7 @@ GDATA(_kernel)
 
 .macro get_cpu xreg0, xreg1, xreg2
 	get_cpu_id \xreg1
-	ldr	\xreg0, =_kernel
-	add	\xreg0, \xreg0, #___kernel_t_cpus_OFFSET
+	ldr	\xreg0, =(_kernel + ___kernel_t_cpus_OFFSET)
 	mov	\xreg2, #___cpu_t_SIZEOF
 	madd	\xreg0, \xreg1, \xreg2, \xreg0
 .endm

@carlocaione
Copy link
Contributor Author

carlocaione commented Mar 9, 2021

You could save one insn by combining the symbol with an offset:

ah! indeed. And it's even nicer. Fixing it.

@zephyrbot zephyrbot added the area: ARM64 ARM (64-bit) Architecture label Mar 10, 2021
@zephyrbot zephyrbot requested review from ceolin and pabigot March 10, 2021 11:13
@carlocaione
Copy link
Contributor Author

@nashif can you merge this?

Currently _curr_cpu is only used by the get_cpu macro to quickly access
the cpu struct. This is not really necessary because we can access to
the struct by directly referencing &(_kernel.cpus[cpu_num]) in assembly

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
@nashif nashif merged commit 64dfa69 into zephyrproject-rtos:master Apr 9, 2021
@carlocaione carlocaione deleted the remove_curr_cpu branch April 9, 2021 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ARM ARM (32-bit) Architecture area: ARM64 ARM (64-bit) Architecture area: Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants