On 22 January 2015 at 14:33, Olivier Martin olivier.martin@arm.com wrote:
I guess the reason why I initially did this 'hack' (mark the DRAM occupied by the FD as non-present) is because the DXE (or something else) was copying over the FD during the dispatching of the UEFI drivers. You might not see this issue with your implementation of MemoryInitPeiLib because UEFI drivers will be loaded way above the FD file. But the risk might still exist - except if the DXE core now takes care of this case.
So which part of the FD file would we still be using at DXE time? And couldn't we use ConvertPages() to turn it into boot services code instead of removing it entirely?
-----Original Message----- From: linaro-uefi-bounces@lists.linaro.org [mailto:linaro-uefi- bounces@lists.linaro.org] On Behalf Of Ard Biesheuvel Sent: 19 January 2015 17:34 To: Varad Gautam Cc: Linaro UEFI Mailman List Subject: Re: [Linaro-uefi] [RFC] arm: efi: handle zImage relocation
On 19 January 2015 at 17:28, Varad Gautam varadgautam@gmail.com wrote:
On 01/19/15 at 05:21 PM Ard Biesheuvel ard.biesheuvel@linaro.org
wrote:
The current implementation fails in `handle_kernel_image()` when
UEFI
finds a discontinuity in the memory map during
`allocate_pages()`[1].
This patch
Footnote?
January/000645.html
The current ARM port in Tianocore does not deal very well with a flash device in RAM. It assumes you are shadowing from flash if it detects that PrePi is running from RAM.
I hit something similar here https://git.linaro.org/people/ard.biesheuvel/uefi- next.git/commit/470ecd1480880a80bbb29077a22a3e640d9633f7
So how do you load the UEFI image?
Linaro-uefi mailing list Linaro-uefi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-uefi
On 22 January 2015 at 17:41, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 22 January 2015 at 14:33, Olivier Martin olivier.martin@arm.com wrote:
I guess the reason why I initially did this 'hack' (mark the DRAM occupied by the FD as non-present) is because the DXE (or something else) was copying over the FD during the dispatching of the UEFI drivers. You might not see this issue with your implementation of MemoryInitPeiLib because UEFI drivers will be loaded way above the FD file. But the risk might still exist - except if the DXE core now takes care of this case.
So which part of the FD file would we still be using at DXE time? And couldn't we use ConvertPages() to turn it into boot services code instead of removing it entirely?
... or more specifically: when you did this 'hack', were you already using a compressed FV inside the FD? I guess decompressing the payload into RAM would eliminate any dependencies that would in fact exist when the DXE core loads module straight from the FD.
-----Original Message----- From: linaro-uefi-bounces@lists.linaro.org [mailto:linaro-uefi- bounces@lists.linaro.org] On Behalf Of Ard Biesheuvel Sent: 19 January 2015 17:34 To: Varad Gautam Cc: Linaro UEFI Mailman List Subject: Re: [Linaro-uefi] [RFC] arm: efi: handle zImage relocation
On 19 January 2015 at 17:28, Varad Gautam varadgautam@gmail.com wrote:
On 01/19/15 at 05:21 PM Ard Biesheuvel ard.biesheuvel@linaro.org
wrote:
The current implementation fails in `handle_kernel_image()` when
UEFI
finds a discontinuity in the memory map during
`allocate_pages()`[1].
This patch
Footnote?
January/000645.html
The current ARM port in Tianocore does not deal very well with a flash device in RAM. It assumes you are shadowing from flash if it detects that PrePi is running from RAM.
I hit something similar here https://git.linaro.org/people/ard.biesheuvel/uefi- next.git/commit/470ecd1480880a80bbb29077a22a3e640d9633f7
So how do you load the UEFI image?
Linaro-uefi mailing list Linaro-uefi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-uefi
On 26 January 2015 at 08:37, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 22 January 2015 at 17:41, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 22 January 2015 at 14:33, Olivier Martin olivier.martin@arm.com wrote:
I guess the reason why I initially did this 'hack' (mark the DRAM occupied by the FD as non-present) is because the DXE (or something else) was copying over the FD during the dispatching of the UEFI drivers. You might not see this issue with your implementation of MemoryInitPeiLib because UEFI drivers will be loaded way above the FD file. But the risk might still exist - except if the DXE core now takes care of this case.
So which part of the FD file would we still be using at DXE time? And couldn't we use ConvertPages() to turn it into boot services code instead of removing it entirely?
... or more specifically: when you did this 'hack', were you already using a compressed FV inside the FD? I guess decompressing the payload into RAM would eliminate any dependencies that would in fact exist when the DXE core loads module straight from the FD.
FYI my PrePi Xen port still boots correctly when I clear the entire FD area right before jumping into DXE core. I.e., using this patch
------>8--------- diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c index 9a1ef344df6e..db5aacaf7ffb 100644 --- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c +++ b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c @@ -133,9 +133,19 @@ LoadDxeCoreFromFfsFile (
Hob = GetHobList (); if (StackSize == 0) { - // User the current stack - - ((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob); + unsigned int trampoline[] = { + 0xd2a8011d, // mov x29, #0x40080000 + 0xd2a8051e, // mov x30, #0x40280000 + 0xa8817fbf, // stp xzr, xzr, [x29], #16 + 0xeb1e03bf, // cmp x29, x30 + 0x54ffffcb, // blt (. - 8) + 0x5800005e, // ldr x30, 0xc + 0xd63f03c0, // blr x30 + (INT32)EntryPoint, + (INT32)(EntryPoint >> 32) + }; + + ((DXE_CORE_ENTRY_POINT)(UINTN)trampoline) (Hob); } else {
// ------>8---------
So Varad, can you confirm that your port consists of a primary FV containing PrePi and a compressed secondary FV, which in turn contains all the other modules? If this is the case, I think it is safe to go with my version of the MemoryInitPeiLib and not remove the memory used by the FD from the memory map.
Cheers, Ard.
On 01/27/15 at 11:44 AM Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
So Varad, can you confirm that your port consists of a primary FV containing PrePi and a compressed secondary FV, which in turn contains all the other modules?
I'm using the same FD layout, I have switched to your version of MemoryInitPeiLib.
On 11 January 2015 at 17:23, Varad Gautam varadgautam@gmail.com wrote:
- arch/arm/boot/compressed/head.S: jump to zImage `mov pc, r3` fails,
although jump
to hard-coded relocated address (`ldr pc, =0x80008000`) works, 0x80008000
being the
new zImage location. Need help with calling convention - am I setting
*image_addr
correctly?
^ this problem still persists, except the zImage is now placed at 0x82000000; but I noticed that clearing (or changing) r4 in head.S after `efi_entry` returns causes the kernel to boot and show early debug messages! I am figuring out what's causing this oddity.
--- diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S @@ -166,6 +166,7 @@ efi_stub_entry: mov r2, sp @ pass pointer in r2 bl efi_entry ldr r3, [sp], #8 @ get new zImage address from stack + mov r4, #0x00 @ doing this strangely boots the kernel
@ Check for error return from EFI stub. r0 has FDT address @ or error code. ---
Thanks, Varad
On 28 January 2015 at 17:00, Varad Gautam varadgautam@gmail.com wrote:
On 01/27/15 at 11:44 AM Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
So Varad, can you confirm that your port consists of a primary FV containing PrePi and a compressed secondary FV, which in turn contains all the other modules?
I'm using the same FD layout, I have switched to your version of MemoryInitPeiLib.
On 11 January 2015 at 17:23, Varad Gautam varadgautam@gmail.com wrote:
- arch/arm/boot/compressed/head.S: jump to zImage `mov pc, r3` fails,
although jump
to hard-coded relocated address (`ldr pc, =0x80008000`) works, 0x80008000
being the
new zImage location. Need help with calling convention - am I setting
*image_addr
correctly?
^ this problem still persists, except the zImage is now placed at 0x82000000; but I noticed that clearing (or changing) r4 in head.S after `efi_entry` returns causes the kernel to boot and show early debug messages! I am figuring out what's causing this oddity.
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S @@ -166,6 +166,7 @@ efi_stub_entry: mov r2, sp @ pass pointer in r2 bl efi_entry ldr r3, [sp], #8 @ get new zImage address from stack
mov r4, #0x00 @ doing this strangely boots the kernel @ Check for error return from EFI stub. r0 has FDT address @ or error code.
Nice bug! Do you have a git tree somewhere?
On 01/28/15 at 06:16 PM Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
Nice bug! Do you have a git tree somewhere?
I set one up here [1].
Is the arm kernel functional on other uefi platforms which I can refer to?
[1] https://github.com/varadgautam/linux/tree/topic-leg-uefi-dev
Thanks, Varad
On 30 January 2015 at 10:16, Varad Gautam varadgautam@gmail.com wrote:
On 01/28/15 at 06:16 PM Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
Nice bug! Do you have a git tree somewhere?
I set one up here [1].
Is the arm kernel functional on other uefi platforms which I can refer to?
You should be able to run it under QEMU, look at my wiki page here
https://wiki.linaro.org/LEG/UEFIforQEMU
[1] https://github.com/varadgautam/linux/tree/topic-leg-uefi-dev
I tried building your branch and booting it under UEFI on QEMU. I can boot the zImage from the shell, and I can trace it into the kernel proper via GDB, but then it hits an early exception somewhere. I can dig a bit deeper but that takes time.
Command line, for reference
qemu-system-aarch64 -M virt -cpu cortex-a15 -m 512 -bios Build/ArmVirtualizationQemu-ARM/RELEASE_GCC48/FV/QEMU_EFI.fd -nographic -drive if=none,id=boot,file=fat:$HOME/linux-arm-build/arch/arm/boot,format=raw -device virtio-blk-device,drive=boot
Thanks, Varad
On 30 January 2015 at 17:48, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 30 January 2015 at 10:16, Varad Gautam varadgautam@gmail.com wrote:
On 01/28/15 at 06:16 PM Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
Nice bug! Do you have a git tree somewhere?
I set one up here [1].
Is the arm kernel functional on other uefi platforms which I can refer to?
You should be able to run it under QEMU, look at my wiki page here
https://wiki.linaro.org/LEG/UEFIforQEMU
[1] https://github.com/varadgautam/linux/tree/topic-leg-uefi-dev
I tried building your branch and booting it under UEFI on QEMU. I can boot the zImage from the shell, and I can trace it into the kernel proper via GDB, but then it hits an early exception somewhere. I can dig a bit deeper but that takes time.
Not the kernel proper, but the decompressor
Command line, for reference
qemu-system-aarch64 -M virt -cpu cortex-a15 -m 512 -bios Build/ArmVirtualizationQemu-ARM/RELEASE_GCC48/FV/QEMU_EFI.fd -nographic -drive if=none,id=boot,file=fat:$HOME/linux-arm-build/arch/arm/boot,format=raw -device virtio-blk-device,drive=boot
Thanks, Varad