From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-sparc+bounces-877-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 5886513832E
	for <garchives@archives.gentoo.org>; Tue,  9 Aug 2016 05:25:50 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 8C85CE0B24;
	Tue,  9 Aug 2016 05:25:49 +0000 (UTC)
Received: from SMTP.Tech.Triadic.US (smtp.tech.triadic.us [98.102.61.98])
	by pigeon.gentoo.org (Postfix) with ESMTP id F0E98E0B24
	for <gentoo-sparc@lists.gentoo.org>; Tue,  9 Aug 2016 05:25:48 +0000 (UTC)
Received: from localhost (unknown [10.128.0.32])
	by SMTP.Tech.Triadic.US (Postfix) with ESMTP id E8A2510413CF;
	Tue,  9 Aug 2016 01:14:18 -0400 (EDT)
X-Virus-Scanned: amavisd-new at Tech.Triadic.US
Received: from SMTP.Tech.Triadic.US ([IPv6:::ffff:10.128.0.24])
	by localhost (Milter1.Tech.Triadic.US [IPv6:::ffff:10.128.0.32]) (amavisd-new, port 10024)
	with LMTP id yBhATypaYQLa; Tue,  9 Aug 2016 01:14:10 -0400 (EDT)
Received: from webmail.tech.triadic.us (unknown [10.128.0.56])
	by SMTP.Tech.Triadic.US (Postfix) with ESMTPSA id 1D0D510413C9;
	Tue,  9 Aug 2016 01:14:10 -0400 (EDT)
Precedence: bulk
List-Post: <mailto:gentoo-sparc@lists.gentoo.org>
List-Help: <mailto:gentoo-sparc+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-sparc+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-sparc+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-sparc.gentoo.org>
X-BeenThere: gentoo-sparc@lists.gentoo.org
Reply-to: gentoo-sparc@lists.gentoo.org
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Tue, 09 Aug 2016 01:14:09 -0400
From: alexmcwhirter@triadic.us
To: gentoo-sparc@lists.gentoo.org
Cc: Jack Morgan <jmorgan@gentoo.org>
Subject: Re: [gentoo-sparc] Official SPARC64 Port
In-Reply-To: <2d21669d-5598-f6b9-beda-2e1e9ef45e06@gentoo.org>
References: <56B97515.70303@triadic.us> <20160209061441.GD7732@vapier.lan>
 <56BEF6AD.5080203@triadic.us> <20160213112541.GZ7732@vapier.lan>
 <56BF68B9.50904@triadic.us> <56BF9F6B.9030304@triadic.us>
 <20160214004443.GC7732@vapier.lan> <56C11173.4080400@triadic.us>
 <20160215021305.GK7732@vapier.lan> <56C4F01E.9050402@triadic.us>
 <20160217224651.GT7732@vapier.lan> <56C4F9AA.7080701@triadic.us>
 <56C6D43A.4040606@triadic.us> <56E2412B.5070806@triadic.us>
 <2d21669d-5598-f6b9-beda-2e1e9ef45e06@gentoo.org>
Message-ID: <724f1ba4a26c0f1e75e4b4be2a79c0e4@triadic.us>
X-Sender: alexmcwhirter@triadic.us
User-Agent: Roundcube Webmail/1.0.5
X-Archives-Salt: cfd0f109-54a4-458d-a153-a7a1aafcddeb
X-Archives-Hash: dea92637ea98553d07d4a44b70d0aae6

On 2016-08-08 18:52, Jack Morgan wrote:
> Any update on this issue? rsync is still broken on sparc.

Yes it, as well as ssh, ssl, and ext4 bugs were fixed via this patch. It 
was taged for stable.



-------- Original Message --------
Subject: [PATCH] sparc: Don't leak context bits into 
thread->fault_address
Date: 2016-07-27 20:53
 From: David Miller <davem@davemloft.net>
To: sparclinux@vger.kernel.org
Cc: mpatocka@redhat.com

On pre-Niagara systems, we fetch the fault address on data TLB
exceptions from the TLB_TAG_ACCESS register.  But this register also
contains the context ID assosciated with the fault in the low 13 bits
of the register value.

This propagates into current_thread_info()->fault_address and can
cause trouble later on.

