From patchwork Wed Oct 31 13:57:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 149816 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6826796ljp; Wed, 31 Oct 2018 06:57:45 -0700 (PDT) X-Received: by 2002:a9f:35a2:: with SMTP id t31mr1343105uad.98.1540994265002; Wed, 31 Oct 2018 06:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540994264; cv=none; d=google.com; s=arc-20160816; b=OA4rh2INjR8eXrjLtBxHoh8WRCY/p3z7d9fAofWlgFU/vi4Ty6cJGnY5WthUNt1r90 S4ia2YKGMUcQxnRoFGAZ3fWpVCKyZ2n9YdYgtXTrhqIUk81UR+Ve+wvz3MCMaOX5uLx8 s2bFyUJqBAd103WMIxMASmSUTmALo+h+d0coces7TAYCQu5v18dbYPTppuK21B9KgITu ICRwlMNCHuxssJIV6Pv58+8erBDZ5UCtkcGa9AEBpp63FZexhUfeegTbz6rhZZx7YCNS SQFg3ao35XzlzRa4/cRl83GqdRIwp+vR78RrVWPDEw/nim1CTbdYQaQxX1lbfk6TWjF+ 5Qyw== 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=ooCq3zDEQFNaEs3SH2OOgctB7upQfBN8UmRyJCq4nuI=; b=mhxwLSCyazAwoec1/D0ZeK0l8bCaDibD6EM7LMK+jgJMcW4+UFNHYlz+pyhpcmg4jZ R4bPbs8O0OnG8o/DRJlzy8+PLi0lqXLXD4mTVMpuEBNzJKVBa7Y/bcW6u158+kIdH6rX D2q53EIeDC76XSFRmkZMD5nXrWdL/Rvvo5DIZgdMPkKPBhOc723kRa9DDhkIAJ6w/0Ob oHFnVzAll5CKEbOtOavKh9DOWPXJWVxHRlwjUk6BUq/fBFLLh0zT+RjzYLk/UypWdEso 4oQiIoY3QDUH81RoyhwEl5h/H2brG1AIPeMXr9pC8/Wt749ycRR1zJOg0XP7kODL8NMD hBIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kg3GTWkV; 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 w85sor13446456vkw.43.2018.10.31.06.57.44 for (Google Transport Security); Wed, 31 Oct 2018 06:57:44 -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=kg3GTWkV; 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=ooCq3zDEQFNaEs3SH2OOgctB7upQfBN8UmRyJCq4nuI=; b=kg3GTWkVVZIphm7ikY4C0s4xkWmXos8YxpDT03bPTTuvOj/cbwfwLhVeuQ7mQUmrBf Sw47XjfIxhfgU3IrkVezLY9OJIYkDhddYrhLXw1xsjRaMdfeWhoZvBL8kLoytlKCjHSn w8mCNxLP70KmL3B2tBdgtcKzmUZpYlv+16yk8= 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=ooCq3zDEQFNaEs3SH2OOgctB7upQfBN8UmRyJCq4nuI=; b=aWz8LpBB3SJyBguAUmi6hfYvSt4w7CmsaYM3ZegKnZ2Tx8cXviGHiTp0ujiW4iNPUG O+hyF9R4zTxFTaZ1/T7PrRpotTkE1udLFMRxFuHGgaVUL0IH6DRUy11g1FsulOaAmwSa wbsUCgNH7kud+TzLohEHbu3XRFbe/I79hi7dy599Txk94LBZGucnBV7rtY5QKwLPBvfG AacO9vVH6q6I1v5ZyPaJSskli7lJoDfln00zXWBbONjiuejO/7DGdgNgnLgG0xHLM2dQ 7+F0y6wiv3iPPVR4XRb9JK+R9la2yCA6uosMq1n0tQo/oTiLpKW5/ctD6NX+t0xjU9vm BO6g== X-Gm-Message-State: AGRZ1gJhummnEaU+ysgU8RcYfAgxLBOxtgZzJiODk9tlR201pSW6E/mP cRqEmQ0znWbZ9V7LxQVBzmaFaUfAmER68Q== X-Google-Smtp-Source: AJdET5fG+Ffp9uVDC83vUPAj6PBxtEHgHliar2Ne9qVch13Bk/d0yQucTQqRfKAhNahxj1+3s0AkNQ== X-Received: by 2002:a1f:c3c5:: with SMTP id t188-v6mr1362969vkf.67.1540994264378; Wed, 31 Oct 2018 06:57:44 -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 s85-v6sm2275624vse.29.2018.10.31.06.57.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:57:43 -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.9 22/24] ARM: use __inttype() in get_user() Date: Wed, 31 Oct 2018 09:57:11 -0400 Message-Id: <20181031135713.2873-23-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031135713.2873-1-dave.long@linaro.org> References: <20181031135713.2873-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 b7e0125c0bbf..4a61f36c7397 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -114,6 +114,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 @@ -183,7 +190,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(); \