From patchwork Thu May 16 19:22:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 2579691 Return-Path: X-Original-To: patchwork-linux-parisc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 886B74020A for ; Thu, 16 May 2013 19:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752823Ab3EPTWZ (ORCPT ); Thu, 16 May 2013 15:22:25 -0400 Received: from mout.gmx.net ([212.227.17.21]:49418 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752084Ab3EPTWY (ORCPT ); Thu, 16 May 2013 15:22:24 -0400 Received: from mailout-de.gmx.net ([10.1.76.33]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0MVGca-1V0jw03i7q-00YlYE for ; Thu, 16 May 2013 21:22:22 +0200 Received: (qmail invoked by alias); 16 May 2013 19:22:22 -0000 Received: from p54AD4764.dip0.t-ipconnect.de (EHLO p100.box) [84.173.71.100] by mail.gmx.net (mp033) with SMTP; 16 May 2013 21:22:22 +0200 X-Authenticated: #1045983 X-Provags-ID: V01U2FsdGVkX19hywpdJT1hR5OJLJz1OJhJ9/CB+FKg69vSv2aPAq Uv0jzNyE4R0+f8 Date: Thu, 16 May 2013 21:22:20 +0200 From: Helge Deller To: stable@vger.kernel.org, linux-parisc@vger.kernel.org Subject: [PATCH] parisc: only re-enable interrupts if we need to schedule or deliver signals when returning to userspace Message-ID: <20130516192220.GA32308@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Y-GMX-Trusted: 0 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org please include to stable kernel v3.9 series. upstream commit c207a76bf155cb5cf24cf849c08f6555e9180594 From: John David Anglin Helge and I have found that we have a kernel stack overflow problem which causes a variety of random failures. Currently, we re-enable interrupts when returning from an external interrupt incase we need to schedule or delivery signals. As a result, a potentially unlimited number of interrupts can occur while we are running on the kernel stack. It is very limited in space (currently, 16k). This change defers enabling interrupts until we have actually decided to schedule or delivery signals. This only occurs when we about to return to userspace. This limits the number of interrupts on the kernel stack to one. In other cases, interrupts remain disabled until the final return from interrupt (rfi). Signed-off-by: John David Anglin Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S index 36f4f1d..3f3326d 100644 --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -833,11 +833,6 @@ ENTRY(syscall_exit_rfi) STREG %r19,PT_SR7(%r16) intr_return: - /* NOTE: Need to enable interrupts incase we schedule. */ - ssm PSW_SM_I, %r0 - -intr_check_resched: - /* check for reschedule */ mfctl %cr30,%r1 LDREG TI_FLAGS(%r1),%r19 /* sched.h: TIF_NEED_RESCHED */ @@ -864,6 +859,11 @@ intr_check_sig: LDREG PT_IASQ1(%r16), %r20 cmpib,COND(=),n 0,%r20,intr_restore /* backward */ + /* NOTE: We need to enable interrupts if we have to deliver + * signals. We used to do this earlier but it caused kernel + * stack overflows. */ + ssm PSW_SM_I, %r0 + copy %r0, %r25 /* long in_syscall = 0 */ #ifdef CONFIG_64BIT ldo -16(%r30),%r29 /* Reference param save area */ @@ -915,6 +915,10 @@ intr_do_resched: cmpib,COND(=) 0, %r20, intr_do_preempt nop + /* NOTE: We need to enable interrupts if we schedule. We used + * to do this earlier but it caused kernel stack overflows. */ + ssm PSW_SM_I, %r0 + #ifdef CONFIG_64BIT ldo -16(%r30),%r29 /* Reference param save area */ #endif