OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: [patch] Installboot.c add -c to force_chs on amd64 & i386

From: Jérôme Loyet (jeromeloyet.net)
Date: Thu Aug 07 2008 - 15:06:42 CDT


Hi tech,

I was reading the changes made since 4.3
(http://www.openbsd.org/plus.html) and I saw this line:

Fix in bootloader to skip CHS checks if LBA is found and OK.

I searched for this change in the sources but I was unable to find it.
Can someone tell me where the change has been made please ?

On the same subject, I submited a patch to add the -c flag to
installboot for i386 and amd64 in order to force CHS mode at
installboot. Nobody commented it, no one is interested ? No one wants
to include it in the source ?

Thx for the answers.

++ Jerome

2008/4/25 Jirtme Loyet <jeromeloyet.net>
>
> Sorry guys,
>
> I sent you the wrong version of the patch. Thanks to Kenneth who made
> me realise I forgot to update the getopt argument.
>
> here is the updated version (the patch is still attached):
>
>
> Index: sys/arch/i386/stand/installboot/installboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/stand/installboot/installboot.c,v
> retrieving revision 1.49
> diff -u -r1.49 installboot.c
> --- sys/arch/i386/stand/installboot/installboot.c 14 Feb 2006
17:16:19
> -0000 1.49
> +++ sys/arch/i386/stand/installboot/installboot.c 25 Apr 2008 12:17:02
-0000
> -70,7 +70,7
> };
>
> extern char *__progname;
> -int verbose, nowrite = 0;
> +int verbose, nowrite = 0, forcechs = 0;
> char *boot, *proto, *dev, *realdev;
> struct sym_data pbr_symbols[] = {
> {"_fs_bsize_p", 2},
> -80,6 +80,7
> {"_inodeblk", 4},
> {"_inodedbl", 4},
> {"_nblocks", 2},
> + {"_force_chs", 1},
> {NULL}
> };
>
> -98,7 +99,7
> static void
> usage(void)
> {
> - fprintf(stderr, "usage: %s [-nv] boot biosboot device\n",
__progname);
> + fprintf(stderr, "usage: %s [-cnv] boot biosboot device\n",
__progname);
> exit(1);
> }
>
> -120,8 +121,12
> struct dos_partition *dp;
> off_t startoff = 0;
>
> - while ((c = getopt(argc, argv, "vn")) != -1) {
> + while ((c = getopt(argc, argv, "cvn")) != -1) {
> switch (c) {
> + case 'c':
> + /* Force CHS mode at biosboot runtime */
> + forcechs = 1;
> + break;
> case 'n':
> /* Do not actually write the bootblock to disk. */
> nowrite = 1;
> -434,6 +439,8
> sym_set_value(pbr_symbols, "_inodedbl",
> ((((char *)ap) - buf) + INODEOFF));
> sym_set_value(pbr_symbols, "_nblocks", ndb);
> + if (forcechs)
> + sym_set_value(pbr_symbols, "_force_chs", 1);
>
> if (verbose) {
> fprintf(stderr, "%s is %d blocks x %d bytes\n",
> Index: sys/arch/i386/stand/installboot/installboot.8
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/stand/installboot/installboot.8,v
> retrieving revision 1.28
> diff -u -r1.28 installboot.8
> --- sys/arch/i386/stand/installboot/installboot.8 31 May 2007
19:20:03
> -0000 1.28
> +++ sys/arch/i386/stand/installboot/installboot.8 25 Apr 2008 12:17:03
-0000
> -33,7 +33,7
> .Nd installs a bootstrap on an FFS disk or partition
> .Sh SYNOPSIS
> .Nm installboot
> -.Op Fl nv
> +.Op Fl cnv
> .Ar boot
> .Ar biosboot
> .Ar disk
> -52,6 +52,10
> .Pp
> The options are as follows:
> .Bl -tag -width flag_opt
> +.It Fl c
> +Force CHS mode at
> +.Ar biosboot
> +runtime.
> .It Fl n
> Do not actually write anything on the disk.
> .It Fl v
> Index: sys/arch/i386/stand/biosboot/biosboot.S
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/stand/biosboot/biosboot.S,v
> retrieving revision 1.38
> diff -u -r1.38 biosboot.S
> --- sys/arch/i386/stand/biosboot/biosboot.S 31 May 2007 23:34:46 -0000
1.38
> +++ sys/arch/i386/stand/biosboot/biosboot.S 25 Apr 2008 12:17:03 -0000
> -108,16 +108,13
> * While this can be calculated as
> * howmany(di_size, fs_bsize) it takes us too
> * many code bytes to do it.
> + * force_chs uint8 set to the value 1 to force biosboot to use CHS
> + * reads (this will of course cause the boot sequence
> + * to fail if /boot is above 8 GB) ("-c" flag in
installboot).
> *
> * All of these are patched directly into the code where they are used
> * (once only, each), to save space.
> *
> - * One more symbol is exported, in anticipation of a "-c" flag in
> - * installboot to force CHS reads:
> - *
> - * force_chs uint8 set to the value 1 to force biosboot to use CHS
> - * reads (this will of course cause the boot sequence
> - * to fail if /boot is above 8 GB).
> */
>
> .globl inodeblk, inodedbl, fs_bsize_p, fsbtodb, p_offset, nblocks
> Index: sys/arch/amd64/stand/installboot/installboot.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/installboot/installboot.c,v
> retrieving revision 1.6
> diff -u -r1.6 installboot.c
> --- sys/arch/amd64/stand/installboot/installboot.c 14 Feb 2006
> 17:16:19 -0000 1.6
> +++ sys/arch/amd64/stand/installboot/installboot.c 25 Apr 2008 12:17:03
-0000
> -74,7 +74,7
> };
>
> extern char *__progname;
> -int verbose, nowrite = 0;
> +int verbose, nowrite = 0, forcechs = 0;
> char *boot, *proto, *dev, *realdev;
> struct sym_data pbr_symbols[] = {
> {"_fs_bsize_p", 2},
> -84,6 +84,7
> {"_inodeblk", 4},
> {"_inodedbl", 4},
> {"_nblocks", 2},
> + {"_force_chs", 1},
> {NULL}
> };
>
> -102,7 +103,7
> static void
> usage(void)
> {
> - fprintf(stderr, "usage: %s [-nv] boot biosboot device\n",
__progname);
> + fprintf(stderr, "usage: %s [-cnv] boot biosboot device\n",
__progname);
> exit(1);
> }
>
> -124,8 +125,12
> struct dos_partition *dp;
> off_t startoff = 0;
>
> - while ((c = getopt(argc, argv, "vn")) != -1) {
> + while ((c = getopt(argc, argv, "cvn")) != -1) {
> switch (c) {
> + case 'c':
> + /* Force CHS mode at biosboot runtime */
> + forcechs = 1;
> + break;
> case 'n':
> /* Do not actually write the bootblock to disk. */
> nowrite = 1;
> -438,6 +443,8
> sym_set_value(pbr_symbols, "_inodedbl",
> ((((char *)ap) - buf) + INODEOFF));
> sym_set_value(pbr_symbols, "_nblocks", ndb);
> + if (forcechs)
> + sym_set_value(pbr_symbols, "_force_chs", 1);
>
> if (verbose) {
> fprintf(stderr, "%s is %d blocks x %d bytes\n",
> Index: sys/arch/amd64/stand/installboot/installboot.8
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/installboot/installboot.8,v
> retrieving revision 1.3
> diff -u -r1.3 installboot.8
> --- sys/arch/amd64/stand/installboot/installboot.8 31 May 2007
> 19:20:02 -0000 1.3
> +++ sys/arch/amd64/stand/installboot/installboot.8 25 Apr 2008 12:17:03
-0000
> -33,7 +33,7
> .Nd installs a bootstrap on an FFS disk or partition
> .Sh SYNOPSIS
> .Nm installboot
> -.Op Fl nv
> +.Op Fl cnv
> .Ar boot
> .Ar biosboot
> .Ar disk
> -52,6 +52,10
> .Pp
> The options are as follows:
> .Bl -tag -width flag_opt
> +.It Fl c
> +Force CHS mode at
> +.Ar biosboot
> +runtime.
> .It Fl n
> Do not actually write anything on the disk.
> .It Fl v
> Index: sys/arch/amd64/stand/biosboot/biosboot.S
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/stand/biosboot/biosboot.S,v
> retrieving revision 1.3
> diff -u -r1.3 biosboot.S
> --- sys/arch/amd64/stand/biosboot/biosboot.S 31 May 2007 18:08:13 -0000
1.3
> +++ sys/arch/amd64/stand/biosboot/biosboot.S 25 Apr 2008 12:17:04 -0000
> -108,16 +108,12
> * While this can be calculated as
> * howmany(di_size, fs_bsize) it takes us too
> * many code bytes to do it.
> + * force_chs uint8 set to the value 1 to force biosboot to use CHS
> + * reads (this will of course cause the boot sequence
> + * to fail if /boot is above 8 GB) ("-c" flag in
installboot).
> *
> * All of these are patched directly into the code where they are used
> * (once only, each), to save space.
> - *
> - * One more symbol is exported, in anticipation of a "-c" flag in
> - * installboot to force CHS reads:
> - *
> - * force_chs uint8 set to the value 1 to force biosboot to use CHS
> - * reads (this will of course cause the boot sequence
> - * to fail if /boot is above 8 GB).
> */
>
> .globl inodeblk, inodedbl, fs_bsize_p, fsbtodb, p_offset, nblocks
>
>
> 2008/4/25, Jirtme Loyet <jeromeloyet.net>:
> > Hi,
> >
> > as I was unable to boot in LBA mode and as the biosboot wan not able
> > to switch back to CHS mode by itself and as I had no keyboard on the
> > computer (I can't hold the SHIFT key to force CHS mode at runtime), I
> > looked into the sources of biosboot. I've seen that a parameter
> > (force_chs) was there to force CHS mode but was not used by
> > installboot. I made a patch to add "-c" flag in installboot to set
> > this global parameter in biosboot.
> >
> > As far as I know it works for amd64. I apply the same modifications to
i386's.
> > This patch changes installboot.c installboot.8 and biosboot.S (the
> > comment about force_chs is exported but not yet used by installboot
> > cause waiting for "-c" flag). I hope I didn't forget something.
> >
> > Is it the good way to make it works ?
> > Any comments are welcome.
> > The patch is included "in text" below and as an attachment to avoid
> > syntax format problems.
> >
> > ++ Jerome
> >
> > Index: sys/arch/amd64/stand/installboot/installboot.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/amd64/stand/installboot/installboot.c,v
> > retrieving revision 1.6
> > diff -u -r1.6 installboot.c
> > --- sys/arch/amd64/stand/installboot/installboot.c 14 Feb 2006
> > 17:16:19 -0000 1.6
> > +++ sys/arch/amd64/stand/installboot/installboot.c 25 Apr 2008
07:47:07 -0000
> > -74,7 +74,7
> > };
> >
> > extern char *__progname;
> > -int verbose, nowrite = 0;
> > +int verbose, nowrite = 0, forcechs = 0;
> > char *boot, *proto, *dev, *realdev;
> > struct sym_data pbr_symbols[] = {
> > {"_fs_bsize_p", 2},
> > -84,6 +84,7
> > {"_inodeblk", 4},
> > {"_inodedbl", 4},
> > {"_nblocks", 2},
> > + {"_force_chs", 1},
> > {NULL}
> > };
> >
> > -102,7 +103,7
> > static void
> > usage(void)
> > {
> > - fprintf(stderr, "usage: %s [-nv] boot biosboot device\n",
__progname);
> > + fprintf(stderr, "usage: %s [-cnv] boot biosboot device\n",
__progname);
> > exit(1);
> > }
> >
> > -126,6 +127,10
> >
> > while ((c = getopt(argc, argv, "vn")) != -1) {
> > switch (c) {
> > + case 'c':
> > + /* Force CHS mode at biosboot runtime */
> > + forcechs = 1;
> > + break;
> > case 'n':
> > /* Do not actually write the bootblock to disk.
*/
> > nowrite = 1;
> > -438,6 +443,8
> > sym_set_value(pbr_symbols, "_inodedbl",
> > ((((char *)ap) - buf) + INODEOFF));
> > sym_set_value(pbr_symbols, "_nblocks", ndb);
> > + if (forcechs)
> > + sym_set_value(pbr_symbols, "_force_chs", 1);
> >
> > if (verbose) {
> > fprintf(stderr, "%s is %d blocks x %d bytes\n",
> > Index: sys/arch/amd64/stand/installboot/installboot.8
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/amd64/stand/installboot/installboot.8,v
> > retrieving revision 1.3
> > diff -u -r1.3 installboot.8
> > --- sys/arch/amd64/stand/installboot/installboot.8 31 May 2007
> > 19:20:02 -0000 1.3
> > +++ sys/arch/amd64/stand/installboot/installboot.8 25 Apr 2008
07:47:07 -0000
> > -33,7 +33,7
> > .Nd installs a bootstrap on an FFS disk or partition
> > .Sh SYNOPSIS
> > .Nm installboot
> > -.Op Fl nv
> > +.Op Fl cnv
> > .Ar boot
> > .Ar biosboot
> > .Ar disk
> > -52,6 +52,10
> > .Pp
> > The options are as follows:
> > .Bl -tag -width flag_opt
> > +.It Fl c
> > +Force CHS mode at
> > +.Ar biosboot
> > +runtime.
> > .It Fl n
> > Do not actually write anything on the disk.
> > .It Fl v
> > Index: sys/arch/i386/stand/installboot/installboot.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/i386/stand/installboot/installboot.c,v
> > retrieving revision 1.49
> > diff -u -r1.49 installboot.c
> > --- sys/arch/i386/stand/installboot/installboot.c 14 Feb 2006
17:16:19
> > -0000 1.49
> > +++ sys/arch/i386/stand/installboot/installboot.c 25 Apr 2008
07:47:08 -0000
> > -70,7 +70,7
> > };
> >
> > extern char *__progname;
> > -int verbose, nowrite = 0;
> > +int verbose, nowrite = 0, forcechs = 0;
> > char *boot, *proto, *dev, *realdev;
> > struct sym_data pbr_symbols[] = {
> > {"_fs_bsize_p", 2},
> > -80,6 +80,7
> > {"_inodeblk", 4},
> > {"_inodedbl", 4},
> > {"_nblocks", 2},
> > + {"_force_chs", 1},
> > {NULL}
> > };
> >
> > -98,7 +99,7
> > static void
> > usage(void)
> > {
> > - fprintf(stderr, "usage: %s [-nv] boot biosboot device\n",
__progname);
> > + fprintf(stderr, "usage: %s [-cnv] boot biosboot device\n",
__progname);
> > exit(1);
> > }
> >
> > -122,6 +123,10
> >
> > while ((c = getopt(argc, argv, "vn")) != -1) {
> > switch (c) {
> > + case 'c':
> > + /* Force CHS mode at biosboot runtime */
> > + forcechs = 1;
> > + break;
> > case 'n':
> > /* Do not actually write the bootblock to disk.
*/
> > nowrite = 1;
> > -434,6 +439,8
> > sym_set_value(pbr_symbols, "_inodedbl",
> > ((((char *)ap) - buf) + INODEOFF));
> > sym_set_value(pbr_symbols, "_nblocks", ndb);
> > + if (forcechs)
> > + sym_set_value(pbr_symbols, "_force_chs", 1);
> >
> > if (verbose) {
> > fprintf(stderr, "%s is %d blocks x %d bytes\n",
> > Index: sys/arch/i386/stand/installboot/installboot.8
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/i386/stand/installboot/installboot.8,v
> > retrieving revision 1.28
> > diff -u -r1.28 installboot.8
> > --- sys/arch/i386/stand/installboot/installboot.8 31 May 2007
19:20:03
> > -0000 1.28
> > +++ sys/arch/i386/stand/installboot/installboot.8 25 Apr 2008
07:47:08 -0000
> > -33,7 +33,7
> > .Nd installs a bootstrap on an FFS disk or partition
> > .Sh SYNOPSIS
> > .Nm installboot
> > -.Op Fl nv
> > +.Op Fl cnv
> > .Ar boot
> > .Ar biosboot
> > .Ar disk
> > -52,6 +52,10
> > .Pp
> > The options are as follows:
> > .Bl -tag -width flag_opt
> > +.It Fl c
> > +Force CHS mode at
> > +.Ar biosboot
> > +runtime.
> > .It Fl n
> > Do not actually write anything on the disk.
> > .It Fl v
> > Index: sys/arch/amd64/stand/biosboot/biosboot.S
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/amd64/stand/biosboot/biosboot.S,v
> > retrieving revision 1.3
> > diff -u -r1.3 biosboot.S
> > --- sys/arch/amd64/stand/biosboot/biosboot.S 31 May 2007 18:08:13
-0000 1.3
> > +++ sys/arch/amd64/stand/biosboot/biosboot.S 25 Apr 2008 07:47:08
-0000
> > -108,16 +108,12
> > * While this can be calculated as
> > * howmany(di_size, fs_bsize) it takes us too
> > * many code bytes to do it.
> > + * force_chs uint8 set to the value 1 to force biosboot to use CHS
> > + * reads (this will of course cause the boot
sequence
> > + * to fail if /boot is above 8 GB) ("-c" flag in
installboot).
> > *
> > * All of these are patched directly into the code where they are used
> > * (once only, each), to save space.
> > - *
> > - * One more symbol is exported, in anticipation of a "-c" flag in
> > - * installboot to force CHS reads:
> > - *
> > - * force_chs uint8 set to the value 1 to force biosboot to use CHS
> > - * reads (this will of course cause the boot
sequence
> > - * to fail if /boot is above 8 GB).
> > */
> >
> > .globl inodeblk, inodedbl, fs_bsize_p, fsbtodb, p_offset,
nblocks
> > Index: sys/arch/i386/stand/biosboot/biosboot.S
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/i386/stand/biosboot/biosboot.S,v
> > retrieving revision 1.38
> > diff -u -r1.38 biosboot.S
> > --- sys/arch/i386/stand/biosboot/biosboot.S 31 May 2007 23:34:46
-0000 1.38
> > +++ sys/arch/i386/stand/biosboot/biosboot.S 25 Apr 2008 07:47:08
-0000
> > -108,16 +108,13
> > * While this can be calculated as
> > * howmany(di_size, fs_bsize) it takes us too
> > * many code bytes to do it.
> > + * force_chs uint8 set to the value 1 to force biosboot to use CHS
> > + * reads (this will of course cause the boot
sequence
> > + * to fail if /boot is above 8 GB) ("-c" flag in
installboot).
> > *
> > * All of these are patched directly into the code where they are used
> > * (once only, each), to save space.
> > *
> > - * One more symbol is exported, in anticipation of a "-c" flag in
> > - * installboot to force CHS reads:
> > - *
> > - * force_chs uint8 set to the value 1 to force biosboot to use CHS
> > - * reads (this will of course cause the boot
sequence
> > - * to fail if /boot is above 8 GB).
> > */
> >
> > .globl inodeblk, inodedbl, fs_bsize_p, fsbtodb, p_offset,
nblocks

[demime 1.01d removed an attachment of type application/octet-stream which had a name of installboot-force-chs.patch]