Re: [PATCH v4 02/24] powerpc/pseries: Fix alignment of PLPKS structures and buffers

From
Michael Ellerman <mpe@ellerman.id.au>
Date
2023-01-27 10:52:54
Also in
linux-integrity, lkml
Reply to
Segher Boessenkool, 2023-01-26
Segher Boessenkool [off-list ref] writes:
On Thu, Jan 26, 2023 at 12:09:53AM +1100, Michael Ellerman wrote:
quoted
Andrew Donnellan [off-list ref] writes:
quoted
A number of structures and buffers passed to PKS hcalls have alignment
requirements, which could on occasion cause problems:

- Authorisation structures must be 16-byte aligned and must not cross a
  page boundary

- Label structures must not cross page boundaries

- Password output buffers must not cross page boundaries

Round up the allocations of these structures/buffers to the next power of
2 to make sure this happens.
It's not the *next* power of 2, it's the *nearest* power of 2, including
the initial value if it's already a power of 2.
It's not the nearest either, the nearest power of two to 65 is 64.  You
could say "but, round up" to which I would say "round?"  :-P
OK you got me there :)

The function name makes it pretty clear that it will round *up* to the
nearest power of 2 but you're right the comment should also make that
clear.
"Adjust the allocation size to be the smallest power of two greater than
or equal to the given size."

"Pad to a power of two" in shorthand.  "Padded to a power of two if
necessary" if you want to emphasise it can be a no-op.
The initial wording implied that it would always over-allocate so yes I
think it's important to make it clear that it doesn't round up if it
doesn't need to.

cheers
Thread (52 messages) 52 messages, 8 authors, last reply 2023-02-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help