From patchwork Sun Sep 23 14:55:18 2018
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: John David Anglin <dave.anglin@bell.net>
X-Patchwork-Id: 10611761
Return-Path: <linux-parisc-owner@kernel.org>
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 6EA7214BD
	for <patchwork-linux-parisc@patchwork.kernel.org>;
 Sun, 23 Sep 2018 14:55:23 +0000 (UTC)
Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B969299C6
	for <patchwork-linux-parisc@patchwork.kernel.org>;
 Sun, 23 Sep 2018 14:55:23 +0000 (UTC)
Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486)
	id 4E1A429DD4; Sun, 23 Sep 2018 14:55:23 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI,
	RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
	by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3B7E299C6
	for <patchwork-linux-parisc@patchwork.kernel.org>;
 Sun, 23 Sep 2018 14:55:22 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1726280AbeIWUxG (ORCPT
        <rfc822;patchwork-linux-parisc@patchwork.kernel.org>);
        Sun, 23 Sep 2018 16:53:06 -0400
Received: from belmont80srvr.owm.bell.net ([184.150.200.80]:37536 "EHLO
        mtlfep02.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org
        with ESMTP id S1726259AbeIWUxF (ORCPT
        <rfc822;linux-parisc@vger.kernel.org>);
        Sun, 23 Sep 2018 16:53:05 -0400
Received: from bell.net mtlfep02 184.150.200.30 by mtlfep02.bell.net
          with ESMTP
          id <20180923145520.EFWF11841.mtlfep02.bell.net@mtlspm01.bell.net>
          for <linux-parisc@vger.kernel.org>;
          Sun, 23 Sep 2018 10:55:20 -0400
Received: from mx3210.localdomain ([70.53.62.196]) by mtlspm01.bell.net
          with ESMTP
          id <20180923145520.KFQA28394.mtlspm01.bell.net@mx3210.localdomain>;
          Sun, 23 Sep 2018 10:55:20 -0400
Received: by mx3210.localdomain (Postfix, from userid 1000)
        id 6F3AC2200F9; Sun, 23 Sep 2018 10:55:19 -0400 (EDT)
Date: Sun, 23 Sep 2018 10:55:18 -0400
From: John David Anglin <dave.anglin@bell.net>
To: linux-parisc@vger.kernel.org
Cc: deller@gmx.de, James.Bottomley@HansenPartnership.com
Subject: [PATCH] parisc: Remove PTE load and fault check from L2_ptep macro
Message-ID: <20180923145518.GA9595@mx3210.localdomain>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
        protocol="application/pgp-signature"; boundary="SLDf9lqlvOQaIe6s"
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Cloudmark-Analysis: v=2.2 cv=XaJm9Mx5 c=1 sm=0 tr=0
 a=Zvhif4XNTjWcJyJCfFIh1A==:17 a=JBFolyDoGHsA:10 a=FBHGMhGWAAAA:8
 a=FssbAEJRoSVUQZ_H9XUA:9 a=CjuIK1q_8ugA:10 a=Njz2nQnGTZkk9KuUsUEA:9
 a=ONNS8QRKHyMA:10 a=9gvnlMMaQFpL9xblJ6ne:22
Sender: linux-parisc-owner@vger.kernel.org
Precedence: bulk
List-ID: <linux-parisc.vger.kernel.org>
X-Mailing-List: linux-parisc@vger.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP

This change removes the PTE load and present check from the L2_ptep macro.
The load and check for kernel pages is now done in the tlb_lock macro.
This avoids a double load and check for user pages.  The load and check
for user pages is now done inside the lock so the fault handler can't be
called while the entry is being updated.


Signed-off-by: John David Anglin <dave.anglin@bell.net>

diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index 1b4732e20137..be1ef02a4799 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -430,8 +430,6 @@
 	extru		\va,31-PAGE_SHIFT,ASM_BITS_PER_PTE,\index
 	dep		%r0,31,PAGE_SHIFT,\pmd  /* clear offset */
 	shladd		\index,BITS_PER_PTE_ENTRY,\pmd,\pmd /* pmd is now pte */
-	LDREG		%r0(\pmd),\pte
-	bb,>=,n		\pte,_PAGE_PRESENT_BIT,\fault
 	.endm
 
 	/* Look up PTE in a 3-Level scheme.
@@ -462,7 +460,7 @@
 	L2_ptep		\pgd,\pte,\index,\va,\fault
 	.endm
 
-	/* Acquire pa_tlb_lock lock and recheck page is still present. */
+	/* Acquire pa_tlb_lock lock and check page is present. */
 	.macro		tlb_lock	spc,ptp,pte,tmp,tmp1,fault
 #ifdef CONFIG_SMP
 	cmpib,COND(=),n	0,\spc,2f
@@ -471,10 +469,12 @@
 	cmpib,COND(=)	0,\tmp1,1b
 	nop
 	LDREG		0(\ptp),\pte
-	bb,<,n		\pte,_PAGE_PRESENT_BIT,2f
+	bb,<,n		\pte,_PAGE_PRESENT_BIT,3f
 	b		\fault
 	stw		 \spc,0(\tmp)
-2:
+2:	LDREG		0(\ptp),\pte
+	bb,>=,n		\pte,_PAGE_PRESENT_BIT,\fault
+3:
 #endif
 	.endm
 
