Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151409640
D39311.id119599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D39311.id119599.diff
View Options
diff --git a/usr.sbin/bhyve/pci_lpc.c b/usr.sbin/bhyve/pci_lpc.c
--- a/usr.sbin/bhyve/pci_lpc.c
+++ b/usr.sbin/bhyve/pci_lpc.c
@@ -453,12 +453,16 @@
#define LPC_SUBVEND_0 0x0000
#define LPC_SUBDEV_0 0x0000
-static int
-pci_lpc_get_sel(struct pcisel *const sel)
+static struct pcisel*
+pci_lpc_get_sel()
{
- assert(sel != NULL);
-
- memset(sel, 0, sizeof(*sel));
+ struct pcisel *sel;
+
+ sel = calloc(1, sizeof(struct pcisel));
+ if (sel == NULL) {
+ warnx("%s: Unable to allocate pcisel", __func__);
+ return (NULL);
+ }
for (uint8_t slot = 0; slot <= PCI_SLOTMAX; ++slot) {
uint8_t max_func = 0;
@@ -475,18 +479,22 @@
if ((read_config(sel, PCIR_CLASS, 1) == PCIC_BRIDGE) &&
(read_config(sel, PCIR_SUBCLASS, 1) ==
PCIS_BRIDGE_ISA)) {
- return (0);
+ return (sel);
}
}
}
- return (-1);
+ warnx("%s: Unable to find host selector of LPC bridge.", __func__);
+
+ free(sel);
+
+ return (NULL);
}
static int
pci_lpc_init(struct pci_devinst *pi, nvlist_t *nvl)
{
- struct pcisel sel = { 0 };
+ struct pcisel *sel;
uint16_t device, subdevice, subvendor, vendor;
uint8_t revid;
@@ -511,15 +519,17 @@
if (lpc_init(pi->pi_vmctx) != 0)
return (-1);
- if (pci_lpc_get_sel(&sel) != 0)
- return (-1);
+ if ((sel = pci_lpc_get_sel()) == NULL)
+ warnx(
+ "%s: Setting pcireg to 'host' doesn't work without a host selector",
+ __func__);
- vendor = pci_config_read_reg(&sel, nvl, PCIR_VENDOR, 2, LPC_VENDOR);
- device = pci_config_read_reg(&sel, nvl, PCIR_DEVICE, 2, LPC_DEV);
- revid = pci_config_read_reg(&sel, nvl, PCIR_REVID, 1, LPC_REVID);
- subvendor = pci_config_read_reg(&sel, nvl, PCIR_SUBVEND_0, 2,
+ vendor = pci_config_read_reg(sel, nvl, PCIR_VENDOR, 2, LPC_VENDOR);
+ device = pci_config_read_reg(sel, nvl, PCIR_DEVICE, 2, LPC_DEV);
+ revid = pci_config_read_reg(sel, nvl, PCIR_REVID, 1, LPC_REVID);
+ subvendor = pci_config_read_reg(sel, nvl, PCIR_SUBVEND_0, 2,
LPC_SUBVEND_0);
- subdevice = pci_config_read_reg(&sel, nvl, PCIR_SUBDEV_0, 2,
+ subdevice = pci_config_read_reg(sel, nvl, PCIR_SUBDEV_0, 2,
LPC_SUBDEV_0);
/* initialize config space */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 9, 6:00 AM (10 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31138430
Default Alt Text
D39311.id119599.diff (2 KB)
Attached To
Mode
D39311: bhyve: do not exit if LPC finds no host selector
Attached
Detach File
Event Timeline
Log In to Comment