From patchwork Tue Dec 11 20:53:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 153517 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1085261ljp; Tue, 11 Dec 2018 12:59:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/UUBbTBgEu/MLtL5zfl8YqLiCGosSBlSY1fBr+Gm5tbZCLAL2KAuaUHVUMrp4yeLsxE5T9A X-Received: by 2002:ac8:43d0:: with SMTP id w16mr17582394qtn.78.1544561968127; Tue, 11 Dec 2018 12:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544561968; cv=none; d=google.com; s=arc-20160816; b=PBOCclWgs89zpaUGwCPtOmYZpn6OwvbPv0yJbs0c37Z9wepMRtx5HH7IFo8kevfxwl /xw7/YjZ+xdg9nOYHJ9Veb/bQQLuavNaF1vRd3zfni286Lm30Q7agA5lzwc6eafpUhm7 QzPdFzOWgH6eeAmxtKM2k1S56qufxqTQCEELCXHRP4bg6r05W6gnpx1QnxGBeGQ8rTNn tr+0C0QNod+Sbv/jzoGGHIqtFjnvXKNNH+EmacfBE9gBZyHVKIf2O9nXGpxC41o6yIgz wkOFo1ASnNyFSfurcy1zofYz4A8REfuEPm+WSLeD079KHml1XJ8JxVrC5sEJEZy5vye+ vdGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=K9PSikUi19/k9UfR1UEBfkwlR4exkK1R3jNurJgg7p8=; b=NR+Dz+2TgSNfCwOyeKtc9lKoOyT1M78sF+bXD5WKMabKyYO6k52tod/vpYUbPUhex5 Mmf+bI7GU8KGexSQEU28LFQ7KflGK72vRddNlOV5PVPoGXyNA6zg/oJ5LJzDuqVo4n0u npCd79/TChkNYvC0rB6jZk0LzftCib7rJV8/4nq3Mk1llWFS6jZuTHuGFkJlXq3Q88Qm ClEGIJDc6iP5wLAzToLu17Rggxt0ENDCu9za2UKePFwyFsMNsBJl8e5vbow32w0TLodS lQ9xcXkF1jf0KPysXjcTinqKatOMuQl/HYEFM/frDinyPxwVdLoFLMysJxRNhLl9NVc4 mP0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f11si3239011qka.139.2018.12.11.12.59.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Dec 2018 12:59:28 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:41396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWp7m-0007n6-VY for patch@linaro.org; Tue, 11 Dec 2018 15:59:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWp2a-00047T-Fe for qemu-devel@nongnu.org; Tue, 11 Dec 2018 15:54:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWp2Z-0001ni-2m for qemu-devel@nongnu.org; Tue, 11 Dec 2018 15:54:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWp2Y-0001nD-S4 for qemu-devel@nongnu.org; Tue, 11 Dec 2018 15:54:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 308CC80F79; Tue, 11 Dec 2018 20:54:02 +0000 (UTC) Received: from localhost (ovpn-116-63.gru2.redhat.com [10.97.116.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6B255C219; Tue, 11 Dec 2018 20:54:01 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 11 Dec 2018 18:53:45 -0200 Message-Id: <20181211205346.11118-4-ehabkost@redhat.com> In-Reply-To: <20181211205346.11118-1-ehabkost@redhat.com> References: <20181211205346.11118-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 11 Dec 2018 20:54:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/4] target/i386/kvm.c: Don't mark cpuid_data as QEMU_PACKED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , kvm@vger.kernel.org, "Michael S. Tsirkin" , Marcelo Tosatti , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell clang complains about taking the address of a packed member of a struct: target/i386/kvm.c:1245:27: warning: taking address of packed member 'cpuid' of class or structure '' may result in an unaligned pointer value [-Waddress-of-packed-member] c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0); ^~~~~~~~~~~~~~~~ target/i386/kvm.c:1297:31: warning: taking address of packed member 'cpuid' of class or structure '' may result in an unaligned pointer value [-Waddress-of-packed-member] c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); ^~~~~~~~~~~~~~~~ The kernel's definitions of struct kvm_cpuid2 and struct kvm_cpuid_entry2 are carefully set up with padding fields so that there is no between-struct padding anyway, so the QEMU_PACKED annotation is unnecessary and might result in the compiler generating worse code. Drop it, and instead assert at build time that there is no stray padding. Signed-off-by: Peter Maydell Message-Id: <20181210114654.31433-1-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Eduardo Habkost --- target/i386/kvm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.18.0.rc1.1.g3f1ff2140 diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b2401d13ea..739cf8c8ea 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -864,7 +864,15 @@ int kvm_arch_init_vcpu(CPUState *cs) struct { struct kvm_cpuid2 cpuid; struct kvm_cpuid_entry2 entries[KVM_MAX_CPUID_ENTRIES]; - } QEMU_PACKED cpuid_data; + } cpuid_data; + /* + * The kernel defines these structs with padding fields so there + * should be no extra padding in our cpuid_data struct. + */ + QEMU_BUILD_BUG_ON(sizeof(cpuid_data) != + sizeof(struct kvm_cpuid2) + + sizeof(struct kvm_cpuid_entry2) * KVM_MAX_CPUID_ENTRIES); + X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint32_t limit, i, j, cpuid_i;