x86 pause misbehaves with -cpu haswell
Bug #1693649 reported by
Paul Goyette
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Using qemu-2.9.0
When booting NetBSD using '-cpu haswell -smp 4', the system fails to initialize the additional CPUs. It appears as though the "application processor" enters routine x86_pause() but never returns.
x86_pause() is simply two assembler instructions: 'pause; ret;'
Replacing the routine with 'nop; nop; ret;' allows the system to proceed, of course without the benefit of the pause instruction on spin-loops!
Additionally, booting with '-cpu phenom -smp 4' also works, although the system does seem confused about the type of CPU being used.
To post a comment you must log in.
Further investigation shows that pause may be working, but very very slowly.
The "use-case" in NetBSD is for "hatching" application CPUs. The target CPU runs a loop that does
while (flag_1 not set)
x86_ pause() ; /* which is assembly code: "pause; ret;" */
for (i = 0; i < 10000; i++)
...
set flag_2;
return;
The boot CPU executes the following code for each application CPU:
set flag_1;
i8254_ delay(10) ; /* this should be 10usec per iteration, 1.0 sec total */
for (i = 0; i < 100000 && flag_2 not set; i++)
if (flag_2 not set)
panic(cpu did not hatch);
....
So, the 10k executions of x86_pause are taking in excess of 1 sec to complete. Indeed, reducing that constant value from 10k to only 100 results in the same failure. So it would seem that the pause instruction is taking an extremely long time to complete. (Further reducing the interation count to only 50 results in success, although it "feels" very sluggish.)