[PATCH v2] x86: Disallow GOT memory as vector memory operand

Jan Beulich jbeulich@suse.com
Fri Feb 7 06:32:30 GMT 2025


On 07.02.2025 06:22, H.J. Lu wrote:
> On Thu, Feb 6, 2025 at 9:02 PM Jan Beulich <jbeulich@suse.com> wrote:
>> On 06.02.2025 04:32, H.J. Lu wrote:
>>> GOT memory is 4-byte for i386 and 8-byte for x86-64.  Disallow GOT memory
>>> as vector memory operand for vector instructions which don't support 32-bit
>>> nor 64-bit memory.
>>>
>>> PR gas/32624
>>> * config/tc-i386.c (output_disp): Disallow GOT memory as vector
>>> memory operand.
>>> * testsuite/gas/i386/got.s: Add vcvtph2qq with GOT memory.
>>> * testsuite/gas/i386/x86-64-gotpcrel-2.s: Add vcvtph2qq and
>>> vcvtps2pd with GOT memory.
>>> * testsuite/gas/i386/got-no-relax.d: Updated.
>>> * testsuite/gas/i386/got.d: Likewise.
>>> * testsuite/gas/i386/x86-64-gotpcrel-2.d: Likewise.
>>> * testsuite/gas/i386/i386.exp: Run inval-got.
>>> * testsuite/gas/i386/inval-got.l: New file.
>>> * testsuite/gas/i386/inval-got.s: Likewise.
>>> * testsuite/gas/i386/x86-64-inval-got.l: Likewise.
>>> * testsuite/gas/i386/x86-64-inval-got.l: Likewise.
>>> * testsuite/gas/i386/x86-64.exp: Run x86-64-inval-got.
>>
>> Hmm, I'm further puzzled: On what basis would VCVTPS2DQ and VCVTPH2QQ be
>> okay to use with an operand in GOT?
>>
>> And then, if I'm reading the added logic right,
>>
>>         VADDPS foo@GOTPCREL(%rip), %zmm0, %zmm1
>>
>> would be permitted despite having a 512-bit memory operand, just because
>> it also permits embedded broadcast (which isn't in use here). Whereas
> 
> Only for broadcast.

Hmm, perhaps I'm reading the code change incorrectly then. By checking
the template rather than i.types[] (as I had asked you to do) I would
assume templates permitting for broadcast would allow all forms of their
insns through.

>>         VADDPS foo@GOTPCREL(%rip), %ymm0, %ymm1
>>
>> wouldn't be, unless prefixed by {evex}. How in the world are people to
>> infer what is or is not allowed by the assembler?
> 
> Only 8-bit, 16-bit, 32-bit, 64-bit (in 64-bit mode) is allowed.
> 
>> As before, my requirements are:
>> 1) underlying criteria being clearly / unambiguously spelled out in the
>>    psABI, and/or
> 
> GOT is specified in the psABI.

GOT is, but I'm pretty sure there's nothing there about how GOT is to
be accessed.

>> 2) such extra checking being optional, default-off (to some degree
>> depending on how things would be worded in the psABI).
> 
> GOT size check should be on always.

Which is because you know better than any programmer what may make
sense in their specific case?

Jan


More information about the Binutils mailing list