Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp862129ybj; Tue, 5 May 2020 08:42:35 -0700 (PDT) X-Google-Smtp-Source: APiQypLOEhK0BuqZfw9LX3oLWLJ3cItlARMDRYG+bX4/qARO7X0Ho9r/UNX4MZb4bCzy0yAEIq+g X-Received: by 2002:a17:906:edc2:: with SMTP id sb2mr3037615ejb.129.1588693355151; Tue, 05 May 2020 08:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588693355; cv=none; d=google.com; s=arc-20160816; b=Cr7rcf++nHjIt7yXyt8akv8/CpU23BOF9mcRbm45zFAlBYEh6owq2Xe7W4K1W8m2FQ fnoHmuDf4KF10+N/Vjoug8zQCU2QZKsY3En8ukbERqPQzs6dGPWvvJG2CbzlmqoYpHKM bFcXKfWM8hRF4blEWCvdR/EJUXDWG2v4DjErD2k0QhSA7Wa9/mCsuZtsmCGsEeREKZ8C OP3IyLc4O8iakISDVecYI6G/udwVjDrEVZiua7/82oilmX/K1ZZyUWYJM7k9LYY2Zhyc bA+famrNgwcz3Di1Cc8EyFIF61wFeW06BhNcK7Bwc6NT3+DW+4aUqBgQs231/tGZi9Yo heQw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=kx9pvZJwcWEP82ZYrkr/WOW1hxTcFiUoJnkPS6XqyQ8=; b=qX3o5sEHNn4FugEVMDINqxjlxpZ+cc4zEgEkzRG0gc19MvHMSNjvQFSnKWN6X+wTJJ Mzk9xVP2bDKk1fpkAJnC40JRVew08CbYxILdfarvxhc7Rq/8qKr5JmlKknYewAOOEb9L UWnIJfDk257ld0bMfAtb6+mewJlyRtEhfDt3wNtHJaPs318MfZBDL15TLIwO4Hi2W9F5 aNZqjhry4fPGcjffbqVutIs7dH6b39xhEVq06fRQoxPlYvNJjubs5TD+856/gFZCNQh6 dkgBFLWYAOu7W13VQ3Gdov7LKZsG4osUbsqX+tEPP2hvNGMLdUTrHDmTofJb81zc7kym SWXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si1262545ejh.303.2020.05.05.08.42.12; Tue, 05 May 2020 08:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730429AbgEEPk0 (ORCPT + 99 others); Tue, 5 May 2020 11:40:26 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:42653 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729317AbgEEPk0 (ORCPT ); Tue, 5 May 2020 11:40:26 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 49GkSk662Lz9v6ZJ; Tue, 5 May 2020 17:40:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id lB47a1rBtIIP; Tue, 5 May 2020 17:40:22 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 49GkSk5DfVz9v6ZG; Tue, 5 May 2020 17:40:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 69F418B7B3; Tue, 5 May 2020 17:40:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ZCQ8FQrSrO81; Tue, 5 May 2020 17:40:24 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E76B98B7A8; Tue, 5 May 2020 17:40:22 +0200 (CEST) Subject: Re: [PATCH v4 1/2] powerpc/uaccess: Implement unsafe_put_user() using 'asm goto' To: Michael Ellerman , Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , npiggin@gmail.com, segher@kernel.crashing.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <23e680624680a9a5405f4b88740d2596d4b17c26.1587143308.git.christophe.leroy@c-s.fr> <87sggecv81.fsf@mpe.ellerman.id.au> From: Christophe Leroy Message-ID: <1c6379b2-7e0a-91fe-34f0-51f5adca7929@csgroup.eu> Date: Tue, 5 May 2020 17:40:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <87sggecv81.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le 05/05/2020 à 16:27, Michael Ellerman a écrit : > Christophe Leroy writes: >> unsafe_put_user() is designed to take benefit of 'asm goto'. >> >> Instead of using the standard __put_user() approach and branch >> based on the returned error, use 'asm goto' and make the >> exception code branch directly to the error label. There is >> no code anymore in the fixup section. >> >> This change significantly simplifies functions using >> unsafe_put_user() >> > ... >> >> Signed-off-by: Christophe Leroy >> --- >> arch/powerpc/include/asm/uaccess.h | 61 +++++++++++++++++++++++++----- >> 1 file changed, 52 insertions(+), 9 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h >> index 9cc9c106ae2a..9365b59495a2 100644 >> --- a/arch/powerpc/include/asm/uaccess.h >> +++ b/arch/powerpc/include/asm/uaccess.h >> @@ -196,6 +193,52 @@ do { \ >> }) >> >> >> +#define __put_user_asm_goto(x, addr, label, op) \ >> + asm volatile goto( \ >> + "1: " op "%U1%X1 %0,%1 # put_user\n" \ >> + EX_TABLE(1b, %l2) \ >> + : \ >> + : "r" (x), "m<>" (*addr) \ > > The "m<>" here is breaking GCC 4.6.3, which we allegedly still support. > > Plain "m" works, how much does the "<>" affect code gen in practice? > > A quick diff here shows no difference from removing "<>". It was recommended by Segher, there has been some discussion about it on v1 of this patch, see https://patchwork.ozlabs.org/project/linuxppc-dev/patch/4fdc2aba6f5e51887d1cd0fee94be0989eada2cd.1586942312.git.christophe.leroy@c-s.fr/ As far as I understood that's mandatory on recent gcc to get the pre-update form of the instruction. With older versions "m" was doing the same, but not anymore. Should we ifdef the "m<>" or "m" based on GCC version ? Christophe