Correct the input/output/clobber specifications for the cpuid

instruction.  Stefan Keller <dres@earth.serd.org> noticed that CPU
identification was broken when compiled with -O2, and tracked it
down to the asm statement, which was storing values into memory
without specifying that memory was modified.  He submitted a patch
which added "memory" as a clobber, but I refined it further to
arrive at this version.

MFC after:	3 days
This commit is contained in:
jdp 2001-10-12 16:49:28 +00:00
parent 369a58f711
commit b5831c2530
2 changed files with 6 additions and 16 deletions

View File

@ -116,14 +116,9 @@ static void
do_cpuid(u_int ax, u_int *p)
{
__asm __volatile(
"cpuid;"
"movl %%eax, (%2);"
"movl %%ebx, 4(%2);"
"movl %%ecx, 8(%2);"
"movl %%edx, 12(%2);"
: "=a" (ax)
: "0" (ax), "S" (p)
: "bx", "cx", "dx"
"cpuid"
: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
: "0" (ax)
);
}

View File

@ -116,14 +116,9 @@ static void
do_cpuid(u_int ax, u_int *p)
{
__asm __volatile(
"cpuid;"
"movl %%eax, (%2);"
"movl %%ebx, 4(%2);"
"movl %%ecx, 8(%2);"
"movl %%edx, 12(%2);"
: "=a" (ax)
: "0" (ax), "S" (p)
: "bx", "cx", "dx"
"cpuid"
: "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3])
: "0" (ax)
);
}