From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752495AbcHHSqD (ORCPT ); Mon, 8 Aug 2016 14:46:03 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:33323 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbcHHSp7 (ORCPT ); Mon, 8 Aug 2016 14:45:59 -0400 MIME-Version: 1.0 In-Reply-To: <20160808183726.GA22641@nazgul.tnic> References: <1470677729-10561-1-git-send-email-ville.syrjala@linux.intel.com> <20160808180430.GE511@nazgul.tnic> <20160808183726.GA22641@nazgul.tnic> From: Linus Torvalds Date: Mon, 8 Aug 2016 11:45:58 -0700 X-Google-Sender-Auth: k1jFUOHnGM1eCZRCKCWYbEcNBxY Message-ID: Subject: Re: [PATCH] x86/hweight: Don't clobber %rdi To: Borislav Petkov Cc: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Linux Kernel Mailing List , "the arch/x86 maintainers" , Borislav Petkov , "H . Peter Anvin" , Andy Lutomirski , Brian Gerst , Denys Vlasenko , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Jiri Kosina Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 8, 2016 at 11:37 AM, Borislav Petkov wrote: > > Ok, so do you think it would work too if I stated that the input > register gets clobbered: > > asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT) > : "="REG_OUT (res) > : REG_IN (w) > : REG_IN); That would work (although the clobbered registers have a different syntax than the in/out registers), but it would be wrong, in my opinion. We want the actual POPCNT instruction to be the common case, and that instruction does *not* clobber any other registers than the output. So I think it's much better to just say: "the __sw_hweight functions should have the same semantics as popcnt" (although without the eflags rules that we don't care about). There's nothing wrong with keeping it as assembly language - it's not like it's a maintenance headache once it is written. Linus