From 8ef367d43c79724bcffa8ee6bcdcefdcbb43278e Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Thu, 8 Oct 1998 21:03:41 +0000 Subject: [PATCH] Fix up the kernel environment and module data pointers in the bootinfo if they are present. If we are told where the end of the loaded kernel image is, believe it. --- sys/amd64/amd64/genassym.c | 5 ++++- sys/amd64/amd64/locore.S | 27 +++++++++++++++++++++++++-- sys/amd64/amd64/locore.s | 27 +++++++++++++++++++++++++-- sys/i386/i386/genassym.c | 5 ++++- sys/i386/i386/locore.s | 27 +++++++++++++++++++++++++-- 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index faffe5168d2..31e5702070e 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.60 1998/08/18 07:46:58 msmith Exp $ + * $Id: genassym.c,v 1.61 1998/09/24 10:22:21 bde Exp $ */ #include "opt_vm86.h" @@ -189,6 +189,9 @@ main() printf("#define\tBI_SIZE %#x\n", OS(bootinfo, bi_size)); printf("#define\tBI_SYMTAB %#x\n", OS(bootinfo, bi_symtab)); printf("#define\tBI_ESYMTAB %#x\n", OS(bootinfo, bi_esymtab)); + printf("#define\tBI_KERNEND %#x\n", OS(bootinfo, bi_kernend)); + printf("#define\tBI_ENVP %#x\n", OS(bootinfo, bi_envp)); + printf("#define\tBI_MODULEP %#x\n", OS(bootinfo, bi_modulep)); printf("#define\tGD_SIZEOF %u\n", sizeof(struct globaldata)); printf("#define\tGD_CURPROC %#x\n", OS(globaldata, curproc)); diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S index 9c3251787d6..0d6ba182e03 100644 --- a/sys/amd64/amd64/locore.S +++ b/sys/amd64/amd64/locore.S @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.112 1998/08/03 21:31:32 msmith Exp $ + * $Id: locore.s,v 1.113 1998/09/28 03:26:22 tegge Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -569,6 +569,22 @@ got_common_bi_size: rep movsb + /* + * Fix up the module data and kernel environment pointers. + */ + movl R(_bootinfo+BI_ENVP),%eax + testl %eax,%eax + je no_envp + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_ENVP) +no_envp: + movl R(_bootinfo+BI_MODULEP),%eax + testl %eax,%eax + je no_modulep + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_MODULEP) +no_modulep: + #ifdef NFS_ROOT #ifndef BOOTP_NFSV3 /* @@ -756,7 +772,7 @@ create_pagetables: /* Find end of kernel image (rounded up to a page boundary). */ movl $R(_end),%esi -/* include symbols in "kernel image" if they are loaded and useful */ +/* include symbols if loaded and useful */ #ifdef DDB movl R(_bootinfo+BI_ESYMTAB),%edi testl %edi,%edi @@ -768,6 +784,13 @@ create_pagetables: over_symalloc: #endif +/* If we are told where the end of the kernel space is, believe it. */ + movl R(_bootinfo+BI_KERNEND),%edi + testl %edi,%edi + je no_kernend + movl %edi,%esi +no_kernend: + addl $PAGE_MASK,%esi andl $~PAGE_MASK,%esi movl %esi,R(_KERNend) /* save end of kernel */ diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s index 9c3251787d6..0d6ba182e03 100644 --- a/sys/amd64/amd64/locore.s +++ b/sys/amd64/amd64/locore.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.112 1998/08/03 21:31:32 msmith Exp $ + * $Id: locore.s,v 1.113 1998/09/28 03:26:22 tegge Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -569,6 +569,22 @@ got_common_bi_size: rep movsb + /* + * Fix up the module data and kernel environment pointers. + */ + movl R(_bootinfo+BI_ENVP),%eax + testl %eax,%eax + je no_envp + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_ENVP) +no_envp: + movl R(_bootinfo+BI_MODULEP),%eax + testl %eax,%eax + je no_modulep + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_MODULEP) +no_modulep: + #ifdef NFS_ROOT #ifndef BOOTP_NFSV3 /* @@ -756,7 +772,7 @@ create_pagetables: /* Find end of kernel image (rounded up to a page boundary). */ movl $R(_end),%esi -/* include symbols in "kernel image" if they are loaded and useful */ +/* include symbols if loaded and useful */ #ifdef DDB movl R(_bootinfo+BI_ESYMTAB),%edi testl %edi,%edi @@ -768,6 +784,13 @@ create_pagetables: over_symalloc: #endif +/* If we are told where the end of the kernel space is, believe it. */ + movl R(_bootinfo+BI_KERNEND),%edi + testl %edi,%edi + je no_kernend + movl %edi,%esi +no_kernend: + addl $PAGE_MASK,%esi andl $~PAGE_MASK,%esi movl %esi,R(_KERNend) /* save end of kernel */ diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index faffe5168d2..31e5702070e 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 - * $Id: genassym.c,v 1.60 1998/08/18 07:46:58 msmith Exp $ + * $Id: genassym.c,v 1.61 1998/09/24 10:22:21 bde Exp $ */ #include "opt_vm86.h" @@ -189,6 +189,9 @@ main() printf("#define\tBI_SIZE %#x\n", OS(bootinfo, bi_size)); printf("#define\tBI_SYMTAB %#x\n", OS(bootinfo, bi_symtab)); printf("#define\tBI_ESYMTAB %#x\n", OS(bootinfo, bi_esymtab)); + printf("#define\tBI_KERNEND %#x\n", OS(bootinfo, bi_kernend)); + printf("#define\tBI_ENVP %#x\n", OS(bootinfo, bi_envp)); + printf("#define\tBI_MODULEP %#x\n", OS(bootinfo, bi_modulep)); printf("#define\tGD_SIZEOF %u\n", sizeof(struct globaldata)); printf("#define\tGD_CURPROC %#x\n", OS(globaldata, curproc)); diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 9c3251787d6..0d6ba182e03 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 - * $Id: locore.s,v 1.112 1998/08/03 21:31:32 msmith Exp $ + * $Id: locore.s,v 1.113 1998/09/28 03:26:22 tegge Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -569,6 +569,22 @@ got_common_bi_size: rep movsb + /* + * Fix up the module data and kernel environment pointers. + */ + movl R(_bootinfo+BI_ENVP),%eax + testl %eax,%eax + je no_envp + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_ENVP) +no_envp: + movl R(_bootinfo+BI_MODULEP),%eax + testl %eax,%eax + je no_modulep + movl $KERNBASE,%eax + addl %eax,R(_bootinfo+BI_MODULEP) +no_modulep: + #ifdef NFS_ROOT #ifndef BOOTP_NFSV3 /* @@ -756,7 +772,7 @@ create_pagetables: /* Find end of kernel image (rounded up to a page boundary). */ movl $R(_end),%esi -/* include symbols in "kernel image" if they are loaded and useful */ +/* include symbols if loaded and useful */ #ifdef DDB movl R(_bootinfo+BI_ESYMTAB),%edi testl %edi,%edi @@ -768,6 +784,13 @@ create_pagetables: over_symalloc: #endif +/* If we are told where the end of the kernel space is, believe it. */ + movl R(_bootinfo+BI_KERNEND),%edi + testl %edi,%edi + je no_kernend + movl %edi,%esi +no_kernend: + addl $PAGE_MASK,%esi andl $~PAGE_MASK,%esi movl %esi,R(_KERNend) /* save end of kernel */