From patchwork Wed Oct 31 14:04:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 149835 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6836467ljp; Wed, 31 Oct 2018 07:05:05 -0700 (PDT) X-Received: by 2002:a67:d309:: with SMTP id a9mr1322857vsj.229.1540994705198; Wed, 31 Oct 2018 07:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540994705; cv=none; d=google.com; s=arc-20160816; b=jJle+wGKJCe4Htm6h1IB6PYDJM6BLn4wouzmegGm+1Gfj+BXjT8s3sczMhd20cLSLw 7dtr1Fcu9ZQEkJ1hh+Rcyh9mmGAOjDkrYCD/5gNMhT/Z+nj7uJVURjpjsZttl5KVsvdn Dx7fS9sAE/NwBQ9qgean/0nhxt5W4A83hjAdY3s4ty9unlROoc4C6RY+njqw/W7s8Scn ac2WAvZVjkgIQYFlkUNRyHBkmYH9jbyJAMgFc0ZLjfnGpzRKgjvEFSI0sF9SUc5QCRvD n3yPr3GnLl4BzNHWD4lMYpfPy6wafuW/aYUIoI5F2UGt8f3Vsp7Hgd0Yi4oaF3Cvko4+ R0jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qFPA/Nuv5CvVFze52wqR0w87HvJAXZ36fXdUmDk6ygE=; b=q0nuZCWgh4D7LGy/Swxcjy2vvRj1a0Dv1lQwUJHsAYoTuoIIAwnQfCYsqfNappRTij 1mg0HTOAfbSXgSMmwSP9XrvxtWTkeNp2wMv3Dnj8JcQ15iubpOG3Sl4UCNi1PtcidJv6 Df73SIhFSlikypB2AdNP8szS1hn2tCCug70LdyUpJXeoIyqEFLWa+PlhMyQXT/EXIz1o 1kojCY/NPcLGhwo7XlOElf2WHutKm1MDt8YVcMOmcy1YNPSNfp3RPp1BSDjFmkxJ/sjn ONfESh5KKeUXG0X7+A3ZqiSK2M9ZEpcxkRFSUh5Y5ctK/bGyZuMTQLrNHEwOFNTChhku a8Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JLMvTkIs; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g24sor16315848vso.35.2018.10.31.07.05.05 for (Google Transport Security); Wed, 31 Oct 2018 07:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JLMvTkIs; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qFPA/Nuv5CvVFze52wqR0w87HvJAXZ36fXdUmDk6ygE=; b=JLMvTkIs3NeQ4vAEGYGGP0sdtxddhixNcy86vSORYa7dazlhdiUY0Tr/+PVAMtxBAe 24U29dSA27MbBCv9h7HMh3N+teapTnVyW39FVKmZYbbLOwhHYrUVTY3+qXEO7WJmbMWe mLVWeD5NUQn7zJCLsxyYHdcflRx+QM1FjWLQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qFPA/Nuv5CvVFze52wqR0w87HvJAXZ36fXdUmDk6ygE=; b=uewopNyFxaOzlxYHAvRWaCuokkiKwSMFNsSrbOUcZ/ASJxzYxMvQ5AHN8YBcKYeA8+ OqSn7kfN6yu+Ir76T4Gqf20GmfhXwWgf7Qn2enRIX9ewlG81VuBRI+mCSCtxQBpY3T/4 i4EUDDBME2de0y87T3Wjufa/HuQvraD+niGmERGjB28zt4yX5dPkW14V2S7ni7ZDHg5e kLh1KPrn/c/9mOzoXyhrD3PCEjFd9CTpSbr5xVal2HCVIO9e5QmYW+cPXHdIunGBKolU H2qemFXfckX6sDvxSgBdmb3J0vX2aYCs327AJLCiX0tJVoJCkuscumdennMfMLNIGmZc HpPw== X-Gm-Message-State: AGRZ1gJtrViWdyjeZYCgN7nK5l1yApOcDxeXP+0KR2qxy3LwwWP1B2mt GBy7WTEJiTKqfmcu/Y+mSf6HzTpy X-Google-Smtp-Source: AJdET5eGncXJ/X6sDza2AAy6T3vVAqULuT8CvLhPD/Z3n5OTrV7IymavBnBfM8LbG2vn94xsicOkqA== X-Received: by 2002:a67:820f:: with SMTP id e15mr1345260vsd.156.1540994704538; Wed, 31 Oct 2018 07:05:04 -0700 (PDT) Return-Path: Received: from dave-Dell-System-XPS-L502X.hsd1.nh.comcast.net ([2603:3005:3403:7100:2c71:8680:34e1:a6aa]) by smtp.googlemail.com with ESMTPSA id 6sm6795632vsy.25.2018.10.31.07.05.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 07:05:03 -0700 (PDT) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.4 16/18] ARM: use __inttype() in get_user() Date: Wed, 31 Oct 2018 10:04:34 -0400 Message-Id: <20181031140436.2964-17-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031140436.2964-1-dave.long@linaro.org> References: <20181031140436.2964-1-dave.long@linaro.org> From: Russell King Commit d09fbb327d670737ab40fd8bbb0765ae06b8b739 upstream. Borrow the x86 implementation of __inttype() to use in get_user() to select an integer type suitable to temporarily hold the result value. This is necessary to avoid propagating the volatile nature of the result argument, which can cause the following warning: lib/iov_iter.c:413:5: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var] Acked-by: Mark Rutland Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/include/asm/uaccess.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index cd8b589111ba..968b50063431 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -122,6 +122,13 @@ static inline void set_fs(mm_segment_t fs) : "cc"); \ flag; }) +/* + * This is a type: either unsigned long, if the argument fits into + * that type, or otherwise unsigned long long. + */ +#define __inttype(x) \ + __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) + /* * Single-value transfer routines. They automatically use the right * size if we just have the right pointer type. Note that the functions @@ -191,7 +198,7 @@ extern int __get_user_64t_4(void *); ({ \ unsigned long __limit = current_thread_info()->addr_limit - 1; \ register const typeof(*(p)) __user *__p asm("r0") = (p);\ - register typeof(x) __r2 asm("r2"); \ + register __inttype(x) __r2 asm("r2"); \ register unsigned long __l asm("r1") = __limit; \ register int __e asm("r0"); \ unsigned int __ua_flags = uaccess_save_and_enable(); \