From patchwork Fri Apr 28 12:03:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Nikoleris X-Patchwork-Id: 13226307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E355C77B61 for ; Fri, 28 Apr 2023 12:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345961AbjD1MFK (ORCPT ); Fri, 28 Apr 2023 08:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345870AbjD1ME5 (ORCPT ); Fri, 28 Apr 2023 08:04:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A3A71BEC for ; Fri, 28 Apr 2023 05:04:57 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC2EA14BF; Fri, 28 Apr 2023 05:05:40 -0700 (PDT) Received: from godel.lab.cambridge.arm.com (godel.lab.cambridge.arm.com [10.7.66.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EAA1E3F5A1; Fri, 28 Apr 2023 05:04:55 -0700 (PDT) From: Nikos Nikoleris To: kvm@vger.kernel.org, kvmarm@lists.linux.dev, andrew.jones@linux.dev Cc: pbonzini@redhat.com, alexandru.elisei@arm.com, ricarkol@google.com Subject: [kvm-unit-tests PATCH v5 07/29] lib/acpi: Ensure all struct definition for ACPI tables are packed Date: Fri, 28 Apr 2023 13:03:43 +0100 Message-Id: <20230428120405.3770496-8-nikos.nikoleris@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428120405.3770496-1-nikos.nikoleris@arm.com> References: <20230428120405.3770496-1-nikos.nikoleris@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org All ACPI table definitions are provided with precise definitions of field sizes and offsets, make sure that no compiler optimization can interfere with the memory layout of the corresponding structs. Signed-off-by: Nikos Nikoleris Reviewed-by: Andrew Jones --- lib/acpi.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/acpi.h b/lib/acpi.h index f9a344e9..53e41c4b 100644 --- a/lib/acpi.h +++ b/lib/acpi.h @@ -3,6 +3,12 @@ #include "libcflat.h" +/* + * All tables and structures must be byte-packed to match the ACPI + * specification, since the tables are provided by the system firmware. + */ +#pragma pack(1) + #define ACPI_SIGNATURE(c1, c2, c3, c4) \ ((c1) | ((c2) << 8) | ((c3) << 16) | ((c4) << 24)) @@ -103,6 +109,8 @@ struct acpi_table_facs_rev1 { u8 reserved3[40]; /* Reserved - must be zero */ }; +#pragma pack(0) + void set_efi_rsdp(struct acpi_table_rsdp *rsdp); void *find_acpi_table_addr(u32 sig);