Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4458314imm; Mon, 15 Oct 2018 15:25:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV612ytUmSmDlmGIC+XXG/O4Og6TLE8eQd02eF+QM38X+9u14XCvGWfQfuwd4Co0yfbll36QS X-Received: by 2002:a17:902:70c3:: with SMTP id l3-v6mr19494204plt.125.1539642329643; Mon, 15 Oct 2018 15:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539642329; cv=none; d=google.com; s=arc-20160816; b=IlrjJrgwJ8V9koXwhXowR5bWMaJaD9F0vzrb8NKC38GNYNqPmL0hRduwTQtWT1VpIY EKAezHjZcr7gzKVC1eQvLfSmSIFCoAtHMcloVIfZiCgaBcoUf/KFQX7VWW2uOfoBQah8 atvxTLpMnYlJuCqVVBOI2+V86nKNLOKiCMQAR1yLdzVl5ER+BSY8WIBF16JDiDWDHO28 OC/gkQpydJeBfGWZG/EwslR18BrWbQhOM+Bd0qKk61jtpWV7lWflPubiau+DS1BFyqtU JV3k2wbibqfatXJl8jbEaS7HJBMlCdUmXtILhfW++mosw7yBW5r8IbqDizuop28hls+n 0+CQ== 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=SI69yfW0GAWg4TCAlrbh78ou5TZRrPG2qzsQPbYsRsQ=; b=XF2OWQ35j3J1qPVve5vUooIRd+JJkuEL3pi1e2WbblypLB2hcrYItpjqW3EkCeFZYg UZ8+Ag7Em845uY70h1dJC08fZQIrb38bFubxSEqvTz1wWU+EDj3Ub5LgTT71yj3PvLrT 9yNo4V6SKMv6yeJRsMlD2jTSxtQSAIJbDqlCRDZeysveB9SE8RlKW2OGpUqukBU25mk9 QVEzrtc+VTbLtuWJsdpf898MibnqqiTZ4/WNGPqRFJOL6kDcb6269dxYUM1K/CMKWG4d 3/r9A0yVufQGb71hmeDdMDYvakt2mSxK8vuNDAAy+EmyoELavyZUA+aJHrc5ekne89UR rL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=BXEy0zUK; 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 u15-v6si12547260pga.23.2018.10.15.15.25.13; Mon, 15 Oct 2018 15:25:29 -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=BXEy0zUK; 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 S1726989AbeJPGKh (ORCPT + 99 others); Tue, 16 Oct 2018 02:10:37 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:47974 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbeJPGKh (ORCPT ); Tue, 16 Oct 2018 02:10:37 -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=SI69yfW0GAWg4TCAlrbh78ou5TZRrPG2qzsQPbYsRsQ=; b=BXEy0zUKR9Apg3YFx+roEw4wo 2iCzYRPpqvuxxI/LLs3HznnzlA7dhrBEGJl/Om+A4Hkgi0dTH0R0DzvVo4HN5LzCwqst6+AbOiMou XDgG1MZN7y23447M2YuIv6G6emOyfqOJ8RGt0ql5/pdO60JghS8tiFUXX5pADtNwhu+Yo=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:49128) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gCBGc-00031Q-EK; Mon, 15 Oct 2018 23:23:14 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gCBGV-0007jv-NL; Mon, 15 Oct 2018 23:23:08 +0100 Date: Mon, 15 Oct 2018 23:23:03 +0100 From: Russell King - ARM Linux To: Stefan Agner Cc: ulli.kroll@googlemail.com, joel@jms.id.au, nico@linaro.org, arnd@arndb.de, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] ARM: copypage-fa: add kto and kfrom to input operands list Message-ID: <20181015222302.GZ30658@n2100.armlinux.org.uk> References: <20181015221629.13924-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181015221629.13924-1-stefan@agner.ch> 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 Tue, Oct 16, 2018 at 12:16:29AM +0200, Stefan Agner wrote: > When functions incoming parameters are not in input operands list gcc > 4.5 does not load the parameters into registers before calling this > function but the inline assembly assumes valid addresses inside this > function. This breaks the code because r0 and r1 are invalid when > execution enters v4wb_copy_user_page () NAK. Naked functions must never be inlined. Please add a "noinline" attribute to the function rather than making things more complex. The GCC manual states: `naked' Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU ports to indicate that the specified function does not need prologue/epilogue sequences generated by the compiler. It is up to the programmer to provide these sequences. The only ^^^^^^^^ statements that can be safely included in naked functions are ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `asm' statements that do not have operands. All other statements, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ including declarations of local variables, `if' statements, and so forth, should be avoided. Naked functions should be used to implement the body of an assembly function, while allowing the compiler to construct the requisite function declaration for the assembler. The 'I' attribute is fine here because it is a constant that is not allowed to be in a register (and hence has no code generation side effects.) Adding operands for the input parameters, however, isn't going to work around the fact that _this_ assembly is written to be out of line and so it must never be inlined by the compiler. > Also the constant needs to be used as third input operand so account > for that as well. > > This fixes copypage-fa.c what has previously done before for the other > copypage implementations in commit 9a40ac86152c ("ARM: 6164/1: Add kto > and kfrom to input operands list."). > > Signed-off-by: Stefan Agner > --- > arch/arm/mm/copypage-fa.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mm/copypage-fa.c b/arch/arm/mm/copypage-fa.c > index d130a5ece5d5..ec6501308c60 100644 > --- a/arch/arm/mm/copypage-fa.c > +++ b/arch/arm/mm/copypage-fa.c > @@ -22,7 +22,7 @@ fa_copy_user_page(void *kto, const void *kfrom) > { > asm("\ > stmfd sp!, {r4, lr} @ 2\n\ > - mov r2, %0 @ 1\n\ > + mov r2, %2 @ 1\n\ > 1: ldmia r1!, {r3, r4, ip, lr} @ 4\n\ > stmia r0, {r3, r4, ip, lr} @ 4\n\ > mcr p15, 0, r0, c7, c14, 1 @ 1 clean and invalidate D line\n\ > @@ -36,7 +36,7 @@ fa_copy_user_page(void *kto, const void *kfrom) > mcr p15, 0, r2, c7, c10, 4 @ 1 drain WB\n\ > ldmfd sp!, {r4, pc} @ 3" > : > - : "I" (PAGE_SIZE / 32)); > + : "r" (kto), "r" (kfrom), "I" (PAGE_SIZE / 32)); > } > > void fa_copy_user_highpage(struct page *to, struct page *from, > -- > 2.19.1 > -- 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