From d77d315128708badbb2e634d2cfaea6d64d19f00 Mon Sep 17 00:00:00 2001 From: Nate Lawson Date: Tue, 15 Feb 2005 07:21:20 +0000 Subject: [PATCH] Correct a few bugs in the legacy cpu attachment. Get the unit from the parent cpu device before passing it to pcpu_find(). Get the ivars from the child, not parent cpu device. These bugs would cause a panic when dereferencing the pcpu ivar, but weren't present in the acpi attachment which it seems most people are using. --- sys/i386/i386/legacy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/i386/i386/legacy.c b/sys/i386/i386/legacy.c index 276c40f3f07..e5f7e8e67d1 100644 --- a/sys/i386/i386/legacy.c +++ b/sys/i386/i386/legacy.c @@ -314,8 +314,7 @@ cpu_add_child(device_t bus, int order, const char *name, int unit) return (NULL); resource_list_init(&cd->cd_rl); - pc = pcpu_find(unit); - KASSERT(pc != NULL, ("pcpu_find failed")); + pc = pcpu_find(device_get_unit(bus)); cd->cd_pcpu = pc; child = device_add_child_ordered(bus, order, name, unit); @@ -343,7 +342,7 @@ cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) if (index != CPU_IVAR_PCPU) return (ENOENT); - cpdev = device_get_ivars(dev); + cpdev = device_get_ivars(child); *result = (uintptr_t)cpdev->cd_pcpu; return (0); }