Re: [PATCH v5 2/3] x86/asm: Add suffix macro for GEN_*_RMWcc()

From: Kees Cook
Date: Wed May 31 2017 - 12:09:24 EST


On Wed, May 31, 2017 at 7:03 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> On Wed, May 31, 2017 at 06:17:16AM -0700, Kees Cook wrote:
>> On Wed, May 31, 2017 at 4:13 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>> > On Tue, May 30, 2017 at 02:39:51PM -0700, Kees Cook wrote:
>> >> The coming x86 refcount protection needs to be able to add trailing
>> >> instructions to the GEN_*_RMWcc() operations. This extracts the
>> >> difference between the goto/non-goto cases so the helper macros
>> >> can be defined outside the #ifdef cases. Additionally adds argument
>> >> naming to the resulting asm for referencing from suffixed
>> >> instructions, and adds clobbers for "cc", and "cx" to let suffixes
>> >> use _ASM_CX, and retain any set flags.
>> >
>> > Another option is to simply require __GCC_ASM_FLAG_OUTPUT__ for the fast
>> > refcount stuff. That would result in simpler and more readable code.
>>
>> What versions of GCC support that?
>
> IIRC 6+

Given how many folks are still using 4.9 (and lower, see the thread
with Arnd[1]), I'd like to just keep this as I have it. It's not much
less readable, IMO (It was already pretty complex). I cleaned it up a
little before making it more ugly, so I think on sum, it's only a
little more weird. I think that's better than making this
compiler-specific or copy/pasting.

-Kees

[1] https://lkml.org/lkml/2017/4/25/66

--
Kees Cook
Pixel Security