From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbcEDTeo (ORCPT ); Wed, 4 May 2016 15:34:44 -0400 Received: from terminus.zytor.com ([198.137.202.10]:55356 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937AbcEDTem (ORCPT ); Wed, 4 May 2016 15:34:42 -0400 Subject: Re: [RFC PATCH] x86/hweight: Get rid of the special calling convention To: Brian Gerst , Borislav Petkov References: <57031D9D.801@gmail.com> <1459934085-7152-1-git-send-email-zengzhaoxiu@163.com> <87wpoay10o.fsf@tassilo.jf.intel.com> <20160407094333.GD3866@pd.tnic> <20160504184612.GC23257@pd.tnic> Cc: LKML , Dmitry Vyukov , Andi Kleen , zengzhaoxiu@163.com, Thomas Gleixner , Ingo Molnar , Denys Vlasenko , Andrew Morton , Kees Cook , Zhaoxiu Zeng , Andy Lutomirski , Peter Zijlstra From: "H. Peter Anvin" Message-ID: <5998407c-3497-22c1-45dc-a86afcb73c94@zytor.com> Date: Wed, 4 May 2016 12:33:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/04/2016 12:31 PM, Brian Gerst wrote: >> >> - asm (ALTERNATIVE("call __sw_hweight32", POPCNT32, X86_FEATURE_POPCNT) >> - : "="REG_OUT (res) >> - : REG_IN (w)); >> + if (likely(static_cpu_has(X86_FEATURE_POPCNT))) { >> + asm volatile("popcnt %[w], %[res]" : [res] "=r" (res) : [w] "r" (w)); > > Do all supported versions of the assembler know of the popcnt > instruction? That's why is was open coded before. The problem is > Intel and AMD are constantly adding new instructions and it's a long > cycle for the user's assembler to get updated. > Most likely not. It would be nice to have some more uniform solution to that. I'm wondering if we could use the -Wa option to load some kind of macro package. -hpa