提交 ff593e5a 编写于 作者: L Laurent Vivier 提交者: Avi Kivity

KVM: VMX: Let gcc to choose which registers to save (i386)

This patch lets GCC to determine which registers to save when we
switch to/from a VCPU in the case of intel i386.

* Original code saves following registers:

    eax, ebx, ecx, edx, edi, esi, ebp (using popa)

* Patched code:

  - informs GCC that we modify following registers
    using the clobber description:

    ebx, edi, rsi

  - doesn't save eax because it is an output operand (vmx->fail)

  - cannot put ecx in clobber description because it is an input operand,
    but as we modify it and we want to keep its value (vcpu), we must
    save it (pop/push)

  - ebp is saved (pop/push) because GCC seems to ignore its use the clobber
    description.

  - edx is saved (pop/push) because it is reserved by GCC (REGPARM) and
    cannot be put in the clobber description.

  - line "mov (%%esp), %3 \n\t" has been removed because %3
    is ecx and ecx is restored just after.
Signed-off-by: NLaurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: NAvi Kivity <avi@qumranet.com>
上级 c2036300
...@@ -2268,7 +2268,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -2268,7 +2268,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
"push %%rdx; push %%rbp;" "push %%rdx; push %%rbp;"
"push %%rcx \n\t" "push %%rcx \n\t"
#else #else
"pusha; push %%ecx \n\t" "push %%edx; push %%ebp;"
"push %%ecx \n\t"
#endif #endif
ASM_VMX_VMWRITE_RSP_RDX "\n\t" ASM_VMX_VMWRITE_RSP_RDX "\n\t"
/* Check if vmlaunch of vmresume is needed */ /* Check if vmlaunch of vmresume is needed */
...@@ -2342,9 +2343,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -2342,9 +2343,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
"mov %%ebp, %c[rbp](%3) \n\t" "mov %%ebp, %c[rbp](%3) \n\t"
"mov %%cr2, %%eax \n\t" "mov %%cr2, %%eax \n\t"
"mov %%eax, %c[cr2](%3) \n\t" "mov %%eax, %c[cr2](%3) \n\t"
"mov (%%esp), %3 \n\t"
"pop %%ecx; popa \n\t" "pop %%ecx; pop %%ebp; pop %%edx \n\t"
#endif #endif
"setbe %0 \n\t" "setbe %0 \n\t"
: "=q" (vmx->fail) : "=q" (vmx->fail)
...@@ -2372,6 +2372,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) ...@@ -2372,6 +2372,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
, "rbx", "rdi", "rsi" , "rbx", "rdi", "rsi"
, "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
#else
, "ebx", "edi", "rsi"
#endif #endif
); );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册