diff mbox series

[U-Boot,v2,03/18] bootvx: x86: Explicitly clear the bootloader image size

Message ID 1523509343-18123-4-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Bin Meng
Headers show
Series bootvx: Various enhancements to booting VxWorks x86 kernels | expand

Commit Message

Bin Meng April 12, 2018, 5:02 a.m. UTC
VxWorks bootloader stores its size at a pre-defined offset @ 0x5004.
Later when VxWorks kernel boots up and system memory information is
retrieved from the E820 table, the bootloader size will be subtracted
from the total system memory size to calculate the size of available
memory for the OS.

Explicitly clear the bootloader image size otherwise if memory
at this offset happens to contain some garbage data, the final
available memory size for the kernel is insane.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

Changes in v2: None

 cmd/elf.c         | 7 +++++++
 include/vxworks.h | 9 +++++++++
 2 files changed, 16 insertions(+)

Comments

Simon Glass April 12, 2018, 4:41 p.m. UTC | #1
On 11 April 2018 at 23:02, Bin Meng <bmeng.cn@gmail.com> wrote:
> VxWorks bootloader stores its size at a pre-defined offset @ 0x5004.
> Later when VxWorks kernel boots up and system memory information is
> retrieved from the E820 table, the bootloader size will be subtracted
> from the total system memory size to calculate the size of available
> memory for the OS.
>
> Explicitly clear the bootloader image size otherwise if memory
> at this offset happens to contain some garbage data, the final
> available memory size for the kernel is insane.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
> Changes in v2: None
>
>  cmd/elf.c         | 7 +++++++
>  include/vxworks.h | 9 +++++++++
>  2 files changed, 16 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng April 16, 2018, 9:15 a.m. UTC | #2
On Fri, Apr 13, 2018 at 12:41 AM, Simon Glass <sjg@chromium.org> wrote:
> On 11 April 2018 at 23:02, Bin Meng <bmeng.cn@gmail.com> wrote:
>> VxWorks bootloader stores its size at a pre-defined offset @ 0x5004.
>> Later when VxWorks kernel boots up and system memory information is
>> retrieved from the E820 table, the bootloader size will be subtracted
>> from the total system memory size to calculate the size of available
>> memory for the OS.
>>
>> Explicitly clear the bootloader image size otherwise if memory
>> at this offset happens to contain some garbage data, the final
>> available memory size for the kernel is insane.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>> ---
>>
>> Changes in v2: None
>>
>>  cmd/elf.c         | 7 +++++++
>>  include/vxworks.h | 9 +++++++++
>>  2 files changed, 16 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/cmd/elf.c b/cmd/elf.c
index c83d4cd..4638d79 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -347,6 +347,13 @@  int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	info->entries = install_e820_map(E820MAX, data);
 	info->addr = (info->entries - 1) * sizeof(struct e820entry) +
 		     E820_DATA_OFFSET;
+
+	/*
+	 * Explicitly clear the bootloader image size otherwise if memory
+	 * at this offset happens to contain some garbage data, the final
+	 * available memory size for the kernel is insane.
+	 */
+	*(u32 *)(base + BOOT_IMAGE_SIZE_OFFSET) = 0;
 #endif
 
 	/*
diff --git a/include/vxworks.h b/include/vxworks.h
index f600dfa..d912076 100644
--- a/include/vxworks.h
+++ b/include/vxworks.h
@@ -43,6 +43,15 @@  struct e820info {
 	u32 error;	/* must be zero */
 };
 
+/*
+ * VxWorks bootloader stores its size at a pre-defined offset @ 0x5004.
+ * Later when VxWorks kernel boots up and system memory information is
+ * retrieved from the E820 table, the bootloader size will be subtracted
+ * from the total system memory size to calculate the size of available
+ * memory for the OS.
+ */
+#define BOOT_IMAGE_SIZE_OFFSET	0x5004
+
 int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 void boot_prep_vxworks(bootm_headers_t *images);
 void boot_jump_vxworks(bootm_headers_t *images);