summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Wilsdon <jwilsdon@joyent.com>2012-08-07 11:44:00 -0700
committerJosh Wilsdon <jwilsdon@joyent.com>2012-08-07 11:44:00 -0700
commitbacaa89de738eb247571353feefc280727fd26e8 (patch)
tree7219c5998e68a54f0646322e74d573d5805d9440
parentd145a69b03243d4ec0db78fd70ce2fd2ebcb8bea (diff)
downloadillumos-kvm-cmd-bacaa89de738eb247571353feefc280727fd26e8.tar.gz
HVM-741 add SmartOS gPXE patch that was applied for OS-11532012082320120809
-rw-r--r--pc-bios/smartos-gpxe.patch112
1 files changed, 112 insertions, 0 deletions
diff --git a/pc-bios/smartos-gpxe.patch b/pc-bios/smartos-gpxe.patch
new file mode 100644
index 0000000..869017e
--- /dev/null
+++ b/pc-bios/smartos-gpxe.patch
@@ -0,0 +1,112 @@
+diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c
+index 5b62095..a581318 100644
+--- a/src/arch/i386/image/multiboot.c
++++ b/src/arch/i386/image/multiboot.c
+@@ -37,6 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
+ #include <gpxe/elf.h>
+ #include <gpxe/init.h>
+ #include <gpxe/features.h>
++#include <gpxe/umalloc.h>
+
+ FEATURE ( FEATURE_IMAGE, "Multiboot", DHCP_EB_FEATURE_MULTIBOOT, 1 );
+
+@@ -416,6 +417,44 @@ static int multiboot_load_elf ( struct image *image ) {
+ return 0;
+ }
+
++static void multiboot_solaris_workarounds ( struct image *image ) {
++ Elf32_Ehdr ehdr;
++
++ if ( image->len < sizeof (ehdr) )
++ return;
++
++ copy_from_user( &ehdr, image->data, 0, sizeof (ehdr) );
++
++ if ( memcmp ( &ehdr.e_ident[EI_MAG0], ELFMAG, SELFMAG ) != 0 ||
++ ehdr.e_ident[EI_OSABI] != ELFOSABI_SOLARIS )
++ return;
++
++ DBGC ( image, "MULTIBOOT %p: applying Solaris workarounds\n", image );
++
++ /* Solaris expects a full path containing the architecture, not just
++ * the filename of the kernel
++ */
++ if ( ehdr.e_ident[EI_CLASS] == ELFCLASS64 ) {
++ strncpy ( image->name, "/platform/i86pc/kernel/amd64/unix",
++ sizeof (image->name) );
++ } else {
++ strncpy ( image->name, "/platform/i86pc/kernel/unix",
++ sizeof (image->name) );
++ }
++
++ /* Solaris's pre-kernel routine expects to have a free memory region
++ * directly after the ramdisk. However, gPXE allocates memory from
++ * high addresses to low, causing the ramdisk to be placed directly
++ * before the kernel in memory. To workaround this, we allocate a
++ * chunk of memory here, opening up a free memory region between the
++ * kernel and ramdisk. Note that the size of this region must be
++ * balanced: it must be large enough for Solaris to boot without
++ * being so large that an important class of machines is rendered
++ * unbootable. For now, 128MB seems to hit that sweet spot.
++ */
++ urealloc( UNULL, 128 * 1024 * 1024 );
++}
++
+ /**
+ * Load multiboot image into memory
+ *
+@@ -455,6 +494,8 @@ static int multiboot_load ( struct image *image ) {
+ ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
+ return rc;
+
++ multiboot_solaris_workarounds( image );
++
+ return 0;
+ }
+
+diff --git a/src/include/elf.h b/src/include/elf.h
+index 04022b6..63bed89 100644
+--- a/src/include/elf.h
++++ b/src/include/elf.h
+@@ -138,6 +138,28 @@ FILE_LICENCE ( GPL2_OR_LATER );
+ #define EI_VERSION 6 /* File version byte index */
+ /* Value must be EV_CURRENT */
+
++#define EI_OSABI 7 /* OS ABI byte index */
++
++#define ELFOSABI_NONE 0 /* No extensions or unspecified */
++#define ELFOSABI_SYSV ELFOSABI_NONE
++#define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
++#define ELFOSABI_NETBSD 2 /* NetBSD */
++#define ELFOSABI_LINUX 3 /* Linux */
++#define ELFOSABI_HURD 4 /* Hurd */
++#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
++#define ELFOSABI_SOLARIS 6 /* Sun Solaris */
++#define ELFOSABI_AIX 7 /* AIX */
++#define ELFOSABI_IRIX 8 /* IRIX */
++#define ELFOSABI_FREEBSD 9 /* FreeBSD */
++#define ELFOSABI_TRU64 10 /* TRU64 UNIX */
++#define ELFOSABI_MODESTO 11 /* Novell Modesto */
++#define ELFOSABI_OPENBSD 12 /* Open BSD */
++#define ELFOSABI_OPENVMS 13 /* Open VMS */
++#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
++#define ELFOSABI_AROS 15 /* Amiga Research OS */
++#define ELFOSABI_ARM 97 /* ARM */
++#define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
++
+ #define EV_NONE 0 /* Invalid ELF Version */
+ #define EV_CURRENT 1 /* Current version */
+
+diff --git a/src/include/gpxe/image.h b/src/include/gpxe/image.h
+index 10db8af..702ad45 100644
+--- a/src/include/gpxe/image.h
++++ b/src/include/gpxe/image.h
+@@ -29,7 +29,7 @@ struct image {
+ /** URI of image */
+ struct uri *uri;
+ /** Name */
+- char name[16];
++ char name[256];
+ /** Flags */
+ unsigned int flags;
+