From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795942594; b=TRMs9jWLrJ6TUofSN+4y5ZaMXmUHir0DB75zxlsWPnOu5pt63k/Ec/f2vUBi6OiXGMcR ZdMMkiyZrcrO0qP+YmLoFIf4HWmW9P0VU5KvokuLnHo5jM0edRhI5XCOxqWL41LoXYab5 bpam2/av6btK/B7DrECEID3eGv8mNKvZhwD7FP9r7S6zGzZGCS7j83GYeEeEPLLE2HWMg Moy3J3gLyHKHLHHH9Jj9TJn3d/u/eLPN/nWWL14Zw63y7Kaz6fYch+4CmN8qKq6yFNu21 wfHRd53g2q4SlMvANHGvG4ZpWlaAl/ut3dh3rqBKw1+s5f4RVjgP6Wuvvk1thO3eAdQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795942594; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted: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=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=CKBoiTUVkxp6G4OVIS2aTTrWRjOXTTYHkSKKniqr9LyUIxBYPU3qX2jQJEnXEOz6N3sf rNBjXdVITV6ZPbk7r3a5eqop+vFE2rNGJNtvVXBbw15yRqtYJ/qUkNEbjeHsQbNAMx5AI 9zt5T/2doOOh6VqAlwa2JzbcYIObW2FdT/35ypiwc7e4kIaV56I3yXUbh95RqbTNS91o9 YjIKp7KqDXEqGILgAObnYvIUATUn0Zkdi5bfBPMFzEY5pPkHxOnt5CbfchyXQrf16FG76 b36RuIwywXHRyzvcOhAEVjbywMWDVuS1s5VFhIZrhSmBeUp1kC7/U4kBslwCecBXrRQ== 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="E/u26ASc"; arc=none smtp.remote-ip=209.85.214.173 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 68452606A682 for ; Sun, 29 Nov 2026 08:56:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 68452606A682 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=E/u26ASc Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2efddf749e5so38707325ad.1 for ; Sun, 29 Nov 2026 00:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795942594; x=1796547394; 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=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=E/u26AScc/jPlEDbI+XipZjU5TllpUyhrOU49lNasAfa/sfF4qwt6v0Q/E+hSaC6yK wNtyMVDYUAKoxRu4QZ25s0TX2b+nxkIyPthzGX6W2UgnB2BfNI0fic6p0+xLuISI3o90 qtVCQF9D8m5FEgEXW53SpyvtLF/N2i+ned7mX3+FKT9DEA8HHJ2AkBH+2a7LaoKdz6Gw ZiU2kayGw2NGDf+nsNn63Y2n/IGLHBC7iLlmDfACG0u2Ahy1j1Hl591XqUrGVT1ikJOC 8c9LS3GwZz9iZNz5Cq+D4+3ADu5znD/mdGPhRIdA+9gjVT2MtAgQKIQpVj2G2L5DPLGf bCyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795942594; x=1796547394; 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=1nXLB3hpFCwugvXZuqXQHCnaCcxjuLJzUskoPcyoK0Y=; b=TOTEsKDCLHhnU10xNmK6zKr0CmdERXNGe7/xvBYNd1KfnzmPKcezB5cRqX6tPkq+41 R+TayLeerdkSxrNcXJm1jrhlfAbbaNR15wZu+C7z7A9pCcOMSKMt3ukx4i5qOJuEFJRA 9Xxev0DEfuDKhZO7MsYKpgq49+FF+h4JJG2eXwJNmR7n5ByBystT6MXrZOoOk1Z3jJNC 1JKxACeUtzFBhTv+gxoUrPqIFGLSv637c30LeShh4ST4HyC4dAEYSp05j0Jr3YR+rOC4 mr8OQBabl1MsEyrMxdrDXj2jS5926sAdPUMWeG2Tu6bMrt/zTu3/QeZsHaWL5GXN2qNv dPSg== X-Forwarded-Encrypted: i=1; AL+hErEduElg1YSbRXbySXt0en11wGhqSvnzCx35rNjGv0RFUKZpyICHHIKZ55Csz0uoC6+7Zfe+dvsdnNQOjKc=@vger.kernel.org X-Gm-Message-State: APuU4Z8Ui7pPHvuyVlM1nBEg2F0+XH4LyfAU7+UcXCXdFURk8nJXcXYj hndDo+dv2r1nDOvuUTGewasNM7E5/DRCRI/Ecw9m6MYJEn9V3kOVzAqh X-Gm-Gg: AZFdTZc9iMvlHBm4Cw3sPG769uDKCdJQFXZ5qdxjppOpI8tcpxEFr4fsrOEPgvmBVDx v6ZL6HLHcaj27SuQrRTskA0jt4tKQ3LxRaupxicUL9ge28wxc4iU7J5sU5WSwlptsSb7NMc71Xv DRLqvGjjMal+ih+0eG5vS4vrud2gxOMfSL54Er/UnzX/2om8kkA/0F7X0cAOpIwNNaF0ICM2UMZ 9UnNOmp4T/mKke9XytaxDQt2IxRfsdIjE1wZeANDFXmanAwovGwPRVAavxBxvXNP38Jr/XzNCne VLNe/KYeHvYE6S5dDOZ4BNvX9XgT+UH4zWtJUjdaYdqwkV8PpM2T16+GXubkNDhjdP67q8YKiSv haTtlh7mXVUMB9osuJ1DEhS3JKQNM/gkikSmYHceBqbR+7iq/P4w6wXOje9k79CvZB81S8X5cFp i+d1lE8BlXnyDSUBjXy617CEzNdvFNeZmLBTGdx4lMPCF+x4oMU2CN0B9pOCs7wOU8DE+zoA8x8 H7vyde3535q1I+wP3Sa4rjqR3XpCPdozy7yrmG+XJauodKK4zrCK6ngri2vT0upIk6I5sJ/UBSc J6CRasz/+CxhdH3LgPZxLh0Sf1UJtWrTUH4DRco/u/l3TbrxaF+LatongNMBOlW+5tr8z/lXrk3 y9pqC3plb+7EOnMOUHl5KFgclvTEju4Kc77PKmWef00aIpJrU3Wbp5aYYZ8FrmZzQZCcBrViEvh N/oGrlBdPVthMkyjgfE2TVnqTYLw== X-Received: by 2002:a17:903:b8e:b0:2dd:86a3:232d with SMTP id d9443c01a7336-2f031e22ce0mr202763775ad.8.1795942593655; Sun, 29 Nov 2026 00:56:33 -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.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 00:56:33 -0800 (PST) From: Jack Wallner To: Kees Cook Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Frank Li , Arnd Bergmann , Greg Kroah-Hartman , linux-pci@vger.kernel.org Subject: [PATCH 3/8] misc: pci_endpoint_test: Use ALIGN() on DMA addresses Date: Sun, 29 Nov 2026 00:56:05 -0800 Message-ID: <20261129085612.22266-4-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-kernel@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. The copy, write and read tests pass it a dma_addr_t in four places. 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. With that change these four lines get -Wint-to-pointer-cast and -Wpointer-to-int-cast warnings on 32-bit kernels with a 64-bit dma_addr_t (x86 with PAE, for example). Use ALIGN(), which works in the type of its argument. There is no change on 64-bit kernels. On a 32-bit kernel with a 64-bit dma_addr_t the old form would drop the upper 32 bits of the address. I have not seen that happen and did not try to trigger it: this is a cleanup and a prerequisite for the PTR_ALIGN() change, not a fix for a reported problem. Compile tested only, including i386 allmodconfig, which has a 64-bit dma_addr_t. 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/misc/pci_endpoint_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index dd49ca7f4..17d53375e 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -750,7 +750,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_src_phys_addr, alignment)) { - src_phys_addr = PTR_ALIGN(orig_src_phys_addr, alignment); + src_phys_addr = ALIGN(orig_src_phys_addr, alignment); offset = src_phys_addr - orig_src_phys_addr; src_addr = orig_src_addr + offset; } else { @@ -782,7 +782,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_dst_phys_addr, alignment)) { - dst_phys_addr = PTR_ALIGN(orig_dst_phys_addr, alignment); + dst_phys_addr = ALIGN(orig_dst_phys_addr, alignment); offset = dst_phys_addr - orig_dst_phys_addr; dst_addr = orig_dst_addr + offset; } else { @@ -884,7 +884,7 @@ static int pci_endpoint_test_write(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { - phys_addr = PTR_ALIGN(orig_phys_addr, alignment); + phys_addr = ALIGN(orig_phys_addr, alignment); offset = phys_addr - orig_phys_addr; addr = orig_addr + offset; } else { @@ -979,7 +979,7 @@ static int pci_endpoint_test_read(struct pci_endpoint_test *test, } if (alignment && !IS_ALIGNED(orig_phys_addr, alignment)) { - phys_addr = PTR_ALIGN(orig_phys_addr, alignment); + phys_addr = ALIGN(orig_phys_addr, alignment); offset = phys_addr - orig_phys_addr; addr = orig_addr + offset; } else { -- 2.43.0