On 23.04.2025 03:02, Andrew Cooper wrote:
> Encoding altcalls as regular alternatives leads to an unreasonable amount of
> complexity in _apply_alternatives().
> 
> Introduce apply_alt_calls(), and an .alt_call_sites section which simply
> tracks the source address (relative, to save on space).  That's literally all
> that is needed in order to devirtualise the function pointers.
> 
> apply_alt_calls() is mostly as per _apply_alternatives(), except the size is
> known to be 6 bytes.  Drop the logic for JMP *RIPREL, as there's no support
> for tailcall optimisations, nor a feasbile plan on how to introduce support.
> Pad with a redundant prefix to avoid needing a separate NOP on the end.
> 
> Wire it up in nmi_apply_alternatives(), although the section is empty at this
> juncture so nothing happens in practice.
> 
> Signed-off-by: Andrew Cooper <[email protected]>

Reviewed-by: Jan Beulich <[email protected]>

> Finding a 6-byte UD instruction that is distinct from ud2 turns out to be
> quite challengning.  The easy way involves a length changing prefix, which is
> best avoided.  Suggestions for alternative patterns welcome.

(Intel syntax, sorry.)

        ud0     edi, [edi+edi-1]
        ud1     edi, [edi+edi-1]

        ud0     edi, cs:[rdi+rdi-1]
        ud1     edi, cs:[rdi+rdi-1]

Jan

Reply via email to