On Thu, Nov 25, 2010 at 02:13:35PM +0100, Mark Kettenis wrote:
> > Date: Wed, 24 Nov 2010 23:07:45 +1000
> > From: David Gwynne <l...@animata.net>
> > X-Scanned-By: MIMEDefang 2.62 on 220.110.80.83
> > List-Owner: <mailto:tech-ow...@openbsd.org>
> > X-Loop: tech@openbsd.org
> > Sender: owner-t...@openbsd.org
> > X-XS4ALL-DNSBL-Checked: mxdrop234.xs4all.nl checked 192.43.244.163 against 
> > DNS blacklists
> > X-CNFS-Analysis: v=1.1 cv=nPak59oIMtOfdVQch4uYmxGPiLR+hhfJMKqCKb05RZs= c=1
> >  sm=0 a=JX5xobAnsNsA:10 a=kj9zAlcOel0A:10 a=A3duGc4wJ8K8BtNzzvyz4A==:17
> >  a=UJL0KVoXsl7s0H4imRkA:9 a=jBQNsEcNSG5iu2jYQfsA:7
> >  a=KW889z4Bgh1uv_EMWkrDp0U9jl4A:4 a=CjuIK1q_8ugA:10 a=NDu43_ybFpjtrQvi:21
> >  a=7GxpAH8eZbexILTH:21 a=A3duGc4wJ8K8BtNzzvyz4A==:117
> > X-Virus-Scanned: by XS4ALL Virus Scanner
> > X-XS4ALL-Spam-Score: 0.0 () none
> > X-XS4ALL-Spam: NO
> > Envelope-To: mark.kette...@xs4all.nl
> > 
> > without this diff this box panics on boot while attaching the 36th
> > cpu. its a buffer overrun...
> > 
> > analysis done by kettenis.
> > 
> > ok?
> 
> I think the check should involve MAXCPUS.  Your diff makes clear
> though that simply bumping MAXCPUS to 64 isn't going to fly.  At the
> very least cpus_attached needs to be changed into a 64-bit integer.
> 
> > Index: cpu.c
> > ===================================================================
> > RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
> > retrieving revision 1.38
> > diff -u -p -r1.38 cpu.c
> > --- cpu.c   13 Nov 2010 04:16:42 -0000      1.38
> > +++ cpu.c   24 Nov 2010 13:04:30 -0000
> > @@ -168,6 +168,9 @@ cpu_match(struct device *parent, void *m
> >     struct cfdata *cf = match;
> >     struct cpu_attach_args *caa = aux;
> >  
> > +   if (~cpus_attached == 0)
> > +           return 0;
> > +
> >     if (strcmp(caa->caa_name, cf->cf_driver->cd_name) == 0)
> >             return 1;
> >     return 0;
> 

Hmmm. I can't actually find any *use* of cpus_attached. Is it a relic?

The diff below compiles and runs fine on my 6-proc amd64 box.

.... Ken

Index: amd64/cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
retrieving revision 1.38
diff -u -p -r1.38 cpu.c
--- amd64/cpu.c 13 Nov 2010 04:16:42 -0000      1.38
+++ amd64/cpu.c 25 Nov 2010 23:00:44 -0000
@@ -135,8 +135,6 @@ struct cpu_info cpu_info_primary = { 0, 
 
 struct cpu_info *cpu_info_list = &cpu_info_primary;
 
-u_int32_t cpus_attached = 0;
-
 #ifdef MULTIPROCESSOR
 /*
  * Array of CPU info structures.  Must be statically-allocated because
@@ -345,8 +343,6 @@ cpu_attach(struct device *parent, struct
                panic("unknown processor type??");
        }
        cpu_vm_init(ci);
-
-       cpus_attached |= (1 << ci->ci_cpuid);
 
 #if defined(MULTIPROCESSOR)
        if (mp_verbose) {
Index: include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v
retrieving revision 1.60
diff -u -p -r1.60 cpu.h
--- include/cpu.h       22 Nov 2010 21:07:18 -0000      1.60
+++ include/cpu.h       25 Nov 2010 23:00:44 -0000
@@ -211,8 +211,6 @@ extern struct cpu_info cpu_info_primary;
 
 #define aston(p)       ((p)->p_md.md_astpending = 1)
 
-extern u_int32_t cpus_attached;
-
 #define curpcb         curcpu()->ci_curpcb
 
 /*

Reply via email to