arch/x86/include/arch: fix assembly clobber for 64bit
the "x86 PIC code ebx" workaround done previously
by commit 689e31d18b
("Make cpuid functions usable
when compiled with PIC") does not work for x86_64
(the upper dword of rbx is set to 0)
the GCC bug that needed the workaround was fixed
in version 5 (see GCC bug 54232)
Change-Id: Iff1dd72c7423a3b385a000457bcd065cf7ed6b95
Signed-off-by: Matei Dibu <matdibu@protonmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66345
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
parent
436f1c471a
commit
516eff01e6
|
@ -15,96 +15,80 @@ struct cpuid_result {
|
||||||
/*
|
/*
|
||||||
* Generic CPUID function
|
* Generic CPUID function
|
||||||
*/
|
*/
|
||||||
static inline struct cpuid_result cpuid(int op)
|
static inline struct cpuid_result cpuid(const uint32_t eax)
|
||||||
{
|
{
|
||||||
struct cpuid_result result;
|
struct cpuid_result result;
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"mov %%ebx, %%edi;"
|
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%ebx, %%esi;"
|
|
||||||
"mov %%edi, %%ebx;"
|
|
||||||
: "=a" (result.eax),
|
: "=a" (result.eax),
|
||||||
"=S" (result.ebx),
|
"=b" (result.ebx),
|
||||||
"=c" (result.ecx),
|
"=c" (result.ecx),
|
||||||
"=d" (result.edx)
|
"=d" (result.edx)
|
||||||
: "0" (op)
|
: "a" (eax));
|
||||||
: "edi");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic Extended CPUID function
|
* Generic Extended CPUID function
|
||||||
*/
|
*/
|
||||||
static inline struct cpuid_result cpuid_ext(int op, unsigned int ecx)
|
static inline struct cpuid_result cpuid_ext(const uint32_t eax, const uint32_t ecx)
|
||||||
{
|
{
|
||||||
struct cpuid_result result;
|
struct cpuid_result result;
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"mov %%ebx, %%edi;"
|
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%ebx, %%esi;"
|
|
||||||
"mov %%edi, %%ebx;"
|
|
||||||
: "=a" (result.eax),
|
: "=a" (result.eax),
|
||||||
"=S" (result.ebx),
|
"=b" (result.ebx),
|
||||||
"=c" (result.ecx),
|
"=c" (result.ecx),
|
||||||
"=d" (result.edx)
|
"=d" (result.edx)
|
||||||
: "0" (op), "2" (ecx)
|
: "a" (eax), "c" (ecx));
|
||||||
: "edi");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CPUID functions returning a single datum
|
* CPUID functions returning a single datum
|
||||||
*/
|
*/
|
||||||
static inline unsigned int cpuid_eax(unsigned int op)
|
static inline uint32_t cpuid_eax(uint32_t eax)
|
||||||
{
|
{
|
||||||
unsigned int eax;
|
asm volatile(
|
||||||
|
|
||||||
__asm__("mov %%ebx, %%edi;"
|
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%edi, %%ebx;"
|
: "+a" (eax)
|
||||||
: "=a" (eax)
|
:: "ebx", "ecx", "edx");
|
||||||
: "0" (op)
|
|
||||||
: "ecx", "edx", "edi");
|
|
||||||
return eax;
|
return eax;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int cpuid_ebx(unsigned int op)
|
static inline uint32_t cpuid_ebx(const uint32_t eax)
|
||||||
{
|
{
|
||||||
unsigned int eax, ebx;
|
uint32_t ebx;
|
||||||
|
|
||||||
__asm__("mov %%ebx, %%edi;"
|
asm volatile(
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%ebx, %%esi;"
|
: "=b" (ebx)
|
||||||
"mov %%edi, %%ebx;"
|
: "a" (eax)
|
||||||
: "=a" (eax), "=S" (ebx)
|
: "ecx", "edx");
|
||||||
: "0" (op)
|
|
||||||
: "ecx", "edx", "edi");
|
|
||||||
return ebx;
|
return ebx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int cpuid_ecx(unsigned int op)
|
static inline uint32_t cpuid_ecx(const uint32_t eax)
|
||||||
{
|
{
|
||||||
unsigned int eax, ecx;
|
uint32_t ecx;
|
||||||
|
|
||||||
__asm__("mov %%ebx, %%edi;"
|
asm volatile(
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%edi, %%ebx;"
|
: "=c" (ecx)
|
||||||
: "=a" (eax), "=c" (ecx)
|
: "a" (eax)
|
||||||
: "0" (op)
|
: "ebx", "edx");
|
||||||
: "edx", "edi");
|
|
||||||
return ecx;
|
return ecx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int cpuid_edx(unsigned int op)
|
static inline uint32_t cpuid_edx(const uint32_t eax)
|
||||||
{
|
{
|
||||||
unsigned int eax, edx;
|
uint32_t edx;
|
||||||
|
|
||||||
__asm__("mov %%ebx, %%edi;"
|
asm volatile(
|
||||||
"cpuid;"
|
"cpuid;"
|
||||||
"mov %%edi, %%ebx;"
|
: "=d" (edx)
|
||||||
: "=a" (eax), "=d" (edx)
|
: "a" (eax)
|
||||||
: "0" (op)
|
: "ebx", "ecx");
|
||||||
: "ecx", "edi");
|
|
||||||
return edx;
|
return edx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue