Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp190466imu; Wed, 21 Nov 2018 17:56:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WnRrabr3oC8VsEP4ILJsx9gsQsCPxEZ4MZ0njW/wULGhQ/mj2wSG6FRV1oJ6M5k+XmvxV/ X-Received: by 2002:a63:cc43:: with SMTP id q3mr8078284pgi.291.1542851791357; Wed, 21 Nov 2018 17:56:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542851791; cv=none; d=google.com; s=arc-20160816; b=u2fjXcrzifUgJRyPg1GAPfY2gItuIyZ4rqkAcgpGPYbvWFakhZsgsucZFWvt0O4WK5 eEAzWC8kzCZ9JGf3bMf7i6UUO4ba3w1CCmEYP4KM5GQGTRZGZXTQDL+WfW+Lhk/Dh70s HF2nITtLkficZ6S1vzZHHT5/PlD9gyAv/aQUO7b+lP4DiYDYclvtcP29qUzrU3ojpkEo Nj1qKJmqan1ncN1vWM6PStUOgOFXr2Z1QNOJ3WFnUqk0AxJbUFExAQy5V4dxuDGUC+GA 353+sDRYw5wD8wgKocLcKAv0PzUkKvdZQQ+QJNukoT6+ANKQqCB/7UiIz+jDciP1Lpql poWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ojOXdCzgMMS/KNYi6S1UptJ738SgLEsFNODBGhxHmbM=; b=09kU0VvXMkxKVQ+fQybE3lb8vT0CTFdG0OseU47kDv1SM1iDRPkyThzm5TP6b+V0q/ DA0P78+oDaGvh/Gq8Q2wvSVql+Wsfbs33wNkgJtPwG8f7R2EoKNeEg5mPqbV2nEBr/gk si5UigSU7YoyAePNAb+yLmxpGLmLSO9UkfVYDQIIrRrLq4/ykbspZQgeP7zdhwv4GFI6 pTAQ32Pg4FAwEYpGK1NVJfOvhzS9ykj+OMBoaNHYCFZSj3qeyVst1vqA0NA9j5wK8x4n w6uqEtASd3XU9C14p0StpC15ztNOBX3W+5HR+EyXKTHl5IYCJ42AhyzQogT4oUXk2Ftk t38g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y8DTMIIX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17-v6si6299175pfa.227.2018.11.21.17.56.16; Wed, 21 Nov 2018 17:56:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y8DTMIIX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389165AbeKVFrf (ORCPT + 99 others); Thu, 22 Nov 2018 00:47:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:43152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389139AbeKVFre (ORCPT ); Thu, 22 Nov 2018 00:47:34 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F47D206BB; Wed, 21 Nov 2018 19:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542827520; bh=KbCNDhqeRC6lM8xuozkTYKQJsafE1Fm296pZ4vSZTr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8DTMIIXMzHPygA9J6IcDXMfk0ohrBkzRMrT/fcfGZnMS+OCfW2B8cZ7i5gylWwdv 5X/WeGi+ksWGW5YyIPqVkCQJVbIKBGe/m/Ixn6FkNYckYHMtfmBrz7YZcsdYlc048S DKeCuRDX7zD5RTYdgRroa+/mbbYOmGuuopv9Ar8A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Mark Rutland , Matthias Kaehlcke , Catalin Marinas , Nick Desaulniers Subject: [PATCH 4.9 35/59] arm64: uaccess: suppress spurious clang warning Date: Wed, 21 Nov 2018 20:06:50 +0100 Message-Id: <20181121183509.626442199@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121183508.262873520@linuxfoundation.org> References: <20181121183508.262873520@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland commit d135b8b5060ea91dd751ff172d179eb4eab1e966 upstream. Clang tries to warn when there's a mismatch between an operand's size, and the size of the register it is held in, as this may indicate a bug. Specifically, clang warns when the operand's type is less than 64 bits wide, and the register is used unqualified (i.e. %N rather than %xN or %wN). Unfortunately clang can generate these warnings for unreachable code. For example, for code like: do { \ typeof(*(ptr)) __v = (v); \ switch(sizeof(*(ptr))) { \ case 1: \ // assume __v is 1 byte wide \ asm ("{op}b %w0" : : "r" (v)); \ break; \ case 8: \ // assume __v is 8 bytes wide \ asm ("{op} %0" : : "r" (v)); \ break; \ } while (0) ... if op() were passed a char value and pointer to char, clang may produce a warning for the unreachable case where sizeof(*(ptr)) is 8. For the same reasons, clang produces warnings when __put_user_err() is used for types that are less than 64 bits wide. We could avoid this with a cast to a fixed-width type in each of the cases. However, GCC will then warn that pointer types are being cast to mismatched integer sizes (in unreachable paths). Another option would be to use the same union trickery as we do for __smp_store_release() and __smp_load_acquire(), but this is fairly invasive. Instead, this patch suppresses the clang warning by using an x modifier in the assembly for the 8 byte case of __put_user_err(). No additional work is necessary as the value has been cast to typeof(*(ptr)), so the compiler will have performed any necessary extension for the reachable case. For consistency, __get_user_err() is also updated to use the x modifier for its 8 byte case. Acked-by: Will Deacon Signed-off-by: Mark Rutland Reported-by: Matthias Kaehlcke Signed-off-by: Catalin Marinas Signed-off-by: Nick Desaulniers Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -198,7 +198,7 @@ do { \ (err), ARM64_HAS_UAO); \ break; \ case 8: \ - __get_user_asm("ldr", "ldtr", "%", __gu_val, (ptr), \ + __get_user_asm("ldr", "ldtr", "%x", __gu_val, (ptr), \ (err), ARM64_HAS_UAO); \ break; \ default: \ @@ -272,7 +272,7 @@ do { \ (err), ARM64_HAS_UAO); \ break; \ case 8: \ - __put_user_asm("str", "sttr", "%", __pu_val, (ptr), \ + __put_user_asm("str", "sttr", "%x", __pu_val, (ptr), \ (err), ARM64_HAS_UAO); \ break; \ default: \