Re: [PATCH v3 0/6] Static calls

From: Nadav Amit
Date: Thu Jan 10 2019 - 16:47:50 EST


> On Jan 10, 2019, at 12:57 PM, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> On Thu, Jan 10, 2019 at 08:48:31PM +0000, Nadav Amit wrote:
>>> On Jan 10, 2019, at 12:32 PM, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>>>
>>> On Thu, Jan 10, 2019 at 07:45:26PM +0000, Nadav Amit wrote:
>>>>>> Iâm not GCC expert either and writing this code was not making me full of
>>>>>> joy, etc.. Iâll be happy that my code would be reviewed, but it does work. I
>>>>>> donât think an early pass is needed, as long as hardware registers were not
>>>>>> allocated.
>>>>>>
>>>>>>> Would it work with more than 5 arguments, where args get passed on the
>>>>>>> stack?
>>>>>>
>>>>>> It does.
>>>>>>
>>>>>>> At the very least, it would (at least partially) defeat the point of the
>>>>>>> callee-saved paravirt ops.
>>>>>>
>>>>>> Actually, I think you can even deal with callee-saved functions and remove
>>>>>> all the (terrible) macros. You would need to tell the extension not to
>>>>>> clobber the registers through a new attribute.
>>>>>
>>>>> Ok, it does sound interesting then. I assume you'll be sharing the
>>>>> code?
>>>>
>>>> Of course. If this what is going to convince, Iâll make a small version for
>>>> PV callee-saved first.
>>>
>>> It wasn't *only* the PV callee-saved part which interested me, so if you
>>> already have something which implements the other parts, I'd still like
>>> to see it.
>>
>> Did you have a look at https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20181231072112.21051-4-namit%40vmware.com%2F&amp;data=02%7C01%7Cnamit%40vmware.com%7C169b737792134fc852d808d6773e454b%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636827506683819442&amp;sdata=FhM%2F5OD%2FNHx9Jr97iPIBNyn0BoLAlyiSv%2BT4XICBUdg%3D&amp;reserved=0 ?
>>
>> See the changes to x86_call_markup_plugin.c .
>>
>> The missing part (that I just finished but need to cleanup) is attributes
>> that allow you to provide key and dynamically enable the patching.
>
> Aha, so it's the basically the same plugin you had for optpolines. I
> missed that. I'll need to stare at the code for a little bit.

Pretty much. You would want to change the assembly code block, and based on
the use-case (e.g., callee-saved, static-calls) clobber or set as an input
more or fewer registers.