summaryrefslogtreecommitdiff
path: root/util/cbfstool/linux_trampoline.h
diff options
context:
space:
mode:
authorCurt Brune <curt@cumulusnetworks.com>2014-08-29 10:43:36 -0700
committerRonald G. Minnich <rminnich@gmail.com>2014-09-04 23:34:32 +0200
commit3c12cb03847d2db41809ae434530782a7dbef48b (patch)
tree9b55d0f3f28c688258c71dba5627d5ff5f0f7c38 /util/cbfstool/linux_trampoline.h
parent062e408bc77b935798145e29d4031f8105be5086 (diff)
downloadcoreboot-3c12cb03847d2db41809ae434530782a7dbef48b.tar.xz
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>
Diffstat (limited to 'util/cbfstool/linux_trampoline.h')
-rw-r--r--util/cbfstool/linux_trampoline.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/util/cbfstool/linux_trampoline.h b/util/cbfstool/linux_trampoline.h
new file mode 100644
index 0000000000..ed5b824825
--- /dev/null
+++ b/util/cbfstool/linux_trampoline.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of coreboot..
+ *
+ * Based on work by Patrick Georgi <patrick@georgi-clan.de>
+ * Copyright 2014 Curt Brune <curt@cumulusnetworks.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * This file contains #define constants used by both the Linux
+ * trampoline C-code and assembly language code. As such it can only
+ * contain preprocessor macros. Do not inlucde C language
+ * declarations in this file.
+ */
+
+#ifndef LINUX_TRAMPOLINE_H__
+#define LINUX_TRAMPOLINE_H__
+
+/*
+ * Trampoline entry point
+ * TODO: any better place?
+ */
+#define TRAMPOLINE_ENTRY_LOC 0x40000
+
+#define LINUX_PARAM_LOC 0x90000
+#define COMMAND_LINE_LOC 0x91000
+
+#endif /* LINUX_TRAMPOLINE_H__ */