> Date: Tue, 3 May 2016 08:47:22 -0700
> From: Philip Guenther <[email protected]>
>
> On Tue, 3 May 2016, Mark Kettenis wrote:
> > I think the answer is that we should set CPUF_PRIMARY earlier. In fact
> > we can set it in the initializer of cpu_info_primary. I'll need to
> > check i386 as well.
>
> Beware, i386 is weird: quoting i386/machdep.c:
>
> * Note that identifycpu() is called twice for the primary CPU: the first
> * is very early (right after the "OpenBSD X.Y" line) with the CPUF_PRIMARY
> * flag *not* set, then again later in the config sequence with CPUF_PRIMARY
> * set. Thus, the tests here for ((ci->ci_flags & CPUF_PRIMARY) == 0) are
> * actually saying "do this on the first call for each CPU". Don't change
> * them to use CPU_IS_PRIMARY() because then they would be done on both
> * calls in the SP build.
>
> Setting CPUF_PRIMARY early without doing something about the tests and/or
> rearranging the calls on the primary CPU will cause problems.
Thanks for the heads-up. That code is pretty gross. But I'm sure we
can figure out some sort of MD hack for it.
Meanwhile, here is how I propose to address the issue on amd64.
ok?
Index: cpu.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/cpu.c,v
retrieving revision 1.96
diff -u -p -r1.96 cpu.c
--- cpu.c 17 Mar 2016 13:18:47 -0000 1.96
+++ cpu.c 4 May 2016 14:15:26 -0000
@@ -170,7 +170,10 @@ struct cfdriver cpu_cd = {
* CPU, on uniprocessors). The CPU info list is initialized to
* point at it.
*/
-struct cpu_info cpu_info_primary = { 0, &cpu_info_primary };
+struct cpu_info cpu_info_primary = {
+ .ci_self = &cpu_info_primary,
+ .ci_flags = CPUF_PRIMARY
+};
struct cpu_info *cpu_info_list = &cpu_info_primary;
@@ -401,7 +404,7 @@ cpu_attach(struct device *parent, struct
switch (caa->cpu_role) {
case CPU_ROLE_SP:
printf("(uniprocessor)\n");
- ci->ci_flags |= CPUF_PRESENT | CPUF_SP | CPUF_PRIMARY;
+ ci->ci_flags |= CPUF_PRESENT | CPUF_SP;
cpu_intr_init(ci);
identifycpu(ci);
#ifdef MTRR
@@ -413,7 +416,7 @@ cpu_attach(struct device *parent, struct
case CPU_ROLE_BP:
printf("apid %d (boot processor)\n", caa->cpu_number);
- ci->ci_flags |= CPUF_PRESENT | CPUF_BSP | CPUF_PRIMARY;
+ ci->ci_flags |= CPUF_PRESENT | CPUF_BSP;
cpu_intr_init(ci);
identifycpu(ci);
#ifdef MTRR