From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752015AbcEJTGc (ORCPT ); Tue, 10 May 2016 15:06:32 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56834 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbcEJTGb (ORCPT ); Tue, 10 May 2016 15:06:31 -0400 User-Agent: K-9 Mail for Android In-Reply-To: <20160510172313.GA3192@twins.programming.kicks-ass.net> References: <20160407094333.GD3866@pd.tnic> <20160504184612.GC23257@pd.tnic> <5998407c-3497-22c1-45dc-a86afcb73c94@zytor.com> <20160504194101.GE23257@pd.tnic> <20160504202213.GF23257@pd.tnic> <572B446D.1030000@redhat.com> <20160505140446.GE534@pd.tnic> <20160510165318.GD28520@pd.tnic> <20160510172313.GA3192@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Subject: Re: [PATCH -v2] x86/hweight: Get rid of the special calling convention From: "H. Peter Anvin" Date: Tue, 10 May 2016 12:03:48 -0700 To: Peter Zijlstra , Borislav Petkov CC: x86-ml , Denys Vlasenko , Brian Gerst , LKML , Dmitry Vyukov , Andi Kleen , zengzhaoxiu@163.com, Thomas Gleixner , Ingo Molnar , Andrew Morton , Kees Cook , Zhaoxiu Zeng , Andy Lutomirski Message-ID: <8FE6169B-4F2E-4B7D-A271-14FEC245F663@zytor.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On May 10, 2016 10:23:13 AM PDT, Peter Zijlstra wrote: >On Tue, May 10, 2016 at 06:53:18PM +0200, Borislav Petkov wrote: >> static __always_inline unsigned int __arch_hweight32(unsigned int w) >> { >> - unsigned int res = 0; >> + unsigned int res; >> >> - asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, >X86_FEATURE_POPCNT) >> - : "="REG_OUT (res) >> - : REG_IN (w)); >> + if (likely(static_cpu_has(X86_FEATURE_POPCNT))) { >> + /* popcnt %eax, %eax */ >> + asm volatile(POPCNT32 >> + : "="REG_OUT (res) >> + : REG_IN (w)); >> >> - return res; >> + return res; >> + } >> + return __sw_hweight32(w); >> } > >So what was wrong with using the normal thunk_*.S wrappers for the >calls? That would allow you to use the alternative() stuff which does >generate smaller code. Also, to be fair... if the problem is with these being in C then we could just do it in assembly easily enough. -- Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.