From patchwork Fri Sep 13 10:05:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 2882661 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6D997BFF05 for ; Fri, 13 Sep 2013 10:06:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D8172038C for ; Fri, 13 Sep 2013 10:06:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBA23202F7 for ; Fri, 13 Sep 2013 10:06:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755146Ab3IMKGr (ORCPT ); Fri, 13 Sep 2013 06:06:47 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:49714 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755137Ab3IMKGq (ORCPT ); Fri, 13 Sep 2013 06:06:46 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc17so1039058pbc.4 for ; Fri, 13 Sep 2013 03:06:45 -0700 (PDT) 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; bh=Ws8oOCrliJl+LZfm0qT9a5RYktwN3+TJmkZKGJpLlkQ=; b=KuVazLHdQdPc0qwpEUkqdt7qgnthc+fHhpWiyqezniQ3xIhiDEy1hPzu1gPpvVYpJe 9obQzgqw8iVUBCyp/ewvaZUhCZ1XIyWx1aBgB+D/ZyTwYvoETkSJNOO1jSR9HTR3KbtU z3eAQFeNDiaqT8Qzhd1Abv86h30dg4xqceDultghCjZlorI+F7KuP9lQ8btsEsLHwR0c r4ZlCryv2zmsXxpcQruzsgPNvgcmqs16Fhu9+LGfAZ2+nZWP5AuYL2gBn1CEfNfNeuRr rbJXle4jBiwsjdac7T/2aOKNE43KPWdoR10hjir304yntycQH/OMMkO8xqxaabrYtSMV kV/g== X-Gm-Message-State: ALoCoQlzCzBoc8Tqjqm/yYKayWFfjpv5K/SxVP+aj5nggIlV1MD3SzE5HY6X4okeODgxoZBfhC4h X-Received: by 10.68.13.3 with SMTP id d3mr12788336pbc.62.1379066805679; Fri, 13 Sep 2013 03:06:45 -0700 (PDT) Received: from localhost ([218.17.215.175]) by mx.google.com with ESMTPSA id f2sm10604154pbg.44.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 03:06:44 -0700 (PDT) From: Hanjun Guo To: "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Bob Moore , linux-acpi@vger.kernel.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linaro-acpi@lists.linaro.org, Hanjun Guo Subject: [PATCH] ACPICA / hwreg: Use acpi_gbl_reduced_hardware to prevent accessing PM registers Date: Fri, 13 Sep 2013 18:05:41 +0800 Message-Id: <1379066741-23689-1-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, 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 On hardware reduced platforms, there is no support for the following: - PM Event and Control registers - SCI interrupt (and handler) - Fixed Events - General Purpose Events (GPEs) - Global Lock - ACPI PM timer - FACS table (Waking vectors and Global Lock) acpi_gbl_reduced_hardware is a global flag and can be used to prevent misbehavior on hardware reduced platforms, and this flag is initialized at the very beginning of the system boot when FADT is parsed, this flag is set to 1 when the FACP Hardware Reduced flag is set, so we can use it to prevent accessing registers which do not exist on reduced hardware platform. but when FACP Hardware Reduced flag is set, ACPI drivers will still access some registers directly which do not exist on reduced hardware platform and cause boot failure: [ 9.024370] Unable to handle kernel paging request at virtual address ffffffbffbe00001 [ 9.024423] pgd = ffffffc00007d000 [ 9.024468] [ffffffbffbe00001] *pgd=000000008007f003, *pmd=0000000000000000 [ 9.024538] Internal error: Oops: 96000006 [#1] SMP [ 9.024577] Modules linked in: [ 9.024627] CPU: 0 Not tainted (3.9.0+ #3) [ 9.024691] PC is at acpi_os_read_port+0x58/0xc8 [ 9.024753] LR is at acpi_hw_read_port+0x4c/0xc4 [ 9.024810] pc : [] lr : [] pstate: 600003c5 .... [ 9.031956] Call trace: [ 9.032021] [] acpi_os_read_port+0x58/0xc8 [ 9.032094] [] acpi_hw_read_port+0x4c/0xc4 [ 9.032165] [] acpi_hw_read+0x6c/0x100 [ 9.032237] [] acpi_hw_read_multiple+0x24/0x70 [ 9.032312] [] acpi_hw_register_read+0xa8/0x164 [ 9.032386] [] acpi_write_bit_register+0x9c/0x194 [ 9.032472] [] acpi_processor_get_power_info+0x6c4/0x748 [ 9.032550] [] acpi_processor_power_init+0xac/0x138 [ 9.032630] [] acpi_processor_start+0x48/0x138 [ 9.032704] [] acpi_processor_add+0x43c/0x498 [ 9.032784] [] acpi_device_probe+0x3c/0x198 [ 9.032862] [] driver_probe_device+0x90/0x348 [ 9.032940] [] __driver_attach+0x9c/0xa0 [ 9.033015] [] bus_for_each_dev+0x4c/0x8c [ 9.033090] [] driver_attach+0x20/0x28 [ 9.033166] [] bus_add_driver+0xfc/0x254 [ 9.033244] [] driver_register+0x6c/0x184 [ 9.033325] [] acpi_bus_register_driver+0x34/0x44 [ 9.033400] [] acpi_processor_init+0x28/0x40 [ 9.033469] [] do_one_initcall+0x100/0x138 [ 9.033544] [] kernel_init_freeable+0x128/0x1cc [ 9.033620] [] kernel_init+0x10/0xcc [ 9.033700] Code: d2bf7c02 f2dff7e2 f2ffffe2 8b020000 (79400000) [ 9.033843] ---[ end trace 64376967e6bc20a9 ]--- [ 9.033995] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b So acpi_gbl_reduced_hardware should be used to check if reduced hardware or not, if it is reduced hardware, just return with some error and do not access the no-existent registers. Signed-off-by: Hanjun Guo --- drivers/acpi/acpica/hwregs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 8d2e866..4c270c3 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c @@ -265,6 +265,11 @@ acpi_status acpi_hw_clear_acpi_status(void) ACPI_FUNCTION_TRACE(hw_clear_acpi_status); + /* If Hardware Reduced flag is set, there are no GPEs */ + if (acpi_gbl_reduced_hardware) { + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); + } + ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n", ACPI_BITMASK_ALL_FIXED_STATUS, ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address))); @@ -305,6 +310,10 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) { ACPI_FUNCTION_ENTRY(); + if (acpi_gbl_reduced_hardware) { + return (NULL); + } + if (register_id > ACPI_BITREG_MAX) { ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: 0x%X", register_id)); @@ -337,6 +346,11 @@ acpi_status acpi_hw_write_pm1_control(u32 pm1a_control, u32 pm1b_control) ACPI_FUNCTION_TRACE(hw_write_pm1_control); + /* If Hardware Reduced flag is set, there are no PM Control registers */ + if (acpi_gbl_reduced_hardware) { + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); + } + status = acpi_hw_write(pm1a_control, &acpi_gbl_FADT.xpm1a_control_block); if (ACPI_FAILURE(status)) { @@ -370,6 +384,11 @@ acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value) ACPI_FUNCTION_TRACE(hw_register_read); + /* If Hardware Reduced flag is set, there are no PM Control registers */ + if (acpi_gbl_reduced_hardware) { + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); + } + switch (register_id) { case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ @@ -465,6 +484,11 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) ACPI_FUNCTION_TRACE(hw_register_write); + /* If Hardware Reduced flag is set, there are no PM Control registers */ + if (acpi_gbl_reduced_hardware) { + return_ACPI_STATUS(AE_NOT_IMPLEMENTED); + } + switch (register_id) { case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ /*