aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/kvm
diff options
context:
space:
mode:
authorGravatar Sean Christopherson <sean.j.christopherson@intel.com> 2019-08-15 10:22:37 -0700
committerGravatar Paolo Bonzini <pbonzini@redhat.com> 2019-08-22 10:09:27 +0200
commit12b58f4ed2a1b93f0eae84f308f6e0a143a533d4 (patch)
tree89d75b8f505eb4df55d23b026a85889f6b1f0521 /arch/powerpc/kvm
parentKVM: X86: Add pv tlb shootdown tracepoint (diff)
downloadlinux-12b58f4ed2a1b93f0eae84f308f6e0a143a533d4.tar.gz
linux-12b58f4ed2a1b93f0eae84f308f6e0a143a533d4.tar.bz2
linux-12b58f4ed2a1b93f0eae84f308f6e0a143a533d4.zip
KVM: Assert that struct kvm_vcpu is always as offset zero
KVM implementations that wrap struct kvm_vcpu with a vendor specific struct, e.g. struct vcpu_vmx, must place the vcpu member at offset 0, otherwise the usercopy region intended to encompass struct kvm_vcpu_arch will instead overlap random chunks of the vendor specific struct. E.g. padding a large number of bytes before struct kvm_vcpu triggers a usercopy warn when running with CONFIG_HARDENED_USERCOPY=y. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r--arch/powerpc/kvm/e500.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index b5a848a55504..00649ca5fa9a 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -440,6 +440,9 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_e500(struct kvm *kvm,
struct kvm_vcpu *vcpu;
int err;
+ BUILD_BUG_ON_MSG(offsetof(struct kvmppc_vcpu_e500, vcpu) != 0,
+ "struct kvm_vcpu must be at offset 0 for arch usercopy region");
+
vcpu_e500 = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
if (!vcpu_e500) {
err = -ENOMEM;