Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2018 12:12:13 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r337126 - head/sys/riscv/riscv
Message-ID:  <201808021212.w72CCDG1065142@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: br
Date: Thu Aug  2 12:12:13 2018
New Revision: 337126
URL: https://svnweb.freebsd.org/changeset/base/337126

Log:
  o Don't overwrite tp in fork_trampoline().
  o Save and restore tp in cpu_switch().
  o Restore tp in cpu_throw().
  o Save tp in savectx().
  
  This makes libthr tests happy. In particular fork_test:fork.
  
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/riscv/riscv/swtch.S

Modified: head/sys/riscv/riscv/swtch.S
==============================================================================
--- head/sys/riscv/riscv/swtch.S	Thu Aug  2 12:08:52 2018	(r337125)
+++ head/sys/riscv/riscv/swtch.S	Thu Aug  2 12:12:13 2018	(r337126)
@@ -179,6 +179,7 @@ ENTRY(cpu_throw)
 	/* Load registers */
 	ld	ra, (PCB_RA)(x13)
 	ld	sp, (PCB_SP)(x13)
+	ld	tp, (PCB_TP)(x13)
 
 	/* s[0-11] */
 	ld	s0, (PCB_S + 0 * 8)(x13)
@@ -231,6 +232,7 @@ ENTRY(cpu_switch)
 	/* Store ra, sp and the callee-saved registers */
 	sd	ra, (PCB_RA)(x13)
 	sd	sp, (PCB_SP)(x13)
+	sd	tp, (PCB_TP)(x13)
 
 	/* s[0-11] */
 	sd	s0, (PCB_S + 0 * 8)(x13)
@@ -303,6 +305,7 @@ ENTRY(cpu_switch)
 #endif
 
 	/* Restore the registers */
+	ld	tp, (PCB_TP)(x13)
 	ld	ra, (PCB_RA)(x13)
 	ld	sp, (PCB_SP)(x13)
 
@@ -392,7 +395,6 @@ ENTRY(fork_trampoline)
 	ld	a7, (TF_A + 7 * 8)(sp)
 
 	/* Load user ra and sp */
-	ld	tp, (TF_TP)(sp)
 	ld	ra, (TF_RA)(sp)
 
 	/*
@@ -416,6 +418,7 @@ ENTRY(savectx)
 	/* Store ra, sp and the callee-saved registers */
 	sd	ra, (PCB_RA)(a0)
 	sd	sp, (PCB_SP)(a0)
+	sd	tp, (PCB_TP)(a0)
 
 	/* s[0-11] */
 	sd	s0, (PCB_S + 0 * 8)(a0)



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