From patchwork Tue Jan 15 20:04:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1025428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43fM482BNjz9sBQ for ; Wed, 16 Jan 2019 07:14:00 +1100 (AEDT) Received: from localhost ([127.0.0.1]:42523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjV5y-000656-3K for incoming@patchwork.ozlabs.org; Tue, 15 Jan 2019 15:13:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjUxJ-0006Ow-Vg for qemu-devel@nongnu.org; Tue, 15 Jan 2019 15:05:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjUxH-0002QC-Ka for qemu-devel@nongnu.org; Tue, 15 Jan 2019 15:05:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gjUxG-0002He-Kf for qemu-devel@nongnu.org; Tue, 15 Jan 2019 15:04:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AED0E369C9; Tue, 15 Jan 2019 20:04:51 +0000 (UTC) Received: from redhat.com (ovpn-125-113.rdu2.redhat.com [10.10.125.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661649F7A; Tue, 15 Jan 2019 20:04:45 +0000 (UTC) Date: Tue, 15 Jan 2019 15:04:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190115200252.25911-14-mst@redhat.com> References: <20190115200252.25911-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190115200252.25911-1-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 15 Jan 2019 20:04:51 +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 v2 13/49] tests: smbios: fetch whole table in one step instead of reading it step by step 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 , Igor Mammedov , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov replace a bunch of ACPI_READ_ARRAY/ACPI_READ_FIELD macro, that read SMBIOS table field by field with one memread() to fetch whole table at once and drop no longer used ACPI_READ_ARRAY/ACPI_READ_FIELD macro. Signed-off-by: Igor Mammedov Acked-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/acpi-utils.h | 17 ----------------- tests/bios-tables-test.c | 15 +-------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h index 1aa00db2b6..cb7183e057 100644 --- a/tests/acpi-utils.h +++ b/tests/acpi-utils.h @@ -30,23 +30,6 @@ typedef struct { bool tmp_files_retain; /* do not delete the temp asl/aml */ } AcpiSdtTable; -#define ACPI_READ_FIELD(qts, field, addr) \ - do { \ - qtest_memread(qts, addr, &field, sizeof(field)); \ - addr += sizeof(field); \ - } while (0) - -#define ACPI_READ_ARRAY_PTR(qts, arr, length, addr) \ - do { \ - int idx; \ - for (idx = 0; idx < length; ++idx) { \ - ACPI_READ_FIELD(qts, arr[idx], addr); \ - } \ - } while (0) - -#define ACPI_READ_ARRAY(qts, arr, addr) \ - ACPI_READ_ARRAY_PTR(qts, arr, sizeof(arr) / sizeof(arr[0]), addr) - #define ACPI_ASSERT_CMP(actual, expected) do { \ char ACPI_ASSERT_CMP_str[5] = {}; \ memcpy(ACPI_ASSERT_CMP_str, &actual, 4); \ diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 8fdd1c173a..dcd6be8bbd 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -406,32 +406,19 @@ static bool smbios_ep_table_ok(test_data *data) struct smbios_21_entry_point *ep_table = &data->smbios_ep_table; uint32_t addr = data->smbios_ep_addr; - ACPI_READ_ARRAY(data->qts, ep_table->anchor_string, addr); + qtest_memread(data->qts, addr, ep_table, sizeof(*ep_table)); if (memcmp(ep_table->anchor_string, "_SM_", 4)) { return false; } - ACPI_READ_FIELD(data->qts, ep_table->checksum, addr); - ACPI_READ_FIELD(data->qts, ep_table->length, addr); - ACPI_READ_FIELD(data->qts, ep_table->smbios_major_version, addr); - ACPI_READ_FIELD(data->qts, ep_table->smbios_minor_version, addr); - ACPI_READ_FIELD(data->qts, ep_table->max_structure_size, addr); - ACPI_READ_FIELD(data->qts, ep_table->entry_point_revision, addr); - ACPI_READ_ARRAY(data->qts, ep_table->formatted_area, addr); - ACPI_READ_ARRAY(data->qts, ep_table->intermediate_anchor_string, addr); if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) { return false; } - ACPI_READ_FIELD(data->qts, ep_table->intermediate_checksum, addr); - ACPI_READ_FIELD(data->qts, ep_table->structure_table_length, addr); if (ep_table->structure_table_length == 0) { return false; } - ACPI_READ_FIELD(data->qts, ep_table->structure_table_address, addr); - ACPI_READ_FIELD(data->qts, ep_table->number_of_structures, addr); if (ep_table->number_of_structures == 0) { return false; } - ACPI_READ_FIELD(data->qts, ep_table->smbios_bcd_revision, addr); if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) || acpi_calc_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) {