From patchwork Sat Apr 5 03:27:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun KS X-Patchwork-Id: 3941791 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55E71BFF02 for ; Sat, 5 Apr 2014 03:29:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80276201EC for ; Sat, 5 Apr 2014 03:29:08 +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 4FD2620148 for ; Sat, 5 Apr 2014 03:29:07 +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 1WWHHg-000301-Ok; Sat, 05 Apr 2014 03:28:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWHHe-000596-BF; Sat, 05 Apr 2014 03:28:42 +0000 Received: from mail-pd0-f171.google.com ([209.85.192.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWHHa-00058T-DI for linux-arm-kernel@lists.infradead.org; Sat, 05 Apr 2014 03:28:39 +0000 Received: by mail-pd0-f171.google.com with SMTP id r10so4117276pdi.16 for ; Fri, 04 Apr 2014 20:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=/dqwQUqwMQnmUpfzpWaQNVvdIOD5Fd6hUze5unSoFWg=; b=VJyohYQei8XppELh8yvl+PiFd2FZo24QycBE/CDngHoyhzOrGeQ2bDJil2+sM02WCT GhMuQVGf/LFm+CG8BA1OsRAmk1SAy3ueRRg8673hvgUL6yzjn/amNEBwJ/udBkcsW0+r SIzGnuQ943zqNMV09RP5z1ZWx+nY64PbzJfpGtkzvKM0J2RygPPK8z6oCfc4xvj5WrEt uMEQGYa/J+N34v94POY1XWego2MtyDuwAdTOtSAsaQZjiq78cJWzzkUpYMqpjDaUHyLF c3QgtC24XaHxQtaFtOI9nhIfgfTBxOBDIkP9mljOReIGwY8EIzs791MgL7ignWwuccRn 752Q== X-Received: by 10.68.244.229 with SMTP id xj5mr18712969pbc.108.1396668490313; Fri, 04 Apr 2014 20:28:10 -0700 (PDT) Received: from localhost ([122.179.95.1]) by mx.google.com with ESMTPSA id zv3sm31019164pab.20.2014.04.04.20.28.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 04 Apr 2014 20:28:09 -0700 (PDT) From: arunks.linux@gmail.com To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v1] ARM: Modify ldrt fixup handler to re-execute the userspace instruction Date: Sat, 5 Apr 2014 08:57:35 +0530 Message-Id: <1396668455-11535-1-git-send-email-arunks.linux@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140404_232838_570030_E40697DB X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: -2.0 (--) Cc: catalin.marinas@arm.com, Arun KS , Vinayak Menon , Arun KS , Danesh Petigara 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: , MIME-Version: 1.0 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 From: Arun KS We will reach fixup handler when one thread(say cpu0) caused an undefined exception, while another thread(say cpu1) is unmmaping the page. Fixup handler returns to the next userspace 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. This patch modifes the fixup handler to re-execute the same instruction which caused undefined execption. Signed-off-by: Danesh Petigara Signed-off-by: Vinayak Menon Signed-off-by: Arun KS Acked-by: Catalin Marinas --- arch/arm/kernel/entry-armv.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 1879e8d..3fa745f 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] @ retry current instruction + mov pc, r9 .popsection .pushsection __ex_table,"a" .long 1b, 4b