summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-09-12 14:46:05 -0300
committerRenato Botelho <renato@netgate.com>2016-09-12 14:46:05 -0300
commit63ce22d1142390b88690c7c0f4bc4cc288e9d185 (patch)
treebe056ff742a6a5ce5b806df22ac305023d980bc0 /sys/boot/i386
parente2fb654fb7e1727e7fc2778c4c2fbd8b4733fe37 (diff)
parent4fad802c4472b62f310fbda8601c80b846f7a1f0 (diff)
downloadFreeBSD-src-63ce22d1142390b88690c7c0f4bc4cc288e9d185.zip
FreeBSD-src-63ce22d1142390b88690c7c0f4bc4cc288e9d185.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'sys/boot/i386')
-rw-r--r--sys/boot/i386/libi386/biosdisk.c25
-rw-r--r--sys/boot/i386/zfsboot/zfsboot.c2
2 files changed, 15 insertions, 12 deletions
diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c
index 209eaed..d10555f 100644
--- a/sys/boot/i386/libi386/biosdisk.c
+++ b/sys/boot/i386/libi386/biosdisk.c
@@ -315,9 +315,11 @@ bd_print(int verbose)
pager_open();
for (i = 0; i < nbdinfo; i++) {
- sprintf(line, " disk%d: BIOS drive %c:\n", i,
+ sprintf(line, " disk%d: BIOS drive %c (%ju X %u):\n", i,
(bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit):
- ('C' + bdinfo[i].bd_unit - 0x80));
+ ('C' + bdinfo[i].bd_unit - 0x80),
+ (uintmax_t)bdinfo[i].bd_sectors,
+ bdinfo[i].bd_sectorsize);
if (pager_output(line))
break;
dev.d_dev = &biosdisk;
@@ -495,7 +497,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size,
char *buf, size_t *rsize)
{
struct disk_devdesc *dev = (struct disk_devdesc *)devdata;
- int blks;
+ int blks, remaining;
#ifdef BD_SUPPORT_FRAGS /* XXX: sector size */
char fragbuf[BIOSDISK_SECSIZE];
size_t fragsize;
@@ -511,14 +513,15 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, size_t offset, size_t size,
if (rsize)
*rsize = 0;
- if (dblk >= BD(dev).bd_sectors) {
- DEBUG("IO past disk end %llu", (unsigned long long)dblk);
- return (EIO);
- }
-
- if (dblk + blks > BD(dev).bd_sectors) {
- /* perform partial read */
- blks = BD(dev).bd_sectors - dblk;
+ /*
+ * Perform partial read to prevent read-ahead crossing
+ * the end of disk - or any 32 bit aliases of the end.
+ * Signed arithmetic is used to handle wrap-around cases
+ * like we do for TCP sequence numbers.
+ */
+ remaining = (int)(BD(dev).bd_sectors - dblk); /* truncate */
+ if (remaining > 0 && remaining < blks) {
+ blks = remaining;
size = blks * BD(dev).bd_sectorsize;
DEBUG("short read %d", blks);
}
diff --git a/sys/boot/i386/zfsboot/zfsboot.c b/sys/boot/i386/zfsboot/zfsboot.c
index 3b09e55..49140d1 100644
--- a/sys/boot/i386/zfsboot/zfsboot.c
+++ b/sys/boot/i386/zfsboot/zfsboot.c
@@ -576,7 +576,7 @@ main(void)
bootinfo.bi_bios_dev = dsk->drive;
bootdev = MAKEBOOTDEV(dev_maj[dsk->type],
- dsk->slice, dsk->unit, dsk->part),
+ dsk->slice, dsk->unit, dsk->part);
/* Process configuration file */
OpenPOWER on IntegriCloud