Commit 0ee75bea authored by Avi Kivity's avatar Avi Kivity

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: default avatarAvi Kivity <avi@redhat.com>
parent 884a0ff0
...@@ -51,7 +51,7 @@ static int __init kvm_vmm_init(void) ...@@ -51,7 +51,7 @@ static int __init kvm_vmm_init(void)
vmm_fpswa_interface = fpswa_interface; vmm_fpswa_interface = fpswa_interface;
/*Register vmm data to kvm side*/ /*Register vmm data to kvm side*/
return kvm_init(&vmm_info, 1024, THIS_MODULE); return kvm_init(&vmm_info, 1024, 0, THIS_MODULE);
} }
static void __exit kvm_vmm_exit(void) static void __exit kvm_vmm_exit(void)
......
...@@ -147,7 +147,7 @@ static int __init kvmppc_44x_init(void) ...@@ -147,7 +147,7 @@ static int __init kvmppc_44x_init(void)
if (r) if (r)
return r; return r;
return kvm_init(NULL, sizeof(struct kvmppc_vcpu_44x), THIS_MODULE); return kvm_init(NULL, sizeof(struct kvmppc_vcpu_44x), 0, THIS_MODULE);
} }
static void __exit kvmppc_44x_exit(void) static void __exit kvmppc_44x_exit(void)
......
...@@ -1385,7 +1385,8 @@ int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) ...@@ -1385,7 +1385,8 @@ int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
static int kvmppc_book3s_init(void) static int kvmppc_book3s_init(void)
{ {
return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), THIS_MODULE); return kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), 0,
THIS_MODULE);
} }
static void kvmppc_book3s_exit(void) static void kvmppc_book3s_exit(void)
......
...@@ -161,7 +161,7 @@ static int __init kvmppc_e500_init(void) ...@@ -161,7 +161,7 @@ static int __init kvmppc_e500_init(void)
flush_icache_range(kvmppc_booke_handlers, flush_icache_range(kvmppc_booke_handlers,
kvmppc_booke_handlers + max_ivor + kvmppc_handler_len); kvmppc_booke_handlers + max_ivor + kvmppc_handler_len);
return kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), THIS_MODULE); return kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE);
} }
static void __init kvmppc_e500_exit(void) static void __init kvmppc_e500_exit(void)
......
...@@ -752,7 +752,7 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) ...@@ -752,7 +752,7 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
static int __init kvm_s390_init(void) static int __init kvm_s390_init(void)
{ {
int ret; int ret;
ret = kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE); ret = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
if (ret) if (ret)
return ret; return ret;
......
...@@ -3319,7 +3319,7 @@ static struct kvm_x86_ops svm_x86_ops = { ...@@ -3319,7 +3319,7 @@ static struct kvm_x86_ops svm_x86_ops = {
static int __init svm_init(void) static int __init svm_init(void)
{ {
return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm), return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm),
THIS_MODULE); __alignof__(struct vcpu_svm), THIS_MODULE);
} }
static void __exit svm_exit(void) static void __exit svm_exit(void)
......
...@@ -4245,7 +4245,8 @@ static int __init vmx_init(void) ...@@ -4245,7 +4245,8 @@ static int __init vmx_init(void)
set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */ set_bit(0, vmx_vpid_bitmap); /* 0 is reserved for host */
r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE); r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx),
__alignof__(struct vcpu_vmx), THIS_MODULE);
if (r) if (r)
goto out3; goto out3;
......
...@@ -243,7 +243,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); ...@@ -243,7 +243,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
void vcpu_load(struct kvm_vcpu *vcpu); void vcpu_load(struct kvm_vcpu *vcpu);
void vcpu_put(struct kvm_vcpu *vcpu); void vcpu_put(struct kvm_vcpu *vcpu);
int kvm_init(void *opaque, unsigned int vcpu_size, int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
struct module *module); struct module *module);
void kvm_exit(void); void kvm_exit(void);
......
...@@ -2178,7 +2178,7 @@ static void kvm_sched_out(struct preempt_notifier *pn, ...@@ -2178,7 +2178,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
kvm_arch_vcpu_put(vcpu); kvm_arch_vcpu_put(vcpu);
} }
int kvm_init(void *opaque, unsigned int vcpu_size, int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
struct module *module) struct module *module)
{ {
int r; int r;
...@@ -2228,8 +2228,9 @@ int kvm_init(void *opaque, unsigned int vcpu_size, ...@@ -2228,8 +2228,9 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
goto out_free_4; goto out_free_4;
/* A kmem cache lets us meet the alignment requirements of fx_save. */ /* A kmem cache lets us meet the alignment requirements of fx_save. */
kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, if (!vcpu_align)
__alignof__(struct kvm_vcpu), vcpu_align = __alignof__(struct kvm_vcpu);
kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
0, NULL); 0, NULL);
if (!kvm_vcpu_cache) { if (!kvm_vcpu_cache) {
r = -ENOMEM; r = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment