Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 2017 12:18:54 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Toomas Soome <tsoome@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r317097 - in head/sys/boot: common efi/libefi i386/libi386 mips/beri/loader powerpc/ps3 uboot/lib usb/storage userboot/userboot
Message-ID:  <1492539534.96207.33.camel@freebsd.org>
In-Reply-To: <201704181807.v3II7sJ4023532@repo.freebsd.org>
References:  <201704181807.v3II7sJ4023532@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2017-04-18 at 18:07 +0000, Toomas Soome wrote:
> Author: tsoome
> Date: Tue Apr 18 18:07:54 2017
> New Revision: 317097
> URL: https://svnweb.freebsd.org/changeset/base/317097
> 
> Log:
>   loader: F_READ/F_WRITE should be checked against masked flag
>   
>   The work to make it possible to avoid bcache via using F_NORA
> modifier did
>   miss the fact that not all loader platforms are using the bcache,
> and so
>   it is possible the modifier is not cleared, as bcache strategy
> function is
>   not used.
>   
>   For fix, we make sure the checks are dont with masked flag.
>   
>   This patch does fix boot for platforms which do not use bcache.
>   
>   Reported by:	emaste
>   Reviewed by:	emaste
>   Differential Revision:	https://reviews.freebsd.org/D10422
> 

Now the boot fails on arm with:

Found U-Boot device: disk
  Checking unit=0 slice=<auto> partition=<auto>...disk0: real size != size

-- Ian

