Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1684300

[RFC 1/2] x86: mark target address as output in 'insb' asm

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [RFC 1/2] x86: mark target address as output in 'insb' asm
Date 2017-07-10 16:50 +0200
Message-ID <u1IaB-6eJ-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The -Wmaybe-uninitialized warning triggers for one driver using the output
of the 'insb' I/O helper on x86:

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]

Apparently the assember constraints are slightly off here, as marking the
'addr' argument as a memory output seems appropriate here and gets rid
of the warning. For consistency I'm also adding it as input for outsb().

Unfortunately, this fix triggers another problem when CONFIG_KASAN is
set, again only in this one driver:

drivers/net/wireless/wl3501_cs.c: In function 'wl3501_rx_interrupt':
drivers/net/wireless/wl3501_cs.c:1103:1: error: the frame size of 2232 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

I'm not an x86 person and gcc inline assembly mystifies me all the time,
so please review this carefully and suggest a better way if this is not
how it should be done.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 7afb0e2f07f4..d107251eabd9 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), "m" (addr));\
 }									\
 									\
 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), "=m" (addr) : "d"(port));\
 }
 
 BUILDIO(b, b, char)
-- 
2.9.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[RFC 1/2] x86: mark target address as output in 'insb' asm Arnd Bergmann <arnd@arndb.de> - 2017-07-10 16:50 +0200
  [RFC 2/2] wl3501_cs: reduce stack size for KASAN Arnd Bergmann <arnd@arndb.de> - 2017-07-10 16:50 +0200
  [tip:x86/urgent] x86/io: Mark target address as output in 'insb()'  asm tip-bot for Arnd Bergmann <tipbot@zytor.com> - 2017-07-12 15:20 +0200
    Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-12 19:00 +0200
      Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Ingo Molnar <mingo@kernel.org> - 2017-07-12 21:30 +0200
      Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Arnd Bergmann <arnd@arndb.de> - 2017-07-12 23:50 +0200
        Re: [tip:x86/urgent] x86/io: Mark target address as output in  'insb()' asm Linus Torvalds <torvalds@linux-foundation.org> - 2017-07-13 00:50 +0200

csiph-web