From owner-svn-src-head@freebsd.org Tue Apr 18 18:07:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 83288D4430E; Tue, 18 Apr 2017 18:07:56 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DF8A8F2; Tue, 18 Apr 2017 18:07:56 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3II7tei023544; Tue, 18 Apr 2017 18:07:55 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3II7sJ4023532; Tue, 18 Apr 2017 18:07:54 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201704181807.v3II7sJ4023532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Tue, 18 Apr 2017 18:07:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317097 - in head/sys/boot: common efi/libefi i386/libi386 mips/beri/loader powerpc/ps3 uboot/lib usb/storage userboot/userboot X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2017 18:07:56 -0000 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 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)