summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2017-07-12 13:40:59 +0000
committermikeb <mikeb@openbsd.org>2017-07-12 13:40:59 +0000
commitbed1cde7f84c89154614743d7046b3c5bdceeeee (patch)
treebc9f5223a064987a916ff04bba0bb97975750c6d
parentReorganize separate configuration fields into per-CPU structs (diff)
downloadwireguard-openbsd-bed1cde7f84c89154614743d7046b3c5bdceeeee.tar.xz
wireguard-openbsd-bed1cde7f84c89154614743d7046b3c5bdceeeee.zip
Introduce two quirks to prevent attaching ATA and ATAPI devices
Hyper-V and Xen have varying support for detaching emulated IDE devices ranging from none on Hyper-V to only IDE disks but not CDROM (Xen). The quirk mechanism provides a way of enforcing the desired behavior. With suggestions and OK kettenis, tedu, mlarkin
-rw-r--r--sys/dev/ic/wdc.c11
-rw-r--r--sys/dev/ic/wdcvar.h4
-rw-r--r--sys/dev/pci/pciide.c10
3 files changed, 22 insertions, 3 deletions
diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c
index e2b0a159f40..55871544eba 100644
--- a/sys/dev/ic/wdc.c
+++ b/sys/dev/ic/wdc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdc.c,v 1.131 2016/09/15 02:00:17 dlg Exp $ */
+/* $OpenBSD: wdc.c,v 1.132 2017/07/12 13:40:59 mikeb Exp $ */
/* $NetBSD: wdc.c,v 1.68 1999/06/23 19:00:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -646,6 +646,9 @@ wdcprobe(struct channel_softc *chp)
if (ret_value == 0)
return 0;
+ if (chp->wdc->quirks & WDC_QUIRK_NOATAPI)
+ goto noatapi;
+
/*
* Use signatures to find potential ATAPI drives
*/
@@ -676,6 +679,10 @@ wdcprobe(struct channel_softc *chp)
chp->ch_drive[drive].drive_flags |= DRIVE_ATAPI;
}
+noatapi:
+ if (chp->wdc->quirks & WDC_QUIRK_NOATA)
+ goto noata;
+
/*
* Detect ATA drives by poking around the registers
*/
@@ -698,6 +705,8 @@ wdcprobe(struct channel_softc *chp)
wdc_enable_intr(chp);
}
+noata:
+
#ifdef WDCDEBUG
wdcdebug_mask = savedmask;
#endif
diff --git a/sys/dev/ic/wdcvar.h b/sys/dev/ic/wdcvar.h
index 44ee8d3b145..9ddcee73540 100644
--- a/sys/dev/ic/wdcvar.h
+++ b/sys/dev/ic/wdcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wdcvar.h,v 1.55 2015/08/17 15:36:29 krw Exp $ */
+/* $OpenBSD: wdcvar.h,v 1.56 2017/07/12 13:40:59 mikeb Exp $ */
/* $NetBSD: wdcvar.h,v 1.17 1999/04/11 20:50:29 bouyer Exp $ */
/*-
@@ -170,6 +170,8 @@ struct wdc_softc { /* Per controller state */
struct channel_softc **channels; /* channels-specific datas (array) */
u_int16_t quirks; /* per-device oddities */
#define WDC_QUIRK_NOSHORTDMA 0x0001 /* can't do short DMA transfers */
+#define WDC_QUIRK_NOATA 0x0002 /* skip attaching ATA disks */
+#define WDC_QUIRK_NOATAPI 0x0004 /* skip attaching ATAPI devices */
#if 0
/*
diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c
index 094adde744c..81b9ef0c9e7 100644
--- a/sys/dev/pci/pciide.c
+++ b/sys/dev/pci/pciide.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pciide.c,v 1.357 2015/12/21 20:52:33 mmcc Exp $ */
+/* $OpenBSD: pciide.c,v 1.358 2017/07/12 13:40:59 mikeb Exp $ */
/* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */
/*
@@ -125,6 +125,9 @@ int wdcdebug_pciide_mask = WDCDEBUG_PCIIDE_MASK;
#include <dev/pci/pciide_rdc_reg.h>
#include <dev/pci/cy82c693var.h>
+int pciide_skip_ata;
+int pciide_skip_atapi;
+
/* functions for reading/writing 8-bit PCI registers */
u_int8_t pciide_pci_read(pci_chipset_tag_t, pcitag_t,
@@ -1539,6 +1542,11 @@ pciide_attach(struct device *parent, struct device *self, void *aux)
WDCDEBUG_PRINT((" sc_pc=%p, sc_tag=%p, pa_class=0x%x\n", sc->sc_pc,
sc->sc_tag, pa->pa_class), DEBUG_PROBE);
+ if (pciide_skip_ata)
+ sc->sc_wdcdev.quirks |= WDC_QUIRK_NOATA;
+ if (pciide_skip_atapi)
+ sc->sc_wdcdev.quirks |= WDC_QUIRK_NOATAPI;
+
sc->sc_pp->chip_map(sc, pa);
WDCDEBUG_PRINT(("pciide: command/status register=0x%x\n",