Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 5e31c5e

Browse files
committed
patcher: do not clobber ebx
ebx can not be clobbered when using -fPIC so save and restore the register instead of allowing it to be clobbered. Signed-off-by: Nathan Hjelm <[email protected]> (cherry picked from open-mpi/ompi@2d0e2b6) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent f80f73c commit 5e31c5e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

opal/mca/patcher/base/patcher_base_patch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ static void flush_and_invalidate_cache (unsigned long a)
8181
static int have_clflush = -1;
8282

8383
if (OPAL_UNLIKELY(-1 == have_clflush)) {
84-
int32_t cpuid1, cpuid2;
84+
int32_t cpuid1, cpuid2, tmp;
8585
const int32_t level = 1;
8686

87-
__asm__ volatile ("cpuid" :
88-
"=a" (cpuid1), "=d" (cpuid2) :
87+
/* cpuid clobbers ebx but it must be restored for -fPIC so save
88+
* then restore ebx */
89+
__asm__ volatile ("xchgl %%ebx, %2\n"
90+
"cpuid\n"
91+
"xchgl %%ebx, %2\n":
92+
"=a" (cpuid1), "=d" (cpuid2), "=r" (tmp) :
8993
"a" (level) :
90-
"ecx", "ebx");
94+
"ecx");
9195
/* clflush is in edx bit 19 */
9296
have_clflush = !!(cpuid2 & (1 << 19));
9397
}

0 commit comments

Comments
 (0)