Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Sun, 11 Oct 2009
 08:52:58 -0600
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id n9BEqtbS006862	for
 <andy.sharp@lsi.com>; Sun, 11 Oct 2009 07:52:58 -0700
Received: from psmtp.com (na3sys009amx232.postini.com [74.125.149.116])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id n9BEqpWi004784	for
 <andy.sharp@lsi.com>; Sun, 11 Oct 2009 07:52:54 -0700 (PDT)
Received: from source ([78.24.191.182]) by na3sys009amx232.postini.com
 ([74.125.148.14]) with SMTP;	Sun, 11 Oct 2009 09:52:55 CDT
Received: from localhost.localdomain ([127.0.0.1]:45294 "EHLO
	eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org	with
 ESMTP id S1492565AbZJKOwj (ORCPT <rfc822;andy.sharp@lsi.com>);	Sun, 11 Oct
 2009 16:52:39 +0200
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 11 Oct 2009 16:52:21
 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:45292 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP	id
 S1492559AbZJKOwR (ORCPT <rfc822;linux-mips@linux-mips.org>);	Sun, 11 Oct 2009
 16:52:17 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])	by
 h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n9BErWtd000926;	Sun, 11 Oct
 2009 16:53:32 +0200
Received: (from ralf@localhost)	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id
 n9BErUx3000924;	Sun, 11 Oct 2009 16:53:30 +0200
From: Ralf Baechle <ralf@linux-mips.org>
To: Chris Dearman <chris@mips.com>
CC: linux-mips <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Sun, 11 Oct 2009 08:53:30 -0600
Subject: Re: [PATCH] Avoid potential hazard on Context register
Thread-Topic: [PATCH] Avoid potential hazard on Context register
Thread-Index: AcpKgoYP3nMHFBOCTYWQImY+qoDJIA==
Message-ID: <20091011145330.GA23369@linux-mips.org>
References: <4AD17619.1000201@mips.com>
 <20091011133912.GA15684@linux-mips.org>
In-Reply-To: <20091011133912.GA15684@linux-mips.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <ralf@linux-mips.org> [db-null] 
x-pstn-neptune: 0/0/0.00/0
user-agent: Mutt/1.5.19 (2009-01-05)
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

There is no hazard barrier between writes to c0_context and subsequent
read accesses.  This is a fairly theoretical hole as c0_context is only
written on CPU bootup and other, unrelated code will almost certainly
execute a hazard barrier somewhen between the write and read access.
Even if not, the window is probably in the thousands of cycles so likely
too large to actually consistute a pipeline hazard.

Reported and initial patch by Chris Dearman <chris@mips.com>.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

 arch/mips/include/asm/mmu_context.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mm=
u_context.h
index ed331c2..6083db5 100644
--- a/arch/mips/include/asm/mmu_context.h
+++ b/arch/mips/include/asm/mmu_context.h
@@ -16,6 +16,7 @@
 #include <linux/smp.h>
 #include <linux/slab.h>
 #include <asm/cacheflush.h>
+#include <asm/hazards.h>
 #include <asm/tlbflush.h>
 #ifdef CONFIG_MIPS_MT_SMTC
 #include <asm/mipsmtregs.h>
@@ -36,11 +37,13 @@ extern unsigned long pgd_current[];
 #ifdef CONFIG_32BIT
 #define TLBMISS_HANDLER_SETUP()						\
 	write_c0_context((unsigned long) smp_processor_id() << 25);	\
+	back_to_back_c0_hazard();					\
 	TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
 #endif
 #ifdef CONFIG_64BIT
 #define TLBMISS_HANDLER_SETUP()						\
 	write_c0_context((unsigned long) smp_processor_id() << 26);	\
+	back_to_back_c0_hazard();					\
 	TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
 #endif
=20

