From patchwork Mon Feb 27 09:34:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9592873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 179F660453 for ; Mon, 27 Feb 2017 09:35:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10B0928420 for ; Mon, 27 Feb 2017 09:35:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0573528423; Mon, 27 Feb 2017 09:35:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A09A628420 for ; Mon, 27 Feb 2017 09:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751654AbdB0JfN (ORCPT ); Mon, 27 Feb 2017 04:35:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48150 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597AbdB0JfN (ORCPT ); Mon, 27 Feb 2017 04:35:13 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 896EB369C4; Mon, 27 Feb 2017 09:34:37 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E82E30660; Mon, 27 Feb 2017 09:34:35 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Robert Moore , Lv Zheng Cc: Hans de Goede , linux-acpi@vger.kernel.org, devel@acpica.org Subject: [PATCH] ACPICA: Detect duplicate SSDT tables Date: Mon, 27 Feb 2017 10:34:32 +0100 Message-Id: <20170227093432.3308-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 27 Feb 2017 09:34:37 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some machines have the exact (byte for byte) same SSDT tables multiple times in the root_table_list. Detect this and silently skip the duplicates rather then printing a scary looking set of errors. Signed-off-by: Hans de Goede --- drivers/acpi/acpica/tbxfload.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c index 82019c0..1971cd7 100644 --- a/drivers/acpi/acpica/tbxfload.c +++ b/drivers/acpi/acpica/tbxfload.c @@ -125,6 +125,44 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_load_tables) /******************************************************************************* * + * FUNCTION: acpi_tb_find_duplicate_ssdt + * + * PARAMETERS: table - validated acpi_table_desc of table to check + * index - index of table to find a duplicate of + * + * RETURN: TRUE if a duplicate is found, FALSE if not + * + * DESCRIPTION: Private helper function for acpi_tb_load_namespace to + * avoid trying to load duplicate ssdt tables + * + ******************************************************************************/ +static u8 acpi_tb_find_duplicate_ssdt(struct acpi_table_desc *table, u32 index) +{ + struct acpi_table_desc *dup; + u32 i; + + for (i = 0; i < index; ++i) { + dup = &acpi_gbl_root_table_list.tables[i]; + + if (!acpi_gbl_root_table_list.tables[i].address || + (!ACPI_COMPARE_NAME(dup->signature.ascii, ACPI_SIG_SSDT) + && !ACPI_COMPARE_NAME(dup->signature.ascii, + ACPI_SIG_PSDT) + && !ACPI_COMPARE_NAME(dup->signature.ascii, + ACPI_SIG_OSDT)) + || ACPI_FAILURE(acpi_tb_validate_table(dup)) + || dup->length != table->length) { + continue; + } + + if (memcmp(dup->pointer, table->pointer, table->length) == 0) + return TRUE; + } + return FALSE; +} + +/******************************************************************************* + * * FUNCTION: acpi_tb_load_namespace * * PARAMETERS: None @@ -212,7 +250,8 @@ acpi_status acpi_tb_load_namespace(void) ACPI_SIG_PSDT) && !ACPI_COMPARE_NAME(table->signature.ascii, ACPI_SIG_OSDT)) - || ACPI_FAILURE(acpi_tb_validate_table(table))) { + || ACPI_FAILURE(acpi_tb_validate_table(table)) + || acpi_tb_find_duplicate_ssdt(table, i)) { continue; }