Re: [PATCH v5 04/17] x86/acrn: Introduce hypercall interfaces

From: Segher Boessenkool
Date: Mon Nov 02 2020 - 13:16:27 EST


Hi!

On Mon, Nov 02, 2020 at 06:19:50PM +0100, Borislav Petkov wrote:
> On Mon, Nov 02, 2020 at 10:09:01AM -0600, Segher Boessenkool wrote:
> > I think that will work for x86_64. But it won't matter much, most of
> > the time you give an immediate number.
>
> Yeah, my question is more along the lines of "is this constraint somehow
> special, i.e., 'ir' (and not 'm') or can it be whatever, i.e., 'g'"?

movl works for moving anything g->r. This is not true for most insns,
and not for most architectures at all (usually loading from memory has a
separate mnemonic; moving an immediate number often as well (and it does
not usually allow *every* immediate anyway, not even all numbers!)

> > It is a tiny bit neater of course (if anyone still remembers what "g"
> > is, you cannot use it much these days).
>
> Oh I always remember what it is because it is right there in the docs:
>
> "6.47.3.1 Simple Constraints
>
> ...
>
> ‘g’ Any register, memory or immediate integer operand is allowed,
> except for registers that are not general registers."

Most people do not read the documentation, they just copy from (bad)
examples (and arguably, any example you do not really understand is a
bad example).

(It does not allow *all* memory and *all* constants, btw... And the
condition for registers is not really "general register", whatever that
means... I hope no one ever told you our documentation does not have
white lies!)


Segher