Skip to content

Commit

Permalink
KVM: PPC: e500mc: Add build-time assert that vcpu is at offset 0
Browse files Browse the repository at this point in the history
In preparation for moving vcpu allocation to common PPC code, add an
explicit, albeit redundant, build-time assert to ensure the vcpu member
is located at offset 0.  The assert is redundant in the sense that
kvmppc_core_vcpu_create_e500() contains a functionally identical assert.
The motiviation for adding the extra assert is to provide visual
confirmation of the correctness of moving vcpu allocation to common
code.

Signed-off-by: Sean Christopherson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Sean Christopherson authored and bonzini committed Jan 24, 2020
1 parent 987b259 commit 3ec8ca2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/powerpc/kvm/e500mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500mc(struct kvm *kvm,
struct kvm_vcpu *vcpu;
int err;

BUILD_BUG_ON(offsetof(struct kvmppc_vcpu_e500, vcpu) != 0);

vcpu_e500 = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
if (!vcpu_e500) {
err = -ENOMEM;
Expand Down

0 comments on commit 3ec8ca2

Please sign in to comment.