git: 9272b7806266 - main - powerpc: Fix alignment of initial PCB on kstack
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 27 Jan 2026 18:31:45 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=9272b780626640ce9b9ac378fbdd2783aaa33625
commit 9272b780626640ce9b9ac378fbdd2783aaa33625
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-01-27 18:30:46 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-01-27 18:30:46 +0000
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
---
sys/powerpc/powerpc/exec_machdep.c | 2 +-
sys/powerpc/powerpc/vm_machdep.c | 2 +-
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 */