mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 07:31:41 +00:00
KVM: VMX: Avoid vmwrite(HOST_RSP) when possible
Usually HOST_RSP retains its value across guest entries. Take advantage of this and avoid a vmwrite() when this is so. Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
parent
3b4bd7969f
commit
313dbd49dc
1 changed files with 6 additions and 0 deletions
|
@ -58,6 +58,7 @@ struct vmcs {
|
||||||
struct vcpu_vmx {
|
struct vcpu_vmx {
|
||||||
struct kvm_vcpu vcpu;
|
struct kvm_vcpu vcpu;
|
||||||
struct list_head local_vcpus_link;
|
struct list_head local_vcpus_link;
|
||||||
|
unsigned long host_rsp;
|
||||||
int launched;
|
int launched;
|
||||||
u8 fail;
|
u8 fail;
|
||||||
u32 idt_vectoring_info;
|
u32 idt_vectoring_info;
|
||||||
|
@ -2982,7 +2983,11 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
||||||
/* Store host registers */
|
/* Store host registers */
|
||||||
"push %%"R"dx; push %%"R"bp;"
|
"push %%"R"dx; push %%"R"bp;"
|
||||||
"push %%"R"cx \n\t"
|
"push %%"R"cx \n\t"
|
||||||
|
"cmp %%"R"sp, %c[host_rsp](%0) \n\t"
|
||||||
|
"je 1f \n\t"
|
||||||
|
"mov %%"R"sp, %c[host_rsp](%0) \n\t"
|
||||||
__ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
|
__ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
|
||||||
|
"1: \n\t"
|
||||||
/* Check if vmlaunch of vmresume is needed */
|
/* Check if vmlaunch of vmresume is needed */
|
||||||
"cmpl $0, %c[launched](%0) \n\t"
|
"cmpl $0, %c[launched](%0) \n\t"
|
||||||
/* Load guest registers. Don't clobber flags. */
|
/* Load guest registers. Don't clobber flags. */
|
||||||
|
@ -3039,6 +3044,7 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
||||||
: : "c"(vmx), "d"((unsigned long)HOST_RSP),
|
: : "c"(vmx), "d"((unsigned long)HOST_RSP),
|
||||||
[launched]"i"(offsetof(struct vcpu_vmx, launched)),
|
[launched]"i"(offsetof(struct vcpu_vmx, launched)),
|
||||||
[fail]"i"(offsetof(struct vcpu_vmx, fail)),
|
[fail]"i"(offsetof(struct vcpu_vmx, fail)),
|
||||||
|
[host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp)),
|
||||||
[rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])),
|
[rax]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RAX])),
|
||||||
[rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])),
|
[rbx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RBX])),
|
||||||
[rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])),
|
[rcx]"i"(offsetof(struct vcpu_vmx, vcpu.arch.regs[VCPU_REGS_RCX])),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue