From patchwork Fri Feb 15 20:05:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10815795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BCF613A4 for ; Fri, 15 Feb 2019 20:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 449B92FF08 for ; Fri, 15 Feb 2019 20:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E512FF28; Fri, 15 Feb 2019 20:05:47 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B994A2FF08 for ; Fri, 15 Feb 2019 20:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IBLn3lJAESsH6JXnBkh+iM2rF9bqrjOJjGs86fetqfU=; b=PhWCOibpwgu0yK TzydGIFbEoBy3hTzgZyVVoCz5ssyw+66D67C42zM3PwWcAukHDcmolbt0k0YEWyQSqNZG93MbWH0K hXdLubb0v53w2FPucT+LFRqsGPwfdq/K5XRzlrtaJprVcqmk4dSSNb5/4OIS0RF2IeRoqT9UDZ7f1 3M2/XRtyYYQKkzHeIbKqykG4ltv8Lu52hE6TfMEcekce5wvXKWbS8ELsxxDs6bOyXdAZVQCzE8wjQ 6NIo10+lOMHA969JqkfeabEVHg3dlvBWF0Zq2es/Qw2ZpzRmnSMzcXPkG9c8/YwNi2yybONRRhHJj 2xXscCK+TR9qX1q9iJmQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gujk1-0003e3-BE; Fri, 15 Feb 2019 20:05:45 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gujjy-0003dL-Cv for linux-arm-kernel@lists.infradead.org; Fri, 15 Feb 2019 20:05:44 +0000 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gujjp-0001cd-Ed; Fri, 15 Feb 2019 21:05:33 +0100 Date: Fri, 15 Feb 2019 21:05:33 +0100 From: Sebastian Andrzej Siewior To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] ARM: enable irq in translation/section permission fault handlers Message-ID: <20190215200533.ypfrdekg7j4ucu6a@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190215_120542_582801_B30E576B X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Gleixner , Bernd Edlinger , Russell King , Arnd Bergmann , yadi.hu@windriver.com 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 From: "Yadi.hu" Accessing a kernel address in user space causes a SIGSEGV which is sent via -> do_DataAbort -> do_sect_fault || do_translation_fault -> do_bad_area -> __do_user_fault -> force_sig_fault Since commit 02fe2845d6a83 ("ARM: entry: avoid enabling interrupts in prefetch/data abort handlers") that path is carried out with disabled interrupts. Page/alignment fault do enable interrupts but data abort has been left out. On -RT the siglock is a sleeping spinlock and requires interrupts to be enabled in order to acquire it. Enable interrupts in the DataAbort handler if the parent context had interrupts enabled. Move harden_branch_predictor() before interrupts are enabled. Reported-by: Signed-off-by: Yadi.hu [bigeasy: rewrote patch description, reordered patch] Signed-off-by: Sebastian Andrzej Siewior --- I though that the "interrupt enable part" has already been posted and then Bernd complained about a warning from harden_branch_predictor() on -RT so here it is. arch/arm/mm/fault.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 58f69fa07df95..da82967865836 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -161,8 +161,6 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr, unsigned int fsr, unsigned int sig, int code, struct pt_regs *regs) { - if (addr > TASK_SIZE) - harden_branch_predictor(); #ifdef CONFIG_DEBUG_USER if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) || @@ -191,6 +189,11 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs) struct task_struct *tsk = current; struct mm_struct *mm = tsk->active_mm; + if (addr > TASK_SIZE && user_mode(regs)) + harden_branch_predictor(); + + if (interrupts_enabled(regs)) + local_irq_enable(); /* * If we are in kernel mode at this point, we * have no context to handle this fault with.