Re: [PATCH] x86: Use assembly instruction mnemonics instead of .byte streams in arch_hweight.h

From: Uros Bizjak
Date: Sun Oct 14 2018 - 15:15:39 EST


On Sun, Oct 14, 2018 at 8:47 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Sun, Oct 14, 2018 at 08:35:10PM +0200, Uros Bizjak wrote:
> > Recently the minimum required version of binutils was changed to 2.20,
> > which supports popcnt instruction mnemonics. The patch removes
> > all .byte #defines and uses real instruction mnemonics instead.
>
> What is "real insertion mnemonics" ?

The ChangeLog says "real INSTRUCTION mnemonics", e.g. POPCNTQ and POPCNTL.

> To me it looks like this patch replaces our defines with binutils'
> defines and frankly, if it ain't broke, why fix it...

The compiler will generate the register name with the correct implied
width (e.g. %rax for long, %eax for int), so the assembler will be
able to cross check if operands fit the instruction (this issue
happened in KVM, see [1]). And there will be a couple of ugly #defines
less.

[1] https://www.spinics.net/lists/kvm/msg176184.html

Uros.