linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "the arch/x86 maintainers" <x86@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>, Borislav Petkov <bp@suse.de>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 4/8] x86: io: add "memory" clobber to insb/insw/insl/outsb/outsw/outsl
Date: Wed, 19 Jul 2017 21:25:13 +0200	[thread overview]
Message-ID: <CAK8P3a1nLaaTEv8O9UnrwjxCF5NCn-6vJNrWKzq_riud0SjrHA@mail.gmail.com> (raw)
In-Reply-To: <20170719125310.2487451-5-arnd@arndb.de>

[adding Linus to Cc, apparently git send-email ignores the Suggested-by
tag for the cc-list]

On Wed, Jul 19, 2017 at 2:53 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> The x86 version of insb/insw/insl uses an inline assembly that does
> not have the target buffer listed as an output. This can confuse
> the compiler, leading it to think that a subsequent access of the
> buffer is uninitialized:
>
> drivers/net/wireless/wl3501_cs.c: In function ‘wl3501_mgmt_scan_confirm’:
> drivers/net/wireless/wl3501_cs.c:665:9: error: ‘sig.status’ is used uninitialized in this function [-Werror=uninitialized]
> drivers/net/wireless/wl3501_cs.c:668:12: error: ‘sig.cap_info’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/net/sb1000.c: In function 'sb1000_rx':
> drivers/net/sb1000.c:775:9: error: 'st[0]' is used uninitialized in this function [-Werror=uninitialized]
> drivers/net/sb1000.c:776:10: error: 'st[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/net/sb1000.c:784:11: error: 'st[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> I tried to mark the exact input buffer as an output here, but couldn't
> figure it out. As suggested by Linus, marking all memory as clobbered
> however is good enough too. For the outs operations, I also add the
> memory clobber, to force the input to be written to local variables.
> This is probably already guaranteed by the "asm volatile", but it can't
> hurt to do this for symmetry.
>
> Link: https://lkml.org/lkml/2017/7/12/605
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: replace broken original RFC patch with one that probably works.
>     The crazy stack usage I reported in teh wl3501_cs driver with
>     my original patch is gone too now.
> ---
>  arch/x86/include/asm/io.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
> index e080a39b2108..4bc6f459a8b6 100644
> --- a/arch/x86/include/asm/io.h
> +++ b/arch/x86/include/asm/io.h
> @@ -328,13 +328,13 @@ static inline unsigned type in##bwl##_p(int port)                 \
>  static inline void outs##bwl(int port, const void *addr, unsigned long count) \
>  {                                                                      \
>         asm volatile("rep; outs" #bwl                                   \
> -                    : "+S"(addr), "+c"(count) : "d"(port));            \
> +                    : "+S"(addr), "+c"(count) : "d"(port) : "memory"); \
>  }                                                                      \
>                                                                         \
>  static inline void ins##bwl(int port, void *addr, unsigned long count) \
>  {                                                                      \
>         asm volatile("rep; ins" #bwl                                    \
> -                    : "+D"(addr), "+c"(count) : "d"(port));            \
> +                    : "+D"(addr), "+c"(count) : "d"(port) : "memory"); \
>  }
>
>  BUILDIO(b, b, char)
> --
> 2.9.0
>

  reply	other threads:[~2017-07-19 19:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-19 12:52 [PATCH 0/8] x86: randconfig warning fixes Arnd Bergmann
2017-07-19 12:52 ` [PATCH 1/8] perf/x86: shut up false-positive -Wmaybe-uninitialized warning Arnd Bergmann
2017-07-20 10:24   ` [tip:x86/urgent] perf/x86: Shut " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 2/8] x86: math-emu: possible uninitialized variable use Arnd Bergmann
2017-07-20 10:25   ` [tip:x86/urgent] x86/fpu/math-emu: Fix " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 3/8] x86: math-emu: avoid bogus -Wint-in-bool-context warning Arnd Bergmann
2017-07-20 10:25   ` [tip:x86/urgent] x86/fpu/math-emu: Avoid " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 4/8] x86: io: add "memory" clobber to insb/insw/insl/outsb/outsw/outsl Arnd Bergmann
2017-07-19 19:25   ` Arnd Bergmann [this message]
2017-07-19 19:46   ` Linus Torvalds
2017-07-20 10:25   ` [tip:x86/urgent] x86/io: Add " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 5/8] x86: silence build with "make -s" Arnd Bergmann
2017-07-20 10:26   ` [tip:x86/urgent] x86/build: Silence the " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 6/8] x86: add MULTIUSER dependency for KVM Arnd Bergmann
2017-07-19 14:11   ` Radim Krčmář
2017-07-19 14:18     ` Arnd Bergmann
2017-07-19 16:13       ` Radim Krčmář
2017-07-23 13:41         ` Paolo Bonzini
2017-07-19 12:53 ` [PATCH 7/8] x86: add PCI dependency for PUNIT_ATOM_DEBUG Arnd Bergmann
2017-07-20 10:26   ` [tip:x86/urgent] x86/platform: Add " tip-bot for Arnd Bergmann
2017-07-19 12:53 ` [PATCH 8/8] x86: intel-mid: fix a format string overflow warning Arnd Bergmann
2017-07-20 10:27   ` [tip:x86/urgent] x86/platform/intel-mid: Fix " tip-bot for 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=CAK8P3a1nLaaTEv8O9UnrwjxCF5NCn-6vJNrWKzq_riud0SjrHA@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).