Skip to contentSkip to conversation

xen: arm: Update arm64 image header

PATCH In review Dirk Behme 3 participants 12 messages Jun 27, 2016 – Jun 29, 2016

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH v4 1/1 xen: arm: Update arm64 image header

With the Linux kernel commits

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=4370eec05a887b0cd4392cd5dc5b2713174745c0

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=a2c1d73b94ed49f5fac12e95052d7b140783f800

the arm64 image header changed. While the size of the header isn't changed, some members have changed their usage.

Update Xen to this updated image header.

The main changes are that the first magic is gone and that there is an image size, now.

In case we read a size != 0, let's use this image size, now. This does allow us to check if the kernel Image is larger than the size given in the device tree, too.

Additionally, add an error message if the magic is not found. This might be the case with kernel's < 3.12 prior to

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4370eec05a887b0cd4392cd5dc5b2713174745c0

which introduced the second magic.

This is acceptable as the support of Xen for ARM64 in Linux has been added in Linux 3.11 and the number of boards supported by Linux 3.11 on ARM64 is very limited: ARM models and X-gene. And for the latter it was an early support with only the serial and timer upstreamed.

---

Changes in v4: Print header error only based on ZIMAGE64_MAGIC_V0. Drop comment
and unnecessary if statement.

Changes in v3: Just update of the commit message regarding the support
for kernels < 3.12. No change to the patch itself.

 xen/arch/arm/kernel.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)
xen/arch/arm/kernel.c +27 -16
index 9871bd9..1797097 100644
@@ -29,7 +29,7 @@
 #define ZIMAGE32_MAGIC 0x016f2818
 
 #define ZIMAGE64_MAGIC_V0 0x14000008
