git: c6b96921a819 - stable/13 - aarch64: Clear TLS registers during exec().

John Baldwin jhb at FreeBSD.org
Mon Mar 29 22:35:09 UTC 2021


The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=c6b96921a81968aa768b45e32195854aaec81331

commit c6b96921a81968aa768b45e32195854aaec81331
Author:     John Baldwin <jhb at FreeBSD.org>
AuthorDate: 2021-03-17 20:19:04 +0000
Commit:     John Baldwin <jhb at FreeBSD.org>
CommitDate: 2021-03-29 22:17:04 +0000

    aarch64: Clear TLS registers during exec().
    
    These are not stored in the trapframe so must be cleared explicitly.
    
    This is similar to one of the MIPS changes in 822d2d6ac94f.
    
    Obtained from:  CheriBSD
    Sponsored by:   DARPA
    
    (cherry picked from commit 0723b409150ae302eb021cbde86a5f77348a1bb4)
---
 sys/arm64/arm64/machdep.c      | 5 +++++
 sys/arm64/linux/linux_sysvec.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index c825c1a18c70..8a1e7520aacb 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -560,6 +560,11 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 	tf->tf_lr = imgp->entry_addr;
 	tf->tf_elr = imgp->entry_addr;
 
+	td->td_pcb->pcb_tpidr_el0 = 0;
+	td->td_pcb->pcb_tpidrro_el0 = 0;
+	WRITE_SPECIALREG(tpidrro_el0, 0);
+	WRITE_SPECIALREG(tpidr_el0, 0);
+
 #ifdef VFP
 	vfp_reset_state(td, pcb);
 #endif
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index 67feacfa876b..df16db4040a7 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -365,6 +365,11 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp,
 #endif
         regs->tf_elr = imgp->entry_addr;
 
+	td->td_pcb->pcb_tpidr_el0 = 0;
+	td->td_pcb->pcb_tpidrro_el0 = 0;
+	WRITE_SPECIALREG(tpidrro_el0, 0);
+	WRITE_SPECIALREG(tpidr_el0, 0);
+
 #ifdef VFP
 	vfp_reset_state(td, td->td_pcb);
 #endif


More information about the dev-commits-src-branches mailing list