From patchwork Wed Nov 7 16:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 150437 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5387587ljp; Wed, 7 Nov 2018 08:44:31 -0800 (PST) X-Received: by 2002:ac8:7482:: with SMTP id v2-v6mr938687qtq.251.1541609071199; Wed, 07 Nov 2018 08:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541609071; cv=none; d=google.com; s=arc-20160816; b=Dnqi0G53YGh4nU2MuOhR52yiW2iIci59cian99NeLcpSwcjHfmTwR2nr67lh0kqwsT jxKgYp9O/Rwp1NvfKY78O2Dm/vTbeNCvvbt7H5KIZq26WWnAo9ZJhDTDCA8XOdp3AGar hOhXMnKpGqx8U9m7vW5HNZvXVoKiiuoQG/F/ah3p5i5XctuFD7Jlud+OH5aHne7KysWN NflvWC7mYiRxvNu8xsi+CNSSmE1ARyog1soM0POiTLaVvEF0zPtf7E1ZXSWizpMO9jC3 iFS5SGzD4Lwcq+/qM9Ffe5oetIaAamVGxXNkmwzpBVV3P52MXFvkNrmLhZzrrqi3qxcy cU+w== 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=X1tHaIphIoSMhJ9i1LmaCgI0zRbcYWnWhvuhNa7dILYpcVajw8s+niqkBZ9S+qCgiq UoM01o8wTvodq2VEInekG3xIydma179ChTOdS7x1oUMTvbAGUM62eV2eDDan8j8a/N2l ZTIEnrrlmB/SDV4bpCwMXz1plF+78CjUBwgOKegcD6HU2iO5rNtyLcHXznV8CAYcU1NN 8IZufhD6mpQv3qKn1cJ3KHuK84BprCV6Bk2zi4ZC99K5zaRfdlF7taV1+jvMZxJHMu8g AdBbz/1yBeDzWDMO/Agj+W8njepDx6t8zZPFzZuE7EyIY2tCQhETwFXGvVuJeQbajsdV rH7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KAJFN1bC; 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 g9sor1222738qvm.22.2018.11.07.08.44.31 for (Google Transport Security); Wed, 07 Nov 2018 08:44:31 -0800 (PST) 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=KAJFN1bC; 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=KAJFN1bCs9gUESqXlBJ7/0XFlaxDQMW9E+2xAnbWWpW9hEuxlcDbc594E1Db/zTkRs 6r9KbZTPhPPxnX+DyPoxiWjDG7WZuS/aCnCzHNxcspnW9QvBi+vFWj+fMa47eoGlVX6h k7AWoy+Ssv3dVdmm+zIcmZf4Q350PpykpkgUk= 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=YE7Smdwxo5czs/QfX/Anor20Y/VhvCUDzpmxqjAW3CqG15tt9xMgDt1bEVoUEzLO5n Rng5AWfJJnIIzFKRQ1Iq1/rdfXogqyLXmYp6nbyQ9FZlkImf4Cbj165sc/6e/MLWnkCY vpYasU0jdiCknRJCno145EE6erRyYaCWxrTGu5fidHsamoeyN0I30WUNhOdxzrdTCNEU 0yHle1YFXBxTeZRDdH4uLhoqLwkeeb1dUqUcxywdAI2ei7lqEhEQ8OB+GTHlbaej31ui HErsCQIDgUV/dbSOA5r8NGRkn/pPVslxQirj1xIVddp6oOgY0NSMuHC0qa20VKwv7AaB /1Gg== X-Gm-Message-State: AGRZ1gIs3yCrthA0Hk4LwMNKH7EOrHhZ4/w3G9exJVvSC3EvTem2c6V8 bDWFGlP/uDJK7ko/Ic/hLKmhs39m X-Google-Smtp-Source: AJdET5cBZCUThr7/V5qQL599fNwxPzbuklul7M1j5gIFeMpTuPvcvJYc7kqnjRUuW/FIVlwJc3WSjg== X-Received: by 2002:a0c:b509:: with SMTP id d9-v6mr1012604qve.184.1541609070640; Wed, 07 Nov 2018 08:44:30 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id 96-v6sm681817qtc.56.2018.11.07.08.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 08:44:30 -0800 (PST) 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 V2 22/24] ARM: use __inttype() in get_user() Date: Wed, 7 Nov 2018 11:44:00 -0500 Message-Id: <20181107164402.9380-23-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181107164402.9380-1-dave.long@linaro.org> References: <20181107164402.9380-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(); \