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=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT 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 C25D6C43381 for ; Sun, 10 Mar 2019 13:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81FB7207E0 for ; Sun, 10 Mar 2019 13:22:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="m4MVQotY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbfCJNW1 (ORCPT ); Sun, 10 Mar 2019 09:22:27 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53430 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbfCJNW0 (ORCPT ); Sun, 10 Mar 2019 09:22:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender: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=5Gcy2UyQiDiM4wK9wrlIxT2caEWEFf7LA4Zk7YkaQVg=; b=m4MVQotYzeucLSGemdFH2iDQZ gkJguwimXekh40+gEkYpU/dsnDmPgpmQaTXIwkHI3jMsaWUHmusjbrJq5eADfNqcK6V324F7IBNjH Jqj9lREMnB14HMDm9bdHp1Ql3Tf2jL55hvewBKkhYVlzH8BZofq+7eFktIIYnRl4yVWMhlxw7WdRK 417QbkqJJv1wWMnTHhNIw+25whEDjuYJdKo9++tlBqQkSDyDYg+yXqAPX5nT3jag3LCu/E7Z94/E9 8XZYc7u4pjVshuK3X8C2iT3bmay6GlsydIe3n1lVcsnNzHGuXUzndtMJUYcAq8y16OtLyc5WBvAmo cccga7bmw==; Received: from [188.207.104.17] (helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2yPA-00015k-8R; Sun, 10 Mar 2019 13:22:16 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 1D4B7981BBE; Sun, 10 Mar 2019 14:22:14 +0100 (CET) Date: Sun, 10 Mar 2019 14:22:14 +0100 From: Peter Zijlstra To: Josh Poimboeuf Cc: torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, julien.thierry@arm.com, will.deacon@arm.com, luto@amacapital.net, mingo@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, valentin.schneider@arm.com, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, dvyukov@google.com, rostedt@goodmis.org Subject: Re: [PATCH 03/20] x86/uaccess: Move copy_user_handle_tail into asm Message-ID: <20190310132214.GN2482@worktop.programming.kicks-ass.net> References: <20190307114511.870090179@infradead.org> <20190307115159.349746915@infradead.org> <20190308185321.jukfavqk6pl3ifev@treble> <20190308194835.GD32494@hirez.programming.kicks-ass.net> <20190308195302.popw53eqeoozg53r@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190308195302.popw53eqeoozg53r@treble> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 08, 2019 at 01:53:02PM -0600, Josh Poimboeuf wrote: > On Fri, Mar 08, 2019 at 08:48:35PM +0100, Peter Zijlstra wrote: > > On Fri, Mar 08, 2019 at 12:53:21PM -0600, Josh Poimboeuf wrote: > > > On Thu, Mar 07, 2019 at 12:45:14PM +0100, Peter Zijlstra wrote: > > > > /* > > > > + * Try to copy last bytes and clear the rest if needed. > > > > + * Since protection fault in copy_from/to_user is not a normal situation, > > > > + * it is not necessary to optimize tail handling. > > > > + * > > > > + * Input: > > > > + * rdi destination > > > > + * rsi source > > > > + * rdx count > > > > + * > > > > + * Output: > > > > + * eax uncopied bytes or 0 if successful. > > > > + */ > > > > +ALIGN; > > > > +copy_user_handle_tail: > > > > + movl %edx,%ecx > > > > +1: rep movsb > > > > +2: mov %ecx,%eax > > > > + ASM_CLAC > > > > + ret > > > > + > > > > + _ASM_EXTABLE_UA(1b, 2b) > > > > +ENDPROC(copy_user_handle_tail) > > > > > > This is an unstructured piece of code rather than a callable function, > > > END would probably be more appropriate. Or maybe it should just be a > > > local label (.Lcopy_user_handle_tail) because I don't think the > > > alignment and ELF symbol size are even needed. > > > > ENDPROC makes it STT_FUNC and gets us stricter AC tests. > > How so? I would have thought the opposite. Doesn't objtool only follow > a jump if its destination is to a non-function? Otherwise it's > considered a sibling call. Normally yes, but we don't do that for .fixup I think. And by setting STT_FUNC we enable the 'redundant CLAC' warning, which is ignored for !STT_FUNC.