From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795942594; b=IxLyM8uLml5LNlQunWDWAx+hhU16FZVh5Bjq/D9dnKmaz1Vk3YfQNnJFnBrPWYZEe80y Tif8qxwJQE35tfaImj+0xUcuH3OiSUF69z7FAb9DSvryel6Op85QhUjPvxPiHeVIKOc+F tbn4o5V7hVaGb5TKOZMK+dNv0AQh62Kf3z+C20ljQpiANXi5r0GTlIOq7fjSeIAybQq4s Oazzcaa1h9BY8KIfTJNk6Huw8HACqJI0dqOer1yQ7A2wmHseQISl9132vQxhrLJpuhn+o WwdMOCQOQi9/+4jUP5eQCerv5DTTtGVEFBdNIwzJhqi6Eb+y5mlTcJ7Z8PvcZOvmomw== 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=SvJucShazH3x7Lw/mRQ8vMYcFmttEI8aS1dkMx4IyqrGIeu6M/pBQdwE5o0CJM2d/Kf5 FvV33t14ujLb6ACfU9NKM8nATdZBvtxo3KeWI9upuHQyR4zfahU3DZKmeI4LFJbeFDH1p 2qxHa4JjYDEimsIq/8DVPIgqV7MqlaIIGK5NPxqhyQR/Zw5utiy8+HXyUdxevB7ezmzPc jBY9vrbYNB9e2sBZtAhU/66D32xXExAfsdLUV6ASKgfWSZfrBoGBZxLyQZidECO93NbtF jy6LIUqcEstTTp5jWZLn8bbypNQ91RCecJOTIO9rEXmnqodbjKLTEvamefaJCENOifg== 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.178 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 6EA79606A685 for ; Sun, 29 Nov 2026 08:56:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6EA79606A685 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-f178.google.com with SMTP id d9443c01a7336-2f0634667aaso35112375ad.0 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=CJePAwawp5oqHWdgSf8KuBYxBXowGQQqlo02upqD+LwyBqD1Bs/w4kEW/0C+nS1zuT e/RjR91uC/dQnchT3G6D0UjlpywFIqRaLL0Zuca4jy9A6QLb/lZYHKk+jtq/OUZuIiYe aqtZX/EbReovDJOzGj7UiABf/A3AxhfnY/METh2J8LdLWT/i5VoFjo98vVmzIJ6KUeDm iQ5KuYuoJFMEAI/CtGabAHkxGQrgQ2n0lSiweL+1ZLajgz7q9UVA6jdNvPUViUmxo6yK ZcZ+IuqrvBvqT3hYgc1um0AIg18/r88jDmmarUvrrN+dAiyTM8NJ32PozDexPUYA6uTL D1ww== X-Forwarded-Encrypted: i=1; AL+hErGTeEYldaSuTLZc8mIKCVTU0emcXDXlY5Fqi2K20y2YqCPMOe+/KyEbbdD/1wBkRzjTGs48e7E0pY0=@vger.kernel.org X-Gm-Message-State: APuU4Z/dbPURsbNb0bQbMX1tnEVVWWrJjhkO0MZIUzne1PHCFp/Vtmf0 pT+trFtF/XHA9Bs4qTIoLN1EyedGPYEky7U8rRNxJAJcPlBGc/g1VLK423JbiLBKyEs= X-Gm-Gg: AZFdTZf8hY76A1kxPrJiPvMBeGhVOXSZMDe+vMI3pOTZCT0WohRHMM+rkJnVUVMpZJ+ X7NNEngJIGx2gARYg3EZzsHDH6Mjux0hM+1wCsf4NRWacUg/5uf9NbUSuBxwODmwFW9UUwvLPHW R1v6bGjLs6FTdEVSjFqPNauiGoypiUL4/MbcnZT5DzjA41GRb/HRC0JuDtEHlWR//HjQFsNVzE9 ZlvbsJ69tcfOyFn+Pz+cxhNNpWRWbxa76AW/tocnIxK048saGZ4jOHHhHrCX7m9zcF6dDJv5N/z UQp3mWxrPTdQ7z1pM3ZliiFmrJkRPgZZ9CsGsvFujbrr8KOItyPV93X9RxvxlFuhhKuqXwViCAw ZQ1orJ4ksoKTpfgxtktzN3w9uBo4uQEyPB7SdYgoVXE10vyewdqGq8+neNDuDoRuYZzMc0iXLxt /Lbn3NjcEt3KMdRHM0AVfHu5pf35KoBUBgFlFh0a7A6YXmza4Qpv4DiAmZmn/NiH/n6oPw/Yntg Tk5JwcpmZcX6almR1FXLCZ69cH2eLAZhCu7Yxs+a1608i6SD/K8y+rHyIsFuvmW9lTIvMJPW+Nd lzUDZ57u6w8GG6p5hIP7BeIQBlP9R3N3L5HaqUvfxs/F4XA7l+vQpn0zt9KsPE3U7Da/tmGfIb0 UAERRhhz6aAqIotOusFWUbpfg6HpGto0KP9zfiOHg8k2NCHmWORSEBO2WOE9Y6oLtteJnzSnAEx m/JBvXhX5ATTVk2nKI0wTwHw15Ug== 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-pci@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