From patchwork Wed May 15 10:08:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1099931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 453qz34416z9s9T; Wed, 15 May 2019 20:09:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hQqqa-0002sI-1n; Wed, 15 May 2019 10:09:16 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hQqqY-0002s8-Qk for fwts-devel@lists.ubuntu.com; Wed, 15 May 2019 10:09:14 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hQqpa-0001T1-1G; Wed, 15 May 2019 10:08:14 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH][V2] fwts_acpica: don't add in RSDP or null table entries to XSDT or RSDT (LP: #1829167) Date: Wed, 15 May 2019 11:08:13 +0100 Message-Id: <20190515100813.16965-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King BugLink: https://bugs.launchpad.net/fwts/+bug/1829167 Adding in the RSDP table to the XSDT and RSDT is illegal. It also breaks ACPICA as this tries to checksum the RSDP and as it's a non-standard table the length field is offset differently from most tables causing the checksum to segfault. Also don't in null tables, this does not make sense. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- V2: add in missing bug number --- src/acpica/fwts_acpica.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c index 75f8fe3d..65dad3c5 100644 --- a/src/acpica/fwts_acpica.c +++ b/src/acpica/fwts_acpica.c @@ -1125,6 +1125,7 @@ int fwts_acpica_init(fwts_framework *fw) return FWTS_ERROR; if (table != NULL) { uint64_t *entries; + int j; fwts_acpica_XSDT = fwts_low_calloc(1, table->length); if (fwts_acpica_XSDT == NULL) { @@ -1135,18 +1136,19 @@ int fwts_acpica_init(fwts_framework *fw) n = (table->length - sizeof(ACPI_TABLE_HEADER)) / sizeof(uint64_t); entries = (uint64_t*)(table->data + sizeof(ACPI_TABLE_HEADER)); - for (i = 0; i < n; i++) { + for (i = 0, j = 0; i < n; i++) { fwts_acpi_table_info *tbl; + if (fwts_acpi_find_table_by_addr(fw, entries[i], &tbl) != FWTS_OK) return FWTS_ERROR; if (tbl) { + if (strncmp(tbl->name, "RSDP", 4) == 0) + continue; if (strncmp(tbl->name, "FACP", 4) == 0) { - fwts_acpica_XSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(fwts_acpica_FADT); + fwts_acpica_XSDT->TableOffsetEntry[j++] = ACPI_PTR_TO_PHYSADDR(fwts_acpica_FADT); } else { - fwts_acpica_XSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(tbl->data); + fwts_acpica_XSDT->TableOffsetEntry[j++] = ACPI_PTR_TO_PHYSADDR(tbl->data); } - } else { - fwts_acpica_XSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(NULL); } } fwts_acpica_XSDT->Header.Checksum = 0; @@ -1160,6 +1162,7 @@ int fwts_acpica_init(fwts_framework *fw) return FWTS_ERROR; if (table) { uint32_t *entries; + int j; fwts_acpica_RSDT = fwts_low_calloc(1, table->length); if (fwts_acpica_RSDT == NULL) { @@ -1170,19 +1173,18 @@ int fwts_acpica_init(fwts_framework *fw) n = (table->length - sizeof(ACPI_TABLE_HEADER)) / sizeof(uint32_t); entries = (uint32_t*)(table->data + sizeof(ACPI_TABLE_HEADER)); - for (i = 0; i < n; i++) { + for (i = 0, j = 0; i < n; i++) { fwts_acpi_table_info *tbl; if (fwts_acpi_find_table_by_addr(fw, entries[i], &tbl) != FWTS_OK) return FWTS_ERROR; if (tbl) { + if (strncmp(tbl->name, "RSDP", 4) == 0) + continue; if (strncmp(tbl->name, "FACP", 4) == 0) { - fwts_acpica_RSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(fwts_acpica_FADT); - } - else { - fwts_acpica_RSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(tbl->data); + fwts_acpica_RSDT->TableOffsetEntry[j++] = ACPI_PTR_TO_PHYSADDR(fwts_acpica_FADT); + } else { + fwts_acpica_RSDT->TableOffsetEntry[j++] = ACPI_PTR_TO_PHYSADDR(tbl->data); } - } else { - fwts_acpica_RSDT->TableOffsetEntry[i] = ACPI_PTR_TO_PHYSADDR(NULL); } } fwts_acpica_RSDT->Header.Checksum = 0;