Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5685011rwb; Mon, 5 Dec 2022 02:39:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rXy6D4pkCDNj7h7tqz3rVkdSfBLNV3k9XJTCk3D/lik+FmeMekWZ2fydytBBRuUOVZtQ5 X-Received: by 2002:a17:902:bc4a:b0:189:6795:d945 with SMTP id t10-20020a170902bc4a00b001896795d945mr47763697plz.136.1670236771235; Mon, 05 Dec 2022 02:39:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670236771; cv=none; d=google.com; s=arc-20160816; b=SUxunGivJXwczhXA/NQOO0dF9i+f6WvB2RpneTICPPx4CBvQeIJkYDLIkgaepRdlRo 7caGLlxmEYkCyfjKqL3Gdv1jpoKqwgRr1Jz3WAFSyPQXCbba4BJzxC8x4u1iAmVSxVyL dJrAUJYl2bAbCengHQSdiSy68nG4SkkRNbtT5d38gCuqWG7EPj9d5i623AQxsGFJo22i kK4pRC1RbPs4RHs4VedCZ3z4IEtI95qpOlDuvDNAR2klgQgfoRzstQm3Xvn7MhHWygzM zrGyZQJ+ETa8yvwM6qkHmYi0eQckLWoTkw3k4k5JRJQO6bHvaSU+TymR0bfnJUun3sMH A7Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=MRVUFL54lNZS7+NYJKrB4wUaNpwj6xU2cIPBiaS9V9Q=; b=lxs+SeCksyEV9XshK/xi2baYseG2th9gXryWoOBK8ANVCJM612BUN82dcAiIhAcjp/ UWZovm5Y4YVidOPmn7fNqp7+HcveCNabF9QBmwFb/RqS0r2jHKlQRSQePEdjui2tz7Q2 Ufdgr/ZXIQ3NnPdcfRBYkm4+f5cmmGX5k+byDB/lgGCzUekV4qbYiAY6i8pnjL4iffrq qAtaFwFZxGhd+paOph2utAWuHIxccI1wL77CfFVIKZZY2yy4gFaPKZd6QTnc3ZwuU/03 9AIWPQNV7GoBRCUnpwjS28Jba9VE0IKlBSZ/UbJFQ5AweSkqVAB3DX8xPDFneNz27iQW n4Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=Cbt8VWFr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=o79jNTYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170902e2ca00b00189c8b6e603si5400979plc.583.2022.12.05.02.39.20; Mon, 05 Dec 2022 02:39:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=Cbt8VWFr; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=o79jNTYw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbiLEKEa (ORCPT + 82 others); Mon, 5 Dec 2022 05:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbiLEKE2 (ORCPT ); Mon, 5 Dec 2022 05:04:28 -0500 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FFA91151; Mon, 5 Dec 2022 02:04:26 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id F23963200951; Mon, 5 Dec 2022 05:04:22 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Mon, 05 Dec 2022 05:04:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1670234662; x=1670321062; bh=MRVUFL54lN ZS7+NYJKrB4wUaNpwj6xU2cIPBiaS9V9Q=; b=Cbt8VWFrWRAdKMceDnYy3EPreW ox25Ctgw7ZTObiHEnDtyl0iWK6rQrrZvjjAqfoHh1yWnlEyzSN0ayOy3+pl0td1N M3q9uGJJfApXBLEyOjrIBKLZDkSZ1O+IUGIk+sG9/q9RAHdFoqPDZHGFTs4gTC3T e1GB9Cctn8KWzf6uw7U0dJG2q+0l7SdsjHxHel7y+NOx84aubCn9TKOdb8kkLjN3 GltIsCLti/PUAzJG86iZU0fSyl+WVz9edJlaRsAwmBgEFkdf0FcvjAmA7/gixYEZ a1A1eYB/28cGJy3qxWYzqhbIT0lPYtWde8pZETzoP92M+fX1mNZC4q85OXMQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1670234662; x=1670321062; bh=MRVUFL54lNZS7+NYJKrB4wUaNpwj 6xU2cIPBiaS9V9Q=; b=o79jNTYwp9sbOUDauYqMu4XA6yCsWEaJH1fzKisSIf5p 3OA1yZ5jBfGsyGVBaKwX7HG7xo1KSmclHa05RMt/W3wP3fI43m+ovYIM/5MHoF0S W6lwJ/p18zDbPP4Xy9mdeYEt47zChnItIRPlR8K5w3b72N33SPdReedrqU2FyQbl EspBUP0a0S/GpXmr/g14aSoUXyV1oNOrjJYDEKDcBFwq7N+J8rV7vVw2bnTSJX93 mw6gg+aS3IQjoMVBIVsfbV9rV3sDXbNEzg7xPsGT05XuXtBOnPh2s5qRttCRGAan qepv8aaOlNSzg4jbwDmRD6Mno1CGLoWa7Cs2ZlCKOg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudeggdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeevhfffledtgeehfeffhfdtgedvheejtdfgkeeuvefgudffteettdekkeeufeeh udenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 240B4B60086; Mon, 5 Dec 2022 05:04:22 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-Id: <2a3d3359-a5fd-453b-81f1-35c7a35fc12d@app.fastmail.com> In-Reply-To: <1670229006-4063-1-git-send-email-chensong_2000@189.cn> References: <1670229006-4063-1-git-send-email-chensong_2000@189.cn> Date: Mon, 05 Dec 2022 11:04:01 +0100 From: "Arnd Bergmann" To: "Song Chen" , "Steven Rostedt" , "Masami Hiramatsu" , "Niklas Schnelle" Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Linux-Arch Subject: Re: [PATCH v3 3/4] include/asm-generic/io.h: remove performing pointer arithmetic on a null pointer Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 5, 2022, at 09:30, Song Chen wrote: > kernel test robot reports below warnings: > > In file included from kernel/trace/trace_events_synth.c:18: > In file included from include/linux/trace_events.h:9: > In file included from include/linux/hardirq.h:11: > In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1: > In file included from include/asm-generic/hardirq.h:17: > In file included from include/linux/irq.h:20: > In file included from include/linux/io.h:13: > In file included from arch/hexagon/include/asm/io.h:334: > include/asm-generic/io.h:547:31: warning: performing pointer arithmetic > on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > val = __raw_readb(PCI_IOBASE + addr); > ~~~~~~~~~~ ^ > include/asm-generic/io.h:560:61: warning: performing pointer arithmetic > on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); > ~~~~~~~~~~ ^ > include/uapi/linux/byteorder/little_endian.h:37:51: note: > expanded from macro '__le16_to_cpu' > #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) > > The reason could be constant literal zero converted to any pointer type decays > into the null pointer constant. > > I'm not sure why those warnings are only triggered when building hexagon instead > of x86 or arm, but anyway, i found a work around: > > void *pci_iobase = PCI_IOBASE; > val = __raw_readb(pci_iobase + addr); > > The pointer is not evaluated at compile time, so the warnings are removed. > > Signed-off-by: Song Chen > Reported-by: kernel test robot The code is still wrong, you just hide the warning, so no, this is not a correct fix. When PCI_IOBASE is NULL, any call to inb() etc is a NULL pointer dereference that immediately crashes the kernel, so the correct solution is to not allow building code that uses port I/O on kernels that are configured not to support port I/O. We have discussed this bit multiple times, and Niklas Schnelle last posted his series to fix this as an RFC in [1]. Arnd [1] https://lore.kernel.org/lkml/20220429135108.2781579-1-schnelle@linux.ibm.com/