From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47AFBC04EB9 for ; Mon, 15 Oct 2018 22:53:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2F222054F for ; Mon, 15 Oct 2018 22:53:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=agner.ch header.i=@agner.ch header.b="A7ep+OK/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2F222054F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=agner.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbeJPGkT (ORCPT ); Tue, 16 Oct 2018 02:40:19 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:38836 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbeJPGkT (ORCPT ); Tue, 16 Oct 2018 02:40:19 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 375C35C0106; Tue, 16 Oct 2018 00:52:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1539643978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5rkbavHPfQxCl8Z0lLzsOUojKGBkuNkTW+NpVmjRfyA=; b=A7ep+OK/qOFGzWZQi4losLpgwzegLdOs3WnZoaRML+Rup7hl78EGWsu6w1iF5f5pVdpZoR cispOSCkjqIA5tXZcVoAQRsJWxY6vRSHyrxj4UW38XNSOyvxM1+umWy+sbe7IN7JQI6Xjr YCr34V0C7AojgFktO19jLyBlQOcepfE= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Tue, 16 Oct 2018 00:52:58 +0200 From: Stefan Agner To: Russell King - ARM Linux Cc: raj.khem@gmail.com, 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 In-Reply-To: <20181015224614.GB30658@n2100.armlinux.org.uk> References: <20181015221629.13924-1-stefan@agner.ch> <20181015222302.GZ30658@n2100.armlinux.org.uk> <26d465580722c7f65b6916e96e283967@agner.ch> <20181015224614.GB30658@n2100.armlinux.org.uk> Message-ID: <2802c0e549149872aa58da5fb54471fc@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.10.2018 00:46, Russell King - ARM Linux wrote: > On Tue, Oct 16, 2018 at 12:39:54AM +0200, Stefan Agner wrote: >> On 16.10.2018 00:23, Russell King - ARM Linux wrote: >> > 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. >> > >> >> To be honest, I did not put much thought into this commit since it is >> just doing to copypage-fa.c what 9a40ac86152c ("ARM: 6164/1: Add kto and >> kfrom to input operands list.") has been done to the other copypage >> implementations... >> >> [adding Khem] >> >> > 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. >> >> I briefly looked at a disassembled version after applying both patches, >> it indeed leads to inlining. However, the code seems to be working >> (thanks to asm volatile?)... > > Apart from v4wb_copy_user_page() and mc_copy_user_page(), how is > Clang inlining these static functions that are only used through > function pointers? I only looked at copypage-xscale.c (the mc_copy_user_page() case)... -- Stefan