Messages in this thread | | | From | Linus Torvalds <> | Date | Mon, 8 Aug 2016 11:45:58 -0700 | Subject | Re: [PATCH] x86/hweight: Don't clobber %rdi |
| |
On Mon, Aug 8, 2016 at 11:37 AM, Borislav Petkov <bp@alien8.de> 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
| |