On Wed, Nov 24, 2021 at 02:48:29PM -0700, Ted Bullock wrote:

> On 2021-11-20 2:49 p.m., Ted Bullock wrote:
> > This patch disables fchmod in the bootblock for IDE drives on sparc64
> > 
> > I can confirm that this allows my sunblade 100 to boot -current
> Hi folks,
> 
> I'm requesting to have the patch I sent in a previous mail reviewed and
> committed. I also attached the patch here.
> 
> (for reference)
> https://marc.info/?l=openbsd-bugs&m=163744498300496&w=2
> 
> This should affect only a small set of older sparc64 machines that use
> IDE drives instead of SCSI.  At least two such machines types are not
> working and are corrupting filesystems when booted with recent versions
> of OpenBSD since writing calls were introduced to the second stage boot
> block. Tested on an Ultra 5 and Sun Blade 100. The impact is that these
> older sparc64 machines will potentially re-use entropy from previous
> boot cycles if a new random seed file was not written between restarts.
> 
> -- 
> Ted Bullock <[email protected]>

Tests ok (using a SCSI disk, I still see the correct behaviour, I do
not have IDE disks so I cannot test that).

One comment inline,

        -Otto

> Index: arch/sparc64/stand/ofwboot/ofdev.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/stand/ofwboot/ofdev.c,v
> retrieving revision 1.31
> diff -u -p -u -p -r1.31 ofdev.c
> --- arch/sparc64/stand/ofwboot/ofdev.c        9 Dec 2020 18:10:19 -0000       
> 1.31
> +++ arch/sparc64/stand/ofwboot/ofdev.c        20 Nov 2021 12:36:10 -0000
> @@ -520,7 +520,7 @@ devopen(struct open_file *of, const char
>       char fname[256];
>       char buf[DEV_BSIZE];
>       struct disklabel label;
> -     int handle, part;
> +     int handle, part, parent;
>       int error = 0;
>  #ifdef SOFTRAID
>       char volno;
> @@ -649,6 +649,9 @@ devopen(struct open_file *of, const char
>  #endif
>       if ((handle = OF_finddevice(fname)) == -1)
>               return ENOENT;
> +
> +     parent = OF_parent(handle);

I think the OF_parent call can go inside the !strcmp(buf, "block") block.


> +
>       DNPRINTF(BOOT_D_OFDEV, "devopen: found %s\n", fname);
>       if (OF_getprop(handle, "name", buf, sizeof buf) < 0)
>               return ENXIO;
> @@ -685,6 +688,13 @@ devopen(struct open_file *of, const char
>  
>               of->f_dev = devsw;
>               of->f_devdata = &ofdev;
> +
> +             /* Some PROMS have bugged writing code for ide block devices */

here I mean

> +             if (OF_getprop(parent, "name", buf, sizeof buf) < 0)
> +                     return ENXIO;
> +             if (!strcmp(buf, "ide"))
> +                     of->f_flags |= F_NOWRITE;
> +
>  #ifdef SPARC_BOOT_UFS
>               bcopy(&file_system_ufs, &file_system[nfsys++], sizeof 
> file_system[0]);
>               bcopy(&file_system_ufs2, &file_system[nfsys++], sizeof 
> file_system[0]);
> Index: arch/sparc64/stand/ofwboot/vers.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/stand/ofwboot/vers.c,v
> retrieving revision 1.22
> diff -u -p -u -p -r1.22 vers.c
> --- arch/sparc64/stand/ofwboot/vers.c 9 Dec 2020 18:10:19 -0000       1.22
> +++ arch/sparc64/stand/ofwboot/vers.c 20 Nov 2021 12:36:11 -0000
> @@ -1 +1 @@
> -const char version[] = "1.21";
> +const char version[] = "1.22";
> Index: lib/libsa/fchmod.c
> ===================================================================
> RCS file: /cvs/src/sys/lib/libsa/fchmod.c,v
> retrieving revision 1.1
> diff -u -p -u -p -r1.1 fchmod.c
> --- lib/libsa/fchmod.c        3 Aug 2019 15:22:17 -0000       1.1
> +++ lib/libsa/fchmod.c        20 Nov 2021 12:36:12 -0000
> @@ -53,6 +53,11 @@ fchmod(int fd, mode_t m)
>               errno = EOPNOTSUPP;
>               return (-1);
>       }
> +     /* writing is broken or unsupported */
> +     if (f->f_flags & F_NOWRITE) {
> +             errno = EOPNOTSUPP;
> +             return (-1);
> +     }
>  
>       errno = (f->f_ops->fchmod)(f, m);
>       return (0);
> Index: lib/libsa/stand.h
> ===================================================================
> RCS file: /cvs/src/sys/lib/libsa/stand.h,v
> retrieving revision 1.71
> diff -u -p -u -p -r1.71 stand.h
> --- lib/libsa/stand.h 24 Oct 2021 17:49:19 -0000      1.71
> +++ lib/libsa/stand.h 20 Nov 2021 12:36:12 -0000
> @@ -107,10 +107,11 @@ struct open_file {
>  extern struct open_file files[];
>  
>  /* f_flags values */
> -#define      F_READ          0x0001  /* file opened for reading */
> -#define      F_WRITE         0x0002  /* file opened for writing */
> -#define      F_RAW           0x0004  /* raw device open - no file system */
> -#define F_NODEV              0x0008  /* network open - no device */
> +#define F_READ          0x0001 /* file opened for reading */
> +#define F_WRITE         0x0002 /* file opened for writing */
> +#define F_RAW           0x0004 /* raw device open - no file system */
> +#define F_NODEV         0x0008 /* network open - no device */
> +#define F_NOWRITE       0x0010 /* bootblock writing broken or unsupported */
>  
>  #define isupper(c)   ((c) >= 'A' && (c) <= 'Z')
>  #define islower(c)   ((c) >= 'a' && (c) <= 'z')

Reply via email to