Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/78192?usp=email )
Change subject: x86/include/arch/cpuid.h: Fix inline assembly ......................................................................
x86/include/arch/cpuid.h: Fix inline assembly
In the cpuid helper function eax is always written to by cpuid, so add it to the output clobbered list.
This prevent GCC from generating code with undefined behaviour when the function is inlined.
Change-Id: I5dc0bb620184a355716b9c8d4206d55554b41ab9 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/arch/x86/include/arch/cpuid.h 1 file changed, 9 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/92/78192/1
diff --git a/src/arch/x86/include/arch/cpuid.h b/src/arch/x86/include/arch/cpuid.h index 70a5beb..b2780be 100644 --- a/src/arch/x86/include/arch/cpuid.h +++ b/src/arch/x86/include/arch/cpuid.h @@ -56,39 +56,36 @@ return eax; }
-static inline uint32_t cpuid_ebx(const uint32_t eax) +static inline uint32_t cpuid_ebx(uint32_t eax) { uint32_t ebx;
asm volatile( "cpuid;" - : "=b" (ebx) - : "a" (eax) - : "ecx", "edx"); + : "=b" (ebx), "+a" (eax) + :: "ecx", "edx"); return ebx; }
-static inline uint32_t cpuid_ecx(const uint32_t eax) +static inline uint32_t cpuid_ecx(uint32_t eax) { uint32_t ecx;
asm volatile( "cpuid;" - : "=c" (ecx) - : "a" (eax) - : "ebx", "edx"); + : "=c" (ecx), "+a" (eax) + :: "ebx", "edx"); return ecx; }
-static inline uint32_t cpuid_edx(const uint32_t eax) +static inline uint32_t cpuid_edx(uint32_t eax) { uint32_t edx;
asm volatile( "cpuid;" - : "=d" (edx) - : "a" (eax) - : "ebx", "ecx"); + : "=d" (edx), "+a" (eax) + :: "ebx", "ecx"); return edx; }