powerpc: Fix alignment of initial PCB on kstack
Commitcc81c44dd8aimed 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 commit919cb3362f. 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:cc81c44dd8("Unify ABI-related bits of the Book-E and AIM...") Effort: CHERI upstreaming Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D54839
This commit is contained in:
@@ -1083,7 +1083,7 @@ cpu_thread_alloc(struct thread *td)
|
|||||||
struct pcb *pcb;
|
struct pcb *pcb;
|
||||||
|
|
||||||
pcb = (struct pcb *)((td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
|
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_pcb = pcb;
|
||||||
td->td_frame = (struct trapframe *)pcb - 1;
|
td->td_frame = (struct trapframe *)pcb - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags)
|
|||||||
cpu_update_pcb(td1);
|
cpu_update_pcb(td1);
|
||||||
|
|
||||||
pcb = (struct pcb *)((td2->td_kstack +
|
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;
|
td2->td_pcb = pcb;
|
||||||
|
|
||||||
/* Copy the pcb */
|
/* Copy the pcb */
|
||||||
|
|||||||
Reference in New Issue
Block a user