as discussed in "m_pullup alingment crash armv7 sparc64", at worst it
doesnt hurt to have m_pullup maintain the data alignment of payloads,
and at best it will encourage aligned loads even if the arch allows
unaligned accesses. aligned loads are faster than unaligned.

ok?

Index: uipc_mbuf.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v
retrieving revision 1.280
diff -u -p -r1.280 uipc_mbuf.c
--- uipc_mbuf.c 18 Jan 2022 12:38:21 -0000      1.280
+++ uipc_mbuf.c 4 Feb 2022 09:30:02 -0000
@@ -945,9 +945,11 @@ m_pullup(struct mbuf *m0, int len)
                                goto freem0;
                }
 
-               adj = mtod(m, unsigned long) & ALIGNBYTES;
+               adj = mtod(m, unsigned long);
        } else
-               adj = mtod(m0, unsigned long) & ALIGNBYTES;
+               adj = mtod(m0, unsigned long);
+
+       adj &= sizeof(long) - 1;
 
        tail = head + M_SIZE(m0);
        head += adj;

Reply via email to