Re: svn commit: r232570 - head/sys/boot/i386/boot2
On Wednesday, March 07, 2012 5:00:19 pm Jung-uk Kim wrote: On Monday 05 March 2012 02:53 pm, John Baldwin wrote: Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. As many people pointed out, Clang overflows boot2 again after this commit. Long long time ago, I asked this question on arch@: http://docs.freebsd.org/cgi/mid.cgi?200509081418.47794.jkim Why can't we do that now? Can't we build separate ufs1-only and ufs2-only boot2's, at least? Having ufs1+ufs2 boot block is great but I see very little benefit to support that in 2012. :-/ As I said on the reply to current@, I think having separate boot blocks will be a headache and PITA for our users. Let's see if we can get boot2 to fit without breaking functionality first. It is a shame that gcc outperforms clang so drastically in this case (gcc's boot2 is about 250 bytes smaller than clang's). -- John Baldwin ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r232570 - head/sys/boot/i386/boot2
On 8 Mar 2012, at 16:05, John Baldwin wrote: On Wednesday, March 07, 2012 5:00:19 pm Jung-uk Kim wrote: On Monday 05 March 2012 02:53 pm, John Baldwin wrote: Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. As many people pointed out, Clang overflows boot2 again after this commit. Long long time ago, I asked this question on arch@: http://docs.freebsd.org/cgi/mid.cgi?200509081418.47794.jkim Why can't we do that now? Can't we build separate ufs1-only and ufs2-only boot2's, at least? Having ufs1+ufs2 boot block is great but I see very little benefit to support that in 2012. :-/ As I said on the reply to current@, I think having separate boot blocks will be a headache and PITA for our users. Let's see if we can get boot2 to fit without breaking functionality first. It is a shame that gcc outperforms clang so drastically in this case (gcc's boot2 is about 250 bytes smaller than clang's). I'm going to take a look at the sequence of optimisations that are run with -Os. It's currently mostly the same as -O2, which is probably not ideal. I'll also see if I can create a .ll from boot2 that we can add to the LLVM unit tests so that anyone who pushes it over the size boundary will get a buildbot failure. David___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r232570 - head/sys/boot/i386/boot2
On Monday 05 March 2012 02:53 pm, John Baldwin wrote: Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. As many people pointed out, Clang overflows boot2 again after this commit. Long long time ago, I asked this question on arch@: http://docs.freebsd.org/cgi/mid.cgi?200509081418.47794.jkim Why can't we do that now? Can't we build separate ufs1-only and ufs2-only boot2's, at least? Having ufs1+ufs2 boot block is great but I see very little benefit to support that in 2012. :-/ Jung-uk Kim ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r232570 - head/sys/boot/i386/boot2
On Wednesday 07 March 2012 05:00 pm, Jung-uk Kim wrote: On Monday 05 March 2012 02:53 pm, John Baldwin wrote: Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. As many people pointed out, Clang overflows boot2 again after this commit. Long long time ago, I asked this question on arch@: http://docs.freebsd.org/cgi/mid.cgi?200509081418.47794.jkim Why can't we do that now? Can't we build separate ufs1-only and ufs2-only boot2's, at least? Having ufs1+ufs2 boot block is great but I see very little benefit to support that in 2012. :-/ FYI, this patch does the separation. Also available from here: http://people.freebsd.org/~jkim/boot2.diff Jung-uk Kim Index: sys/boot/i386/Makefile === --- sys/boot/i386/Makefile (revision 232670) +++ sys/boot/i386/Makefile (working copy) @@ -2,8 +2,8 @@ .include bsd.own.mk -SUBDIR=mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot kgzldr \ - libi386 libfirewire loader +SUBDIR=mbr pmbr boot0 boot0sio btx boot2 boot2ufs1 cdboot gptboot \ + kgzldr libi386 libfirewire loader # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr Index: sys/boot/i386/boot2/Makefile === --- sys/boot/i386/boot2/Makefile(revision 232670) +++ sys/boot/i386/boot2/Makefile(working copy) @@ -2,8 +2,10 @@ .include bsd.own.mk -FILES= boot boot1 boot2 +FILES= boot${BOOT_SUFFIX} boot2${BOOT2_SUFFIX} +SRCDIR=${.CURDIR}/../boot2 + NM?= nm # A value of 0x80 enables LBA support. @@ -18,10 +20,22 @@ ORG1= 0x7c00 ORG2= 0x2000 # Decide level of UFS support. -BOOT2_UFS?=UFS1_AND_UFS2 -#BOOT2_UFS?= UFS2_ONLY -#BOOT2_UFS?= UFS1_ONLY +BOOT2_UFS?=UFS2_ONLY +#BOOT2_UFS?= UFS1_AND_UFS2 +.if ${BOOT2_UFS} != UFS1_ONLY +FILES+=boot1 +.endif +.if ${BOOT2_UFS} == UFS1_ONLY +BOOT_SUFFIX= .ufs1 +BOOT2_SUFFIX= ufs1 +.elif ${BOOT2_UFS} == UFS2_ONLY +BOOT_SUFFIX= .ufs2 +BOOT2_SUFFIX= ufs2 +LINKS= ${BINDIR}/boot${BOOT_SUFFIX} ${BINDIR}/boot \ + ${BINDIR}/boot2${BOOT2_SUFFIX} ${BINDIR}/boot2 +.endif + CFLAGS=-Os \ -fno-guess-branch-probability \ -fomit-frame-pointer \ @@ -50,8 +64,8 @@ LDFLAGS=-static -N --gc-sections CLEANFILES=boot -boot: boot1 boot2 - cat boot1 boot2 boot +boot${BOOT_SUFFIX}: boot1 boot2${BOOT2_SUFFIX} + cat ${.ALLSRC} ${.TARGET} CLEANFILES+= boot1 boot1.out boot1.o @@ -64,7 +78,7 @@ boot1.out: boot1.o CLEANFILES+= boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \ boot2.s boot2.s.tmp boot2.h sio.o -boot2: boot2.ld +boot2${BOOT2_SUFFIX}: boot2.ld @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \ echo $$x bytes available; test $$x -ge 0 dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync @@ -88,7 +102,7 @@ boot2.o: boot2.s SRCS= boot2.c boot2.h boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c - ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c + ${CC} ${CFLAGS} -S -o boot2.s.tmp ${SRCDIR}/boot2.c sed -e '/align/d' -e '/nop/d' boot2.s.tmp boot2.s rm -f boot2.s.tmp Index: sys/boot/i386/boot2ufs1/Makefile === --- sys/boot/i386/boot2ufs1/Makefile(revision 0) +++ sys/boot/i386/boot2ufs1/Makefile(working copy) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../boot2 + +BOOT2_UFS= UFS1_ONLY + +.include ${.CURDIR}/../boot2/Makefile Property changes on: sys/boot/i386/boot2ufs1/Makefile ___ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r232570 - head/sys/boot/i386/boot2
On Tuesday, March 06, 2012 6:34:42 am Dimitry Andric wrote: On 2012-03-05 20:53, John Baldwin wrote: Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. Sigh, this broke building boot2 with clang again... :( I only put back 1 of the memcpy's instead of 3 to try to make it as small as possible. :( The problem is the last round of changes to shrink it broke functionality. -- John Baldwin ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r232570 - head/sys/boot/i386/boot2
Author: jhb Date: Mon Mar 5 19:53:17 2012 New Revision: 232570 URL: http://svn.freebsd.org/changeset/base/232570 Log: Fix boot2 to handle boot config files that only contain a custom path to a loader or kernel. Specifically, kname cannot be pointed at cmd[] since it's value is change to be an empty string after the initial call to parse, and cmd[]'s value can be changed (thus losing a prior setting for kname) due to user input at the boot prompt. While here, ensure that that initial boot config file text is nul-terminated, that ops is initialized to zero, and that kname is always initialized to a valid string. Tested by:Domagoj Smolcic rank1seeker of gmail MFC after:1 week Modified: head/sys/boot/i386/boot2/boot2.c Modified: head/sys/boot/i386/boot2/boot2.c == --- head/sys/boot/i386/boot2/boot2.cMon Mar 5 19:38:59 2012 (r232569) +++ head/sys/boot/i386/boot2/boot2.cMon Mar 5 19:53:17 2012 (r232570) @@ -128,7 +128,7 @@ static struct dsk { unsigned start; int init; } dsk; -static char cmd[512], cmddup[512]; +static char cmd[512], cmddup[512], knamebuf[1024]; static const char *kname; static uint32_t opts; static int comspeed = SIOSPD; @@ -223,7 +223,9 @@ main(void) { uint8_t autoboot; ino_t ino; +size_t nbyte; +opts = 0; kname = NULL; dmadat = (void *)(roundup2(__base + (int32_t)_end, 0x1) - __base); v86.ctl = V86_FLAGS; @@ -240,8 +242,10 @@ main(void) autoboot = 1; if ((ino = lookup(PATH_CONFIG)) || -(ino = lookup(PATH_DOTCONFIG))) - fsread(ino, cmd, sizeof(cmd)); +(ino = lookup(PATH_DOTCONFIG))) { + nbyte = fsread(ino, cmd, sizeof(cmd) - 1); + cmd[nbyte] = '\0'; +} if (*cmd) { memcpy(cmddup, cmd, sizeof(cmd)); @@ -258,9 +262,9 @@ main(void) * or in case of failure, try to load a kernel directly instead. */ -if (autoboot !kname) { +if (!kname) { kname = PATH_BOOT3; - if (!keyhit(3*SECOND)) { + if (autoboot !keyhit(3*SECOND)) { load(); kname = PATH_KERNEL; } @@ -457,7 +461,12 @@ parse() ? DRV_HARD : 0) + drv; dsk_meta = 0; } -kname = arg; + if ((i = ep - arg)) { + if ((size_t)i = sizeof(knamebuf)) + return -1; + memcpy(knamebuf, arg, i + 1); + kname = knamebuf; + } } arg = p; } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org