From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4776EC52D11 for ; Thu, 26 Jan 2023 17:23:16 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4P2nbk2Z3Wz3fHh for ; Fri, 27 Jan 2023 04:23:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=segher@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4P2nb624mkz3fD7 for ; Fri, 27 Jan 2023 04:22:40 +1100 (AEDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 30QHJRSd028306; Thu, 26 Jan 2023 11:19:27 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 30QHJPDN028305; Thu, 26 Jan 2023 11:19:25 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 26 Jan 2023 11:19:25 -0600 From: Segher Boessenkool To: Michael Ellerman Subject: Re: [PATCH v4 02/24] powerpc/pseries: Fix alignment of PLPKS structures and buffers Message-ID: <20230126171925.GN25951@gate.crashing.org> References: <20230120074306.1326298-1-ajd@linux.ibm.com> <20230120074306.1326298-3-ajd@linux.ibm.com> <87pmb2pxpa.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pmb2pxpa.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.4.2.3i X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gjoyce@linux.ibm.com, Andrew Donnellan , erichte@linux.ibm.com, gregkh@linuxfoundation.org, nayna@linux.ibm.com, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, sudhakar@linux.ibm.com, ruscur@russell.cc, joel@jms.id.au, bgray@linux.ibm.com, linux-integrity@vger.kernel.org, gcwilson@linux.ibm.com, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, Jan 26, 2023 at 12:09:53AM +1100, Michael Ellerman wrote: > Andrew Donnellan writes: > > 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 "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. Segher