Return to BSD News archive
Newsgroups: comp.os.386bsd.bugs Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!darwin.sura.net!newsserver.jvnc.net!gmd.de!borneo!veit From: veit@borneo.gmd.de (Holger Veit) Subject: boot larger kernels repost+add Message-ID: <1993Jul18.204728.14155@gmd.de> Sender: news@gmd.de (USENET News) Nntp-Posting-Host: borneo Organization: GMD - German National Research Center for Computer Science X-Newsreader: Tin 1.1 PL5 Date: Sun, 18 Jul 1993 20:47:28 GMT Lines: 235 This is a repost of the 1MB fix posted some days ago. It seems the original tar file was modified somehow. The tar program reported an error on unpacking, but I verified that the fix itself is intact. Okay, now again, this time as a plain text file. I was too lazy to make a shar for that, so extract the README and the fix yourself. Also, Bruce Evans reminded me that the kvm_mkdb program has the same bug as the dbsym program I fixed. I already encountered this when kvm_mkdb complained at boot up. The fix for kvm_mkdb is now also appended. ================= README: This is hopefully the long awaited >=1MB fix, or at least a part of, because one essential thing is still missing: reclaiming of of the now unoccupied 640K below. Finding the bugs which prevent booting a relocated kernel was hard enough, now modifying the pmap tables to become non-contiguous, is even harder (at least without careful study what is exactly going on in pmap.c). This is left as a homework for someone :-), the critical part in locore.s and machdep.c which is really hard to trace (without having a debugger working) is done. The part to modify pmap.c at least has debugger support. Note the real bug is in machdep.c, and it looks quite innocent. A second one is in boot.c (you need the julian-boot loader patched and installed), this patch has been found by Jamie da Silva who is working on Mach porting to NetBSD/386bsd. I already booted a kernel of 700K with all the goodies I could find, so I think it is not very far from working. I also modified dbsym.c to understand a relinked kernel. Please test these patches and tell me if they work (veit@gmd.de). Holger ==================== fix+kvm_mkdb.patch *** /usr/src/usr.sbin/kvm_mkdb/nlist.c.patchkit Sun Jul 18 11:32:10 1993 --- /usr/src/usr.sbin/kvm_mkdb/nlist.c Sun Jul 18 11:31:55 1993 *************** *** 146,152 **** rel_off = nbuf.n_value & ~KERNBASE; #endif #ifdef i386 ! rel_off = ((nbuf.n_value & ~KERNBASE) + CLBYTES); #endif /* * When loaded, data is rounded to next page cluster --- 146,155 ---- rel_off = nbuf.n_value & ~KERNBASE; #endif #ifdef i386 ! /* -hv- 180793 for kernel loaded at 0xfe100000, ! * ~KERNBASE alone is not correct mask ! */ ! rel_off = ((nbuf.n_value & ~(KERNBASE|0x00F00000)) + CLBYTES); #endif /* * When loaded, data is rounded to next page cluster *** /sys/i386/i386/locore.s.patchkit-0.2.4 Mon Jul 12 09:58:13 1993 --- /sys/i386/i386/locore.s Wed Jul 14 16:31:04 1993 *************** *** 252,258 **** movl %esi,%ecx # this much memory, shrl $ PGSHIFT,%ecx # for this many pte s addl $ UPAGES+4,%ecx # including our early context ! movl $0xa0,%ecx # XXX - cover debugger pages movl $PG_V|PG_KW,%eax # having these bits set, lea (4*NBPG)(%esi),%ebx # physical address of KPT in proc 0, movl %ebx,_KPTphys-SYSTEM # in the kernel page table, --- 252,258 ---- movl %esi,%ecx # this much memory, shrl $ PGSHIFT,%ecx # for this many pte s addl $ UPAGES+4,%ecx # including our early context ! # movl $0xa0,%ecx # XXX - cover debugger pages movl $PG_V|PG_KW,%eax # having these bits set, lea (4*NBPG)(%esi),%ebx # physical address of KPT in proc 0, movl %ebx,_KPTphys-SYSTEM # in the kernel page table, *** /sys/i386/conf/Makefile.i386.patchkit-0.2.4 Mon Jul 12 09:56:13 1993 --- /sys/i386/conf/Makefile.i386 Mon Jul 12 09:57:58 1993 *************** *** 57,63 **** SYSTEM_OBJS=locore.o ${OBJS} param.o ioconf.o conf.o SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ ! SYSTEM_LD= @${LD} -z -T FE000000 -o $@ -X vers.o ${SYSTEM_OBJS} SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ dbsym $@ 2>/dev/null || true; size $@; chmod 755 $@ --- 57,63 ---- SYSTEM_OBJS=locore.o ${OBJS} param.o ioconf.o conf.o SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS} SYSTEM_LD_HEAD= @echo loading $@; rm -f $@ ! SYSTEM_LD= @${LD} -z -T FE100000 -o $@ -X vers.o ${SYSTEM_OBJS} SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \ dbsym $@ 2>/dev/null || true; size $@; chmod 755 $@ *** /sys/i386/i386/machdep.c.patchkit-0.2.4 Tue Jul 13 12:33:46 1993 --- /sys/i386/i386/machdep.c Wed Jul 14 16:33:47 1993 *************** *** 941,947 **** Maxmem = 640/4; else { Maxmem = pagesinext + 0x100000/NBPG; ! first = 0x100000; /* skip hole */ } /* This used to explode, since Maxmem used to be 0 for bas CMOS*/ --- 941,947 ---- Maxmem = 640/4; else { Maxmem = pagesinext + 0x100000/NBPG; ! /*hv This is junk! first = 0x100000; */ /* skip hole */ } /* This used to explode, since Maxmem used to be 0 for bas CMOS*/ *** /sys/i386/boot/boot.c.patchkit Sat Jun 26 03:07:52 1993 --- /sys/i386/boot/boot.c Thu Jul 8 12:42:46 1993 *************** *** 126,132 **** { long int startaddr; long int addr; /* physical address.. not directly useable */ ! int i; static int (*x_entry)() = 0; unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ --- 126,132 ---- { long int startaddr; long int addr; /* physical address.. not directly useable */ ! int atzero, i; static int (*x_entry)() = 0; unsigned char tmpbuf[4096]; /* we need to load the first 4k here */ *************** *** 151,156 **** --- 151,157 ---- , 'a'+part , name , addr); + atzero = (addr == 0); if(addr < ouraddr) { if((addr + head.a_text + head.a_data) > ouraddr) *************** *** 178,187 **** /* LOAD THE TEXT SEGMENT */ /* don't clobber the first 4k yet (BIOS NEEDS IT) */ /********************************************************/ ! read(tmpbuf,4096); ! addr += 4096; ! xread(addr, head.a_text - 4096); ! addr += head.a_text - 4096; /********************************************************/ /* Load the Initialised data after the text */ --- 179,194 ---- /* LOAD THE TEXT SEGMENT */ /* don't clobber the first 4k yet (BIOS NEEDS IT) */ /********************************************************/ ! if(atzero) { ! read(tmpbuf,4096); ! addr += 4096; ! xread(addr, head.a_text - 4096); ! addr += head.a_text - 4096; ! } ! else { ! xread(addr, head.a_text); ! addr += head.a_text; ! } /********************************************************/ /* Load the Initialised data after the text */ *************** *** 279,285 **** /* copy that first page and overwrite any BIOS variables */ /****************************************************************/ printf(" entry point=0x%x \n" ,((int)startaddr) & 0xffffff); ! pcpy(tmpbuf, 0, 4096); startprog(((int)startaddr & 0xffffff),argv); } --- 286,292 ---- /* copy that first page and overwrite any BIOS variables */ /****************************************************************/ printf(" entry point=0x%x \n" ,((int)startaddr) & 0xffffff); ! if(atzero) pcpy(tmpbuf, 0, 4096); startprog(((int)startaddr & 0xffffff),argv); } *** /usr/src/usr.sbin/dbsym/dbsym.c.patchkit Tue Apr 28 21:51:33 1992 --- /usr/src/usr.sbin/dbsym/dbsym.c Tue Jul 13 13:04:19 1993 *************** *** 6,12 **** char *malloc (); ! #define FILE_OFFSET(vadr) (((vadr) & ~0xff000000)-N_DATADDR(hdr)+N_DATOFF(hdr)) struct nlist *old_syms; int num_old_syms; --- 6,19 ---- char *malloc (); ! /* hv 130793: Unfortunately the original code works correct only ! * if the kernel is linked for 0x0. So let's exchange the hack below ! * with one that works only if the kernel image is smaller than 1MB. ! * ! * XXX You can check for the address where "locore.o" is loaded and ! * subtract this, to get a correct value. ! */ ! #define FILE_OFFSET(vadr) (((vadr) & ~0xfff00000)-N_DATADDR(hdr)+N_DATOFF(hdr)) struct nlist *old_syms; int num_old_syms; -- Dr. Holger Veit | INTERNET: Holger.Veit@gmd.de | | / GMD-SET German National Research | Phone: (+49) 2241 14 2448 |__| / Center for Computer Science | Fax: (+49) 2241 14 2342 | | / P.O. Box 13 16 | Had a nightmare yesterday: | |/ Schloss Birlinghoven | My system started up with 53731 St. Augustin, Germany | ... Booting vmunix.el ... -- Dr. Holger Veit | INTERNET: Holger.Veit@gmd.de | | / GMD-SET German National Research | Phone: (+49) 2241 14 2448 |__| / Center for Computer Science | Fax: (+49) 2241 14 2342 | | / P.O. Box 13 16 | Had a nightmare yesterday: | |/ Schloss Birlinghoven | My system started up with 53731 St. Augustin, Germany | ... Booting vmunix.el ...