coreboot-kgpe-d16/util/cbfstool
Curt Brune 3c12cb0384 cbfstool:linux_trampoline: config CS and DS segment descriptors
The Linux trampoline code does not set up the segment descriptors for
__BOOT_CS and __BOOT_DS as described in the Linux kernel
documentation:

  ... a GDT must be loaded with the descriptors for selectors
  __BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G
  flat segment; __BOOT_CS must have execute/read permission, and
  __BOOT_DS must have read/write permission;

This is not a problem when launching a Linux payload from coreboot, as
coreboot configures the segment descriptors at selectors 0x10 and
0x18.  Coreboot configures these selectors in the ramstage to match
what the Linux kernel expects (see
coreboot/src/arch/x86/lib/c_start.S).

When the cbfs payload is launched in other environments, SeaBIOS for
example, the segment descriptors are configured differently and the
cbfs Linux payload does not work.

If the cbfs Linux payload is to be used in multiple environments
should the trampoline needs to take care of the descriptors that Linux
requires.

This patch updates the Linux trampoline code to configure the 4G flat
descriptors that Linux expects.  The configuration is borrowed from
the descriptor configs in coreboot/src/arch/x86/lib/c_start.S for
selectors 0x10 and 0x18.

The linux_trampoline code is slightly refractored by defining the
trampoline entry address, 0x40000, as TRAMPOLINE_ENTRY_LOC.  This
definition is moved into a separate header file, linux_trampoline.h.
This header file is now included by both the trampoline assembly
language code and the trampoline loader C code.

The trampoline assembly language code can now use TRAMPOLINE_ENTRY_LOC
as scratch space for the sgdt CPU instruction.

Testing Done:

Verified the Linux payload is booted correctly in the following
environments:

1.  Coreboot -> Linux Payload

2.  Coreboot -> SeaBIOS -> Linux Payload: (previously did not work)

Change-Id: I888f74ff43073a6b7318f6713a8d4ecb804c0162
Signed-off-by: Curt Brune <curt@cumulusnetworks.com>
Reviewed-on: http://review.coreboot.org/6796
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2014-09-04 23:34:32 +02:00
..
lzma cbfstool/lzma: Remove dead code under #ifdefs 2014-03-02 05:14:30 +01:00
EXAMPLE cbfstool: Update example file. 2013-02-04 11:12:15 +01:00
Makefile utils/cbfstool: No need to pass -g flag twice 2014-06-29 04:16:49 +02:00
Makefile.inc build system: fix another cbfstool race 2014-07-15 14:27:04 +02:00
cbfs-mkpayload.c cbfstool: process cbfs_payload_segment(s) in host byte order 2014-08-07 19:05:43 +02:00
cbfs-mkstage.c util/cbfstool: free buffer on error path 2014-07-30 10:36:00 +02:00
cbfs-payload-linux.c cbfstool:linux_trampoline: config CS and DS segment descriptors 2014-09-04 23:34:32 +02:00
cbfs.h cbfstool: process cbfs_payload_segment(s) in host byte order 2014-08-07 19:05:43 +02:00
cbfs_image.c cbfstool: process cbfs_payload_segment(s) in host byte order 2014-08-07 19:05:43 +02:00
cbfs_image.h cbfstool: Deserialize CBFS master header when reading image 2014-02-11 20:14:39 +01:00
cbfstool.c cbfstool: fix option parsing 2014-08-09 19:54:09 +02:00
coff.h GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
common.c util: replace fseek/ftell/rewind with fstat 2014-08-12 11:53:24 +02:00
common.h cbfstool: provide structure to linux payload builder 2014-03-28 14:40:53 +01:00
compress.c cbfs: fix issues with word size and endianness. 2014-01-29 20:03:44 +01:00
elf.h cbfstool: add a constant for the aarch64 2013-11-18 16:58:58 +01:00
elfheaders.c elfheaders: fix 64-bit ELF writing 2014-08-22 21:30:09 +02:00
elfparsing.h cbfstool: add ELF writing support 2014-03-18 18:59:25 +01:00
fit.c cbfstool: add eflparsing.h 2014-03-13 05:28:44 +01:00
fit.h cbfstool: Add update-fit command 2013-03-27 01:25:12 +01:00
fv.h GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
linux.h cbfstool:linux_trampoline: config CS and DS segment descriptors 2014-09-04 23:34:32 +02:00
linux_trampoline.c cbfstool:linux_trampoline: config CS and DS segment descriptors 2014-09-04 23:34:32 +02:00
linux_trampoline.h cbfstool:linux_trampoline: config CS and DS segment descriptors 2014-09-04 23:34:32 +02:00
rmodtool.c util: add rmodtool for parsing ELF files to rmodules 2014-03-20 21:34:39 +01:00
rmodule.c rmodtool: correct final memory size calculation 2014-08-27 03:20:27 +02:00
rmodule.h util: add rmodtool for parsing ELF files to rmodules 2014-03-20 21:34:39 +01:00
swab.h Various fixes to cbfstool. 2011-10-24 20:29:29 +02:00
xdr.c cbfstool: add bputs() to store a byte stream to a buffer 2014-03-11 19:43:17 +01:00