Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4472765imm; Mon, 15 Oct 2018 15:44:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV638LjjZxx8+bvW/1LMSqcti4u7GkIlYXOWjB7XZ0DVrrxVVZmTZk5odynllpo/8kYPYUl/A X-Received: by 2002:a63:5d55:: with SMTP id o21-v6mr17511263pgm.349.1539643462353; Mon, 15 Oct 2018 15:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539643462; cv=none; d=google.com; s=arc-20160816; b=Cd3WWjo8LcG+ywQ4a7D2/0Ruvs35xaNfrbFnMTqXau4poujLnCec+x72hIAiNG3i88 5fs6YY6jgW/zpCJr7bWwo1sTAWq9EWLkjmDG0UksbuW4PN9g+q8iKBTfbx0cAp+dUabr hfwtsACo3sk/ujiU6qC94VVC5XgGQdkBxr6j+ggCH3CjwbxYQDFuCsRxaivO3Zyw/8jE 0kpIWCoRZav0oGLNV8Kt1JFML/rsOWGwsSh7+ahSO0MZv094bD+NaQiSbBb4TArDPtnZ PI6IoVRotUs+4Rs+5SyFrekoeLrkYeWUOFHD5wnxpd4rxaJugq3RLNKr0v3uTSy9+qHo klLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/xN8gvolZSt9XZH/fTRxQwXggm0vjh7GSB6UdPyIbqg=; b=gYmhiXrIgUb3anXKVsM2oykhZkENoXZVeD/VsLPIBFL4DE1H9gqWLDxHPhK9Yi/bax yU8UWNq7kxoH7rCA48UaY4Paf2vuX6uwkoAw7iDDwK7ockdN6KmdRvdfn3OwPNfZBSl7 q378a+OdfGZfZpKqMeU2XaAz2VKfEeOT8gKIqCjJisJj58gEARCNL5U5+W89/Xf2xerb 3XHMsLobxw+F0OnE2cJg8dciNAl6VsI/va57tqQOI3KSI91ASOKFf2pAIzEn1jpGobjk 8R//YUEwj/J2LJuLXPZD/aI1yBXcyR8p8rcmnrLGdMLQIU4EAdYwyjHASsesazbU6G0I OuzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=mm8AbrUF; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5-v6si11711857pln.232.2018.10.15.15.44.06; Mon, 15 Oct 2018 15:44:22 -0700 (PDT) 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=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=mm8AbrUF; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbeJPG3W (ORCPT + 99 others); Tue, 16 Oct 2018 02:29:22 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:48222 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbeJPG3V (ORCPT ); Tue, 16 Oct 2018 02:29:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/xN8gvolZSt9XZH/fTRxQwXggm0vjh7GSB6UdPyIbqg=; b=mm8AbrUFrR3RNMqtR0nbjKVkJ Mv1bj06WopPXu9VKRK3VLaayxLrINb0VBszD+vTemd/jMMHPTVQPN6IP6yAxquLpuzuXkB3378H7K 6r57O0tf5/GiYKvArpTYLe9nD61TXNGoT9eWubLP9UoQSapzW/sLXnRhs2W85NVVTOLLs=; Received: from n2100.armlinux.org.uk ([fd8f:7570:feb6:1:214:fdff:fe10:4f86]:44238) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gCBYi-00036J-RP; Mon, 15 Oct 2018 23:41:57 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gCBYf-0007x0-Qx; Mon, 15 Oct 2018 23:41:53 +0100 Date: Mon, 15 Oct 2018 23:41:52 +0100 From: Russell King - ARM Linux To: Nicolas Pitre Cc: Stefan Agner , ulli.kroll@googlemail.com, joel@jms.id.au, arnd@arndb.de, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] ARM: copypage: do not use naked functions Message-ID: <20181015224152.GA30658@n2100.armlinux.org.uk> References: <20181015222621.14673-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 15, 2018 at 06:35:33PM -0400, Nicolas Pitre wrote: > On Tue, 16 Oct 2018, Stefan Agner wrote: > > > GCC documentation says naked functions should only use basic ASM > > syntax. The extended ASM or mixture of basic ASM and "C" code is > > not guaranteed. Currently it seems to work though. > > > > Furthermore with Clang using parameters in extended asm in a > > naked function is not supported: > > arch/arm/mm/copypage-v4wb.c:47:9: error: parameter references not > > allowed in naked functions > > : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE / 64)); > > ^ > > > > Use a regular function to be more portable. Also use volatile asm > > to avoid unsolicited optimizations. > > > > Tested with qemu versatileab machine and versatile_defconfig and > > qemu mainstone machine using pxa_defconfig compiled with GCC 7.2.1 > > and Clang 7.0. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/90 > > Reported-by: Joel Stanley > > Signed-off-by: Stefan Agner > > --- > > arch/arm/mm/copypage-fa.c | 17 +++++++++++------ > > arch/arm/mm/copypage-feroceon.c | 17 +++++++++++------ > > arch/arm/mm/copypage-v4mc.c | 14 +++++++++----- > > arch/arm/mm/copypage-v4wb.c | 17 +++++++++++------ > > arch/arm/mm/copypage-v4wt.c | 17 +++++++++++------ > > arch/arm/mm/copypage-xsc3.c | 17 +++++++++++------ > > arch/arm/mm/copypage-xscale.c | 13 ++++++++----- > > 7 files changed, 72 insertions(+), 40 deletions(-) > > > > diff --git a/arch/arm/mm/copypage-fa.c b/arch/arm/mm/copypage-fa.c > > index ec6501308c60..33ccd396bf99 100644 > > --- a/arch/arm/mm/copypage-fa.c > > +++ b/arch/arm/mm/copypage-fa.c > > @@ -17,11 +17,16 @@ > > /* > > * Faraday optimised copy_user_page > > */ > > -static void __naked > > -fa_copy_user_page(void *kto, const void *kfrom) > > +static void fa_copy_user_page(void *kto, const void *kfrom) > > { > > - asm("\ > > - stmfd sp!, {r4, lr} @ 2\n\ > > + register void *r0 asm("r0") = kto; > > + register const void *r1 asm("r1") = kfrom; > > + > > + asm( > > + __asmeq("%0", "r0") > > + __asmeq("%1", "r1") > > + "\ > > + stmfd sp!, {r4} @ 2\n\ > > mov r2, %2 @ 1\n\ > > 1: ldmia r1!, {r3, r4, ip, lr} @ 4\n\ > > stmia r0, {r3, r4, ip, lr} @ 4\n\ > > @@ -34,9 +39,9 @@ fa_copy_user_page(void *kto, const void *kfrom) > > subs r2, r2, #1 @ 1\n\ > > bne 1b @ 1\n\ > > mcr p15, 0, r2, c7, c10, 4 @ 1 drain WB\n\ > > - ldmfd sp!, {r4, pc} @ 3" > > + ldmfd sp!, {r4} @ 3" > > : > > - : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE / 32)); > > + : "r" (r0), "r" (r1), "I" (PAGE_SIZE / 32)); > > This is still wrong as you list r0 and r1 in the input operand list > where they must remain constant but the code does modify them. You > should list them in the output operand list with the "&" attribute. Also > r2 should be listed in the clobbered list. Either we keep these as naked functions (and, if Clang wants to try to inline naked functions which makes no sense, also mark them as noinline) or we make them proper functions and also add (eg) r4 to the clobber list and get rid of the stacking of that register along with LR/PC. Having this half-way house which will generate worse code is not acceptable. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up