> Modified:
>   head/sys/boot/common/md.c
>   head/sys/boot/efi/libefi/efipart.c
>   head/sys/boot/i386/libi386/bioscd.c
>   head/sys/boot/i386/libi386/biosdisk.c
>   head/sys/boot/mips/beri/loader/beri_disk_cfi.c
>   head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
>   head/sys/boot/powerpc/ps3/ps3cdrom.c
>   head/sys/boot/powerpc/ps3/ps3disk.c
>   head/sys/boot/uboot/lib/disk.c
>   head/sys/boot/usb/storage/umass_loader.c
>   head/sys/boot/userboot/userboot/userboot_disk.c
> 
> Modified: head/sys/boot/common/md.c
> =====================================================================
> =========
> --- head/sys/boot/common/md.c	Tue Apr 18 17:39:20 2017	
> (r317096)
> +++ head/sys/boot/common/md.c	Tue Apr 18 18:07:54 2017	
> (r317097)
> @@ -106,7 +106,7 @@ md_strategy(void *devdata, int rw, daddr
>  	if (rsize != NULL)
>  		*rsize = size;
>  
> -	switch (rw) {
> +	switch (rw & F_MASK) {
>  	case F_READ:
>  		bcopy(md_image.start + ofs, buf, size);
>  		return (0);
> 
> Modified: head/sys/boot/efi/libefi/efipart.c
> =====================================================================
> =========
> --- head/sys/boot/efi/libefi/efipart.c	Tue Apr 18 17:39:20
> 2017	(r317096)
> +++ head/sys/boot/efi/libefi/efipart.c	Tue Apr 18 18:07:54
> 2017	(r317097)
> @@ -819,7 +819,7 @@ efipart_readwrite(EFI_BLOCK_IO *blkio, i
>  	if ((blk + nblks - 1) > blkio->Media->LastBlock)
>  		return (EIO);
>  
> -	switch (rw) {
> +	switch (rw & F_MASK) {
>  	case F_READ:
>  		status = blkio->ReadBlocks(blkio, blkio->Media-
> >MediaId, blk,
>  		    nblks * blkio->Media->BlockSize, buf);
> 
> Modified: head/sys/boot/i386/libi386/bioscd.c
> =====================================================================
> =========
> --- head/sys/boot/i386/libi386/bioscd.c	Tue Apr 18 17:39:20
> 2017	(r317096)
> +++ head/sys/boot/i386/libi386/bioscd.c	Tue Apr 18 18:07:54
> 2017	(r317097)
> @@ -268,7 +268,7 @@ bc_realstrategy(void *devdata, int rw, d
>  		return (EINVAL);
>  #endif
>  
> -	if (rw != F_READ)
> +	if ((rw & F_MASK) != F_READ)
>  		return(EROFS);
>  	dev = (struct i386_devdesc *)devdata;
>  	unit = dev->d_unit;
> 
> Modified: head/sys/boot/i386/libi386/biosdisk.c
> =====================================================================
> =========
> --- head/sys/boot/i386/libi386/biosdisk.c	Tue Apr 18 17:39:20
> 2017	(r317096)
> +++ head/sys/boot/i386/libi386/biosdisk.c	Tue Apr 18 18:07:54
> 2017	(r317097)
> @@ -618,7 +618,7 @@ bd_realstrategy(void *devdata, int rw, d
>  	DEBUG("short read %d", blks);
>      }
>  
> -    switch(rw){
> +    switch (rw & F_MASK) {
>      case F_READ:
>  	DEBUG("read %d from %lld to %p", blks, dblk, buf);
>  
> 
> Modified: head/sys/boot/mips/beri/loader/beri_disk_cfi.c
> =====================================================================
> =========
> --- head/sys/boot/mips/beri/loader/beri_disk_cfi.c	Tue Apr 18
> 17:39:20 2017	(r317096)
> +++ head/sys/boot/mips/beri/loader/beri_disk_cfi.c	Tue Apr 18
> 18:07:54 2017	(r317097)
> @@ -73,6 +73,7 @@ beri_cfi_disk_strategy(void *devdata, in
>  {
>  	int error;
>  
> +	flag &= F_MASK;
>  	if (flag == F_WRITE)
>  		return (EROFS);
>  	if (flag != F_READ)
> 
> Modified: head/sys/boot/mips/beri/loader/beri_disk_sdcard.c
> =====================================================================
> =========
> --- head/sys/boot/mips/beri/loader/beri_disk_sdcard.c	Tue Apr
> 18 17:39:20 2017	(r317096)
> +++ head/sys/boot/mips/beri/loader/beri_disk_sdcard.c	Tue Apr
> 18 18:07:54 2017	(r317097)
> @@ -73,6 +73,7 @@ beri_sdcard_disk_strategy(void *devdata,
>  {
>  	int error;
>  
> +	flag &= F_MASK;
>  	if (flag == F_WRITE)
>  		return (EROFS);
>  	if (flag != F_READ)
> 
> Modified: head/sys/boot/powerpc/ps3/ps3cdrom.c
> =====================================================================
> =========
> --- head/sys/boot/powerpc/ps3/ps3cdrom.c	Tue Apr 18 17:39:20
> 2017	(r317096)
> +++ head/sys/boot/powerpc/ps3/ps3cdrom.c	Tue Apr 18 18:07:54
> 2017	(r317097)
> @@ -83,6 +83,7 @@ static int ps3cdrom_strategy(void *devda
>  
>  	DEBUG("d_unit=%u dblk=%llu size=%u", dev->d_unit, dblk,
> size);
>  
> +	flag &= F_MASK;
>  	if (flag != F_READ) {
>  		dev_printf(dev, "write operation is not
> supported!");
>  		return EROFS;
> 
> Modified: head/sys/boot/powerpc/ps3/ps3disk.c
> =====================================================================
> =========
> --- head/sys/boot/powerpc/ps3/ps3disk.c	Tue Apr 18 17:39:20
> 2017	(r317096)
> +++ head/sys/boot/powerpc/ps3/ps3disk.c	Tue Apr 18 18:07:54
> 2017	(r317097)
> @@ -115,6 +115,7 @@ static int ps3disk_strategy(void *devdat
>  	struct open_dev *od = (struct open_dev *) dev->d_disk.data;
>  	int err;
>  
> +	flag &= F_MASK;
>  	if (flag != F_READ) {
>  		dev_printf(dev, "write operation is not
> supported!\n");
>  		return EROFS;
> 
> Modified: head/sys/boot/uboot/lib/disk.c
> =====================================================================
> =========
> --- head/sys/boot/uboot/lib/disk.c	Tue Apr 18 17:39:20 2017	
> (r317096)
> +++ head/sys/boot/uboot/lib/disk.c	Tue Apr 18 18:07:54 2017	
> (r317097)
> @@ -149,6 +149,7 @@ stor_strategy(void *devdata, int rw, dad
>  	daddr_t bcount;
>  	int err;
>  
> +	rw &= F_MASK;
>  	if (rw != F_READ) {
>  		stor_printf("write attempt, operation not
> supported!\n");
>  		return (EROFS);
> 
> Modified: head/sys/boot/usb/storage/umass_loader.c
> =====================================================================
> =========
> --- head/sys/boot/usb/storage/umass_loader.c	Tue Apr 18
> 17:39:20 2017	(r317096)
> +++ head/sys/boot/usb/storage/umass_loader.c	Tue Apr 18
> 18:07:54 2017	(r317097)
> @@ -92,6 +92,7 @@ umass_disk_strategy(void *devdata, int f
>  	if (rsizep != NULL)
>  		*rsizep = 0;
>  
> +	flag &= F_MASK;
>  	if (flag == F_WRITE) {
>  		if (usb_msc_write_10(umass_uaa.device, 0, dblk, size
> >> 9, buf) != 0)
>  			return (EINVAL);
> 
> Modified: head/sys/boot/userboot/userboot/userboot_disk.c
> =====================================================================
> =========
> --- head/sys/boot/userboot/userboot/userboot_disk.c	Tue Apr 18
> 17:39:20 2017	(r317096)
> +++ head/sys/boot/userboot/userboot/userboot_disk.c	Tue Apr 18
> 18:07:54 2017	(r317097)
> @@ -211,6 +211,7 @@ userdisk_realstrategy(void *devdata, int
>  	size_t		resid;
>  	int		rc;
>  
> +	rw &= F_MASK;
>  	if (rw == F_WRITE)
>  		return (EROFS);
>  	if (rw != F_READ)
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1492539534.96207.33.camel>