aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2026-01-27 18:30:46 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2026-01-27 18:30:46 +0000
commit9272b780626640ce9b9ac378fbdd2783aaa33625 (patch)
tree3953d04960e1e51dd58722dfbd3d979e78260325
parent05609c5eff27ea7b382237bd2a937c01c1ceb59a (diff)
powerpc: Fix alignment of initial PCB on kstack
Commit cc81c44dd806737f98b4fd4094674dd71c8749f3 aimed to consolidate duplicated code between the Book-E and AIM backends. For cpu_thread_alloc cpu_thread_alloc and cpu_fork it used the AIM functions which used a bogus alignment mask (~0x2f). The Book-E functions used a proper alignment mask (~0x3f). The AIM functions appear to have been busted since they were first imported in commit 919cb3362fded33aca682a6ac57777f8fff86e36. To fix, use the Book-E mask which requests 64 byte alignment. Probably this was harmless in practice since td_kstack is page aligned and struct pcb is probably a multiple of 32 bytes in size, so the 0x10 bit should have been clear anyway. Reviewed by: fuz, jhibbits Fixes: cc81c44dd806 ("Unify ABI-related bits of the Book-E and AIM...") Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54839
-rw-r--r--sys/powerpc/powerpc/exec_machdep.c2
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 18c9bddb84c5..318927e01360 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -1083,7 +1083,7 @@ cpu_thread_alloc(struct thread *td)
struct pcb *pcb;
pcb = (struct pcb *)((td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
- sizeof(struct pcb)) & ~0x2fUL);
+ sizeof(struct pcb)) & ~0x3fUL);
td->td_pcb = pcb;
td->td_frame = (struct trapframe *)pcb - 1;
}
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index d47beedb595e..1fd853783cc8 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -124,7 +124,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
cpu_update_pcb(td1);
pcb = (struct pcb *)((td2->td_kstack +
- td2->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x2fUL);
+ td2->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb)) & ~0x3fUL);
td2->td_pcb = pcb;
/* Copy the pcb */