Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753958AbdGSMz4 (ORCPT ); Wed, 19 Jul 2017 08:55:56 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:50749 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753906AbdGSMzw (ORCPT ); Wed, 19 Jul 2017 08:55:52 -0400 From: Arnd Bergmann To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Borislav Petkov , Tom Lendacky Subject: [PATCH 4/8] x86: io: add "memory" clobber to insb/insw/insl/outsb/outsw/outsl Date: Wed, 19 Jul 2017 14:53:02 +0200 Message-Id: <20170719125310.2487451-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170719125310.2487451-1-arnd@arndb.de> References: <20170719125310.2487451-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:yEz02GrQ1NDRLU/SmQL+qhi2PiriwIo3dbrOrX7v6VfvQIlcs63 y63eoVWQkC0JmC4OgfasgfZGYJnjs5vLxlSVmdTRP+tU+LuT0i7Ej5IUk2LtGEhfIYFKzII Z9Xxrf6NQq198NDK5zg6GjJT4mBUtMx8jYXoNc3hgSTnC29G60xXz9mPCJ6W55c09jGHRNR OkiRgGQJ1fCvJ9p4aVjvQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:DCgrFFUjmT0=:1Tfc+4P+o1iEn5+aMdPJyj q9Zu5RqDIlUqieh6xRJmjNmvDKImh3ZzM46/sXoImJTmPwbdv6SopQEWt4lcOp4iO0vRbM8/B AGz10xXjYbYkPFtC4gk4xC3GbHveZjQXtWPtnQ0h2g3Zx8CoEeUvL6bmYMpZURNCXpTo8khWN JyqmRfG8+sZ9bgloOtT/4isi/druYcENFjnEMJipVrqRJKGyyXS8Ya13gQZebaYRtDP2ysGbK lhbq1NZ9d0uBFTwbt6/pqv0bcFMINoCl9iPyefggAcW6d7pO1zLiX9iSKyjTAsfsrd0m4uK4z IjPQXTmO5iG4l/VkcmDS5bNWcjTBYrO+5Yil6N5KwEtPuVeaROpKfDvBdPiqHRmOjBknsHsih F7AH79ypjTe2xUW6Y6QNJk8k+/XIai6PaNyhB7d5bQ3+MgWrLdzBYMETjsqhXQ1qn75iUM/LD +ujwN444LYoZagOVt0Sg7WoPomoFGHdpy8tx8k5YcxorcAd2Usw/oYX/apNEGFtuZksgM73Te 4PVir+YMuYuQAcIW4Rh+DaW8DZ43cm7CKI4OSzBteUtMb/7/LXstenr8FWtp7Aw7AoZ+9Kb4J zccvSAAekPP3CXFDJSmYsQRI0KkTDsgriqOyG5B80CqYLJLN9ujKHSEacYuDo/7z9vedFrsXu Npzg5GlHCDzFdlLYBBGLUB/6SgBzMugzpw8ObU9lm3XIPJ0U2Sm1h+uaQCJ/y1A867kEt4ZcD tfUBZMsAlu5tj4XSPc18pu5aO6dRKLfa58rw/nYQJZiY4ETJK+7S6nh/Q0k= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2542 Lines: 53 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 Signed-off-by: Arnd Bergmann --- 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