From patchwork Thu Dec 19 07:51:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 3375501 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 25AD4C0D4B for ; Thu, 19 Dec 2013 07:58:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D59820651 for ; Thu, 19 Dec 2013 07:58:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFD6B2064E for ; Thu, 19 Dec 2013 07:58:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752551Ab3LSHxo (ORCPT ); Thu, 19 Dec 2013 02:53:44 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:61389 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752530Ab3LSHxn (ORCPT ); Thu, 19 Dec 2013 02:53:43 -0500 Received: by mail-pa0-f43.google.com with SMTP id bj1so819041pad.30 for ; Wed, 18 Dec 2013 23:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y0RvPSPjCp/cz3SrBhUVzUu56UBqes9wPtBjbhaJ16I=; b=RLu+eFwMcxpoGrT+zaY8WU0ROtrliDrd1V4N8ciE968z+zE2lsOpeVv1RLtIpGDe2Q aGD7x2rPY7U1g20UcjrqaU6L61TKhcoLfAdn5hiDpcFkDZSn32jLfBNhGsJMTIeEH0As 3maylDQTTENFNwi48ONgbYnChUzdbrBIhk8myos8qi23Hz0Cp4FUsyk+qsa4NaTj8Nlc fTpLjKVnRFxdSFcHdPtB/ornq1LWLrqb4exj4AXqcMk/L4GEEfEWMfg3y1meXHEmljvb KvxBgny8UpFCdA+sxszANwRaPDEXM56ixfaRULqXtQTfUG2EroTaUDNtYee7hMSi73QI 7ceQ== X-Received: by 10.66.250.163 with SMTP id zd3mr38957502pac.109.1387439622710; Wed, 18 Dec 2013 23:53:42 -0800 (PST) Received: from localhost.localdomain ([130.57.30.250]) by mx.google.com with ESMTPSA id qp15sm5173154pbb.2.2013.12.18.23.53.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 18 Dec 2013 23:53:41 -0800 (PST) From: "Lee, Chun-Yi" To: "Rafael J. Wysocki" , Alessandro Zummo , "H. Peter Anvin" , Matt Fleming , Matthew Garrett Cc: Elliott@hp.com, samer.el-haj-mahmoud@hp.com, Oliver Neukum , werner@suse.com, trenn@suse.de, JBeulich@suse.com, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, x86@kernel.org, "linux-efi@vger.kernel.org" , linux-acpi@vger.kernel.org, "Lee, Chun-Yi" Subject: [PATCH 03/14] rtc: block registration of rtc-cmos when CMOS RTC Not Present Date: Thu, 19 Dec 2013 15:51:44 +0800 Message-Id: <1387439515-8926-4-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1387439515-8926-1-git-send-email-jlee@suse.com> References: <1387439515-8926-1-git-send-email-jlee@suse.com> 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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 We should not acess CMOS address when CMOS RTC Not Present bit set in FADT. The ee5872be patch didn't avoid rtc-cmos driver loaded when system support ACPI PNP PNP0B0* devices. So this patch block the registion of rtc-cmos driver to avoid user space access RTC through CMOS interface. Signed-off-by: Lee, Chun-Yi --- arch/x86/kernel/rtc.c | 20 ++++++++++++++++---- drivers/rtc/rtc-cmos.c | 9 +++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index ca9622a..9b6c568 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -174,16 +174,27 @@ static __init int add_rtc_cmos(void) { "PNP0b00", "PNP0b01", "PNP0b02", }; struct pnp_dev *dev; struct pnp_id *id; - int i; + int i = 0; + bool found_pnp; pnp_for_each_dev(dev) { for (id = dev->id; id; id = id->next) { for (i = 0; i < ARRAY_SIZE(ids); i++) { - if (compare_pnp_id(id, ids[i]) != 0) - return 0; + if (compare_pnp_id(id, ids[i]) != 0) { + found_pnp = true; + goto found_pnp; + } } } } + +found_pnp: + if (found_pnp) { + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) + pr_err(FW_BUG "Found %s device but CMOS RTC Not Present flag set\n", ids[i]); + return 0; + } #endif if (of_have_populated_dt()) return 0; @@ -193,7 +204,8 @@ static __init int add_rtc_cmos(void) return -ENODEV; #ifdef CONFIG_ACPI - if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { /* This warning can likely go away again in a year or two. */ pr_info("ACPI: not registering RTC platform device\n"); return -ENODEV; diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index f148762..3a84ca9 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c @@ -28,6 +28,9 @@ * interrupts disabled, holding the global rtc_lock, to exclude those * other drivers and utilities on correctly configured systems. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -1144,6 +1147,12 @@ static int __init cmos_init(void) { int retval = 0; + if (acpi_gbl_FADT.header.revision >= 5 && + acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { + pr_info("ACPI CMOS RTC Not Present detected - not loading\n"); + return 0; + } + #ifdef CONFIG_PNP retval = pnp_register_driver(&cmos_pnp_driver); if (retval == 0)