From patchwork Tue Jun 30 21:23:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 6698381 Return-Path: X-Original-To: patchwork-linux-arm@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 85F50C05AC for ; Tue, 30 Jun 2015 21:25:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6BD12062F for ; Tue, 30 Jun 2015 21:25:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDBDB20621 for ; Tue, 30 Jun 2015 21:25:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZA30I-0003CY-Uk; Tue, 30 Jun 2015 21:23:42 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZA309-00031S-1i for linux-arm-kernel@lists.infradead.org; Tue, 30 Jun 2015 21:23:33 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id E8A7D140939; Tue, 30 Jun 2015 21:23:13 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id CE025140935; Tue, 30 Jun 2015 21:23:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from timur-ubuntu.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 98B36140935; Tue, 30 Jun 2015 21:23:12 +0000 (UTC) From: Timur Tabi To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Shanker Donthineni , awallis@codeaurora.org, abhimany@codeaurora.org, will.deacon@arm.com, sboyd@codeaurora.org, Vipul Gandhi Subject: [PATCH 4/4] hvc_dcc: disable user-space access to DCC Date: Tue, 30 Jun 2015 16:23:07 -0500 Message-Id: <1435699387-32591-4-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1435699387-32591-1-git-send-email-timur@codeaurora.org> References: <1435699387-32591-1-git-send-email-timur@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150630_142333_130515_4BB09DF0 X-CRM114-Status: GOOD ( 13.57 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the DCC driver loads, then disable user-space access to the DCC so that we don't have two entities trying to access the DCC at the same time. Signed-off-by: Timur Tabi --- arch/arm/include/asm/dcc.h | 15 +++++++++++++++ arch/arm64/include/asm/dcc.h | 11 +++++++++++ drivers/tty/hvc/hvc_dcc.c | 2 ++ 3 files changed, 28 insertions(+) diff --git a/arch/arm/include/asm/dcc.h b/arch/arm/include/asm/dcc.h index b74899d..c50056b 100644 --- a/arch/arm/include/asm/dcc.h +++ b/arch/arm/include/asm/dcc.h @@ -9,8 +9,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +#ifndef __ASM_DCC_H +#define __ASM_DCC_H #include +#include static inline u32 __dcc_getstatus(void) { @@ -39,3 +42,15 @@ static inline void __dcc_putchar(char c) : "r" (c)); isb(); } + +static inline void __dcc_initialize(void) +{ + u32 val; + + /* Disable user-space access to DCC */ + val = MRC14(0, c0, c1, 0); + val |= 1 << 12; /* DSCR[Comms] */ + MCR14(val, 0, c0, c1, 0); +} + +#endif diff --git a/arch/arm64/include/asm/dcc.h b/arch/arm64/include/asm/dcc.h index fcb8d7d..7843e62 100644 --- a/arch/arm64/include/asm/dcc.h +++ b/arch/arm64/include/asm/dcc.h @@ -49,4 +49,15 @@ static inline void __dcc_putchar(char c) isb(); } +static inline void __dcc_initialize(void) +{ + u32 val; + + /* Disable user-space access to DCC */ + asm ("mrs %0, mdscr_el1\n" + " orr %0, %0, #4096\n" /* Set the TDCC bit */ + " msr mdscr_el1, %0\n" + : "=r" (val)); +} + #endif diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c index f8b8cf2..5ccafa4 100644 --- a/drivers/tty/hvc/hvc_dcc.c +++ b/drivers/tty/hvc/hvc_dcc.c @@ -231,6 +231,8 @@ static int __init hvc_dcc_console_init(void) if (!hvc_dcc_check()) return -ENODEV; + __dcc_initialize(); + /* Returns -1 if error */ ret = hvc_instantiate(0, 0, &hvc_dcc_get_put_ops);