aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Houchard <cognet@FreeBSD.org>2021-06-30 20:56:50 +0000
committerOlivier Houchard <cognet@FreeBSD.org>2021-07-07 20:22:41 +0000
commit82a1d67f018c7178485166ae3e06f29bff292263 (patch)
tree634921d0dddc6fd1a55439d453670e1d01683939
parentd2e48ad87d3e0f63f4ac73c524fb18afce4a2d53 (diff)
downloadsrc-82a1d67f018c7178485166ae3e06f29bff292263.tar.gz
src-82a1d67f018c7178485166ae3e06f29bff292263.zip
arm: Make sure we can handle a thumb entry point.
Similarly to what's been done on arm64 with commit 712c060c94fd447c91b0e6218c12a431206b487a, when executing a binary, if the entry point is a thumb symbol, then make sure we set the PSL_T flag, otherwise the CPU will interpret it in ARM mode, and that will likely leads to an undefined instruction. PR: 256899 MFC after: 1 week (cherry picked from commit 8c3bd133dd52824e427e350c65eae1fd9eb5a3cd) Signed-off-by: Olivier Houchard <cognet@FreeBSD.org>
-rw-r--r--sys/arm/arm/machdep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index 3296adaaa44b..ea5b5a0de251 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -351,6 +351,8 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
tf->tf_svc_lr = 0x77777777;
tf->tf_pc = imgp->entry_addr;
tf->tf_spsr = PSR_USR32_MODE;
+ if ((register_t)imgp->entry_addr & 1)
+ tf->tf_spsr |= PSR_T;
}
#ifdef VFP