-#define ZIMAGE64_MAGIC_V1 0x644d5241 /* "ARM\x64" */
+#define ZIMAGE64_MAGIC 0x644d5241 /* "ARM\x64" */
 
 struct minimal_dtb_header {
     uint32_t magic;
@@ -335,17 +335,19 @@ static int kernel_zimage64_probe(struct kernel_info *info,
 {
     /* linux/Documentation/arm64/booting.txt */
     struct {
-        uint32_t magic0;
-        uint32_t res0;
-        uint64_t text_offset;  /* Image load offset */
-        uint64_t res1;
+        union {
+                uint32_t code0;
+                uint32_t magic0; /* Old header magic */
+        };
+        uint32_t code1;
+        uint64_t text_offset;  /* Image load offset, little endian */
+        uint64_t image_size;   /* Effective Image size, little endian */
+        uint64_t flags;
         uint64_t res2;
-        /* zImage V1 only from here */
         uint64_t res3;
         uint64_t res4;
-        uint64_t res5;
-        uint32_t magic1;
-        uint32_t res6;
+        uint32_t magic;        /* Magic number, little endian, "ARM\x64" */
+        uint32_t res5;
     } zimage;
     uint64_t start, end;
 
@@ -354,20 +356,29 @@ static int kernel_zimage64_probe(struct kernel_info *info,
 
     copy_from_paddr(&zimage, addr, sizeof(zimage));
 
-    if ( zimage.magic0 != ZIMAGE64_MAGIC_V0 &&
-         zimage.magic1 != ZIMAGE64_MAGIC_V1 )
+    if ( zimage.magic != ZIMAGE64_MAGIC ) {
+        if ( zimage.magic0 == ZIMAGE64_MAGIC_V0 )
+             printk(XENLOG_ERR "No valid magic found in header! Kernel too old\n");
         return -EINVAL;
+    }
 
-    /* Currently there is no length in the header, so just use the size */
     start = 0;
-    end = size;
 
     /*
-     * Given the above this check is a bit pointless, but leave it
-     * here in case someone adds a length field in the future.
+     * Where image_size is non-zero image_size is little-endian
+     * and must be respected.
      */
-    if ( (end - start) > size )
+    if ( zimage.image_size )
+        end = zimage.image_size;
+    else
+        end = size;
+
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes > bootmodule size: %lu bytes\n",
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size of blob!\n");
         return -EINVAL;
+    }
 
     info->zimage.kernel_addr = addr;
     info->zimage.len = end - start;
Signature · 7 lines
2.8.0


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v4 1/1
#1 lore raw

Hi Dirk,

Quoted 23 lines · Dirk Behme

With the Linux kernel commits

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=4370eec05a887b0cd4392cd5dc5b2713174745c0

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/Documentation/arm64/booting.txt?id=a2c1d73b94ed49f5fac12e95052d7b140783f800

the arm64 image header changed. While the size of the header isn't changed, some members have changed their usage.

Update Xen to this updated image header.

The main changes are that the first magic is gone and that there is an image size, now.

In case we read a size != 0, let's use this image size, now. This does allow us to check if the kernel Image is larger than the size given in the device tree, too.

Additionally, add an error message if the magic is not found. This might be the case with kernel's < 3.12 prior to

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4370eec05a887b0cd4392cd5dc5b2713174745c0

Quoted 8 lines

which introduced the second magic.

This is acceptable as the support of Xen for ARM64 in Linux has been added in Linux 3.11 and the number of boards supported by Linux 3.11 on ARM64 is very limited: ARM models and X-gene. And for the latter it was an early support with only the serial and timer upstreamed.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw
Quoted 8 lines · Julien Grall
Quoted 8 lines

This is acceptable as the support of Xen for ARM64 in Linux has been added
in Linux 3.11 and the number of boards supported by Linux 3.11 on ARM64 is
very limited: ARM models and X-gene. And for the latter it was an early support with only the serial and timer upstreamed.

Quoted 6 lines
Quoted 1 line

Regards,

Committed, thanks.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
In reply to Dirk Behme

Hi Dirk,

xen/arch/arm/kernel.c static int kernel_zimage64_probe(struct kernel_info *info, · line 381

Quoted 6 lines · Dirk Behme
xen/arch/arm/kernel.c +5 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes > bootmodule size: %lu bytes\n",
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size of blob!\n");
         return -EINVAL;
+    }

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper). The 'image_size' is the size of the kernel with BSS included. So the bootmodule will always be smaller than 'image_size'.

(XEN) Loading kernel from boot module @ 0000000080080000
(XEN) Error: Kernel Image size: 16482304 bytes > bootmodule size: 15925760bytes (XEN) The field 'size' does not match the size of blob!

So I think this field is intended to be used to tell the bootloader that kernel footprint will "image_size". So the bootloader will not attempt to place any modules (DT, ramdisk...) within this region.

We don't want to use this field to copy the kernel because we may end up to copy extra memory which could contain sensitive data.

Given that the main purpose of this patch is to use the field 'image_size', I would just revert the patch until we figured out what to do.

Dirk, as this patch is meant to be ARM64 only, I am wondering how you were able to boot DOM0 with the patch applied.

Currently the pushgate for ARM64 is only build testing, so I should have tested this patch before giving my ack. I am sorry for that.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#4 lore raw

Hi Julien,

Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper, but could you check the size given for 'size' and the real size of the kernel Image? What's about if you increase 'size'?

Yes, this check is there just to avoid the silent failing I observed. If we have the error message, as I have implemented it, it would have saved some debugging time for me ;) So it's not about using the size for real loading, its just used for checking.

A short term workaround would be to convert the ERR into WARN and remove the return.

It's somehow my feeling that there might be an issue regarding the sizes if the warning is there.

But maybe I'm totally wrong ;)

Best regards

Dirk

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#5 lore raw
Quoted 49 lines · Dirk Behme

Hi Julien,

Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper, but could you check the size given for 'size' and the real size of the kernel Image? What's about if you increase 'size'?

Yes, this check is there just to avoid the silent failing I observed. If we have the error message, as I have implemented it, it would have saved some debugging time for me ;) So it's not about using the size for real loading, its just used for checking.

Quoted 5 lines

A short term workaround would be to convert the ERR into WARN and remove the return.

It's somehow my feeling that there might be an issue regarding the sizes if the warning is there.

Just fyi, with

13517824 arch/arm64/boot/Image

and a quick printk I get

(XEN) -> image_size: 13807616 bytes

So, yes, image_size is ~300k larger than the file size. Yes, that might be due to the BSS.

Best regards

Dirk

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#6 lore raw
In reply to Dirk Behme
Quoted 34 lines · Dirk Behme

Hi Julien,

Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Quoted 7 lines

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper,

Just a question: In case of UEFI and bootwrapper, does Xen know the exact real file size of the Image file?

Then that's the difference to the device tree case, where we don't know the Image file size and use a max size estimation from the device tree.

