From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795942593; b=EUI7jTddnhxw1AzMRhXXVZZECOmlDXr2oGKxOepgkirIqbLC0UaAJjcOlfx7yx9qu0aN CWvrzqJG3pffTWhfZpF3DXP5iuXsZeu9zywJaQEBPkAofb+0401g8MEBOUh2mQm87OjNK LuGTBdz973d2Rro9IgFbyLEe3yEYCBTiVSXPlcCcRR/+rA4KNUjk9kyDVEyvMVZuYC74l oxuHSgKHi0U4gbKVEoHmwLjEyB76m+EZUJUKVuz4JJPOLxwcQpfmQ4jTf0WewyP2oFxuV +7LM3jU4zrBWgBb0GHJYgDs/hJn2Cg2K9h8bzdggxXYGgf5rX1wVWCJCDCUGdrsCRaw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795942593; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=cY0CGWUkBKcmhdmuvv0TqYf1dFcGMAkxpxoY5IqNWwI=; b=ciFr1reNtEoYiWE8TEzOutl0P6MgazWsDqXFIOr7//6GCVJHlUlGgM3lOmHrn4LsS2ZM 71ilJ2OABxs2JEcaudIhK2WFjbUtupjCy4jwvA7qWJ15IbNf81aYhNBkwsrBkl5OGWKfU uFSDFIJOyu+MW+G/gDex8IL6VOt3y4pDtJQAtHYO6BnccnGfgy3dstz2zQlmbaG+Aidec gVDKHtkh7jlMvSb2Hl25UDgTE3H+Vly80tSMehxidUaLwAYrcQVnTcOZb37fBIw8WufgZ IcmTLI5BtngXCm8GQI9ro/ekgpV+G9q40judhf/7dCBizrTNYzazSIplgegR1UV2cDQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=AbYACgMO; arc=none smtp.remote-ip=209.85.214.181 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56476606A32D for ; Sun, 29 Nov 2026 08:56:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56476606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=AbYACgMO Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2f020d0169eso46189355ad.0 for ; Sun, 29 Nov 2026 00:56:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795942592; x=1796547392; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cY0CGWUkBKcmhdmuvv0TqYf1dFcGMAkxpxoY5IqNWwI=; b=AbYACgMOVmQGHGeD+t/Ftp4hu3X5h902DV9xqad7mXE9mFszYypznAy/se7o9HkOKt 5eUI2XHQuYXcUspYUBTftlJNiFlZbuyEShzpF15T983LQiB7LcgdFms1CGVN4Qh7XkA0 8N2zYQcY95dpdJCeq3KRtrSYDZfQsYK8MFuHJ1cYcISbFHb5oNb5XkvR4nNWvgKHGtB9 4la06+LRzErnx/6NZVD9WCckUpLTWWe/H9ldO+efyCnFBrVSCp7wvY3iOanVz6QS4fhx 7nnKryYqAU+310ALDrBx0XQh7UyK/f0y91V21aplvOdSWOPiyMlP35NRDsY5A4Bgx+vM oq0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795942592; x=1796547392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cY0CGWUkBKcmhdmuvv0TqYf1dFcGMAkxpxoY5IqNWwI=; b=ssnFLrpuWT2y7hNPfeSJvlLa0IKIztmdL4pQNab7ahnrGKfDa+WTqudh7gHOWX6F+c 8OZpSPkncmxnoAlQFzRNZs2SI1WMXCVjmfcZk82zPFa7vSv5RYybpRX5QZ3rk0LAKLB/ PYj5fPNWqS5efMxegLJEZ0R5amRwpdft67v2QY1X8aWcpRwbsuUNYplF6novqHJQJeDw KMDFGVaTJB4x1SAfMsiVbUcLXb/wGtcwSrmDbVucBBXm0dl5gCdOLU5wzZHGFCrdq03P nso2l4T2oiT7pUg1KVTz7vOq2/lJ+jDyiMWnjG9g9iq45n2P6VZ5NJugwMyxxQE8UHYq UQaw== X-Gm-Message-State: APuU4Z/Aj0pU6x8PjTUt/BWu4WKcMZaRgTlcLIM7dUVRyh5zl+U0yw3e o0Ii9MMmiMXIWx5tIWarNYcrfQDp9rGqCpva1e6SYD2gIeUbVCyh1aTD X-Gm-Gg: AZFdTZfT+q6117pTaj8Deyr2t7ZSAAF14O5lraFJ0ExEGqELRx6mcmr91occ3It6YZj bfUFfS5HiaZjI5hAGrmT6ic1GmcXo5KzCcDTV+Ik1FMTmn78L9bsNImtRri4GB94yQk2dR59YGh 2jFB9zsrX+6Po8WJtu+LzUPNomTdDrc9zUcPnjR9NhEnTDQ8w8CP+3652uyi+OZEAU2XU2lDmkj +zTcbzdmQCWj5r1tv2fbSKws9ivG1/V2Diksp6vqYhCiVkxGeYc63iBfbEXoqIyT+0qIQz5Csaz rKuSV10eW2hFSWJkvO5V2TV7Hgigta36sdhIj6OO1zj6gr9o5gIljLCu447iir16SEkzPwt6myy Py1zpQZeEghwv1HZsPuWdVIdFIzAmEDMkfocc7hZ2DAFs2NuKG9Wu6ZhzgiWwgV16LIiLSnQ5JE uX2/xeYfc6d9BqjjrUS4cCZ7tXOE//XFmtYn5knY+OosPc7RA4Ibzkqy5V4AADafA2/RmEGi3+J p1i8ckzV0uerdklQARb7NPJPD3GYHUq0OaYunLHbt/zLEbMmQ3oYpEMEfcNlJR9Iblbkzi7Ua21 ImCJXRbAaMfrf+Z4TgztJ97z+e2Pfz0BVpyF//3olUb+I01sh0937gzUPj7Gje1DcS1iR5AyTCl 36JeZckb8tTdMRKBNraW9Gvm6P2bmyPQ+nkKnq05TxdvGX5qtohOO6oM68MD0MkE+jmLCnJvvfv N9fCbh X-Received: by 2002:a17:902:ef45:b0:2e8:7686:4d46 with SMTP id d9443c01a7336-2f03f1b8118mr312849155ad.34.1795942591569; Sun, 29 Nov 2026 00:56:31 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:4100:453:29cf:2f71:51d4:4a57]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0c2091sm144767735ad.20.2026.11.29.00.56.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 00:56:31 -0800 (PST) From: Jack Wallner To: Kees Cook Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Herbert Xu , "David S. Miller" , Srujana Challa , Bharat Bhushan , linux-crypto@vger.kernel.org Subject: [PATCH 2/8] crypto: nitrox, octeontx, octeontx2 - Use ALIGN() on DMA addresses Date: Sun, 29 Nov 2026 00:56:04 -0800 Message-ID: <20261129085612.22266-3-jackwallner@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261129085612.22266-1-jackwallner@gmail.com> References: <20261129085612.22266-1-jackwallner@gmail.com> X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit PTR_ALIGN() is meant for pointers. nitrox_cmdq_init(), copy_ucode_to_dma_mem() and otx2_cpt_alloc_instruction_queues() pass it a dma_addr_t. That compiles because PTR_ALIGN() casts its argument to unsigned long and back. A later patch in this series makes PTR_ALIGN() do pointer arithmetic on its argument so that the compiler can keep track of the object size, and documents that the argument has to be a pointer. Use ALIGN() for these addresses, which works in the type of its argument. No functional change: all three drivers depend on 64BIT, where both macros give the same value. Compile tested only. The change and this changelog were written by an AI coding assistant (Claude, run in Claude Code) at my direction. See the cover letter for how it was used and tested. Signed-off-by: Jack Wallner --- drivers/crypto/cavium/nitrox/nitrox_lib.c | 2 +- drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c | 2 +- drivers/crypto/marvell/octeontx2/otx2_cptlf.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/cavium/nitrox/nitrox_lib.c b/drivers/crypto/cavium/nitrox/nitrox_lib.c index d35303857..e40fcebb3 100644 --- a/drivers/crypto/cavium/nitrox/nitrox_lib.c +++ b/drivers/crypto/cavium/nitrox/nitrox_lib.c @@ -33,7 +33,7 @@ static int nitrox_cmdq_init(struct nitrox_cmdq *cmdq, int align_bytes) if (!cmdq->unalign_base) return -ENOMEM; - cmdq->dma = PTR_ALIGN(cmdq->unalign_dma, align_bytes); + cmdq->dma = ALIGN(cmdq->unalign_dma, align_bytes); cmdq->base = cmdq->unalign_base + (cmdq->dma - cmdq->unalign_dma); cmdq->write_idx = 0; diff --git a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c index c66cd3229..0cac7f104 100644 --- a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c @@ -853,7 +853,7 @@ static int copy_ucode_to_dma_mem(struct device *dev, return -ENOMEM; } ucode->align_va = PTR_ALIGN(ucode->va, OTX_CPT_UCODE_ALIGNMENT); - ucode->align_dma = PTR_ALIGN(ucode->dma, OTX_CPT_UCODE_ALIGNMENT); + ucode->align_dma = ALIGN(ucode->dma, OTX_CPT_UCODE_ALIGNMENT); memcpy((void *) ucode->align_va, (void *) ucode_data + sizeof(struct otx_cpt_ucode_hdr), ucode->size); diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptlf.h b/drivers/crypto/marvell/octeontx2/otx2_cptlf.h index 1b9f75214..c71647c46 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptlf.h +++ b/drivers/crypto/marvell/octeontx2/otx2_cptlf.h @@ -178,8 +178,7 @@ static inline int otx2_cpt_alloc_instruction_queues( /* Align pointers */ iq->vaddr = PTR_ALIGN(iq->vaddr, OTX2_CPT_INST_Q_ALIGNMENT); - iq->dma_addr = PTR_ALIGN(iq->dma_addr, - OTX2_CPT_INST_Q_ALIGNMENT); + iq->dma_addr = ALIGN(iq->dma_addr, OTX2_CPT_INST_Q_ALIGNMENT); } return 0; -- 2.43.0