STACKALIGN: Reimplement in terms of __align_down
This changes STACKALIGN to be type-preserving when operating on pointers. Reviewed by: brooks, kib Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54920
This commit is contained in:
@@ -74,7 +74,8 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||
va_end(ap);
|
||||
|
||||
/* Set the stack */
|
||||
gp->gp_sp = STACKALIGN(ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
|
||||
gp->gp_sp = STACKALIGN((uintptr_t)ucp->uc_stack.ss_sp +
|
||||
ucp->uc_stack.ss_size);
|
||||
/* Arrange for return via the trampoline code. */
|
||||
gp->gp_elr = (__register_t)_ctx_start;
|
||||
gp->gp_x[19] = (__register_t)func;
|
||||
|
||||
@@ -80,7 +80,8 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||
va_end(ap);
|
||||
|
||||
/* Set the stack */
|
||||
gp->gp_sp = STACKALIGN(ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
|
||||
gp->gp_sp = STACKALIGN((uintptr_t)ucp->uc_stack.ss_sp +
|
||||
ucp->uc_stack.ss_size);
|
||||
/* Arrange for return via the trampoline code. */
|
||||
gp->gp_sepc = (__register_t)_ctx_start;
|
||||
gp->gp_s[0] = (__register_t)func;
|
||||
|
||||
@@ -307,7 +307,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
fp--;
|
||||
|
||||
/* make the stack aligned */
|
||||
fp = (struct sigframe *)STACKALIGN(fp);
|
||||
fp = STACKALIGN(fp);
|
||||
/* Populate the siginfo frame. */
|
||||
bzero(&frame, sizeof(frame));
|
||||
get_mcontext(td, &frame.sf_uc.uc_mcontext, 0);
|
||||
|
||||
@@ -655,7 +655,7 @@ initarm(struct arm_boot_params *abp)
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((void *)STACKALIGN(thread0.td_pcb));
|
||||
return (STACKALIGN(thread0.td_pcb));
|
||||
|
||||
}
|
||||
#endif /* FDT */
|
||||
|
||||
@@ -129,7 +129,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
|
||||
pcb2->pcb_regs.sf_r4 = (register_t)fork_return;
|
||||
pcb2->pcb_regs.sf_r5 = (register_t)td2;
|
||||
pcb2->pcb_regs.sf_lr = (register_t)fork_trampoline;
|
||||
pcb2->pcb_regs.sf_sp = STACKALIGN(td2->td_frame);
|
||||
pcb2->pcb_regs.sf_sp = (register_t)STACKALIGN(td2->td_frame);
|
||||
pcb2->pcb_regs.sf_tpidrurw = (register_t)get_tls();
|
||||
|
||||
#ifdef VFP
|
||||
@@ -194,7 +194,7 @@ cpu_copy_thread(struct thread *td, struct thread *td0)
|
||||
td->td_pcb->pcb_regs.sf_r4 = (register_t)fork_return;
|
||||
td->td_pcb->pcb_regs.sf_r5 = (register_t)td;
|
||||
td->td_pcb->pcb_regs.sf_lr = (register_t)fork_trampoline;
|
||||
td->td_pcb->pcb_regs.sf_sp = STACKALIGN(td->td_frame);
|
||||
td->td_pcb->pcb_regs.sf_sp = (register_t)STACKALIGN(td->td_frame);
|
||||
|
||||
td->td_frame->tf_spsr &= ~PSR_C;
|
||||
td->td_frame->tf_r0 = 0;
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <sys/_align.h>
|
||||
|
||||
#define STACKALIGNBYTES (8 - 1)
|
||||
#define STACKALIGN(p) ((u_int)(p) & ~STACKALIGNBYTES)
|
||||
|
||||
#ifndef MACHINE
|
||||
#define MACHINE "arm"
|
||||
|
||||
@@ -838,7 +838,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
/* Make room, keeping the stack aligned */
|
||||
fp = (struct sigframe *)addr;
|
||||
fp--;
|
||||
fp = (struct sigframe *)STACKALIGN(fp);
|
||||
fp = STACKALIGN(fp);
|
||||
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
if (copyout(&frame, fp, sizeof(*fp)) != 0) {
|
||||
|
||||
@@ -100,7 +100,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
|
||||
|
||||
ptrauth_fork(td2, td1);
|
||||
|
||||
tf = (struct trapframe *)STACKALIGN((struct trapframe *)pcb2 - 1);
|
||||
tf = STACKALIGN((struct trapframe *)pcb2 - 1);
|
||||
bcopy(td1->td_frame, tf, sizeof(*tf));
|
||||
tf->tf_x[0] = 0;
|
||||
tf->tf_x[1] = 0;
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <sys/_align.h>
|
||||
|
||||
#define STACKALIGNBYTES (16 - 1)
|
||||
#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
|
||||
|
||||
#ifndef MACHINE
|
||||
#define MACHINE "arm64"
|
||||
|
||||
@@ -338,7 +338,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
|
||||
/* Make room, keeping the stack aligned */
|
||||
fp--;
|
||||
fp = (struct l_sigframe *)STACKALIGN(fp);
|
||||
fp = STACKALIGN(fp);
|
||||
|
||||
get_mcontext(td, &uc.uc_mcontext, 0);
|
||||
uc.uc_sigmask = *mask;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <sys/_align.h>
|
||||
|
||||
#define STACKALIGNBYTES (16 - 1)
|
||||
#define STACKALIGN(p) ((uint64_t)(p) & ~STACKALIGNBYTES)
|
||||
|
||||
#ifndef MACHINE
|
||||
#define MACHINE "riscv"
|
||||
|
||||
@@ -370,7 +370,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
|
||||
/* Make room, keeping the stack aligned */
|
||||
fp--;
|
||||
fp = (struct sigframe *)STACKALIGN(fp);
|
||||
fp = STACKALIGN(fp);
|
||||
|
||||
/* Fill in the frame to copy out */
|
||||
bzero(&frame, sizeof(frame));
|
||||
|
||||
@@ -179,6 +179,9 @@
|
||||
#ifndef MAXDUMPPGS
|
||||
#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
|
||||
#endif
|
||||
#ifdef STACKALIGNBYTES
|
||||
#define STACKALIGN(p) (__align_down(p, STACKALIGNBYTES + 1))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants related to network buffer management.
|
||||
|
||||
Reference in New Issue
Block a user