So clear the low 13-bits out of the TLB_TAG_ACCESS value in the cases
where it matters.

Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
  arch/sparc/kernel/dtlb_prot.S |  4 ++--
  arch/sparc/kernel/ktlb.S      | 12 ++++++++++++
  arch/sparc/kernel/tsb.S       | 12 ++++++++++--
  3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/kernel/dtlb_prot.S 
b/arch/sparc/kernel/dtlb_prot.S
index d668ca14..4087a62 100644
--- a/arch/sparc/kernel/dtlb_prot.S
+++ b/arch/sparc/kernel/dtlb_prot.S
@@ -25,13 +25,13 @@

  /* PROT ** ICACHE line 2: More real fault processing */
  	ldxa		[%g4] ASI_DMMU, %g5		! Put tagaccess in %g5
+	srlx		%g5, PAGE_SHIFT, %g5
+	sllx		%g5, PAGE_SHIFT, %g5		! Clear context ID bits
  	bgu,pn		%xcc, winfix_trampoline		! Yes, perform winfixup
  	 mov		FAULT_CODE_DTLB | FAULT_CODE_WRITE, %g4
  	ba,pt		%xcc, sparc64_realfault_common	! Nope, normal fault
  	 nop
  	nop
-	nop
-	nop

  /* PROT ** ICACHE line 3: Unused...	*/
  	nop
diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
index ef0d8e9..f22bec0 100644
--- a/arch/sparc/kernel/ktlb.S
+++ b/arch/sparc/kernel/ktlb.S
@@ -20,6 +20,10 @@ kvmap_itlb:
  	mov		TLB_TAG_ACCESS, %g4
  	ldxa		[%g4] ASI_IMMU, %g4

+	/* The kernel executes in context zero, therefore we do not
+	 * need to clear the context ID bits out of %g4 here.
+	 */
+
  	/* sun4v_itlb_miss branches here with the missing virtual
  	 * address already loaded into %g4
  	 */
@@ -128,6 +132,10 @@ kvmap_dtlb:
  	mov		TLB_TAG_ACCESS, %g4
  	ldxa		[%g4] ASI_DMMU, %g4

+	/* The kernel executes in context zero, therefore we do not
+	 * need to clear the context ID bits out of %g4 here.
+	 */
+
  	/* sun4v_dtlb_miss branches here with the missing virtual
  	 * address already loaded into %g4
  	 */
@@ -251,6 +259,10 @@ kvmap_dtlb_longpath:
  	nop
  	.previous

+	/* The kernel executes in context zero, therefore we do not
+	 * need to clear the context ID bits out of %g5 here.
+	 */
+
  	be,pt	%xcc, sparc64_realfault_common
  	 mov	FAULT_CODE_DTLB, %g4
  	ba,pt	%xcc, winfix_trampoline
diff --git a/arch/sparc/kernel/tsb.S b/arch/sparc/kernel/tsb.S
index be98685..d568c82 100644
--- a/arch/sparc/kernel/tsb.S
+++ b/arch/sparc/kernel/tsb.S
@@ -29,13 +29,17 @@
  	 */
  tsb_miss_dtlb:
  	mov		TLB_TAG_ACCESS, %g4
+	ldxa		[%g4] ASI_DMMU, %g4
+	srlx		%g4, PAGE_SHIFT, %g4
  	ba,pt		%xcc, tsb_miss_page_table_walk
-	 ldxa		[%g4] ASI_DMMU, %g4
+	 sllx		%g4, PAGE_SHIFT, %g4

  tsb_miss_itlb:
  	mov		TLB_TAG_ACCESS, %g4
+	ldxa		[%g4] ASI_IMMU, %g4
+	srlx		%g4, PAGE_SHIFT, %g4
  	ba,pt		%xcc, tsb_miss_page_table_walk
-	 ldxa		[%g4] ASI_IMMU, %g4
+	 sllx		%g4, PAGE_SHIFT, %g4

  	/* At this point we have:
  	 * %g1 --	PAGE_SIZE TSB entry address
@@ -284,6 +288,10 @@ tsb_do_dtlb_fault:
  	nop
  	.previous

+	/* Clear context ID bits.  */
+	srlx		%g5, PAGE_SHIFT, %g5
+	sllx		%g5, PAGE_SHIFT, %g5
+
  	be,pt	%xcc, sparc64_realfault_common
  	 mov	FAULT_CODE_DTLB, %g4
  	ba,pt	%xcc, winfix_trampoline