summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2017-06-23 12:16:52 +0300
committerRobert Mustacchi <rm@joyent.com>2017-07-13 04:44:00 +0000
commit7b2aa5025b5cb19357aa7a3fb2d5630190d0c552 (patch)
tree87c36cf51cfee5edc0f0f4da31d38999949c88df
parent8221efec02725289918c06a850adcd7393394c8b (diff)
downloadillumos-joyent-7b2aa5025b5cb19357aa7a3fb2d5630190d0c552.tar.gz
8421 loader: chain load relocate data declaration is bad
Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Dillon Amburgey <dillona@dillona.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/libi386.h5
-rw-r--r--usr/src/boot/sys/boot/i386/libi386/linux.c75
-rw-r--r--usr/src/boot/sys/boot/i386/loader/chain.c7
4 files changed, 43 insertions, 46 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index 782a9fa9c1..4a0d16a0d4 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -33,4 +33,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2017.6.11.1
+BOOT_VERSION = $(LOADER_VERSION)-2017.6.29.1
diff --git a/usr/src/boot/sys/boot/i386/libi386/libi386.h b/usr/src/boot/sys/boot/i386/libi386/libi386.h
index f03346f117..9574b15526 100644
--- a/usr/src/boot/sys/boot/i386/libi386/libi386.h
+++ b/usr/src/boot/sys/boot/i386/libi386/libi386.h
@@ -70,7 +70,10 @@ struct relocate_data {
extern void relocater(void);
-extern uint32_t relocater_data;
+/*
+ * The relocater_data[] is fixed size array allocated in relocater_tramp.S
+ */
+extern struct relocate_data relocater_data[];
extern uint32_t relocater_size;
extern uint16_t relocator_ip;
diff --git a/usr/src/boot/sys/boot/i386/libi386/linux.c b/usr/src/boot/sys/boot/i386/libi386/linux.c
index 5d0a6435d3..fe15b14a30 100644
--- a/usr/src/boot/sys/boot/i386/libi386/linux.c
+++ b/usr/src/boot/sys/boot/i386/libi386/linux.c
@@ -97,14 +97,6 @@ linux_loadkernel(char *filename, uint64_t dest, struct preloaded_file **result)
int setup_sects, linux_big;
unsigned long data, text;
vm_offset_t mem;
- struct relocate_data *rdata;
-
- /*
- * relocater_data is space allocated in relocater_tramp.S
- * There is space for 3 instances + terminating zero in case
- * all 3 entries are used.
- */
- rdata = (struct relocate_data *)&relocater_data;
if (filename == NULL)
return (EFTYPE);
@@ -245,25 +237,30 @@ linux_loadkernel(char *filename, uint64_t dest, struct preloaded_file **result)
fp->f_size = LINUX_SETUP_MOVE_SIZE;
linux_text_len = text;
+ /*
+ * relocater_data is space allocated in relocater_tramp.S
+ * There is space for 3 instances + terminating zero in case
+ * all 3 entries are used.
+ */
if (linux_big == 0) {
- rdata[0].src = LINUX_BZIMAGE_ADDR;
- rdata[0].dest = LINUX_ZIMAGE_ADDR;
- rdata[0].size = text;
- rdata[1].src = linux_data_tmp_addr;
- rdata[1].dest = linux_data_real_addr;
- rdata[1].size = LINUX_SETUP_MOVE_SIZE;
+ relocater_data[0].src = LINUX_BZIMAGE_ADDR;
+ relocater_data[0].dest = LINUX_ZIMAGE_ADDR;
+ relocater_data[0].size = text;
+ relocater_data[1].src = linux_data_tmp_addr;
+ relocater_data[1].dest = linux_data_real_addr;
+ relocater_data[1].size = LINUX_SETUP_MOVE_SIZE;
/* make sure the next entry is zeroed */
- rdata[2].src = 0;
- rdata[2].dest = 0;
- rdata[2].size = 0;
+ relocater_data[2].src = 0;
+ relocater_data[2].dest = 0;
+ relocater_data[2].size = 0;
} else {
- rdata[0].src = linux_data_tmp_addr;
- rdata[0].dest = linux_data_real_addr;
- rdata[0].size = LINUX_SETUP_MOVE_SIZE;
+ relocater_data[0].src = linux_data_tmp_addr;
+ relocater_data[0].dest = linux_data_real_addr;
+ relocater_data[0].size = LINUX_SETUP_MOVE_SIZE;
/* make sure the next entry is zeroed */
- rdata[1].src = 0;
- rdata[1].dest = 0;
- rdata[1].size = 0;
+ relocater_data[1].src = 0;
+ relocater_data[1].dest = 0;
+ relocater_data[1].size = 0;
}
*result = fp;
@@ -279,7 +276,6 @@ linux_exec(struct preloaded_file *fp)
struct linux_kernel_header *lh = (struct linux_kernel_header *)
PTOV(linux_data_tmp_addr);
struct preloaded_file *mfp = fp->f_next;
- struct relocate_data *rdata;
char *arg, *vga;
char *src, *dst;
int linux_big;
@@ -298,7 +294,6 @@ linux_exec(struct preloaded_file *fp)
if (rootdev != NULL)
relocator_edx = bd_unit2bios(rootdev->d_unit);
- rdata = (struct relocate_data *)&relocater_data;
/*
* command line
* if not set in fp, read from boot-args env
@@ -367,22 +362,22 @@ linux_exec(struct preloaded_file *fp)
/* need to relocate initrd first */
if (linux_big == 0) {
- rdata[2].src = rdata[1].src;
- rdata[2].dest = rdata[1].dest;
- rdata[2].size = rdata[1].size;
- rdata[1].src = rdata[0].src;
- rdata[1].dest = rdata[0].dest;
- rdata[1].size = rdata[0].size;
- rdata[0].src = mfp->f_addr;
- rdata[0].dest = moveto;
- rdata[0].size = mfp->f_size;
+ relocater_data[2].src = relocater_data[1].src;
+ relocater_data[2].dest = relocater_data[1].dest;
+ relocater_data[2].size = relocater_data[1].size;
+ relocater_data[1].src = relocater_data[0].src;
+ relocater_data[1].dest = relocater_data[0].dest;
+ relocater_data[1].size = relocater_data[0].size;
+ relocater_data[0].src = mfp->f_addr;
+ relocater_data[0].dest = moveto;
+ relocater_data[0].size = mfp->f_size;
} else {
- rdata[1].src = rdata[0].src;
- rdata[1].dest = rdata[0].dest;
- rdata[1].size = rdata[0].size;
- rdata[0].src = mfp->f_addr;
- rdata[0].dest = moveto;
- rdata[0].size = mfp->f_size;
+ relocater_data[1].src = relocater_data[0].src;
+ relocater_data[1].dest = relocater_data[0].dest;
+ relocater_data[1].size = relocater_data[0].size;
+ relocater_data[0].src = mfp->f_addr;
+ relocater_data[0].dest = moveto;
+ relocater_data[0].size = mfp->f_size;
}
lh->ramdisk_image = moveto;
lh->ramdisk_size = mfp->f_size;
diff --git a/usr/src/boot/sys/boot/i386/loader/chain.c b/usr/src/boot/sys/boot/i386/loader/chain.c
index 74f75adffb..faa1dbb608 100644
--- a/usr/src/boot/sys/boot/i386/loader/chain.c
+++ b/usr/src/boot/sys/boot/i386/loader/chain.c
@@ -45,7 +45,6 @@ command_chain(int argc, char *argv[])
int fd, len, size = SECTOR_SIZE;
struct stat st;
vm_offset_t mem = 0x100000;
- uint32_t *uintptr = &relocater_data;
struct i386_devdesc *rootdev;
if (argc == 1) {
@@ -97,9 +96,9 @@ command_chain(int argc, char *argv[])
return (CMD_ERROR);
}
- uintptr[0] = mem;
- uintptr[1] = 0x7C00;
- uintptr[2] = size;
+ relocater_data[0].src = mem;
+ relocater_data[0].dest = 0x7C00;
+ relocater_data[0].size = size;
relocator_edx = bd_unit2bios(rootdev->d_unit);
relocator_esi = relocater_size;