From patchwork Wed Feb 17 15:45:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 8340461 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53657C0553 for ; Wed, 17 Feb 2016 15:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64F72203B7 for ; Wed, 17 Feb 2016 15:46:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CD1B20357 for ; Wed, 17 Feb 2016 15:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424026AbcBQPqE (ORCPT ); Wed, 17 Feb 2016 10:46:04 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38065 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424005AbcBQPpO (ORCPT ); Wed, 17 Feb 2016 10:45:14 -0500 Received: by mail-wm0-f51.google.com with SMTP id a4so34078320wme.1 for ; Wed, 17 Feb 2016 07:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint-co-uk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=90uWQALbY8W7Xw+KbjMAN7nLMgXmBbILcRaaGgQzpDo=; b=kscmgpr7DTK51oGC1xKP14HC6ys1B8/EbU+2ePZSjwQ6x5CJruNrh9Q1IJucbn9EJX 0ALczKyoN/6MfXZR3BsP4fa//dFNfbBdmvtiyBjKWDbQLGoTl5hGSW3mHg32+LP8R3zj 3Lb9iPjYUNkUI21NQ0tnrQ7SYH0rzPLzxZkEnvsXkO+f4OR+4Plyjl/E6lRTsQWZmJau C156tuVK2MZCA8vBvY1KflGKxv1SCs8nhjP/m4JOot/6o9bkA0eEBKB7NUDOSTcbkuDX 0kIwoTmQx2OJnYJnK7V2CWLFEzoyB1g2pOj6FsKzslBDD6P7Qv9Rto/ZpaMkqRqnjxeZ sZLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=90uWQALbY8W7Xw+KbjMAN7nLMgXmBbILcRaaGgQzpDo=; b=kYdK0LkXWsdSVcq7q0PkqdInxsl0VeM3sV6lr9oGm/soYWkp559POmE3PsOZVkQN2x Nvd547KZwkYzdckMZE5nzAdivDCDaNj0o74iT91PS/oGRtrHq2yeL3sesYw/xoiXgrfD bZFlOtewu9kzJ63vRofklZ8E6b/qJ2zpdq+DTA6QcwGsY7RkrdLduR4NDV8TQFd89c/c 91lBygke6sXLIaK/zXqUdRVGSfOUi9CA4diLVuowMZiYBwacDq7t1GifKdF4D73ZrnG8 QgiCRTFXlVS7jKBrt56wIaR5eA46LU21tszgLH/IhklsGdUC4eGHai5v3EyZx3fOIiOl fHqA== X-Gm-Message-State: AG10YOQ64AiPrmFICV9AL2cReSGlGW5Uc6G78/7f+Zd1oSQ69jqktIP23iFQnv/0Q+lrKg== X-Received: by 10.194.7.195 with SMTP id l3mr2597137wja.43.1455723913334; Wed, 17 Feb 2016 07:45:13 -0800 (PST) Received: from localhost (5ec16434.skybroadband.com. [94.193.100.52]) by smtp.gmail.com with ESMTPSA id n131sm26080607wmf.9.2016.02.17.07.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2016 07:45:12 -0800 (PST) From: Matt Fleming To: Dave Young Cc: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-acpi@vger.kernel.org, kexec@lists.infradead.org, "Rafael J . Wysocki" , Josh Triplett , Borislav Petkov , Matthew Garrett , Vivek Goyal , Matt Fleming Subject: [PATCH 1/2] ACPICA: Tables: Add function to remove ACPI tables Date: Wed, 17 Feb 2016 15:45:09 +0000 Message-Id: <1455723910-16710-2-git-send-email-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1455723910-16710-1-git-send-email-matt@codeblueprint.co.uk> References: <1455723910-16710-1-git-send-email-matt@codeblueprint.co.uk> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are existing internal functions that allow the removal of ACPI tables, but they're not exposed to the OS in any useful way. Introduce acpi_remove_table() which allows tables to be invalidated in the global table list, resulting in failure of subsequent calls to acpi_get_table() for those tables. The rationale for this change is the ability to remove the BGRT table during kexec boot. The BGRT table refers to memory regions that are no longer reserved by the firmware once the kexec kernel boots, having been released for general allocation by the previous kernel. Cc: Dave Young Cc: Rafael J. Wysocki Cc: Josh Triplett Cc: Borislav Petkov Cc: Matthew Garrett Cc: Vivek Goyal Cc: Signed-off-by: Matt Fleming --- drivers/acpi/acpica/tbxface.c | 54 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpixf.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c index 326df65decef..999eecd89601 100644 --- a/drivers/acpi/acpica/tbxface.c +++ b/drivers/acpi/acpica/tbxface.c @@ -480,3 +480,57 @@ cleanup: } ACPI_EXPORT_SYMBOL(acpi_remove_table_handler) + +/******************************************************************************* + * + * FUNCTION: acpi_remove_table + * + * PARAMETERS: signature - ACPI signature of needed table + * instance - Which instance (for SSDTs) + * + * RETURN: Status + * + * DESCRIPTION: Finds and removes an ACPI table. + * + ******************************************************************************/ +acpi_status acpi_remove_table(char *signature, u32 instance) +{ + struct acpi_table_desc *table_desc; + acpi_status status; + u32 i; + u32 j; + + /* Parameter validation */ + if (!signature) { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < acpi_gbl_root_table_list.current_table_count; + i++) { + if (!ACPI_COMPARE_NAME + (&(acpi_gbl_root_table_list.tables[i].signature), + signature)) { + continue; + } + + if (++j < instance) { + continue; + } + + table_desc = &acpi_gbl_root_table_list.tables[i]; + + status = acpi_tb_validate_table(table_desc); + if (ACPI_FAILURE(status)) { + return (status); + } + + acpi_tb_uninstall_table(table_desc); + return (AE_OK); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL(acpi_remove_table); diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index c96621e87c19..47e51612293e 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h @@ -505,6 +505,9 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_remove_table_handler(acpi_table_handler handler)) +ACPI_EXTERNAL_RETURN_STATUS(acpi_status + acpi_remove_table(acpi_string signature, + u32 instance)) /* * Namespace and name interfaces