xen/arm: Probe the entry point address of an uImage correctly
PATCH v3 1/1 xen/arm: Probe the entry point address of an uImage correctly
Currently, kernel_uimage_probe() does not set info->zimage.start. As a result, it contains the default value (ie 0). This causes, kernel_zimage_place() to treat the binary (contained within uImage) as position independent executable. Thus, it loads it at an incorrect address.
The correct approach would be to read "uimage.ep" and set info->zimage.start. This will ensure that the binary is loaded at the correct address. Also, it checks that the load address and entry address are the same. The reason being we currently support non compressed images for uImage header. And as seen in uboot sources(image_decomp(), case IH_COMP_NONE), load address and entry address can be the same.
This behavior is applicable for both arm and arm64 platforms.
Earlier for arm32 and arm64 platforms, Xen was ignoring the entry point address set in the uImage header. With this commit, Xen will use the kernel entry point address as specified in the header. This makes the behavior of Xen consistent with uboot for uimage headers.
Users who want to use Xen with statically partitioned domains, can provide the fixed non zero load address for the dom0/domU kernel.
A deviation from uboot behaviour is that we consider load address == 0x0, to denote that the image supports position independent execution. This is to make the behavior consistent across uImage and zImage.
---
Changes from v1 :-
1. Added a check to ensure load address and entry address are the same.
2. Considered load address == 0x0 as position independent execution.
3. Ensured that the uImage header interpretation is consistent across arm32 and arm64.
v2 :-
1. Mentioned the change in existing behavior in booting.txt.
2. Updated booting.txt with a new section to document "Booting Guests".
docs/misc/arm/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/include/asm/kernel.h | 2 +- xen/arch/arm/kernel.c | 27 ++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-)
docs/misc/arm/booting.txt +21 -0
@@ -23,6 +23,24 @@ The exceptions to this on 32-bit ARM are as follows: There are no exception on 64-bit ARM. +Booting Guests +-------------- + +Xen supports the legacy image protocol[3], zImage protocol for 32-bit ARM +Linux[1] and Image protocol defined for ARM64[2]. + +Earlier for legacy image protocol, Xen ignored the load address and entry +point specified in the header. This has now changed. + +Now, it loads the image at the load address provided in the header. +For now, it supports images where load address is same as entry point. + +A deviation from uboot is that, Xen treats "load address == 0x0" as +position independent execution. Thus, Xen will load such an image at an +address it considers appropriate. + +Users who want to use Xen with statically partitioned domains, can provide +the fixed non zero load address for the dom0/domU kernel. Firmware/bootloader requirements --------------------------------
@@ -39,3 +57,6 @@ Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/t [2] linux/Documentation/arm64/booting.rst Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst + +[3] legacy format header +Latest version: https://source.denx.de/u-boot/u-boot/-/blob/master/include/image.h#L315
xen/arch/arm/include/asm/kernel.h +1 -1
@@ -72,7 +72,7 @@ struct kernel_info {#ifdef CONFIG_ARM_64 paddr_t text_offset;/* 64-bit Image only */ #endif -paddr_t start;/* 32-bit zImage only */ +paddr_t start;/* Must be 0 for 64-bit Image */ } zimage; }; };
xen/arch/arm/kernel.c +26 -1
@@ -127,7 +127,7 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info)paddr_t load_addr;#ifdef CONFIG_ARM_64 -if ( info->type ==DOMAIN_64BIT ) +if ( (info->type ==DOMAIN_64BIT ) && (info->zimage.start ==0 ) )return info->mem.bank[0 ].start + info->zimage.text_offset;#endif
@@ -223,6 +223,31 @@ static int __init kernel_uimage_probe(struct kernel_info *info,if ( len > size -sizeof (uimage) )return -EINVAL ; + info->zimage.start =be32_to_cpu (uimage.ep); + +/* +* Currently, we support uImage headers for uncompressed images only. +* Thus, it is valid for the load address and start address to be the +* same. This is consistent with the uboot behavior (Refer +* "case IH_COMP_NONE" in image_decomp(). +*/ +if ( info->zimage.start !=be32_to_cpu (uimage.load) ) + { +panic ("Unable to support mismatching load address and entry address\n" ); +return -EINVAL ; + } + +/* +* While uboot considers 0x0 to be a valid load/start address, for Xen +* to mantain parity with zimage, we consider 0x0 to denote position +* independent image. That means Xen is free to load such an image at +* any valid address. +* Thus, we will print an appropriate message. +*/ +if ( info->zimage.start ==0 ) +printk (XENLOG_INFO +"No load address provided. Xen will decide where to load it\n" ); + info->zimage.kernel_addr = addr +sizeof (uimage); info->zimage.len = len;
Signature · 1 line
2.17.1
Hi Ayan,
Quoted 49 lines · Ayan Kumar Halder
Currently,
kernel_uimage_probe()does not setinfo->zimage.start. As a result, it contains the default value (ie 0). This causes,kernel_zimage_place()to treat the binary (contained within uImage) as position independent executable. Thus, it loads it at an incorrect address.The correct approach would be to read "uimage.ep" and set
info->zimage.start. This will ensure that the binary is loaded at the correct address. Also, it checks that the load address and entry address are the same. The reason being we currently support non compressed images for uImage header. And as seen in ubootsources(image_decomp(), case IH_COMP_NONE), load address and entry address can be the same.This behavior is applicable for both arm and arm64 platforms.
Earlier for arm32 and arm64 platforms, Xen was ignoring the entry point address set in the uImage header. With this commit, Xen will use the kernel entry point address as specified in the header. This makes the behavior of Xen consistent with uboot for uimage headers.
Users who want to use Xen with statically partitioned domains, can provide the fixed non zero load address for the dom0/domU kernel.
A deviation from uboot behaviour is that we consider load address ==
0x0, to denote that the image supports position independent execution. This is to make the behavior consistent across uImage and zImage.Signed-off-by Ayan Kumar Halder <[email protected]>---
Changes from v1 :-
1. Added a check to ensure load address and entry address are the same.
2. Considered load address ==0x0as position independent execution.
3. Ensured that the uImage header interpretation is consistent across arm32 and arm64.v2 :-
1. Mentioned the change in existing behavior in booting.txt.
2. Updated booting.txt with a new section to document "Booting Guests".docs/misc/arm/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/include/asm/kernel.h | 2 +- xen/arch/arm/kernel.c | 27 ++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-)docs/misc/arm/booting.txt +0
-0
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 29
Quoted 7 lines
docs/misc/arm/booting.txt +4
-0@@ -23,6 +23,24 @@ The exceptions to this on 32-bit ARM are as follows: There are no exception on 64-bit ARM. +Booting Guests +-------------- + +Xen supports the legacy image protocol[3], zImage protocol for 32-bit ARM
uImage is not a protocol. It is just a header with no other information \wrt boot requirements.
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 36
Quoted 7 lines
docs/misc/arm/booting.txt +7
-0+Linux[1] and Image protocol defined for ARM64[2]. + +Earlier for legacy image protocol, Xen ignored the load address and entry +point specified in the header. This has now changed. + +Now, it loads the image at the load address provided in the header. +For now, it supports images where load address is same as entry point.
Would be beneficial to add explanation why load address must be equal to start address.
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 43
Quoted 7 lines
docs/misc/arm/booting.txt +7
-0+ +A deviation from uboot is that, Xen treats "load address == 0x0" as +position independent execution. Thus, Xen will load such an image at an +address it considers appropriate. + +Users who want to use Xen with statically partitioned domains, can provide +the fixed non zero load address for the dom0/domU kernel.
I think this section is missing a note that in case of not PIE, a load/start address specified by the user in a header must be within the memory region allocated by Xen.
Quoted 37 lines
docs/misc/arm/booting.txt +3
-0Firmware/bootloader requirements --------------------------------@@ -39,3 +57,6 @@ Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/t [2] linux/Documentation/arm64/booting.rst Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst + +[3] legacy format header +Latest version: https://source.denx.de/u-boot/u-boot/-/blob/master/include/image.h#L315xen/arch/arm/include/asm/kernel.h +1
-1@@ -72,7 +72,7 @@ struct kernel_info {#ifdef CONFIG_ARM_64 paddr_t text_offset;/* 64-bit Image only */ #endif -paddr_t start;/* 32-bit zImage only */ +paddr_t start;/* Must be 0 for 64-bit Image */ } zimage; }; };xen/arch/arm/kernel.c +1
-1@@ -127,7 +127,7 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info)paddr_t load_addr;#ifdef CONFIG_ARM_64 -if ( info->type ==DOMAIN_64BIT ) +if ( (info->type ==DOMAIN_64BIT ) && (info->zimage.start ==0 ) )return info->mem.bank[0 ].start + info->zimage.text_offset;#endif
xen/arch/arm/kernel.c static int __init kernel_uimage_probe(struct kernel_info *info, · line 232
Quoted 10 lines
xen/arch/arm/kernel.c +7
-0@@ -223,6 +223,31 @@ static int __init kernel_uimage_probe(struct kernel_info *info,if ( len > size -sizeof (uimage) )return -EINVAL ; + info->zimage.start =be32_to_cpu (uimage.ep); + +/* +* Currently, we support uImage headers for uncompressed images only. +* Thus, it is valid for the load address and start address to be the +* same. This is consistent with the uboot behavior (Refer +* "case IH_COMP_NONE" in image_decomp().
Please make it clear that you are referring to uboot function.
Quoted 11 lines
xen/arch/arm/kernel.c +11
-0+*/ +if ( info->zimage.start !=be32_to_cpu (uimage.load) ) + { +panic ("Unable to support mismatching load address and entry address\n" ); +return -EINVAL ; + } + +/* +* While uboot considers 0x0 to be a valid load/start address, for Xen +* to mantain parity with zimage, we consider 0x0 to denote position +* independent image. That means Xen is free to load such an image at
xen/arch/arm/kernel.c static int __init kernel_uimage_probe(struct kernel_info *info, · line 253
Quoted 10 lines
xen/arch/arm/kernel.c +7
-0+* any valid address. +* Thus, we will print an appropriate message. +*/ +if ( info->zimage.start ==0 ) +printk (XENLOG_INFO +"No load address provided. Xen will decide where to load it\n" ); + info->zimage.kernel_addr = addr +sizeof (uimage); info->zimage.len = len;
~Michal
Quoted 122 lines · Michal Orzel
Hi Ayan,
Quoted 49 lines · Ayan Kumar Halder
Currently,
kernel_uimage_probe()does not setinfo->zimage.start. As a result, it contains the default value (ie 0). This causes,kernel_zimage_place()to treat the binary (contained within uImage) as position independent executable. Thus, it loads it at an incorrect address.The correct approach would be to read "uimage.ep" and set
info->zimage.start. This will ensure that the binary is loaded at the correct address. Also, it checks that the load address and entry address are the same. The reason being we currently support non compressed images for uImage header. And as seen in ubootsources(image_decomp(), case IH_COMP_NONE), load address and entry address can be the same.This behavior is applicable for both arm and arm64 platforms.
Earlier for arm32 and arm64 platforms, Xen was ignoring the entry point address set in the uImage header. With this commit, Xen will use the kernel entry point address as specified in the header. This makes the behavior of Xen consistent with uboot for uimage headers.
Users who want to use Xen with statically partitioned domains, can provide the fixed non zero load address for the dom0/domU kernel.
A deviation from uboot behaviour is that we consider load address ==
0x0, to denote that the image supports position independent execution. This is to make the behavior consistent across uImage and zImage.Signed-off-by Ayan Kumar Halder <[email protected]>---
Changes from v1 :-
1. Added a check to ensure load address and entry address are the same.
2. Considered load address ==0x0as position independent execution.
3. Ensured that the uImage header interpretation is consistent across arm32 and arm64.v2 :-
1. Mentioned the change in existing behavior in booting.txt.
2. Updated booting.txt with a new section to document "Booting Guests".docs/misc/arm/booting.txt | 21 +++++++++++++++++++++ xen/arch/arm/include/asm/kernel.h | 2 +- xen/arch/arm/kernel.c | 27 ++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-)docs/misc/arm/booting.txt +0
-0docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 29
Quoted 7 lines
docs/misc/arm/booting.txt +4
-0@@ -23,6 +23,24 @@ The exceptions to this on 32-bit ARM are as follows: There are no exception on 64-bit ARM. +Booting Guests +-------------- + +Xen supports the legacy image protocol[3], zImage protocol for 32-bit ARMuImage is not a protocol. It is just a header with no other information \wrt boot requirements.
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 36
Quoted 7 lines
docs/misc/arm/booting.txt +7
-0+Linux[1] and Image protocol defined for ARM64[2]. + +Earlier for legacy image protocol, Xen ignored the load address and entry +point specified in the header. This has now changed. + +Now, it loads the image at the load address provided in the header. +For now, it supports images where load address is same as entry point.Would be beneficial to add explanation why load address must be equal to start address.
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 43
Quoted 7 lines
docs/misc/arm/booting.txt +7
-0+ +A deviation from uboot is that, Xen treats "load address == 0x0" as +position independent execution. Thus, Xen will load such an image at an +address it considers appropriate. + +Users who want to use Xen with statically partitioned domains, can provide +the fixed non zero load address for the dom0/domU kernel.I think this section is missing a note that in case of not PIE, a load/start address specified by the user in a header must be within the memory region allocated by Xen.
Quoted 40 lines
docs/misc/arm/booting.txt +3
-0Firmware/bootloader requirements --------------------------------@@ -39,3 +57,6 @@ Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/t [2] linux/Documentation/arm64/booting.rst Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst + +[3] legacy format header +Latest version: https://source.denx.de/u-boot/u-boot/-/blob/master/include/image.h#L315xen/arch/arm/include/asm/kernel.h +1
-1@@ -72,7 +72,7 @@ struct kernel_info {#ifdef CONFIG_ARM_64 paddr_t text_offset;/* 64-bit Image only */ #endif -paddr_t start;/* 32-bit zImage only */ +paddr_t start;/* Must be 0 for 64-bit Image */ } zimage; }; };xen/arch/arm/kernel.c +1
-1@@ -127,7 +127,7 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info)paddr_t load_addr;#ifdef CONFIG_ARM_64 -if ( info->type ==DOMAIN_64BIT ) +if ( (info->type ==DOMAIN_64BIT ) && (info->zimage.start ==0 ) )return info->mem.bank[0 ].start + info->zimage.text_offset;#endif @@ -223,6 +223,31 @@ static int __init kernel_uimage_probe(struct kernel_info *info,if ( len > size -sizeof (uimage) )return -EINVAL ;
Quoted 8 lines
xen/arch/arm/kernel.c static int __init kernel_uimage_probe(struct kernel_info *info, · line 232
Quoted 7 lines
xen/arch/arm/kernel.c +7
-0+ info->zimage.start =be32_to_cpu (uimage.ep); + +/* +* Currently, we support uImage headers for uncompressed images only. +* Thus, it is valid for the load address and start address to be the +* same. This is consistent with the uboot behavior (Refer +* "case IH_COMP_NONE" in image_decomp(). Please make it clear that you are referring to uboot function.
Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).
Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?
Cheers,
Signature · 1 line
Julien Grall
Hi Julien/Michal,
Quoted 62 lines · Julien Grall
Quoted 61 lines · Michal Orzel
Hi Ayan,
Quoted 54 lines · Ayan Kumar Halder
Currently,
kernel_uimage_probe()does not setinfo->zimage.start. As a result, it contains the default value (ie 0). This causes,kernel_zimage_place()to treat the binary (contained within uImage) as position independent executable. Thus, it loads it at an incorrect address.The correct approach would be to read "uimage.ep" and set
info->zimage.start. This will ensure that the binary is loaded at the correct address. Also, it checks that the load address and entry address are the same. The reason being we currently support non compressed images for uImage header. And as seen in ubootsources(image_decomp(), case IH_COMP_NONE), load address and entry address can be the same.This behavior is applicable for both arm and arm64 platforms.
Earlier for arm32 and arm64 platforms, Xen was ignoring the entry point address set in the uImage header. With this commit, Xen will use the kernel entry point address as specified in the header. This makes the behavior of Xen consistent with uboot for uimage headers.
Users who want to use Xen with statically partitioned domains, can provide the fixed non zero load address for the dom0/domU kernel.
A deviation from uboot behaviour is that we consider load address ==
0x0, to denote that the image supports position independent execution. This is to make the behavior consistent across uImage and zImage.Signed-off-by Ayan Kumar Halder <[email protected]>---
Changes from v1 :-
1. Added a check to ensure load address and entry address are the same.
2. Considered load address ==0x0as position independent execution.
3. Ensured that the uImage header interpretation is consistent across arm32 and arm64.v2 :-
1. Mentioned the change in existing behavior in booting.txt.
2. Updated booting.txt with a new section to document "Booting Guests".docs/misc/arm/booting.txt | 21 +++++++++++++++++++++
xen/arch/arm/include/asm/kernel.h| 2 +- xen/arch/arm/kernel.c | 27 ++++++++++++++++++++++++++-3 files changed, 48 insertions(+), 2 deletions(-)docs/misc/arm/booting.txt +0
-0@@ -23,6 +23,24 @@ The exceptions to this on 32-bit ARM are as follows:There are no exception on 64-bit ARM.
+Booting Guests
+--------------docs/misc/arm/booting.txt +2
-0+ +Xen supports the legacy image protocol[3], zImage protocol forQuoted 1 line
32-bit ARM
uImage is not a protocol. It is just a header with no other information \wrt boot requirements.
Quoted 9 lines
Quoted 9 lines
docs/misc/arm/booting.txt The exceptions to this on 32-bit ARM are as follows: · line 36
Quoted 8 lines
docs/misc/arm/booting.txt +3
-0+Linux[1] and Image protocol defined for ARM64[2]. + +Earlier for legacy image protocol, Xen ignored the load address andentry
docs/misc/arm/booting.txt +4
-0+point specified in the header. This has now changed. + +Now, it loads the image at the load address provided in the header. +For now, it supports images where load address is same as entry point.Would be beneficial to add explanation why load address must be equal to start address.
Answered below.
Quoted 63 lines
Quoted 54 lines
Quoted 10 lines
docs/misc/arm/booting.txt +3
-0+ +A deviation from uboot is that, Xen treats "load address == 0x0" as +position independent execution. Thus, Xen will load such an imageat an
docs/misc/arm/booting.txt +3
-0+address it considers appropriate. + +Users who want to use Xen with statically partitioned domains, canprovide
+the fixed non zero load address for the dom0/domU kernel.I think this section is missing a note that in case of not PIE, a load/start address specified by the user in a header must be within the memory region allocated by Xen.
Quoted 40 lines
Firmware/bootloader requirements
--------------------------------docs/misc/arm/booting.txt +0
-0@@ -39,3 +57,6 @@ Latest version:http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/t
[2]linux/Documentation/arm64/booting.rst
Latest version: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rstdocs/misc/arm/booting.txt +3
-0+ +[3] legacy format header +Latest version:https://source.denx.de/u-boot/u-boot/-/blob/master/include/image.h#L315
xen/arch/arm/include/asm/kernel.h +0
-0@@ -72,7 +72,7 @@ struct kernel_info { #ifdef CONFIG_ARM_64
paddr_ttext_offset; /* 64-bit Image only */ #endif
-paddr_tstart; /* 32-bit zImage only */ +paddr_tstart; /* Must be 0 for 64-bit Image */ } zimage;
};
};xen/arch/arm/kernel.c +1
-1@@ -127,7 +127,7 @@ static paddr_t __init kernel_zimage_place(struct kernel_info *info) paddr_t load_addr; #ifdef CONFIG_ARM_64 - if ( info->type == DOMAIN_64BIT ) + if ( (info->type == DOMAIN_64BIT) && (info->zimage.start == 0) ) return info->mem.bank[0].start + info->zimage.text_offset; #endif @@ -223,6 +223,31 @@ static int __init kernel_uimage_probe(struct kernel_info *info,if ( len > size - sizeof(uimage) ) return
-EINVAL;
+info->zimage.start=be32_to_cpu(uimage.ep); +Quoted 8 lines
Quoted 7 lines
+ /*
+ * Currently, we support uImage headers for uncompressed images only.
+ * Thus, it is valid for the load address and start address to be the
+ * same. This is consistent with the uboot behavior (Refer + * "caseIH_COMP_NONE" inimage_decomp().Please make it clear that you are referring to uboot function.
Quoted 3 lines
Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).
Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?
I could not find any documentation which states this. I found this from the following in uboot source code.
https://source.denx.de/u-boot/u-boot/-/blob/master/boot/image.c#L458
AFAIU when kernel_uimage_probe() get invoked, the image has already been decompressed. So, I added this as a limitation.
I will remove the limitation if it does not look correct.
- Ayan
Quoted 3 lines
Cheers,
Hi Ayan,
Quoted 12 lines · Ayan Kumar Halder
Quoted 12 lines
Quoted 9 lines
Quoted 8 lines
+
+ /*
+ * Currently, we support uImage headers for uncompressed images only.
+ * Thus, it is valid for the load address and start address to be the
+ * same. This is consistent with the uboot behavior (Refer + * "caseIH_COMP_NONE" inimage_decomp().Please make it clear that you are referring to uboot function.
Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).
Quoted 7 lines
Quoted 1 line
Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?
I could not find any documentation which states this. I found this from the following in uboot source code.
https://source.denx.de/u-boot/u-boot/-/blob/master/boot/image.c#L458
AFAIU when
kernel_uimage_probe()get invoked, the image has already been decompressed. So, I added this as a limitation.
I e looked at the U-boot code and, AFAIU, the check is merely to avoid the memcpy() if the image start matches the start of the decompression area. So I don't understand why we need the limitation in Xen.
Now the lack of documentation (or at least I didn't find any) makes a bit more tricky to understand what the fields in the U-boot header are for. I have skimmed through the code and I disagree with the implementation you chose for Xen.
The comment for 'ih_ep' suggests this is the entry point address. That's may be different from the beginning of your blob. I think this is what ih_load is for.
So I think we want to load the blob at ih_load and then set pc to point to ih_ep. This will require a bit more work in Xen because the assumption so far is the entry point matches the start of the blob.
Please let me known if I missed anything.
Cheers,
Signature · 1 line
Julien Grall
Quoted 1 line · Julien Grall
Hi Ayan,
Hi Julien,
Quoted 24 lines · Ayan Kumar Halder
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 8 lines
+
+ /*
+ * Currently, we support uImage headers for uncompressed images only.
+ * Thus, it is valid for the load address and start address to be the
+ * same. This is consistent with the uboot behavior (Refer + * "caseIH_COMP_NONE" inimage_decomp().Please make it clear that you are referring to uboot function.
Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).
Quoted 7 lines
Quoted 1 line
Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?
I could not find any documentation which states this. I found this from the following in uboot source code.
https://source.denx.de/u-boot/u-boot/-/blob/master/boot/image.c#L458
AFAIU when
kernel_uimage_probe()get invoked, the image has already been decompressed. So, I added this as a limitation.I e looked at the U-boot code and, AFAIU, the check is merely to avoid the
memcpy()if the image start matches the start of the decompression area. So I don't understand why we need the limitation in Xen.
Quoted 7 lines
Now the lack of documentation (or at least I didn't find any) makes a bit more tricky to understand what the fields in the U-boot header are for. I have skimmed through the code and I disagree with the implementation you chose for Xen.
The comment for '
ih_ep' suggests this is the entry point address. That's may be different from the beginning of your blob. I think this is whatih_loadis for.So I think we want to load the blob at
ih_loadand then set pc to point toih_ep. This will require a bit more work in Xen because the assumption so far is the entry point matches the start of the blob.Please let me known if I missed anything.
I think you are correct. I will rework this to correctly handle load address and entry point.
- Ayan
Quoted 3 lines
Cheers,
Hi Julien,
I need a clarification.
Quoted 30 lines · Ayan Kumar Halder
Quoted 1 line · Julien Grall
Hi Ayan,
Hi Julien,
Quoted 26 lines · Ayan Kumar Halder
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 8 lines
+
+ /*
+ * Currently, we support uImage headers for uncompressed images only.
+ * Thus, it is valid for the load address and start address to be the
+ * same. This is consistent with the uboot behavior (Refer + * "caseIH_COMP_NONE" inimage_decomp().Please make it clear that you are referring to uboot function.
Could we avoid to mention the u-boot function? The reason I am asking is the code is in a different repo and the function name can easily change without us noticing (so the comment would rot).
Quoted 7 lines
Quoted 1 line
Is the behavior documented somewhere in U-boot (or online)? If not, what's the guarantee that it will not change?
I could not find any documentation which states this. I found this from the following in uboot source code.
https://source.denx.de/u-boot/u-boot/-/blob/master/boot/image.c#L458
AFAIU when
kernel_uimage_probe()get invoked, the image has already been decompressed. So, I added this as a limitation.I e looked at the U-boot code and, AFAIU, the check is merely to avoid the
memcpy()if the image start matches the start of the decompression area. So I don't understand why we need the limitation in Xen.Now the lack of documentation (or at least I didn't find any) makes a bit more tricky to understand what the fields in the U-boot header are for. I have skimmed through the code and I disagree with the implementation you chose for Xen.
Quoted 7 lines
Quoted 5 lines
The comment for '
ih_ep' suggests this is the entry point address. That's may be different from the beginning of your blob. I think this is whatih_loadis for.So I think we want to load the blob at
ih_loadand then set pc to point toih_ep. This will require a bit more work in Xen because the assumption so far is the entry point matches the start of the blob.Please let me known if I missed anything.
I think you are correct. I will rework this to correctly handle load address and entry point.
Is it fine to keep these two constraints ?
/*
* While uboot considers 0x0 to be a valid load/start address, for Xen
* to mantain parity with zimage, we consider 0x0 to denote position
* independent image. That means Xen is free to load such an image at
* any valid address.
* Thus, we will print an appropriate message.
*/
if ( info->zimage.start == 0 )
printk(XENLOG_INFO
"No load address provided. Xen will decide where to load it.\n");
/*
* If the image supports position independent execution, then user cannot
* provide an entry point as Xen will load such an image at any appropriate
* memory address. Thus, we need to return error
*/
if ( (info->zimage.start == 0) && (info->entry != 0) )
{
printk(XENLOG_ERROR
"Entry point cannot be non zero for PIE image.\n"); return -EINVAL;
}
- Ayan
Quoted 6 lines
- Ayan
Quoted 3 lines
Cheers,