Then we should limit the image_size error message to the device tree case only. Ignoring the BSS overhead issue, as the size given by the device tree is an estimation, anyhow.

Best regards

Dirk

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw
Quoted 39 lines · Dirk Behme
Quoted 38 lines · Dirk Behme

Hi Julien,

Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

Quoted 8 lines
Quoted 4 lines

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper,

Just a question: In case of UEFI and bootwrapper, does Xen know the exact real file size of the Image file?

Yes.

Quoted 3 lines

Then that's the difference to the device tree case, where we don't know the Image file size and use a max size estimation from the device tree.

What do you mean by "device tree case"? UEFI and bootwrapper are device tree based. The latter will create the node in the device tree with the correct size, whilst the former will directly fill Xen internal structure (see arch/arm/efi).

Quoted 4 lines

Then we should limit the image_size error message to the device tree case only. Ignoring the BSS overhead issue, as the size given by the device tree is an estimation, anyhow.

Which firmware are you using? If you use u-boot, there are runes to create the proper device-tree node on the wiki [1].

To be honest, the device-tree bindings does not mention any estimation (see [2]). I have noticed that some pages on the wiki use hardcoded DT (see [3]). So the documentation needs to be fixed.

Regards,

[1] http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions#Boot_Modules
[2] http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/arm/device-tree/booting.txt;h=8da1e0b8fcf9c98888ed63cd45bd11f1a880288b;hb=HEAD
[3] http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#8 lore raw
Quoted 64 lines · Julien Grall
Quoted 40 lines · Dirk Behme
Quoted 39 lines · Dirk Behme

Hi Julien,

Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

Quoted 8 lines
Quoted 4 lines

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper,

Just a question: In case of UEFI and bootwrapper, does Xen know the exact real file size of the Image file?

Yes.

Quoted 3 lines

Then that's the difference to the device tree case, where we don't know the Image file size and use a max size estimation from the device tree.

What do you mean by "device tree case"? UEFI and bootwrapper are device tree based. The latter will create the node in the device tree with the correct size, whilst the former will directly fill Xen internal structure (see arch/arm/efi).

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

Then we should limit the image_size error message to the device tree case only. Ignoring the BSS overhead issue, as the size given by the device tree is an estimation, anyhow.

Which firmware are you using? If you use u-boot, there are runes to create the proper device-tree node on the wiki [1].

I'm trying to get it working with ATF. Therefore I think I used the hard coded example from [3].

Quoted 3 lines

To be honest, the device-tree bindings does not mention any estimation (see [2]). I have noticed that some pages on the wiki use hardcoded DT (see [3]). So the documentation needs to be fixed.

Which ignores the fact that it silently fails if the sizes don't match ;)

The only thing I'm looking for is a helpful warning message :)

Quoted 10 lines

Regards,

[1]
http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions#Boot_Modules

[2]
http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=docs/misc/arm/device-tree/booting.txt;h=8da1e0b8fcf9c98888ed63cd45bd11f1a880288b;hb=HEAD

[3]
http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/Lager

Best regards

Dirk

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw
Quoted 8 lines · Dirk Behme
Quoted 3 lines · Julien Grall

To be honest, the device-tree bindings does not mention any estimation (see [2]). I have noticed that some pages on the wiki use hardcoded DT (see [3]). So the documentation needs to be fixed.

Which ignores the fact that it silently fails if the sizes don't match ;) The only thing I'm looking for is a helpful warning message :)

Whilst I am usually happy to see helpful warning message. I don't want to see a warning message when the behavior is actually valid.

There is no way to know whether the device tree has been crafted by the developer or generated by the firmware.

So the only solution is to update the documentation about the device-tree bindings and hope that people will read the doc starting to boot Xen.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#10 lore raw
In reply to Dirk Behme
Quoted 13 lines · Dirk Behme
Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 5 lines
Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

Please read my previous e-mail, I gave an explanation why it breaks on UEFI/bootwrapper.

To summarize, the field 'image_size' is the total size of the kernel in memory BSS included. The section BSS is not included in the blob because it is all zeros and it is a waste of disk space.

Quoted 17 lines

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

Quoted 6 lines

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper, but could you check the size given for 'size' and the real size of the kernel Image? What's about if you increase 'size'?

