Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Mar 2015 22:42:43 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r280402 - head/sys/arm/arm
Message-ID:  <201503232242.t2NMghoP049646@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Mon Mar 23 22:42:42 2015
New Revision: 280402
URL: https://svnweb.freebsd.org/changeset/base/280402

Log:
  Do not save/restore the TLS pointer on context switch for armv6.  The
  pointer cannot be changed directly by userland code on armv6 (it can be on
  armv4), so there's no need to save/restore.
  
  Submitted by:	Michal Meloun

Modified:
  head/sys/arm/arm/swtch.S
  head/sys/arm/arm/sys_machdep.c
  head/sys/arm/arm/vm_machdep.c

Modified: head/sys/arm/arm/swtch.S
==============================================================================
--- head/sys/arm/arm/swtch.S	Mon Mar 23 21:15:07 2015	(r280401)
+++ head/sys/arm/arm/swtch.S	Mon Mar 23 22:42:42 2015	(r280402)
@@ -255,7 +255,7 @@ ENTRY(cpu_switch)
 	mov	r4, r0 /* Save the old thread. */
 
 #ifdef ARM_TP_ADDRESS
-	/* Store the old tp */
+	/* Store the old tp; userland can change it on armv4. */
 	ldr	r3, =ARM_TP_ADDRESS
 	ldr	r9, [r3]
 	str	r9, [r0, #(TD_MD + MD_TP)]
@@ -272,11 +272,10 @@ ENTRY(cpu_switch)
 	ldr	r9, [r1, #(TD_MD + MD_RAS_END)]
 	str	r9, [r3, #8]
 #else
-	/* Store the old tp */
-	mrc p15, 0, r9, c13, c0, 3
-	str	r9, [r0, #(TD_MD + MD_TP)]
-
-	/* Set the new tp */
+	/* 
+	 * Set new tp.  No need to store the old one first, userland can't 
+	 * change it directly on armv6.
+	 */
 	ldr	r9, [r1, #(TD_MD + MD_TP)]
 	mcr p15, 0, r9, c13, c0, 3
 #endif

Modified: head/sys/arm/arm/sys_machdep.c
==============================================================================
--- head/sys/arm/arm/sys_machdep.c	Mon Mar 23 21:15:07 2015	(r280401)
+++ head/sys/arm/arm/sys_machdep.c	Mon Mar 23 22:42:42 2015	(r280402)
@@ -84,13 +84,11 @@ static int
 arm32_set_tp(struct thread *td, void *args)
 {
 
-	if (td != curthread)
-		td->td_md.md_tp = (register_t)args;
-	else 
+	td->td_md.md_tp = (register_t)args;
 #ifndef ARM_TP_ADDRESS
-		set_tls(args);
+	set_tls(args);
 #else
-		*(register_t *)ARM_TP_ADDRESS = (register_t)args;
+	*(register_t *)ARM_TP_ADDRESS = (register_t)args;
 #endif
 	return (0);
 }
@@ -99,13 +97,10 @@ static int
 arm32_get_tp(struct thread *td, void *args)
 {
 
-	if (td != curthread)
-		td->td_retval[0] = td->td_md.md_tp;
-	else
 #ifndef ARM_TP_ADDRESS
-		td->td_retval[0] = (register_t)get_tls();
+	td->td_retval[0] = td->td_md.md_tp;
 #else
-		td->td_retval[0] = *(register_t *)ARM_TP_ADDRESS;
+	td->td_retval[0] = *(register_t *)ARM_TP_ADDRESS;
 #endif
 	return (0);
 }

Modified: head/sys/arm/arm/vm_machdep.c
==============================================================================
--- head/sys/arm/arm/vm_machdep.c	Mon Mar 23 21:15:07 2015	(r280401)
+++ head/sys/arm/arm/vm_machdep.c	Mon Mar 23 22:42:42 2015	(r280402)
@@ -145,7 +145,7 @@ cpu_fork(register struct thread *td1, re
 #ifdef ARM_TP_ADDRESS
 	td2->td_md.md_tp = *(register_t *)ARM_TP_ADDRESS;
 #else
-	td2->td_md.md_tp = (register_t) get_tls();
+	td2->td_md.md_tp = td1->td_md.md_tp;
 #endif
 }
 				
@@ -274,7 +274,7 @@ cpu_set_user_tls(struct thread *td, void
 #ifdef ARM_TP_ADDRESS
 		*(register_t *)ARM_TP_ADDRESS = (register_t)tls_base;
 #else
-		set_tls((void *)tls_base);
+		set_tls(tls_base);
 #endif
 		critical_exit();
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503232242.t2NMghoP049646>