From nobody Thu May 2 15:05:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544442500893290.2907202053018; Mon, 10 Dec 2018 03:48:20 -0800 (PST) Received: from localhost ([::1]:60368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWK2q-0007pH-Q6 for importer@patchew.org; Mon, 10 Dec 2018 06:48:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWK1d-0007Ow-Ok for qemu-devel@nongnu.org; Mon, 10 Dec 2018 06:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWK1Z-0004Lo-7m for qemu-devel@nongnu.org; Mon, 10 Dec 2018 06:47:01 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:53362) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWK1Y-0004Js-W8 for qemu-devel@nongnu.org; Mon, 10 Dec 2018 06:46:57 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gWK1W-0008GT-Fn; Mon, 10 Dec 2018 11:46:54 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2018 11:46:54 +0000 Message-Id: <20181210114654.31433-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH] 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, patches@linaro.org, Marcelo Tosatti , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 [-Waddre= ss-of-packed-member] c =3D 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 [-Waddre= ss-of-packed-member] c =3D 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/i386/kvm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b2401d13ea7..739cf8c8ea1 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) !=3D + sizeof(struct kvm_cpuid2) + + sizeof(struct kvm_cpuid_entry2) * KVM_MAX_CPUID_ENTR= IES); + X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; uint32_t limit, i, j, cpuid_i; --=20 2.19.2