Re: [PATCH] x86/boot: Do not test if AC and ID eflags are changeable on x86_64

From: H. Peter Anvin
Date: Fri Mar 07 2025 - 09:47:19 EST


On March 7, 2025 5:45:42 AM PST, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>On Fri, Mar 7, 2025 at 2:13 PM H. Peter Anvin <hpa@xxxxxxxxx> wrote:
>
>> >> PUSF et al → pushf
>> >>
>> >> The -l and -q suffixes have been optional for a long time.
>> >
>> >No, not in this case. Please see the comment:
>> >
>> >/*
>> >* For building the 16-bit code we want to explicitly specify 32-bit
>> >* push/pop operations, rather than just saying 'pushf' or 'popf' and
>> >* letting the compiler choose.
>> >*/
>> >
>> >We are building 16-bit code here, and we want PUSHFL, the one with
>> >operand size prefix 0x66.
>> >
>> >Please consider the following code:
>> >
>> > .code16
>> > pushf
>> > pushfl
>> >
>> >as -o push.o push.s
>> >
>> >objdump -dr -Mdata16 push.o
>> >
>> >0000000000000000 <.text>:
>> > 0: 9c pushf
>> > 1: 66 9c pushfl
>> >
>> >Uros.
>> >
>>
>> *plonk* I should have remembered (.code16gcc is different then .code16 though.) I wrote the damned things after all...
>
>Please note that while "gcc -m16" emits .code16gcc, "clang -m16" emits
>.code16, so in the latter case we don't have ‘pushf’, and ‘popf’
>instructions default to 32-bit size. So, the only solution is to
>decorate pushfl with operand size prefix in this specific case.
>
>Uros.
>

Can you please beat up the clang people who do gratuitously incompatible things like this?