diff options
author | Avi Kivity <avi@redhat.com> | 2010-04-28 08:39:01 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-19 04:36:29 -0400 |
commit | 0ee75bead83da4791e5cbf659806c54d8ee40f12 (patch) | |
tree | 3b3856aac1fc94d153f9e6c27f383f81be06185a | |
parent | 884a0ff0b68b3ece5987507de168215e14ef7849 (diff) |
KVM: Let vcpu structure alignment be determined at runtime
vmx and svm vcpus have different contents and therefore may have different
alignmment requirements. Let each specify its required alignment.
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/ia64/kvm/vmm.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kvm/44x.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kvm/e500.c | 2 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/svm.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 3 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 2 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 7 |
9 files changed, 14 insertions, 11 deletions
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c index 7a62f75778c5..f0b9cac82414 100644 --- a/arch/ia64/kvm/vmm.c +++ b/arch/ia64/kvm/vmm.c | |||
@@ -51,7 +51,7 @@ static int __init kvm_vmm_init(void) | |||
51 | vmm_fpswa_interface = fpswa_interface; | 51 | vmm_fpswa_interface = fpswa_interface; |
52 | 52 | ||
53 | /*Register vmm data to kvm side*/ | 53 | /*Register vmm data to kvm side*/ |
54 | return kvm_init(&vmm_info, 1024, THIS_MODULE); | 54 | return kvm_init(&vmm_info, 1024, 0, THIS_MODULE); |
55 | } | 55 | } |
56 | 56 | ||
57 | static void __exit kvm_vmm_exit(void) | 57 | static void __exit kvm_vmm_exit(void) |
diff --git a/arch/powerpc/kvm/44x.c b/arch/powerpc/kvm/44x.c index 689a57c2ac80..73c0a3f64ed1 100644 --- a/arch/powerpc/kvm/44x.c +++ b/arch/powerpc/kvm/44x.c | |||
@@ -147,7 +147,7 @@ static int __init kvmppc_44x_init(void) | |||
147 | if (r) | 147 | if (r) |
148 | return r; | 148 | return r; |
149 | 149 | ||
150 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_44x), THIS_MODULE); | 150 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_44x), 0, THIS_MODULE); |
151 | } | 151 | } |
152 | 152 | ||
153 | static void __exit kvmppc_44x_exit(void) | 153 | static void __exit kvmppc_44x_exit(void) |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 28e785fb2cab..11f226ff4468 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -1385,7 +1385,8 @@ int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1385 | 1385 | ||
1386 | static int kvmppc_book3s_init(void) | 1386 | static int kvmppc_book3s_init(void) |
1387 | { | 1387 | { |
1388 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), THIS_MODULE); | 1388 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), 0, |
1389 | THIS_MODULE); | ||
1389 | } | 1390 | } |
1390 | 1391 | ||
1391 | static void kvmppc_book3s_exit(void) | 1392 | static void kvmppc_book3s_exit(void) |
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index 669a5c5fc7d7..bc2b4004eb26 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c | |||
@@ -161,7 +161,7 @@ static int __init kvmppc_e500_init(void) | |||
161 | flush_icache_range(kvmppc_booke_handlers, | 161 | flush_icache_range(kvmppc_booke_handlers, |
162 | kvmppc_booke_handlers + max_ivor + kvmppc_handler_len); | 162 | kvmppc_booke_handlers + max_ivor + kvmppc_handler_len); |
163 | 163 | ||
164 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), THIS_MODULE); | 164 | return kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE); |
165 | } | 165 | } |
166 | 166 | ||
167 | static void __init kvmppc_e500_exit(void) | 167 | static void __init kvmppc_e500_exit(void) |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index ee7c713686ce..8093e6f47f49 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -752,7 +752,7 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) | |||
752 | static int __init kvm_s390_init(void) | 752 | static int __init kvm_s390_init(void) |
753 | { | 753 | { |
754 | int ret; | 754 | int ret; |
755 | ret = kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE); | 755 | ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); |
756 | if (ret) | 756 | if (ret) |
757 | return ret; | 757 | return ret; |
758 | 758 | ||
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 889f66022e57..2511664ff671 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -3319,7 +3319,7 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
3319 | static int __init svm_init(void) | 3319 | static int __init svm_init(void) |
3320 | { | 3320 | { |
3321 | return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm), | 3321 | return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm), |
3322 | THIS_MODULE); | 3322 | __alignof__(struct vcpu_svm), THIS_MODULE); |
3323 | } | 3323 | } |
3324 | 3324 | ||
3325 | static void __exit svm_exit(void) | 3325 | static void __exit svm_exit(void) |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 875b785228f6..2e8729678600 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -4245,7 +4245,8 @@ static int __init vmx_init(void) | |||
4245 | 4245 | ||
4246 | set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ | 4246 | set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ |
4247 | 4247 | ||
4248 | r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE); | 4248 | r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), |
4249 | __alignof__(struct vcpu_vmx), THIS_MODULE); | ||
4249 | if (r) | 4250 | if (r) |
4250 | goto out3; | 4251 | goto out3; |
4251 | 4252 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ce027d518096..7cb116afa1cd 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -243,7 +243,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); | |||
243 | void vcpu_load(struct kvm_vcpu *vcpu); | 243 | void vcpu_load(struct kvm_vcpu *vcpu); |
244 | void vcpu_put(struct kvm_vcpu *vcpu); | 244 | void vcpu_put(struct kvm_vcpu *vcpu); |
245 | 245 | ||
246 | int kvm_init(void *opaque, unsigned int vcpu_size, | 246 | int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, |
247 | struct module *module); | 247 | struct module *module); |
248 | void kvm_exit(void); | 248 | void kvm_exit(void); |
249 | 249 | ||
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9ab1a77941ef..f032806a212f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2178,7 +2178,7 @@ static void kvm_sched_out(struct preempt_notifier *pn, | |||
2178 | kvm_arch_vcpu_put(vcpu); | 2178 | kvm_arch_vcpu_put(vcpu); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | int kvm_init(void *opaque, unsigned int vcpu_size, | 2181 | int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, |
2182 | struct module *module) | 2182 | struct module *module) |
2183 | { | 2183 | { |
2184 | int r; | 2184 | int r; |
@@ -2228,8 +2228,9 @@ int kvm_init(void *opaque, unsigned int vcpu_size, | |||
2228 | goto out_free_4; | 2228 | goto out_free_4; |
2229 | 2229 | ||
2230 | /* A kmem cache lets us meet the alignment requirements of fx_save. */ | 2230 | /* A kmem cache lets us meet the alignment requirements of fx_save. */ |
2231 | kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, | 2231 | if (!vcpu_align) |
2232 | __alignof__(struct kvm_vcpu), | 2232 | vcpu_align = __alignof__(struct kvm_vcpu); |
2233 | kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align, | ||
2233 | 0, NULL); | 2234 | 0, NULL); |
2234 | if (!kvm_vcpu_cache) { | 2235 | if (!kvm_vcpu_cache) { |
2235 | r = -ENOMEM; | 2236 | r = -ENOMEM; |