From: Michael Ellerman <mpe@ellerman•id.au>
To: Arnd Bergmann <arnd@kernel•org>
Cc: Nathan Chancellor <nathan@kernel•org>,
Anders Roxell <anders.roxell@linaro•org>,
Kees Cook <keescook@chromium•org>, Arnd Bergmann <arnd@arndb•de>,
Niklas Schnelle <schnelle@linux•ibm.com>,
Naresh Kamboju <naresh.kamboju@linaro•org>,
clang-built-linux <llvm@lists•linux.dev>,
Nick Desaulniers <ndesaulniers@google•com>,
linux-kernel@vger•kernel.org, Nicholas Piggin <npiggin@gmail•com>,
"Aneesh Kumar K . V" <aneesh.kumar@kernel•org>,
Jeff Xu <jeffxu@chromium•org>, Baoquan He <bhe@redhat•com>,
"Mike Rapoport \(IBM\)" <rppt@kernel•org>,
Justin Stitt <justinstitt@google•com>,
"Naveen N . Rao" <naveen.n.rao@linux•ibm.com>,
linuxppc-dev <linuxppc-dev@lists•ozlabs.org>,
Dan Carpenter <dan.carpenter@linaro•org>,
Bill Wendling <morbo@google•com>
Subject: Re: [PATCH] powerpc: drop port I/O helpers for CONFIG_HAS_IOPORT=n
Date: Thu, 18 Apr 2024 16:26:40 +1000 [thread overview]
Message-ID: <878r1bb2zj.fsf@mail.lhotse> (raw)
In-Reply-To: <20240416153331.1617772-1-arnd@kernel.org>
Arnd Bergmann <arnd@kernel•org> writes:
> From: Arnd Bergmann <arnd@arndb•de>
>
> Calling inb()/outb() on powerpc when CONFIG_PCI is disabled causes
> a NULL pointer dereference, which is bad for a number of reasons.
>
> After my patch to turn on -Werror in linux-next, this caused a
> compiler-time warning with clang:
>
> In file included from arch/powerpc/include/asm/io.h:672:
> arch/powerpc/include/asm/io-defs.h:43:1: error: performing pointer
> arithmetic on a null pointer has undefined behavior
> [-Werror,-Wnull-pointer-arithmetic]
> 43 | DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c),
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 44 | (p, b, c), pio, p)
> | ~~~~~~~~~~~~~~~~~~
>
> In this configuration, CONFIG_HAS_IOPORT is already disabled, and all
> drivers that use inb()/outb() should now depend on that (some patches are
> still in the process of getting marged).
>
> Hide all references to inb()/outb() in the powerpc code and the definitions
> when HAS_IOPORT is disabled to remove the possible NULL pointer access.
> The same should happin in asm-generic in the near future, but for now
> the empty inb() macros are still defined to ensure the generic version
> does not get pulled in.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb•de>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro•org>
> --
This needs a small fixup:
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 86c212fcbc0c..60c80d0baf40 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -692,6 +692,7 @@ static inline void name at \
#define writesw writesw
#define writesl writesl
+#ifdef CONFIG_HAS_IOPORT
#define inb inb
#define inw inw
#define inl inl
@@ -704,6 +705,8 @@ static inline void name at \
#define outsb outsb
#define outsw outsw
#define outsl outsl
+#endif // CONFIG_HAS_IOPORT
+
#ifdef __powerpc64__
#define readq readq
#define writeq writeq
I'm running it through some randconfig builds now.
cheers
next prev parent reply other threads:[~2024-04-18 6:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 15:33 [PATCH] powerpc: drop port I/O helpers for CONFIG_HAS_IOPORT=n Arnd Bergmann
2024-04-18 6:26 ` Michael Ellerman [this message]
2024-04-18 6:33 ` Michael Ellerman
2024-04-18 6:59 ` Arnd Bergmann
2024-04-18 13:01 ` Michael Ellerman
2024-04-19 5:12 ` Michael Ellerman
2024-04-19 5:58 ` Arnd Bergmann
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=878r1bb2zj.fsf@mail.lhotse \
--to=mpe@ellerman$(echo .)id.au \
--cc=anders.roxell@linaro$(echo .)org \
--cc=aneesh.kumar@kernel$(echo .)org \
--cc=arnd@arndb$(echo .)de \
--cc=arnd@kernel$(echo .)org \
--cc=bhe@redhat$(echo .)com \
--cc=dan.carpenter@linaro$(echo .)org \
--cc=jeffxu@chromium$(echo .)org \
--cc=justinstitt@google$(echo .)com \
--cc=keescook@chromium$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=llvm@lists$(echo .)linux.dev \
--cc=morbo@google$(echo .)com \
--cc=naresh.kamboju@linaro$(echo .)org \
--cc=nathan@kernel$(echo .)org \
--cc=naveen.n.rao@linux$(echo .)ibm.com \
--cc=ndesaulniers@google$(echo .)com \
--cc=npiggin@gmail$(echo .)com \
--cc=rppt@kernel$(echo .)org \
--cc=schnelle@linux$(echo .)ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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