Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jun 2021 12:56:13 GMT
From:      Olivier Houchard <cognet@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 712c060c94fd - main - arm64: Make sure COMPAT_FREEBSD32 handles thumb entry point.
Message-ID:  <202106301256.15UCuDeQ025371@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by cognet:

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

commit 712c060c94fd447c91b0e6218c12a431206b487a
Author:     Olivier Houchard <cognet@FreeBSD.org>
AuthorDate: 2021-06-30 12:50:47 +0000
Commit:     Olivier Houchard <cognet@FreeBSD.org>
CommitDate: 2021-06-30 12:55:18 +0000

    arm64: Make sure COMPAT_FREEBSD32 handles thumb entry point.
    
    If the entry point for the binary executed is a thumb 2 entry point, make
    sure we set the PSR_T bit, or the CPU will interpret it as arm32 code and
    bad things will happen.
    
    PR: 256899
    MFC after: 1 week
---
 sys/arm64/arm64/elf32_machdep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c
index 7792374f865b..5321e12d74e9 100644
--- a/sys/arm64/arm64/elf32_machdep.c
+++ b/sys/arm64/arm64/elf32_machdep.c
@@ -258,6 +258,8 @@ freebsd32_setregs(struct thread *td, struct image_params *imgp,
 	tf->tf_x[14] = imgp->entry_addr;
 	tf->tf_elr = imgp->entry_addr;
 	tf->tf_spsr = PSR_M_32;
+	if ((uint32_t)imgp->entry_addr & 1)
+		tf->tf_spsr |= PSR_T;
 
 #ifdef VFP
 	vfp_reset_state(td, pcb);



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