[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] xen/arm64: head: Allow to use early printk while on 1:1 mapping


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 15 Jan 2024 13:48:59 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PQDEF2iuhtk4R2tIGqGFUXRYJohLUzHLoyqSVuATIKw=; b=Blq2QFeRx5x7e9R7ErT8+okeTrhehPPAHLTECddC21Ey1iP4s9s7Foog6W0CdLC9dnm4B5XQa7OzWYBbj0lWHs8W3gmu2LztgRTRppfUbOUYcsHIAP87bMbfKhLAtd0l3LaU95qjKpEFN+5WnYLZ27T2iKB+6cow7NvO//mUQNES6U8J24/I/e4mgs5q/ROyRHsuRqruCYN4SJhT6fhCdvf5lEv8lRXnEyQDBb+8uiAfhNIr+qFkSpaWD67WaZXgBlYOWnlixmJXtpKNqB9bHcstqQmypgg6SI6MTkiihEkOZQMWUO6RRj1GpChAwmpOVozrt89jj02X9oUvoGZXQw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7Hbmgke0zSQ1Z+9ghQ9Xn0lIUW0PICZJv6ENsTkoHr5nDCFMkK+3G6+PZ/B70Eg5tXt4o1FKeSk5nXFWmEPlRiRLzB+9FTgFZc8OWTte2xHLmSOwY3qD7jyUafZzrDHOe8acIki/1/Z5I8uF+0gq83T4YfeCkieq/jG0JfNusfyHI4YTnMQJkXAfMHvEDQN6T2G7eEQMbbvXi0ge5ioEsmAAyndcwkqWyxCPcTRnzMkVuANpG2Zh8aHZjA6WcD+SgtaEMZQJGtMI2eXU65kpAGDxGdaFUcM5ySzvEkE/UuZZEwZfTuUzsQgJWML//TxdVRonq0Brk9i2PXSffg61w==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 15 Jan 2024 12:49:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Take an example from commit 1ec3fe1f664f ("xen/arm32: head: Improve
logging in head.S") to add support for printing early boot messages
while running on identity mapping:
 - define PRINT_SECT() macro to be able to specify a section for storing
   a string. PRINT() will use .rodata.str and PRINT_ID() - .rodata.idmap.
   This is necessary, because when running on identity mapping, the
   strings need to be part of the first page that is mapped,
 - move loading a runtime virtual UART address right after enabling MMU
   (the corresponding steps repeated in {primary,secondary}_switched are
   now consolidated in a single place),
 - move early printk 'hex' string into .rodata.idmap and replace 'adr'
   instruction in asm_putn with 'adr_l' to extend the addressable range,
 - remove RODATA_STR() macro given no use.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/arm64/head.S               | 13 ++-----------
 xen/arch/arm/arm64/mmu/head.S           |  8 ++++++++
 xen/arch/arm/include/asm/arm64/macros.h | 25 ++++++++++++++++++-------
 xen/arch/arm/include/asm/asm_defns.h    |  2 --
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 9d7d83a5ed2b..cfc04c755400 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -256,10 +256,6 @@ real_start_efi:
         b     enable_boot_cpu_mm
 
 primary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
-#endif
         bl    zero_bss
         PRINT("- Ready -\r\n")
         /* Setup the arguments for start_xen and jump to C world */
@@ -304,10 +300,6 @@ GLOBAL(init_secondary)
         b     enable_secondary_cpu_mm
 
 secondary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
-#endif
         PRINT("- Ready -\r\n")
         /* Jump to C world */
         ldr   x2, =start_secondary
@@ -480,7 +472,7 @@ ENDPROC(asm_puts)
  * Clobbers x0-x3
  */
 ENTRY(asm_putn)
-        adr   x1, hex
+        adr_l x1, hex
         mov   x3, #16
 1:
         early_uart_ready x23, 2
@@ -494,8 +486,7 @@ ENTRY(asm_putn)
         ret
 ENDPROC(asm_putn)
 
-hex:    .ascii "0123456789abcdef"
-        .align 2
+RODATA_SECT(.rodata.idmap, hex, "0123456789abcdef")
 
 #endif /* CONFIG_EARLY_PRINTK */
 
diff --git a/xen/arch/arm/arm64/mmu/head.S b/xen/arch/arm/arm64/mmu/head.S
index 10774f30e40e..92b62ae94ce5 100644
--- a/xen/arch/arm/arm64/mmu/head.S
+++ b/xen/arch/arm/arm64/mmu/head.S
@@ -295,6 +295,14 @@ enable_mmu:
         dsb   sy                     /* Flush PTE writes and finish reads */
         msr   SCTLR_EL2, x0          /* now paging is enabled */
         isb                          /* Now, flush the icache */
+
+#ifdef CONFIG_EARLY_PRINTK
+        /* Use a virtual address to access the UART. */
+        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
+#endif
+
+        PRINT_ID("- Paging turned on -\r\n")
+
         ret
 ENDPROC(enable_mmu)
 
diff --git a/xen/arch/arm/include/asm/arm64/macros.h 
b/xen/arch/arm/include/asm/arm64/macros.h
index d108dc3a3a71..10e652041f57 100644
--- a/xen/arch/arm/include/asm/arm64/macros.h
+++ b/xen/arch/arm/include/asm/arm64/macros.h
@@ -34,16 +34,26 @@
 
 #ifdef CONFIG_EARLY_PRINTK
 /*
- * Macro to print a string to the UART, if there is one.
+ * Macros to print a string to the UART, if there is one.
+ *
+ * There are multiple flavors:
+ *  - PRINT_SECT(section, string): The @string will be located in @section
+ *  - PRINT(): The string will be located in .rodata.str.
+ *  - PRINT_ID(): When Xen is running on the Identity Mapping, it is
+ *    only possible to have a limited amount of Xen. This will create
+ *    the string in .rodata.idmap which will always be mapped.
  *
  * Clobbers x0 - x3
  */
-#define PRINT(_s)          \
-        mov   x3, lr ;     \
-        adr_l x0, 98f ;    \
-        bl    asm_puts ;   \
-        mov   lr, x3 ;     \
-        RODATA_STR(98, _s)
+#define PRINT_SECT(section, string)         \
+        mov   x3, lr                       ;\
+        adr_l x0, 98f                      ;\
+        bl    asm_puts                     ;\
+        mov   lr, x3                       ;\
+        RODATA_SECT(section, 98, string)
+
+#define PRINT(string) PRINT_SECT(.rodata.str, string)
+#define PRINT_ID(string) PRINT_SECT(.rodata.idmap, string)
 
 /*
  * Macro to print the value of register \xb
@@ -59,6 +69,7 @@
 
 #else /* CONFIG_EARLY_PRINTK */
 #define PRINT(s)
+#define PRINT_ID(s)
 
 .macro print_reg xb
 .endm
diff --git a/xen/arch/arm/include/asm/asm_defns.h 
b/xen/arch/arm/include/asm/asm_defns.h
index ec803c0a370c..eecafd3b39ef 100644
--- a/xen/arch/arm/include/asm/asm_defns.h
+++ b/xen/arch/arm/include/asm/asm_defns.h
@@ -27,8 +27,6 @@
 label:  .asciz msg;                             \
 .popsection
 
-#define RODATA_STR(label, msg) RODATA_SECT(.rodata.str, label, msg)
-
 #define ASM_INT(label, val)                 \
     .p2align 2;                             \
 label: .long (val);                         \
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.