Curt Brune (curt(a)cumulusnetworks.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6796
-gerrit
commit 6a9b94a201abbb064faeeba6d83080e81b2ac746
Author: Curt Brune <curt(a)cumulusnetworks.com>
Date: Fri Aug 29 10:43:36 2014 -0700
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(a)cumulusnetworks.com>
---
util/cbfstool/cbfs-payload-linux.c | 5 ++---
util/cbfstool/linux.h | 6 +-----
util/cbfstool/linux_trampoline.c | 44 +++++++++++++++++++++++++++++++-------
util/cbfstool/linux_trampoline.h | 42 ++++++++++++++++++++++++++++++++++++
4 files changed, 81 insertions(+), 16 deletions(-)
diff --git a/util/cbfstool/cbfs-payload-linux.c b/util/cbfstool/cbfs-payload-linux.c
index 33a5e1a..9e9a874 100644
--- a/util/cbfstool/cbfs-payload-linux.c
+++ b/util/cbfstool/cbfs-payload-linux.c
@@ -302,9 +302,8 @@ int parse_bzImage_to_payload(const struct buffer *input,
PAYLOAD_SEGMENT_CODE, kernel_base);
/* trampoline */
- uint64_t entrypoint = 0x40000; /*TODO: any better place? */
bzp_output_segment(&bzp, &bzp.trampoline,
- PAYLOAD_SEGMENT_CODE, entrypoint);
+ PAYLOAD_SEGMENT_CODE, TRAMPOLINE_ENTRY_LOC);
/* cmdline */
bzp_output_segment(&bzp, &bzp.cmdline,
@@ -315,7 +314,7 @@ int parse_bzImage_to_payload(const struct buffer *input,
PAYLOAD_SEGMENT_DATA, initrd_base);
/* Terminating entry segment. */
- bzp_output_segment(&bzp, NULL, PAYLOAD_SEGMENT_ENTRY, entrypoint);
+ bzp_output_segment(&bzp, NULL, PAYLOAD_SEGMENT_ENTRY, TRAMPOLINE_ENTRY_LOC);
/* Set size of buffer taking into account potential compression. */
buffer_set_size(&bzp.output, bzp.offset);
diff --git a/util/cbfstool/linux.h b/util/cbfstool/linux.h
index 20837e3..ae747e6 100644
--- a/util/cbfstool/linux.h
+++ b/util/cbfstool/linux.h
@@ -26,17 +26,13 @@
*/
#include <stdint.h>
+#include "linux_trampoline.h"
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
-#define LINUX_PARAM_LOC 0x90000
-#define COMMAND_LINE_LOC 0x91000
-#define GDT_LOC 0x92000
-#define STACK_LOC 0x93000
-
#define E820MAX 32 /* number of entries in E820MAP */
struct e820entry {
unsigned long long addr; /* start of memory segment */
diff --git a/util/cbfstool/linux_trampoline.c b/util/cbfstool/linux_trampoline.c
index 368d63a..649bb64 100644
--- a/util/cbfstool/linux_trampoline.c
+++ b/util/cbfstool/linux_trampoline.c
@@ -24,12 +24,13 @@
*/
.code32
.data
+
+#include "linux_trampoline.h"
#define HEADER_SIG 0x4f49424c // LBIO little endian
#define CB_TAG_FORWARD 0x11
#define CB_TAG_MEMORY 0x1
#define CB_TAG_FRAMEBUFFER 0x12
-#define LINUX_PARAM_LOC 0x90000
#define E820_NR_OFFSET 0x1e8
#define LINUX_ENTRY_OFFSET 0x214
#define E820_OFFSET 0x2d0
@@ -101,6 +102,30 @@ add 4(%ebx), %ebx
dec %ecx
jnz .tableScan
+/* Setup basic code and data segment selectors for Linux
+**
+** Flat code segment descriptor:
+** selector: 0x10
+** base : 0x00000000
+** limit : 0xFFFFFFFF
+** type : code, execute, read
+**
+** Flat data segment descriptor:
+** selector: 0x18
+** base : 0x00000000
+** limit : 0xFFFFFFFF
+** type : data, read/write
+**
+** Use TRAMPOLINE_ENTRY_LOC as a scratchpad.
+*/
+mov $TRAMPOLINE_ENTRY_LOC, %eax
+sgdt (%eax)
+mov 2(%eax), %ebx
+movl $0x0000ffff, 16(%ebx)
+movl $0x00cf9b00, 20(%ebx)
+movl $0x0000ffff, 24(%ebx)
+movl $0x00cf9300, 28(%ebx)
+
/* finally: jump to kernel */
mov $LINUX_PARAM_LOC, %esi
jmp *(LINUX_PARAM_LOC + LINUX_ENTRY_OFFSET)
@@ -128,13 +153,16 @@ trampoline_size:
const 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, 0x74, 0x60, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, 0x83, 0x3b, 0x11, 0x75, 0x05,
-0x8b, 0x4b, 0x08, 0xeb, 0xd3, 0x83, 0x3b, 0x01, 0x75, 0x33, 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, 0xeb, 0x05, 0x83, 0x3b, 0x12,
-0x75, 0x00, 0x03, 0x5b, 0x04, 0x49, 0x75, 0xb3, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14,
-0x02, 0x09, 0x00, 0xf4, 0xeb, 0xfd
+0xcb, 0x0f, 0x84, 0x85, 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, 0x33, 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, 0xeb,
+0x05, 0x83, 0x3b, 0x12, 0x75, 0x00, 0x03, 0x5b, 0x04, 0x49, 0x75, 0xb3, 0xb8, 0x00, 0x00, 0x04,
+0x00, 0x0f, 0x01, 0x00, 0x8b, 0x58, 0x02, 0xc7, 0x43, 0x10, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x43,
+0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x43, 0x18, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x43, 0x1c, 0x00,
+0x93, 0xcf, 0x00, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, 0xeb,
+0xfd
};
const void * const trampoline_start = &trampoline;
diff --git a/util/cbfstool/linux_trampoline.h b/util/cbfstool/linux_trampoline.h
new file mode 100644
index 0000000..a4a6e93
--- /dev/null
+++ b/util/cbfstool/linux_trampoline.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of coreboot..
+ *
+ * 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
+ */
+
+/*
+ * Copyright 2014 Curt Brune <curt(a)cumulusnetworks.com>
+ * Based on work by Patrick Georgi <patrick(a)georgi-clan.de>
+ */
+
+/*
+ * 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__ */
the following patch was just integrated into master:
commit f9d7252a8d869cfda08c872b49d3ce5d7c27b083
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Sat Aug 16 22:50:57 2014 +0200
lint: simplify board-status check
git can do lots of things by itself, no need to parse
its output and redo that.
Change-Id: Id2cdd2ea8d34c1ba2b0abddc88e1f3260d74f47d
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
Reviewed-on: http://review.coreboot.org/6798
Tested-by: build bot (Jenkins)
Reviewed-by: Vladimir Serbinenko <phcoder(a)gmail.com>
Reviewed-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
See http://review.coreboot.org/6798 for details.
-gerrit
the following patch was just integrated into master:
commit d942ed9aa5bb034c2664d27d09ff7b32ed91fb53
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Sat Aug 30 20:44:37 2014 +0200
acpigen: Correctly handle root scope
Change-Id: I9b3c9109b01e348259e64e93a4397212216ab152
Signed-off-by: Vladimir Serbinenko <phcoder(a)gmail.com>
Reviewed-on: http://review.coreboot.org/6799
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)google.com>
See http://review.coreboot.org/6799 for details.
-gerrit
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6795
-gerrit
commit af2c205a3de9b44e750a3d91e8767dc01040f78b
Author: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Date: Thu Aug 28 23:03:15 2014 +0200
Increase space for ACPI tables when using dynamic CBMEM
Unlike in old style CBMEM, dynamic CBMEM does not have a
hand-calculated, hard-coded size, so allow up to 144K of
space for ACPI tables.
Change-Id: Id9dd7447c46d5fe7ed581be753d70e59add05320
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
src/arch/x86/boot/tables.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/arch/x86/boot/tables.c b/src/arch/x86/boot/tables.c
index 16c752a..42b8a67 100644
--- a/src/arch/x86/boot/tables.c
+++ b/src/arch/x86/boot/tables.c
@@ -109,7 +109,11 @@ void write_tables(void)
#endif /* CONFIG_GENERATE_MP_TABLE */
#if CONFIG_GENERATE_ACPI_TABLES
+#if CONFIG_DYNAMIC_CBMEM
+#define MAX_ACPI_SIZE (144 * 1024)
+#else
#define MAX_ACPI_SIZE (45 * 1024)
+#endif
post_code(0x9c);
/* Write ACPI tables to F segment and high tables area */
Vladimir Serbinenko (phcoder(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6799
-gerrit
commit 3a900f0c2f759ddc95a6b8faf51505c14291f205
Author: Vladimir Serbinenko <phcoder(a)gmail.com>
Date: Sat Aug 30 20:44:37 2014 +0200
acpigen: Correctly handle root scope
Change-Id: I9b3c9109b01e348259e64e93a4397212216ab152
Signed-off-by: Vladimir Serbinenko <phcoder(a)gmail.com>
---
src/arch/x86/boot/acpigen.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/arch/x86/boot/acpigen.c b/src/arch/x86/boot/acpigen.c
index ba3d2df..222a2db 100644
--- a/src/arch/x86/boot/acpigen.c
+++ b/src/arch/x86/boot/acpigen.c
@@ -223,7 +223,12 @@ int acpigen_emit_namestring(const char *namepath) {
namepath++;
}
- ASSERT(namepath[0] != '\0');
+ /* If we have only \\ or only ^...^. Then we need to put a null
+ name (0x00). */
+ if(namepath[0] == '\0') {
+ len += acpigen_emit_byte(0x00);
+ return len;
+ }
i = 0;
while (namepath[i] != '\0') {