The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jack Wallner <jackwallner@gmail.com>
To: Kees Cook <kees@kernel.org>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Srujana Challa <schalla@marvell.com>,
	Bharat Bhushan <bbhushan2@marvell.com>,
	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	[thread overview]
Message-ID: <20261129085612.22266-3-jackwallner@gmail.com> (raw)
In-Reply-To: <20261129085612.22266-1-jackwallner@gmail.com>

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 <jackwallner@gmail.com>
---
 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


  parent reply	other threads:[~2026-11-29  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  8:56 [PATCH 0/8] Preserve object size through PTR_ALIGN() Jack Wallner
2026-11-29  8:56 ` [PATCH 1/8] crypto: gcm, ccm - Derive the rfc4106/rfc4309 IV from the request context Jack Wallner
2026-11-29  8:56 ` Jack Wallner [this message]
2026-11-29  8:56 ` [PATCH 3/8] misc: pci_endpoint_test: Use ALIGN() on DMA addresses Jack Wallner
2026-11-29  8:56 ` [PATCH 4/8] be2net: Use ALIGN() on a DMA address Jack Wallner
2026-11-29  8:56 ` [PATCH 5/8] octeontx2-pf: " Jack Wallner
2026-11-29  8:56 ` [PATCH 6/8] scsi: be2iscsi: " Jack Wallner
2026-11-29  8:56 ` [PATCH 7/8] vdso/align: Preserve object size through PTR_ALIGN() Jack Wallner
2026-11-29  8:56 ` [PATCH 8/8] kunit/fortify: Add PTR_ALIGN() object size test Jack Wallner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129085612.22266-3-jackwallner@gmail.com \
    --to=jackwallner@gmail.com \
    --cc=bbhushan2@marvell.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=kees@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schalla@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox