All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: xen-devel@lists.xenproject.org
Cc: julien@xen.org, Julien Grall <jgrall@amazon.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: [PATCH 2/7] xen/arm32: head.S: Introduce a macro to load the physical address of a symbol
Date: Fri, 24 Jun 2022 10:11:41 +0100	[thread overview]
Message-ID: <20220624091146.35716-3-julien@xen.org> (raw)
In-Reply-To: <20220624091146.35716-1-julien@xen.org>

From: Julien Grall <jgrall@amazon.com>

A lot of places in the ARM32 assembly requires to load the physical address
of a symbol. Rather than open-coding the translation, introduce a new macro
that will load the phyiscal address of a symbol.

Lastly, use the new macro to replace all the current open-coded version.

Note that most of the comments associated to the code changed have been
removed because the code is now self-explanatory.

Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm32/head.S | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index c837d3054cf9..77f0a619ca51 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -65,6 +65,11 @@
         .endif
 .endm
 
+.macro load_paddr rb, sym
+        ldr   \rb, =\sym
+        add   \rb, \rb, r10
+.endm
+
 /*
  * Common register usage in this file:
  *   r0  -
@@ -157,8 +162,7 @@ past_zImage:
 
         /* Using the DTB in the .dtb section? */
 .ifnes CONFIG_DTB_FILE,""
-        ldr   r8, =_sdtb
-        add   r8, r10                /* r8 := paddr(DTB) */
+        load_paddr r8, _stdb
 .endif
 
         /* Initialize the UART if earlyprintk has been enabled. */
@@ -208,8 +212,7 @@ GLOBAL(init_secondary)
         mrc   CP32(r1, MPIDR)
         bic   r7, r1, #(~MPIDR_HWID_MASK) /* Mask out flags to get CPU ID */
 
-        ldr   r0, =smp_up_cpu
-        add   r0, r0, r10            /* Apply physical offset */
+        load_paddr r0, smp_up_cpu
         dsb
 2:      ldr   r1, [r0]
         cmp   r1, r7
@@ -376,8 +379,7 @@ ENDPROC(cpu_init)
         and   r1, r1, r2             /* r1 := slot in \tlb */
         lsl   r1, r1, #3             /* r1 := slot offset in \tlb */
 
-        ldr   r4, =\tbl
-        add   r4, r4, r10            /* r4 := paddr(\tlb) */
+        load_paddr r4, \tbl
 
         movw  r2, #PT_PT             /* r2:r3 := right for linear PT */
         orr   r2, r2, r4             /*           + \tlb paddr */
@@ -536,8 +538,7 @@ enable_mmu:
         dsb   nsh
 
         /* Write Xen's PT's paddr into the HTTBR */
-        ldr   r0, =boot_pgtable
-        add   r0, r0, r10            /* r0 := paddr (boot_pagetable) */
+        load_paddr r0, boot_pgtable
         mov   r1, #0                 /* r0:r1 is paddr (boot_pagetable) */
         mcrr  CP64(r0, r1, HTTBR)
         isb
@@ -782,10 +783,8 @@ ENTRY(lookup_processor_type)
  */
 __lookup_processor_type:
         mrc   CP32(r0, MIDR)                /* r0 := our cpu id */
-        ldr   r1, = __proc_info_start
-        add   r1, r1, r10                   /* r1 := paddr of table (start) */
-        ldr   r2, = __proc_info_end
-        add   r2, r2, r10                   /* r2 := paddr of table (end) */
+        load_paddr r1, __proc_info_start
+        load_paddr r2, __proc_info_end
 1:      ldr   r3, [r1, #PROCINFO_cpu_mask]
         and   r4, r0, r3                    /* r4 := our cpu id with mask */
         ldr   r3, [r1, #PROCINFO_cpu_val]   /* r3 := cpu val in current proc info */
-- 
2.32.0



  parent reply	other threads:[~2022-06-24  9:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  9:11 [PATCH 0/7] xen/arm: mm: Bunch of clean-ups Julien Grall
2022-06-24  9:11 ` [PATCH 1/7] xen/arm: Remove most of the *_VIRT_END defines Julien Grall
2022-06-27  6:23   ` Michal Orzel
2022-06-27  9:48     ` Julien Grall
2022-06-24  9:11 ` Julien Grall [this message]
2022-06-27  6:31   ` [PATCH 2/7] xen/arm32: head.S: Introduce a macro to load the physical address of a symbol Michal Orzel
2022-06-27  9:52     ` Julien Grall
2022-06-27  9:59       ` Michal Orzel
2022-06-27 10:09         ` Julien Grall
2022-06-27 13:59           ` Bertrand Marquis
2022-06-24  9:11 ` [PATCH 3/7] xen/arm: head: Add missing isb after writing to SCTLR_EL2/HSCTLR Julien Grall
2022-06-27  6:36   ` Michal Orzel
2022-06-27 14:00   ` Bertrand Marquis
2022-06-24  9:11 ` [PATCH 4/7] xen/arm: mm: Add more ASSERT() in {destroy, modify}_xen_mappings() Julien Grall
2022-06-27  6:45   ` Michal Orzel
2022-07-04 12:35   ` Bertrand Marquis
2022-07-16 14:38     ` Julien Grall
2022-07-18  8:47       ` Jan Beulich
2022-07-18 14:06         ` Julien Grall
2022-06-24  9:11 ` [PATCH 5/7] xen/arm32: mm: Consolidate the domheap mappings initialization Julien Grall
2022-06-27  7:24   ` Michal Orzel
2022-06-30 23:09     ` Julien Grall
2022-06-24  9:11 ` [PATCH 6/7] xen/arm: mm: Move domain_{,un}map_* helpers in a separate file Julien Grall
2022-06-24  9:43   ` Jan Beulich
2022-07-16 15:00     ` Julien Grall
2022-06-24  9:11 ` [PATCH 7/7] xen/arm: mm: Reduce the area that xen_second covers Julien Grall
2022-06-27  7:51   ` Michal Orzel
2022-07-17 13:06     ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220624091146.35716-3-julien@xen.org \
    --to=julien@xen.org \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jgrall@amazon.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.