Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 3b861d2

Browse files
committed
Preserve rbx regsiter when cpuid is called.
x86-64 uses rbx as the base register, so preserve it. Fix #56.
1 parent 39593a7 commit 3b861d2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ main_loop(int return_on_sigret)
145145
vmm_read_register(HV_X86_XCR0, &xcr0);
146146
if ((xcr0 & XCR0_AVX_STATE) == 0) {
147147
uint64_t eax;
148-
asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0));
148+
asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0) : "rbx");
149149
if (eax & XCR0_AVX_STATE) {
150150
vmm_write_register(HV_X86_XCR0, xcr0 | XCR0_AVX_STATE);
151151
continue;
@@ -331,7 +331,7 @@ init_regs()
331331
/* set up cpu regs */
332332
vmm_write_register(HV_X86_RFLAGS, 0x2);
333333
uint64_t eax;
334-
asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0));
334+
asm ("cpuid" : "=a" (eax) : "a" (0x0d), "c" (0): "rbx");
335335
if (eax & XCR0_SSE_STATE) {
336336
uint64_t xcr0;
337337
vmm_read_register(HV_X86_XCR0, &xcr0);

0 commit comments

Comments
 (0)