From patchwork Thu Nov 15 00:08:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 1744831 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 11C483FC64 for ; Thu, 15 Nov 2012 01:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992539Ab2KOB17 (ORCPT ); Wed, 14 Nov 2012 20:27:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51505 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992520Ab2KOB1y (ORCPT ); Wed, 14 Nov 2012 20:27:54 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qAF1ROVe008687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Nov 2012 20:27:50 -0500 Received: from amt.cnet (vpn1-5-41.gru2.redhat.com [10.97.5.41]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qAF08mGc024587; Wed, 14 Nov 2012 19:08:49 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id B9DE666E188; Wed, 14 Nov 2012 22:07:37 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id qAF07bF8001720; Wed, 14 Nov 2012 22:07:37 -0200 Message-Id: <20121115000944.675695743@redhat.com> User-Agent: quilt/0.47-1 Date: Wed, 14 Nov 2012 22:08:39 -0200 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: johnstul@us.ibm.com, jeremy@goop.org, glommer@parallels.com, zamsden@gmail.com, gleb@redhat.com, avi@redhat.com, pbonzini@redhat.com, Marcelo Tosatti Subject: [patch 16/18] KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization References: <20121115000823.285102321@redhat.com> Content-Disposition: inline; filename=16-add-kvm-add-vcpu-postcreate X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org TSC initialization will soon make use of online_vcpus. Signed-off-by: Marcelo Tosatti --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: vsyscall/arch/ia64/kvm/kvm-ia64.c =================================================================== --- vsyscall.orig/arch/ia64/kvm/kvm-ia64.c +++ vsyscall/arch/ia64/kvm/kvm-ia64.c @@ -1330,6 +1330,11 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu return 0; } +int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) +{ + return 0; +} + int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) { return -EINVAL; Index: vsyscall/arch/powerpc/kvm/powerpc.c =================================================================== --- vsyscall.orig/arch/powerpc/kvm/powerpc.c +++ vsyscall/arch/powerpc/kvm/powerpc.c @@ -354,6 +354,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(st return vcpu; } +void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) +{ + return 0; +} + void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) { /* Make sure we're not using the vcpu anymore */ Index: vsyscall/arch/s390/kvm/kvm-s390.c =================================================================== --- vsyscall.orig/arch/s390/kvm/kvm-s390.c +++ vsyscall/arch/s390/kvm/kvm-s390.c @@ -355,6 +355,11 @@ static void kvm_s390_vcpu_initial_reset( atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags); } +void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) +{ + return 0; +} + int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | Index: vsyscall/arch/x86/kvm/svm.c =================================================================== --- vsyscall.orig/arch/x86/kvm/svm.c +++ vsyscall/arch/x86/kvm/svm.c @@ -1254,7 +1254,6 @@ static struct kvm_vcpu *svm_create_vcpu( svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; svm->asid_generation = 0; init_vmcb(svm); - kvm_write_tsc(&svm->vcpu, 0); err = fx_init(&svm->vcpu); if (err) Index: vsyscall/arch/x86/kvm/vmx.c =================================================================== --- vsyscall.orig/arch/x86/kvm/vmx.c +++ vsyscall/arch/x86/kvm/vmx.c @@ -3896,8 +3896,6 @@ static int vmx_vcpu_setup(struct vcpu_vm vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL); set_cr4_guest_host_mask(vmx); - kvm_write_tsc(&vmx->vcpu, 0); - return 0; } Index: vsyscall/arch/x86/kvm/x86.c =================================================================== --- vsyscall.orig/arch/x86/kvm/x86.c +++ vsyscall/arch/x86/kvm/x86.c @@ -6289,6 +6289,19 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu return r; } +int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) +{ + int r; + + r = vcpu_load(vcpu); + if (r) + return r; + kvm_write_tsc(vcpu, 0); + vcpu_put(vcpu); + + return r; +} + void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) { int r; Index: vsyscall/include/linux/kvm_host.h =================================================================== --- vsyscall.orig/include/linux/kvm_host.h +++ vsyscall/include/linux/kvm_host.h @@ -583,6 +583,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu); struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id); int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu); +int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu); int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu); Index: vsyscall/virt/kvm/kvm_main.c =================================================================== --- vsyscall.orig/virt/kvm/kvm_main.c +++ vsyscall/virt/kvm/kvm_main.c @@ -1855,6 +1855,7 @@ static int kvm_vm_ioctl_create_vcpu(stru atomic_inc(&kvm->online_vcpus); mutex_unlock(&kvm->lock); + kvm_arch_vcpu_postcreate(vcpu); return r; unlock_vcpu_destroy: