Skip to contentSkip to conversation

xen:arm: Populate arm64 image header

PATCH In review Amit Singh Tomar 3 participants 3 messages Sep 11, 2018 – Sep 24, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xen:arm: Populate arm64 image header

This patch adds image size and flags to XEN image header. It uses those fields according to the updated Linux kernel image definition.

With this patch bootloader can now place XEN image anywhere in system RAM at 2MB aligned address without to worry about relocation.
For instance, it fixes the XEN boot on Amlogic SoC where bootloader(U-BOOT) always relocates the XEN image to an address range reserved for firmware data.

---
Changes since v2:
* Undo changes in assembler.h(as suggested by Andre)
Changes since v1:
* Updated commit message
* Removed endianess code

---
 xen/arch/arm/arm64/head.S | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
xen/arch/arm/arm64/head.S +9 -2
index d63734f..ef87b5c 100644
@@ -32,6 +32,13 @@
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
 #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
 
+#define __HEAD_FLAG_PAGE_SIZE   ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAG_PHYS_BASE   1
+
+#define __HEAD_FLAGS            ((__HEAD_FLAG_PAGE_SIZE << 1) | \
+                                 (__HEAD_FLAG_PHYS_BASE << 3))
+
 #if (defined (CONFIG_EARLY_PRINTK)) && (defined (EARLY_PRINTK_INC))
 #include EARLY_PRINTK_INC
 #endif
@@ -120,8 +127,8 @@ efi_head:
         add     x13, x18, #0x16
         b       real_start           /* branch to kernel start */
         .quad   0                    /* Image load offset from start of RAM */
-        .quad   0                    /* reserved */
-        .quad   0                    /* reserved */
+        .quad   _end - start         /* Effective size of kernel image, little-endian */
+        .quad   __HEAD_FLAGS         /* Informative flags, little-endian */
         .quad   0                    /* reserved */
         .quad   0                    /* reserved */
         .quad   0                    /* reserved */
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v3 1/1
#1 lore raw

Hi,

Quoted 9 lines · Amit Singh Tomar

This patch adds image size and flags to XEN image header. It uses those fields according to the updated Linux kernel image definition.

With this patch bootloader can now place XEN image anywhere in system RAM at 2MB aligned address without to worry about relocation.
For instance, it fixes the XEN boot on Amlogic SoC where bootloader(U-BOOT) always relocates the XEN image to an address range reserved for firmware data.

Thanks, looks good to me now:

Cheers,
Andre.

Quoted 30 lines

---
Changes since v2:
* Undo changes in assembler.h(as suggested by Andre)
Changes since v1:
* Updated commit message
* Removed endianess code

---
 xen/arch/arm/arm64/head.S | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
xen/arch/arm/arm64/head.S +7 -0
index d63734f..ef87b5c 100644
@@ -32,6 +32,13 @@
 #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
 #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
 
+#define __HEAD_FLAG_PAGE_SIZE   ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAG_PHYS_BASE   1
+
+#define __HEAD_FLAGS            ((__HEAD_FLAG_PAGE_SIZE << 1) | \
+                                 (__HEAD_FLAG_PHYS_BASE << 3))
+
 #if (defined (CONFIG_EARLY_PRINTK)) && (defined (EARLY_PRINTK_INC))
 #include EARLY_PRINTK_INC
 #endif

xen/arch/arm/arm64/head.S efi_head: · line 134

Quoted 10 lines
xen/arch/arm/arm64/head.S +2 -2
@@ -120,8 +127,8 @@ efi_head:
         add     x13, x18, #0x16
         b       real_start           /* branch to kernel start */
         .quad   0                    /* Image load offset from start of RAM */
-        .quad   0                    /* reserved */
-        .quad   0                    /* reserved */
+        .quad   _end - start         /* Effective size of kernel image, little-endian */
+        .quad   __HEAD_FLAGS         /* Informative flags, little-endian */
         .quad   0                    /* reserved */
         .quad   0                    /* reserved */
         .quad   0                    /* reserved */

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by
#2 lore raw
Quoted 11 lines · Andre Przywara

Hi,

Quoted 8 lines · Amit Singh Tomar

This patch adds image size and flags to XEN image header. It uses those fields according to the updated Linux kernel image definition.

With this patch bootloader can now place XEN image anywhere in system RAM at 2MB aligned address without to worry about relocation.
For instance, it fixes the XEN boot on Amlogic SoC where bootloader(U-BOOT) always relocates the XEN image to an address range reserved for firmware data.

Quoted 5 lines
Quoted 1 line

Thanks, looks good to me now:

And commited.

Cheers,

Quoted 44 lines

Cheers,
Andre.

Quoted 40 lines

---
Changes since v2:
* Undo changes in assembler.h(as suggested by Andre)
Changes since v1:
* Updated commit message
* Removed endianess code

---
  xen/arch/arm/arm64/head.S | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
xen/arch/arm/arm64/head.S +9 -2
index d63734f..ef87b5c 100644
@@ -32,6 +32,13 @@
  #define PT_DEV    0xe71 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=0 P=1 */
  #define PT_DEV_L3 0xe73 /* nG=1 AF=1 SH=10 AP=01 NS=1 ATTR=100 T=1 P=1 */
 
+#define __HEAD_FLAG_PAGE_SIZE   ((PAGE_SHIFT - 10) / 2)
+
+#define __HEAD_FLAG_PHYS_BASE   1
+
+#define __HEAD_FLAGS            ((__HEAD_FLAG_PAGE_SIZE << 1) | \
+                                 (__HEAD_FLAG_PHYS_BASE << 3))
+
  #if (defined (CONFIG_EARLY_PRINTK)) && (defined (EARLY_PRINTK_INC))
  #include EARLY_PRINTK_INC
  #endif
@@ -120,8 +127,8 @@ efi_head:
          add     x13, x18, #0x16
          b       real_start           /* branch to kernel start */
          .quad   0                    /* Image load offset from start of RAM */
-        .quad   0                    /* reserved */
-        .quad   0                    /* reserved */
+        .quad   _end - start         /* Effective size of kernel image, little-endian */
+        .quad   __HEAD_FLAGS         /* Informative flags, little-endian */
          .quad   0                    /* reserved */
          .quad   0                    /* reserved */
          .quad   0                    /* reserved */
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel