Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/63611 )
Change subject: util/cbfstool/linux_trampoline: Use Payload calling argument ......................................................................
util/cbfstool/linux_trampoline: Use Payload calling argument
A pointer to the coreboot tables is pushed on the stack when the payload is called. That means there is no need to scan for lower memory and follow the forwarding pointer.
Tested on Qemu Q35: Linux is properly loaded.
Change-Id: Ie0e000470299bddde3cae9347a1b18cc5b0cfc77 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M util/cbfstool/linux_trampoline.S M util/cbfstool/linux_trampoline.c 2 files changed, 20 insertions(+), 38 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/63611/1
diff --git a/util/cbfstool/linux_trampoline.S b/util/cbfstool/linux_trampoline.S index 767c8be..b7610ed 100644 --- a/util/cbfstool/linux_trampoline.S +++ b/util/cbfstool/linux_trampoline.S @@ -25,33 +25,16 @@ xor %edx, %edx mov $0, %ecx
-.headerSearch: -mov $0x10000, %ebx -add %ecx, %ebx -mov (%ecx), %eax -cmp $HEADER_SIG, %eax -je .headerSearchDone // found the header -add $16, %ecx -cmp %ecx, %ebx -jne .headerSearch - -.headerSearchDone: -cmp %ecx, %ebx // reached the end == not found anything? -je 2f // give up +// The Linuxboot tables are pushed on the stack +mov 4(%esp), %ecx +cmp $HEADER_SIG, (%ecx) +jne 2f // give up
// we assume the checksum is okay, no test mov 4(%ecx), %ebx add %ecx, %ebx // ebx = cb_header + header_bytes mov 20(%ecx), %ecx // ecx = table_entries
-.tableScan: -cmp $CB_TAG_FORWARD, (%ebx) -jne .testMemory - -/* forward tag: assume 32bit pointer */ -mov 8(%ebx), %ecx -jmp .headerSearch - .testMemory: cmp $CB_TAG_MEMORY, (%ebx) jne .testAcpiRsdp @@ -107,7 +90,7 @@ .endScan: add 4(%ebx), %ebx dec %ecx -jnz .tableScan +jnz .testMemory
/* Setup basic code and data segment selectors for Linux ** diff --git a/util/cbfstool/linux_trampoline.c b/util/cbfstool/linux_trampoline.c index 46bb800..6aef2e8 100644 --- a/util/cbfstool/linux_trampoline.c +++ b/util/cbfstool/linux_trampoline.c @@ -1,20 +1,19 @@ /* This file is automatically generated. Do not manually change */ /* SPDX-License-Identifier: GPL-2.0-only */ unsigned char trampoline[] = { - 0xfc, 0x31, 0xd2, 0xb9, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x01, 0x00, 0x01, 0xcb, 0x8b, - 0x01, 0x3d, 0x4c, 0x42, 0x49, 0x4f, 0x74, 0x07, 0x83, 0xc1, 0x10, 0x39, 0xcb, 0x75, 0xe9, 0x39, - 0xcb, 0x0f, 0x84, 0xc5, 0x00, 0x00, 0x00, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, 0x83, - 0x3b, 0x11, 0x75, 0x05, 0x8b, 0x4b, 0x08, 0xeb, 0xcf, 0x83, 0x3b, 0x01, 0x75, 0x53, 0x8b, 0x43, - 0x04, 0x83, 0xe8, 0x08, 0xc1, 0xe8, 0x02, 0x3d, 0xa0, 0x00, 0x00, 0x00, 0x7e, 0x05, 0xb8, 0xa0, - 0x00, 0x00, 0x00, 0x89, 0xc6, 0xbf, 0x05, 0x00, 0x00, 0x00, 0xf7, 0xf7, 0xa3, 0xe8, 0x01, 0x09, - 0x00, 0x89, 0xf0, 0x91, 0x8d, 0x73, 0x08, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0xf3, 0xa5, 0x91, 0xa1, - 0xe8, 0x01, 0x09, 0x00, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0x83, 0xf8, 0x00, 0x74, 0x2f, 0x83, 0x7f, - 0x10, 0x0c, 0x7e, 0x07, 0xc7, 0x47, 0x10, 0x02, 0x00, 0x00, 0x00, 0x48, 0x83, 0xc7, 0x14, 0xeb, - 0xe8, 0x83, 0x3b, 0x43, 0x75, 0x12, 0x8b, 0x43, 0x08, 0xa3, 0x70, 0x00, 0x09, 0x00, 0x8b, 0x43, - 0x0c, 0xa3, 0x74, 0x00, 0x09, 0x00, 0xeb, 0x05, 0x83, 0x3b, 0x12, 0x75, 0x00, 0x03, 0x5b, 0x04, - 0x49, 0x0f, 0x85, 0x78, 0xff, 0xff, 0xff, 0xb8, 0x00, 0x00, 0x04, 0x00, 0xc7, 0x40, 0x10, 0xff, - 0xff, 0x00, 0x00, 0xc7, 0x40, 0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x40, 0x18, 0xff, 0xff, 0x00, - 0x00, 0xc7, 0x40, 0x1c, 0x00, 0x93, 0xcf, 0x00, 0xc6, 0x00, 0x2b, 0x89, 0x40, 0x02, 0x0f, 0x01, - 0x10, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, 0xeb, 0xfd + 0xfc, 0x31, 0xd2, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x8b, 0x4c, 0x24, 0x04, 0x81, 0x39, 0x4c, 0x42, + 0x49, 0x4f, 0x0f, 0x85, 0xb7, 0x00, 0x00, 0x00, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, + 0x83, 0x3b, 0x01, 0x75, 0x53, 0x8b, 0x43, 0x04, 0x83, 0xe8, 0x08, 0xc1, 0xe8, 0x02, 0x3d, 0xa0, + 0x00, 0x00, 0x00, 0x7e, 0x05, 0xb8, 0xa0, 0x00, 0x00, 0x00, 0x89, 0xc6, 0xbf, 0x05, 0x00, 0x00, + 0x00, 0xf7, 0xf7, 0xa3, 0xe8, 0x01, 0x09, 0x00, 0x89, 0xf0, 0x91, 0x8d, 0x73, 0x08, 0xbf, 0xd0, + 0x02, 0x09, 0x00, 0xf3, 0xa5, 0x91, 0xa1, 0xe8, 0x01, 0x09, 0x00, 0xbf, 0xd0, 0x02, 0x09, 0x00, + 0x83, 0xf8, 0x00, 0x74, 0x2f, 0x83, 0x7f, 0x10, 0x0c, 0x7e, 0x07, 0xc7, 0x47, 0x10, 0x02, 0x00, + 0x00, 0x00, 0x48, 0x83, 0xc7, 0x14, 0xeb, 0xe8, 0x83, 0x3b, 0x43, 0x75, 0x12, 0x8b, 0x43, 0x08, + 0xa3, 0x70, 0x00, 0x09, 0x00, 0x8b, 0x43, 0x0c, 0xa3, 0x74, 0x00, 0x09, 0x00, 0xeb, 0x05, 0x83, + 0x3b, 0x12, 0x75, 0x00, 0x03, 0x5b, 0x04, 0x49, 0x75, 0x86, 0xb8, 0x00, 0x00, 0x04, 0x00, 0xc7, + 0x40, 0x10, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x40, 0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x40, 0x18, + 0xff, 0xff, 0x00, 0x00, 0xc7, 0x40, 0x1c, 0x00, 0x93, 0xcf, 0x00, 0xc6, 0x00, 0x2b, 0x89, 0x40, + 0x02, 0x0f, 0x01, 0x10, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, + 0xeb, 0xfd }; -unsigned int trampoline_len = 239; +unsigned int trampoline_len = 210;