diff --git a/src/arch/x86/32/c_traps.c b/src/arch/x86/32/c_traps.c index 68b4dc0e8..7d27325b5 100644 --- a/src/arch/x86/32/c_traps.c +++ b/src/arch/x86/32/c_traps.c @@ -36,11 +36,12 @@ static void NORETURN restore_vmx(tcb_t *cur_thread, vcpu_t *vcpu) /* Do not support breakpoints in VMs, so just disable all breakpoints */ loadAllDisabledBreakpointState(cur_thread); #endif + word_t *guest_regs_ptr = vcpu->gp_registers; if (vcpu->launched) { /* attempt to do a vmresume */ asm volatile( // Set our stack pointer to the top of the tcb so we can efficiently pop - "movl %0, %%esp\n" + "movl %[guest_regs], %%esp\n" "popl %%eax\n" "popl %%ebx\n" "popl %%ecx\n" @@ -57,18 +58,17 @@ static void NORETURN restore_vmx(tcb_t *cur_thread, vcpu_t *vcpu) "leal kernel_stack_alloc + %c1, %%esp\n" #endif "call vmlaunch_failed\n" - : - : "r"(&vcpu->gp_registers[VCPU_EAX]), - "i"(BIT(CONFIG_KERNEL_STACK_BITS) - sizeof(word_t)) + : [guest_regs] "+a"(guest_regs_ptr) + : "i"(BIT(CONFIG_KERNEL_STACK_BITS) - sizeof(word_t)) // Clobber memory so the compiler is forced to complete all stores // before running this assembler - : "memory" + : "ebx", "ecx", "edx", "esi", "edi", "ebp", "memory" ); } else { /* attempt to do a vmlaunch */ asm volatile( // Set our stack pointer to the top of the tcb so we can efficiently pop - "movl %0, %%esp\n" + "movl %[guest_regs], %%esp\n" "popl %%eax\n" "popl %%ebx\n" "popl %%ecx\n" @@ -85,12 +85,11 @@ static void NORETURN restore_vmx(tcb_t *cur_thread, vcpu_t *vcpu) "leal kernel_stack_alloc + %c1, %%esp\n" #endif "call vmlaunch_failed\n" - : - : "r"(&vcpu->gp_registers[VCPU_EAX]), - "i"(BIT(CONFIG_KERNEL_STACK_BITS) - sizeof(word_t)) + : [guest_regs] "+a"(guest_regs_ptr) + : "i"(BIT(CONFIG_KERNEL_STACK_BITS) - sizeof(word_t)) // Clobber memory so the compiler is forced to complete all stores // before running this assembler - : "memory" + : "ebx", "ecx", "edx", "esi", "edi", "ebp", "memory" ); } UNREACHABLE();