From 0e9bdd3354becb790180a9e6249783daea1161ce Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 14 Nov 2018 23:06:33 +0000 Subject: [PATCH] OS-7378 kvm build needs GCC fixes Reviewed by: Robert Mustacchi Approved by: Robert Mustacchi --- Makefile | 2 +- kvm_vmx.c | 60 +++++++++++++++++++++++++------------------------------ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index f783718..a803090 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2015 Joyent, Inc. +# Copyright (c) 2018, Joyent, Inc. # KERNEL_SOURCE = $(PWD)/../../illumos diff --git a/kvm_vmx.c b/kvm_vmx.c index 6243af6..ed1ec21 100644 --- a/kvm_vmx.c +++ b/kvm_vmx.c @@ -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) { @@ -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" @@ -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" @@ -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" @@ -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)), @@ -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*/ @@ -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) {