Page MenuHomeFreeBSD

D29060.id85138.diff
No OneTemporary

D29060.id85138.diff

Index: sys/arm64/arm64/machdep.c
===================================================================
--- sys/arm64/arm64/machdep.c
+++ sys/arm64/arm64/machdep.c
@@ -552,6 +552,7 @@
exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
{
struct trapframe *tf = td->td_frame;
+ struct pcb *pcb = td->td_pcb;
memset(tf, 0, sizeof(struct trapframe));
@@ -559,6 +560,22 @@
tf->tf_sp = STACKALIGN(stack);
tf->tf_lr = imgp->entry_addr;
tf->tf_elr = imgp->entry_addr;
+
+ /*
+ * Reset the FP state to avoid leaking state from the parent process
+ * across execve() (and to ensure that we get a consitent floating
+ * point environment in every new process).
+ */
+ bzero(&pcb->pcb_fpustate.vfp_regs, sizeof(pcb->pcb_fpustate.vfp_regs));
+ KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate,
+ ("pcb_fpusaved should point to pcb_fpustate."));
+ pcb->pcb_fpustate.vfp_fpcr = initial_fpcr;
+ pcb->pcb_fpustate.vfp_fpsr = 0;
+ pcb->pcb_vfpcpu = UINT_MAX;
+ pcb->pcb_fpflags = 0;
+
+ /* FIXME: Shouldn't we also reset pcb_dbg_regs? */
+ /* XXX: should exec clear single-step in pcb_flags? */
}
/* Sanity check these are the same size, they will be memcpy'd to and fro */
Index: sys/arm64/arm64/vfp.c
===================================================================
--- sys/arm64/arm64/vfp.c
+++ sys/arm64/arm64/vfp.c
@@ -102,7 +102,7 @@
static void
vfp_store(struct vfpstate *state)
{
- __int128_t *vfp_state;
+ __uint128_t *vfp_state;
uint64_t fpcr, fpsr;
vfp_state = state->vfp_regs;
@@ -134,7 +134,7 @@
static void
vfp_restore(struct vfpstate *state)
{
- __int128_t *vfp_state;
+ __uint128_t *vfp_state;
uint64_t fpcr, fpsr;
vfp_state = state->vfp_regs;
@@ -357,7 +357,7 @@
}
int
-fpu_kern_thread(u_int flags)
+fpu_kern_thread(u_int flags __unused)
{
struct pcb *pcb = curthread->td_pcb;
@@ -372,7 +372,7 @@
}
int
-is_fpu_kern_thread(u_int flags)
+is_fpu_kern_thread(u_int flags __unused)
{
struct pcb *curpcb;
Index: sys/arm64/arm64/vm_machdep.c
===================================================================
--- sys/arm64/arm64/vm_machdep.c
+++ sys/arm64/arm64/vm_machdep.c
@@ -108,7 +108,6 @@
td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame;
td2->td_pcb->pcb_fpusaved = &td2->td_pcb->pcb_fpustate;
td2->td_pcb->pcb_vfpcpu = UINT_MAX;
- td2->td_pcb->pcb_fpusaved->vfp_fpcr = initial_fpcr;
/* Setup to release spin count in fork_exit(). */
td2->td_md.md_spinlock_count = 1;
Index: sys/sys/systm.h
===================================================================
--- sys/sys/systm.h
+++ sys/sys/systm.h
@@ -193,7 +193,7 @@
* Assert that a thread is in critical(9) section.
*/
#define CRITICAL_ASSERT(td) \
- KASSERT((td)->td_critnest >= 1, ("Not in critical section"));
+ KASSERT((td)->td_critnest >= 1, ("Not in critical section"))
/*
* If we have already panic'd and this is the thread that called

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 14, 11:17 PM (15 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27640625
Default Alt Text
D29060.id85138.diff (2 KB)

Event Timeline