Skip to content

Commit

Permalink
Merge pull request TritonDataCenter#2 from joyent/master
Browse files Browse the repository at this point in the history
update joyent commits
  • Loading branch information
plitc authored Nov 21, 2018
2 parents 9507d22 + 0e9bdd3 commit dcd0e0e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2015 Joyent, Inc.
# Copyright (c) 2018, Joyent, Inc.
#

KERNEL_SOURCE = $(PWD)/../../illumos
Expand Down
60 changes: 27 additions & 33 deletions kvm_vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4026,9 +4026,6 @@ fixup_rmode_irq(struct vcpu_vmx *vmx)
INTR_TYPE_EXT_INTR | vmx->rmode.irq.vector;
}

#define R "r"
#define Q "q"

static void
vmx_vcpu_run(struct kvm_vcpu *vcpu)
{
Expand Down Expand Up @@ -4075,29 +4072,29 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)

__asm__(
/* Store host registers */
"push %%"R"dx; push %%"R"bp;"
"push %%"R"cx \n\t"
"cmp %%"R"sp, %c[host_rsp](%0) \n\t"
"push %%rdx; push %%rbp;"
"push %%rcx \n\t"
"cmp %%rsp, %c[host_rsp](%0) \n\t"
"je 1f \n\t"
"mov %%"R"sp, %c[host_rsp](%0) \n\t"
"mov %%rsp, %c[host_rsp](%0) \n\t"
__ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
"1: \n\t"
/* Reload cr2 if changed */
"mov %c[cr2](%0), %%"R"ax \n\t"
"mov %%cr2, %%"R"dx \n\t"
"cmp %%"R"ax, %%"R"dx \n\t"
"mov %c[cr2](%0), %%rax \n\t"
"mov %%cr2, %%rdx \n\t"
"cmp %%rax, %%rdx \n\t"
"je 2f \n\t"
"mov %%"R"ax, %%cr2 \n\t"
"mov %%rax, %%cr2 \n\t"
"2: \n\t"
/* Check if vmlaunch of vmresume is needed */
"cmpl $0, %c[launched](%0) \n\t"
/* Load guest registers. Don't clobber flags. */
"mov %c[rax](%0), %%"R"ax \n\t"
"mov %c[rbx](%0), %%"R"bx \n\t"
"mov %c[rdx](%0), %%"R"dx \n\t"
"mov %c[rsi](%0), %%"R"si \n\t"
"mov %c[rdi](%0), %%"R"di \n\t"
"mov %c[rbp](%0), %%"R"bp \n\t"
"mov %c[rax](%0), %%rax \n\t"
"mov %c[rbx](%0), %%rbx \n\t"
"mov %c[rdx](%0), %%rdx \n\t"
"mov %c[rsi](%0), %%rsi \n\t"
"mov %c[rdi](%0), %%rdi \n\t"
"mov %c[rbp](%0), %%rbp \n\t"
"mov %c[r8](%0), %%r8 \n\t"
"mov %c[r9](%0), %%r9 \n\t"
"mov %c[r10](%0), %%r10 \n\t"
Expand All @@ -4106,7 +4103,7 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
"mov %c[r13](%0), %%r13 \n\t"
"mov %c[r14](%0), %%r14 \n\t"
"mov %c[r15](%0), %%r15 \n\t"
"mov %c[rcx](%0), %%"R"cx \n\t" /* kills %0 (ecx) */
"mov %c[rcx](%0), %%rcx \n\t" /* kills %0 (ecx) */

/* Enter guest mode */
"jne .Llaunched \n\t"
Expand All @@ -4115,14 +4112,14 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t"
".Lkvm_vmx_return: "
/* Save guest registers, load host registers, keep flags */
"xchg %0, (%%"R"sp) \n\t"
"mov %%"R"ax, %c[rax](%0) \n\t"
"mov %%"R"bx, %c[rbx](%0) \n\t"
"push"Q" (%%"R"sp); pop"Q" %c[rcx](%0) \n\t"
"mov %%"R"dx, %c[rdx](%0) \n\t"
"mov %%"R"si, %c[rsi](%0) \n\t"
"mov %%"R"di, %c[rdi](%0) \n\t"
"mov %%"R"bp, %c[rbp](%0) \n\t"
"xchg %0, (%%rsp) \n\t"
"mov %%rax, %c[rax](%0) \n\t"
"mov %%rbx, %c[rbx](%0) \n\t"
"pushq (%%rsp); popq %c[rcx](%0) \n\t"
"mov %%rdx, %c[rdx](%0) \n\t"
"mov %%rsi, %c[rsi](%0) \n\t"
"mov %%rdi, %c[rdi](%0) \n\t"
"mov %%rbp, %c[rbp](%0) \n\t"
"mov %%r8, %c[r8](%0) \n\t"
"mov %%r9, %c[r9](%0) \n\t"
"mov %%r10, %c[r10](%0) \n\t"
Expand All @@ -4131,10 +4128,10 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
"mov %%r13, %c[r13](%0) \n\t"
"mov %%r14, %c[r14](%0) \n\t"
"mov %%r15, %c[r15](%0) \n\t"
"mov %%cr2, %%"R"ax \n\t"
"mov %%"R"ax, %c[cr2](%0) \n\t"
"mov %%cr2, %%rax \n\t"
"mov %%rax, %c[cr2](%0) \n\t"

"pop %%"R"bp; pop %%"R"bp; pop %%"R"dx \n\t"
"pop %%rbp; pop %%rbp; pop %%rdx \n\t"
"setbe %c[fail](%0) \n\t"
: : "c"(vmx), "d"((unsigned long)HOST_RSP),
[launched]"i"(offsetof(struct vcpu_vmx, launched)),
Expand All @@ -4158,7 +4155,7 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
[cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2))
: "cc", "memory"
/*CSTYLED*/
, R"bx", R"di", R"si"
, "rbx", "rdi", "rsi"
/*CSTYLED*/
, "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
/*CSTYLED*/
Expand All @@ -4185,9 +4182,6 @@ vmx_vcpu_run(struct kvm_vcpu *vcpu)
vmx_complete_interrupts(vmx);
}

#undef R
#undef Q

static void
vmx_destroy_vcpu(struct kvm_vcpu *vcpu)
{
Expand Down

0 comments on commit dcd0e0e

Please sign in to comment.