From 3bb88c3c7f56a322e1fe29d2c6716ac126e813d9 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 29 Mar 2018 00:55:11 +0000 Subject: [PATCH] stand: Add workaround for HP BIOS issues hrs@ and kuriyama@ have found that on some HP BIOS, a system will fail to boot immediately after installation with the claim that it can't work out which disk they are booting from. They tracked it down to a buffer overrun, and found that it could be alleviated by doing a dummy read before-hand. Submitted by: kuriyama MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14341 --- stand/i386/libi386/biosdisk.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c index 3b41ab6572f..eb1f688e884 100644 --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -122,6 +122,8 @@ static int nbdinfo = 0; #define BD(dev) (bdinfo[(dev)->dd.d_unit]) +static void bd_io_workaround(struct disk_devdesc *dev); + static int bd_read(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest); static int bd_write(struct disk_devdesc *dev, daddr_t dblk, int blks, @@ -724,6 +726,15 @@ bd_chs_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, return (0); } +static void +bd_io_workaround(struct disk_devdesc *dev) +{ + uint8_t buf[8 * 1024]; + + bd_edd_io(dev, 0xffffffff, 1, (caddr_t)buf, 0); +} + + static int bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) { @@ -737,6 +748,17 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest, int write) resid = blks; p = dest; + /* + * Workaround for a problem with some HP ProLiant BIOS failing to work out + * the boot disk after installation. hrs and kuriyama discovered this + * problem with an HP ProLiant DL320e Gen 8 with a 3TB HDD, and discovered + * that an int13h call seems to cause a buffer overrun in the bios. The + * problem is alleviated by doing an extra read before the buggy read. It + * is not immediately known whether other models are similarly affected. + */ + if (dblk >= 0x100000000) + bd_io_workaround(dev); + /* Decide whether we have to bounce */ if (VTOP(dest) >> 20 != 0 || (BD(dev).bd_unit < 0x80 && (VTOP(dest) >> 16) != (VTOP(dest +