From nobody Fri Nov 7 10:32:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15475180395691019.4078398858038; Mon, 14 Jan 2019 18:07:19 -0800 (PST) Received: from localhost ([127.0.0.1]:53576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjE8H-0002X6-Br for importer@patchew.org; Mon, 14 Jan 2019 21:07:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjDjm-0007oY-7G for qemu-devel@nongnu.org; Mon, 14 Jan 2019 20:41:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjDeG-00082C-Ve for qemu-devel@nongnu.org; Mon, 14 Jan 2019 20:36:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gjDeG-00081U-Ll for qemu-devel@nongnu.org; Mon, 14 Jan 2019 20:36:12 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E5476C0467DF; Tue, 15 Jan 2019 01:36:11 +0000 (UTC) Received: from redhat.com (ovpn-124-229.rdu2.redhat.com [10.10.124.229]) by smtp.corp.redhat.com (Postfix) with SMTP id 1D99E1048100; Tue, 15 Jan 2019 01:36:10 +0000 (UTC) Date: Mon, 14 Jan 2019 20:36:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190115003812.11329-15-mst@redhat.com> References: <20190115003812.11329-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190115003812.11329-1-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 15 Jan 2019 01:36:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/44] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table() 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: Laurent Vivier , Peter Maydell , Thomas Huth , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov some parts of sanitize_fadt_ptrs() do redundant job - locating FADT - checking original checksum There is no need to do it as test_acpi_fadt_table() already does that, so drop duplicate code and move remaining fixup code into test_acpi_fadt_table(). Signed-off-by: Igor Mammedov Acked-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index dcd6be8bbd..9139decc68 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -128,6 +128,7 @@ static void test_acpi_fadt_table(test_data *data) /* FADT table is 1st */ AcpiSdtTable table =3D g_array_index(data->tables, typeof(table), 0); uint8_t *fadt_aml =3D table.aml; + uint32_t fadt_len =3D table.aml_len; =20 ACPI_ASSERT_CMP(table.header->signature, "FACP"); =20 @@ -139,35 +140,17 @@ static void test_acpi_fadt_table(test_data *data) acpi_fetch_table(data->qts, &table.aml, &table.aml_len, fadt_aml + 40 /* DSDT */, "DSDT", true); g_array_append_val(data->tables, table); -} =20 -static void sanitize_fadt_ptrs(test_data *data) -{ - /* fixup pointers in FADT */ - int i; - - for (i =3D 0; i < data->tables->len; i++) { - AcpiSdtTable *sdt =3D &g_array_index(data->tables, AcpiSdtTable, i= ); - - if (memcmp(&sdt->header->signature, "FACP", 4)) { - continue; - } - - /* check original FADT checksum before sanitizing table */ - g_assert(!acpi_calc_checksum(sdt->aml, sdt->aml_len)); - - memset(sdt->aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */ - memset(sdt->aml + 40, 0, 4); /* sanitize DSDT ptr */ - if (sdt->header->revision >=3D 3) { - memset(sdt->aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr = */ - memset(sdt->aml + 140, 0, 8); /* sanitize X_DSDT ptr */ - } - - /* update checksum */ - sdt->header->checksum =3D 0; - sdt->header->checksum -=3D acpi_calc_checksum(sdt->aml, sdt->aml_l= en); - break; + memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */ + memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */ + if (fadt_aml[8 /* FADT Major Version */] >=3D 3) { + memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */ + memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */ } + + /* update checksum */ + fadt_aml[9 /* Checksum */] =3D 0; + fadt_aml[9 /* Checksum */] -=3D acpi_calc_checksum(fadt_aml, fadt_len); } =20 static void dump_aml_files(test_data *data, bool rebuild) @@ -541,8 +524,6 @@ static void test_acpi_one(const char *params, test_data= *data) test_acpi_rsdt_table(data); test_acpi_fadt_table(data); =20 - sanitize_fadt_ptrs(data); - if (iasl) { if (getenv(ACPI_REBUILD_EXPECTED_AML)) { dump_aml_files(data, true); --=20 MST