mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Because the BTX mini-kernel now uses flat memory mode and clients
are no longer limited to a virtual address space of 16 megabytes, only mask high two bits of a virtual address. This allows to load larger kernels (up to 1 gigabyte). Not masking addresses at all was a bad idea on machines with less than >3G of memory -- kernels are linked at 0xc0xxxxxx, and that would attempt to load a kernel at above 3G. By masking only two highest bits we stay within the safe limits while still allowing to boot larger kernels. (This is a safer reimplmentation of sys/boot/i386/boot2/boot.2.c rev. 1.71.) Prodded by: jhb Tested by: nyan (pc98)
This commit is contained in:
parent
96ed72ac81
commit
da6d4298b7
5 changed files with 10 additions and 10 deletions
|
|
@ -263,7 +263,7 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off)
|
|||
#if __ELF_WORD_SIZE == 64
|
||||
off = - (off & 0xffffffffff000000ull);/* x86_64 relocates after locore */
|
||||
#else
|
||||
off = - (off & 0xff000000u); /* i386 relocates after locore */
|
||||
off = - (off & 0xc0000000u); /* i386 relocates after locore */
|
||||
#endif
|
||||
#else
|
||||
off = 0; /* other archs use direct mapped kernels */
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ load(void)
|
|||
return;
|
||||
}
|
||||
if (fmt == 0) {
|
||||
addr = hdr.ex.a_entry & 0xffffff;
|
||||
addr = hdr.ex.a_entry & 0x3fffffff;
|
||||
p = PTOV(addr);
|
||||
fs_off = PAGE_SIZE;
|
||||
if (xfsread(ino, p, hdr.ex.a_text))
|
||||
|
|
@ -368,7 +368,7 @@ load(void)
|
|||
j++;
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
p = PTOV(ep[i].p_paddr & 0xffffff);
|
||||
p = PTOV(ep[i].p_paddr & 0x3fffffff);
|
||||
fs_off = ep[i].p_offset;
|
||||
if (xfsread(ino, p, ep[i].p_filesz))
|
||||
return;
|
||||
|
|
@ -389,7 +389,7 @@ load(void)
|
|||
p += es[i].sh_size;
|
||||
}
|
||||
}
|
||||
addr = hdr.eh.e_entry & 0xffffff;
|
||||
addr = hdr.eh.e_entry & 0x3fffffff;
|
||||
}
|
||||
bootinfo.bi_esymtab = VTOP(p);
|
||||
bootinfo.bi_kernelname = VTOP(kname);
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ load(void)
|
|||
return;
|
||||
}
|
||||
if (fmt == 0) {
|
||||
addr = hdr.ex.a_entry & 0xffffff;
|
||||
addr = hdr.ex.a_entry & 0x3fffffff;
|
||||
p = PTOV(addr);
|
||||
fs_off = PAGE_SIZE;
|
||||
if (xfsread(ino, p, hdr.ex.a_text))
|
||||
|
|
@ -368,7 +368,7 @@ load(void)
|
|||
j++;
|
||||
}
|
||||
for (i = 0; i < 2; i++) {
|
||||
p = PTOV(ep[i].p_paddr & 0xffffff);
|
||||
p = PTOV(ep[i].p_paddr & 0x3fffffff);
|
||||
fs_off = ep[i].p_offset;
|
||||
if (xfsread(ino, p, ep[i].p_filesz))
|
||||
return;
|
||||
|
|
@ -389,7 +389,7 @@ load(void)
|
|||
p += es[i].sh_size;
|
||||
}
|
||||
}
|
||||
addr = hdr.eh.e_entry & 0xffffff;
|
||||
addr = hdr.eh.e_entry & 0x3fffffff;
|
||||
}
|
||||
bootinfo.bi_esymtab = VTOP(p);
|
||||
bootinfo.bi_kernelname = VTOP(kname);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ elf32_exec(struct preloaded_file *fp)
|
|||
err = bi_load32(fp->f_args, &boothowto, &bootdev, &bootinfop, &modulep, &kernend);
|
||||
if (err != 0)
|
||||
return(err);
|
||||
entry = ehdr->e_entry & 0xffffff;
|
||||
entry = ehdr->e_entry & 0x3fffffff;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Start @ 0x%lx ...\n", entry);
|
||||
|
|
|
|||
|
|
@ -199,9 +199,9 @@ loadprog(void)
|
|||
/*
|
||||
* We assume that the entry address is the same as the lowest text
|
||||
* address and that the kernel startup code handles relocation by
|
||||
* this address rounded down to a multiple of 16M.
|
||||
* this address rounded down to a multiple of 1G.
|
||||
*/
|
||||
startaddr = head.a_entry & 0x00FFFFFF;
|
||||
startaddr = head.a_entry & 0x3FFFFFFF;
|
||||
addr = startaddr;
|
||||
printf("Booting %d:%s(%d,%c)%s @ 0x%x\n"
|
||||
, dosdev & 0x0f
|
||||
|
|
|
|||
Loading…
Reference in a new issue