(XEN) Loading kernel from boot module @ 0000000080080000
(XEN) Error: Kernel Image size: 16482304 bytes > bootmodule size: 15925760bytes (XEN) The field 'size' does not match the size of blob!

For both UEFI and Bootwrapper, the bootmodule is created automatically and the size of the Image on the disk (e.g BSS not included) is used.

Quoted 8 lines

Yes, this check is there just to avoid the silent failing I observed. If we have the error message, as I have implemented it, it would have saved some debugging time for me ;) So it's not about using the size for real loading, its just used for checking.

A short term workaround would be to convert the ERR into WARN and remove the return.

This warning will always be printed for all the platform where the size is retrieved from the firmware (e.g UEFI, GRUB).

As mentioned in my previous mail, we should not copy more than the size of the bootmodule. Otherwise we may copy sensitive data in DOM0.

Quoted 2 lines

It's somehow my feeling that there might be an issue regarding the sizes if the warning is there.

No, there is no issue. We misinterpreted the meaning of the field 'image_size'. In the case of Xen, the size should only be used for placing the module.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#11 lore raw

Hi Julien,

Quoted 54 lines · Julien Grall
Quoted 13 lines · Dirk Behme
Quoted 12 lines · Julien Grall

Hi Dirk,

Quoted 8 lines · Dirk Behme
(quoted diff) +2 -0
+    if ( (end - start) > size ) {
+        printk(XENLOG_ERR "Error: Kernel Image size: %lu bytes >

bootmodule size: %lu bytes\n",

(quoted diff) +2 -0
+               zimage.image_size, (uint64_t)size);
+        printk(XENLOG_ERR "The field 'size' does not match the size
of blob!\n");
         return -EINVAL;

+ }

Quoted 5 lines
Quoted 2 lines

This patch is breaking boot on any ARM64 platform (UEFI and bootwrapper).

Well, I wonder if it breaks because the kernel is too large? As intended?

Please read my previous e-mail, I gave an explanation why it breaks on UEFI/bootwrapper.

To summarize, the field 'image_size' is the total size of the kernel in memory BSS included. The section BSS is not included in the blob because it is all zeros and it is a waste of disk space.

Quoted 18 lines

You are the expert on this, so I just can give my (limited?) understanding:

In my use case, starting with the Xen development and not really knowing the details, taking a random example from the net I had configured 10MB in the device tree:

module@0x48200000 {
       compatible = "xen,linux-zimage", "xen,multiboot-module";
       reg = <0x48200000 0x00A00000>; /* Max Image size 10MB */
};

This failed silently. No error message.

Without knowing any details, my first workaround was to make the kernel smaller. Having a kernel Image smaller than 10MB worked, then.

Quoted 6 lines

While debugging it, I found that these 0x00A00000 are used for 'size'. And increasing it to 0x00F00000 (15MB) does work for me, now.

I don't know anything aobut UEFI and bootwrapper, but could you check the size given for 'size' and the real size of the kernel Image? What's about if you increase 'size'?

Quoted 7 lines

(XEN) Loading kernel from boot module @ 0000000080080000 (XEN) Error: Kernel Image size: 16482304 bytes > bootmodule size:
15925760bytes
(XEN) The field 'size' does not match the size of blob!

For both UEFI and Bootwrapper, the bootmodule is created automatically and the size of the Image on the disk (e.g BSS not included) is used.

Ok, yes, that answers my question from the previous mail. Thanks!

Quoted 14 lines
Quoted 7 lines

Yes, this check is there just to avoid the silent failing I observed. If we have the error message, as I have implemented it, it would have saved some debugging time for me ;) So it's not about using the size for real loading, its just used for checking.

A short term workaround would be to convert the ERR into WARN and remove the return.

This warning will always be printed for all the platform where the size is retrieved from the firmware (e.g UEFI, GRUB).

As mentioned in my previous mail, we should not copy more than the size of the bootmodule. Otherwise we may copy sensitive data in DOM0.

Quoted 6 lines
Quoted 2 lines

It's somehow my feeling that there might be an issue regarding the sizes if the warning is there.

No, there is no issue. We misinterpreted the meaning of the field 'image_size'. In the case of Xen, the size should only be used for placing the module.

Yes.

Then the device tree case I like to cover is special.

Would it be the solution to add an additional

if ( device_tree )

and maybe convert it to a warning?

Best regards

Dirk

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel