aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2012-11-27 20:29:02 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2012-11-27 20:29:14 -0500
commit42897d866b120547777ae1fd316680ec53356d9c (patch)
tree29eb544b4361d964dab0d1b3e27f9f2e64597daf
parentd828199e84447795c6669ff0e6c6d55eb9beeff6 (diff)
KVM: x86: add kvm_arch_vcpu_postcreate callback, move TSC initialization
TSC initialization will soon make use of online_vcpus. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--arch/ia64/kvm/kvm-ia64.c5
-rw-r--r--arch/powerpc/kvm/powerpc.c5
-rw-r--r--arch/s390/kvm/kvm-s390.c5
-rw-r--r--arch/x86/kvm/svm.c1
-rw-r--r--arch/x86/kvm/vmx.c2
-rw-r--r--arch/x86/kvm/x86.c13
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--virt/kvm/kvm_main.c1
8 files changed, 30 insertions, 3 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index c71acd7f9a1..83b54530916 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1330,6 +1330,11 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
1330 return 0; 1330 return 0;
1331} 1331}
1332 1332
1333int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
1334{
1335 return 0;
1336}
1337
1333int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 1338int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
1334{ 1339{
1335 return -EINVAL; 1340 return -EINVAL;
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index deb0d596d81..f9ab12aea82 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -439,6 +439,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
439 return vcpu; 439 return vcpu;
440} 440}
441 441
442int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
443{
444 return 0;
445}
446
442void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) 447void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
443{ 448{
444 /* Make sure we're not using the vcpu anymore */ 449 /* Make sure we're not using the vcpu anymore */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 38883f0bf27..731ddeee32e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -355,6 +355,11 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
355 atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags); 355 atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
356} 356}
357 357
358int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
359{
360 return 0;
361}
362
358int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) 363int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
359{ 364{
360 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | 365 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 94f5ceba7e1..161a5fa66d8 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1251,7 +1251,6 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
1251 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT; 1251 svm->vmcb_pa = page_to_pfn(page) << PAGE_SHIFT;
1252 svm->asid_generation = 0; 1252 svm->asid_generation = 0;
1253 init_vmcb(svm); 1253 init_vmcb(svm);
1254 kvm_write_tsc(&svm->vcpu, 0);
1255 1254
1256 err = fx_init(&svm->vcpu); 1255 err = fx_init(&svm->vcpu);
1257 if (err) 1256 if (err)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 896efd4842e..bb18923bf63 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3896,8 +3896,6 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
3896 vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL); 3896 vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL);
3897 set_cr4_guest_host_mask(vmx); 3897 set_cr4_guest_host_mask(vmx);
3898 3898
3899 kvm_write_tsc(&vmx->vcpu, 0);
3900
3901 return 0; 3899 return 0;
3902} 3900}
3903 3901
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index a7b97a49d8a..f3c069efc72 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6320,6 +6320,19 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
6320 return r; 6320 return r;
6321} 6321}
6322 6322
6323int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
6324{
6325 int r;
6326
6327 r = vcpu_load(vcpu);
6328 if (r)
6329 return r;
6330 kvm_write_tsc(vcpu, 0);
6331 vcpu_put(vcpu);
6332
6333 return r;
6334}
6335
6323void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) 6336void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
6324{ 6337{
6325 int r; 6338 int r;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c94c9985dee..8e5c7b65165 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -596,6 +596,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
596void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu); 596void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
597struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id); 597struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
598int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu); 598int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
599int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu);
599void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu); 600void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
600 601
601int kvm_arch_hardware_enable(void *garbage); 602int kvm_arch_hardware_enable(void *garbage);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index be3e7bb73b1..e6cfd4344d2 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1853,6 +1853,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
1853 atomic_inc(&kvm->online_vcpus); 1853 atomic_inc(&kvm->online_vcpus);
1854 1854
1855 mutex_unlock(&kvm->lock); 1855 mutex_unlock(&kvm->lock);
1856 kvm_arch_vcpu_postcreate(vcpu);
1856 return r; 1857 return r;
1857 1858
1858unlock_vcpu_destroy: 1859unlock_vcpu_destroy: