From ae15515d80559ff95b315e3342c3baa00b87be1c Mon Sep 17 00:00:00 2001 From: Frans Kaashoek <kaashoek@mit.edu> Date: Fri, 2 Sep 2016 08:31:13 -0400 Subject: APIC IDs may not be consecutive and start from zero, so we cannot really use it as a direct index into cpus. Record apicid in struct cpu and have cpunum() look for it. Replace cpu->id with cpunum() everywhere, and replace cpu->id with cpu->apicid. Thanks to Xi Wang. --- mp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mp.c') diff --git a/mp.c b/mp.c index 977a823..ade8930 100644 --- a/mp.c +++ b/mp.c @@ -106,12 +106,10 @@ mpinit(void) switch(*p){ case MPPROC: proc = (struct mpproc*)p; - if(ncpu != proc->apicid){ - cprintf("mpinit: ncpu=%d apicid=%d\n", ncpu, proc->apicid); - ismp = 0; + if(ncpu < NCPU) { + cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu + ncpu++; } - cpus[ncpu].id = ncpu; - ncpu++; p += sizeof(struct mpproc); continue; case MPIOAPIC: @@ -125,8 +123,8 @@ mpinit(void) p += 8; continue; default: - cprintf("mpinit: unknown config type %x\n", *p); ismp = 0; + break; } } if(!ismp){ -- cgit v1.2.3