From patchwork Mon Oct 15 15:32:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 148872 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3934124lji; Mon, 15 Oct 2018 08:32:44 -0700 (PDT) X-Received: by 2002:a37:cfc7:: with SMTP id v68-v6mr16386099qkl.35.1539617564870; Mon, 15 Oct 2018 08:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617564; cv=none; d=google.com; s=arc-20160816; b=j7LOHBWpwsnOE+lXE4hyo8FppPY7zwk5AX3CZj82yD/4tA6pPfpKp9LFWKIxlgg7J9 48Bhc/iLnwlh0wu9NTudO/3kiz1x4CO/58vU5b7U2oVusnQZ1+R/C/YljavBLMLUIkwU il9xI2ybJ7pfQBaV4ToRE0hAp55p5ILvsnW9km6XTmzFljtcHn+JT1BMZii9iqVc7Maw j3aIdFgZ0UH2q8vobFLHtEYUFOjsQ1npvZS6xwf1KffolgtDjfXV64RbYEd7XEXqMWLJ Z4iXpdiv3GYwehbOzCxToovPtXpZXiNwmXyeUALe3MYjNEVJKBbkB+SW1SniVQutApr4 PVMA== 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=eIwJIocQo8va5lpAwcQJo6X+9iu1+obJxDFLeyPtjSM=; b=R6ZixCiuCep4pHLByyxudRscc2sF2UYxjdHXkQ4Z+raHhnZqIJAj7b7aDusdfGRWDL lxZu0vV9NAs9wpc/Y06zV3UvoCiphvUqJeK9t63Tgccirp6Hm9tJuPqtOtwYKPoyeYp3 7yb9g9amQqDyH6Z5M9qXbIGFMRJ04sUUTPL4Z1LqPIurzuqF2GFgIzwUvXjTa5gjvrFB pO8lhPkJr0LRiynUvG2lakYECTzIJJt9hJQUqUymttkqsZvHGEQhr2xUDWnFEZjVzzUi EPVJR7STQWrjXXfuu7TggCH7M+X/ZEqvkQbD9zFkM/Nw6lcARSLkDfE7BSSFCzN2gZvg t3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q62PTFSv; 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 w20-v6sor12582362qtj.37.2018.10.15.08.32.44 for (Google Transport Security); Mon, 15 Oct 2018 08:32: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=Q62PTFSv; 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=eIwJIocQo8va5lpAwcQJo6X+9iu1+obJxDFLeyPtjSM=; b=Q62PTFSvOJBC4fXit01yZqldYdMbhZYSxiZVlNmbIU2oP/9mW3K5/m4iyKRRzEuN8+ QDJPV2zmG3v3UUbDhH9HM3TT4woEzkry3CE5d2JVd5B+NCH2LT+mLgI2rxkoOPXateQ5 /NCkmmcUrEc6Ty2MC9m6VqVQf6STuWdkX++7I= 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=eIwJIocQo8va5lpAwcQJo6X+9iu1+obJxDFLeyPtjSM=; b=KtiJTZlg94774UpH100mmyrLKrwmz5sxrJFr4XD9sr0I8OhSMjfBcLO21ZY4drNnJL clTWNkoiOhI7Q32/WDTewhB9/S6nhXj38H0owOmYI0qybe8gSSKJDZpQVVkXh9bvaMgG eXpUObkPBvyLAO5+k6iuKETn/ZqlSoziXToeHQCH6rqDppG/Q3uoZ5AWd7YA26xh9IQq LsCJGamp2xFW5Q1hincCp6owTkjAn4mIlfZVBZztc8ZxTj1sohBA2hZ9TkQsQcnUVDOY GdCuzFpTGuPBH7Hz/A0zmejQfQLxy1DhjR7kGMKvOT/6lnn2xr0QnnN3vE49LsiRWm0t 25VA== X-Gm-Message-State: ABuFfogQ7vW8Yrv2Hos7pa3crd4kunXAUlvhWlwdv3dvvhvduGOyMDgp HEuA2zOLYC4+B/SgmCBpTJ3e6oI8 X-Google-Smtp-Source: ACcGV63Td2IpmfTA0lHKuiaH+lAQDPHK1TJ5Z/VmeoIGP7HGaHvgM+A1tXV/eK1VPv8kSKCcgo1UvQ== X-Received: by 2002:ac8:1af4:: with SMTP id h49-v6mr16375899qtk.258.1539617564485; Mon, 15 Oct 2018 08:32:44 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([72.71.243.63]) by smtp.googlemail.com with ESMTPSA id g82-v6sm10087768qkh.24.2018.10.15.08.32.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 08:32:44 -0700 (PDT) From: David Long To: , Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 22/24] ARM: use __inttype() in get_user() Date: Mon, 15 Oct 2018 11:32:16 -0400 Message-Id: <1539617538-22328-23-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1539617538-22328-1-git-send-email-dave.long@linaro.org> References: <1539617538-22328-1-git-send-email-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.5.0 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 0bf2347..29fa6f3 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -85,6 +85,13 @@ static inline void set_fs(mm_segment_t fs) 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 * which read from user space (*get_*) need to take care not to leak @@ -153,7 +160,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(); \