From patchwork Fri Apr 4 11:29:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 3937721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B1F659F1EE for ; Fri, 4 Apr 2014 11:29:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D229E203E1 for ; Fri, 4 Apr 2014 11:29:40 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 870C120340 for ; Fri, 4 Apr 2014 11:29:39 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW2JQ-00009f-NC; Fri, 04 Apr 2014 11:29:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW2JO-0006XW-8T; Fri, 04 Apr 2014 11:29:30 +0000 Received: from mail-ob0-x230.google.com ([2607:f8b0:4003:c01::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WW2JL-0006WV-6K for linux-arm-kernel@lists.infradead.org; Fri, 04 Apr 2014 11:29:28 +0000 Received: by mail-ob0-f176.google.com with SMTP id wp18so3311511obc.21 for ; Fri, 04 Apr 2014 04:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=mzc6hAhC4hifB2Q3DlR+WYAPYGZtIfaYVNyeTfy/dcU=; b=ITHWhuD4o0jdcC55oLZrF53xBvwOCjpfXDE/xuVT0SEh0jjkXGIW5HVxlX+G5DsCp1 HXeifCAwc0I5Cra/VImdZvl9TYkcaEv0g/n4pOoP2EknpncaQIrYj9NiJr4qtRlVMFMn 5XInUqRoX4SlRIGdhO0XKoV5dpEWb9bpiqY6bGAOXR4wjc2ES2gcJFIACPtu5cdGwbCg RgqyiYG+mXTNGzGyo3cMilYUhJlWfTQ4vIL+gBU2J8pem1NDA6yZ1owTxzYE0tNuHb8/ pwocHs8OtudJePJVM61zn7xANN3GsyKAT6198n7AtEyz7HpnCpwQCDYajCw4caszDeze OlLA== MIME-Version: 1.0 X-Received: by 10.60.45.35 with SMTP id j3mr181685oem.68.1396610944123; Fri, 04 Apr 2014 04:29:04 -0700 (PDT) X-Google-Sender-Delegation: getarunks@gmail.com Received: by 10.76.71.170 with HTTP; Fri, 4 Apr 2014 04:29:04 -0700 (PDT) In-Reply-To: <20140401144815.GA7528@n2100.arm.linux.org.uk> References: <1394734552-4704-1-git-send-email-catalin.marinas@arm.com> <1394734552-4704-6-git-send-email-catalin.marinas@arm.com> <20140401144815.GA7528@n2100.arm.linux.org.uk> Date: Fri, 4 Apr 2014 16:59:04 +0530 X-Google-Sender-Auth: c59CmmJl4jkK99s2eTdWXE4gf7o Message-ID: Subject: Re: [PATCH 5/5] arm: Enable IRQs before attempting to read user space in __und_usr From: Arun KS To: Russell King - ARM Linux X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140404_072927_315045_D9616ACC X-CRM114-Status: GOOD ( 23.02 ) X-Spam-Score: -2.0 (--) Cc: Catalin Marinas , Ryan Mallon , "linux-arm-kernel@lists.infradead.org" , Hartley Sweeten X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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 On Tue, Apr 1, 2014 at 8:18 PM, Russell King - ARM Linux wrote: > On Tue, Apr 01, 2014 at 05:54:15PM +0530, Arun KS wrote: >> As the data abort is now handled in normal way, can we remove the >> fixup handler for ldrt? > > No, because all instructions which access userspace, and therefore may > fault, must be given a fixup handler so the kernel knows what to do > should it not be able to supply the page. > > Omitting that marking means the only other option in that case is for > the kernel to oops. Hi Catalin/Russell, I have a concern regarding the fixup handler. Fixup handler returns to the next instruction which has caused the undef execption, rather than going to the same instruction. ARM ARM says that after undefined exception, the pc will be pointing to the next instruction. ie +4 offset in case of ARM and +2 in case of Thumb. And there is no correction offset passed to vector_stub in case of undef exception. File: arch/arm/kernel/entry-armv.S +1085 vector_stub und, UND_MODE During an undefined exception, in normal scenario(ie when ldrt instruction does not cause an abort) after resorting the context in VFP hardware, the PC is modified as show below before jumping to ret_from_exception which is in r9. File: arch/arm/vfp/vfphw.S +169 @ The context stored in the VFP hardware is up to date with this thread vfp_hw_state_valid: tst r1, #FPEXC_EX bne process_exception @ might as well handle the pending @ exception before retrying branch @ out before setting an FPEXC that @ stops us reading stuff VFPFMXR FPEXC, r1 @ Restore FPEXC last sub r2, r2, #4 @ Retry current instruction - if Thumb str r2, [sp, #S_PC] @ mode it's two 16-bit instructions, @ else it's one 32-bit instruction, so @ always subtract 4 from the following @ instruction address. But if ldrt results in an abort, we reach the fixup handler and return to ret_from_execption without correcting the pc. File: arch/arm/kernel/entry-armv.S + 482 /* * The out of line fixup for the ldrt instructions above. */ .pushsection .fixup, "ax" .align 2 4: mov pc, r9 .popsection Below patch fixes this, From d72e15d92c1016ce3b1c7c7da01ca60cf21340d5 Mon Sep 17 00:00:00 2001 From: Arun KS Date: Fri, 4 Apr 2014 16:42:58 +0530 Subject: Modify fixup handler to re-execute the original instruction Signed-off-by: Danesh Petigara Signed-off-by: Vinayak Menon Acked-by: Catalin Marinas --- arch/arm/kernel/entry-armv.S | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) -- 1.7.6 Thanks, Arun > > -- > FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly > improving, and getting towards what was expected from it. diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 1879e8d..e801c7d 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -484,7 +484,8 @@ ENDPROC(__und_usr) */ .pushsection .fixup, "ax" .align 2 -4: mov pc, r9 +4: str r4, [sp, #S_PC] + mov pc, r9 .popsection .pushsection __ex_table,"a" .long 1b, 4b