[FFmpeg-devel] [PATCH] Replace br return with ret

Martin Storsjö martin at martin.st
Fri Aug 4 13:48:51 EEST 2023


On Thu, 27 Jul 2023, Rémi Denis-Courmont wrote:

> Hi,
>
> The use of RET vs BR also has microarchitectural side effects. AFAIU, RET should always be paired with an earlier BL/BLR to avoid interfering with branch prediction.
>
> So depending on the circumstances, either one of these should be 
> addressed:
> * Clarify that this is actually a function return , and RET should be 
> used anyway, regardless of BTI.

This is the case, and the patch looks good to me.

I guess the commit message could be clarified that this is an issue even 
without BTI (even if the effect is much harder to notice there).

Would this amended commit message be ok with you? (If no input I guess 
I'll push it in a few days.)

---8<---
Subject: aarch64/hevc: Replace br return with ret

This patch changes the return instruction in the tr_32x4 macro from br to 
ret.

Function returns should always use the RET instruction instead of BR, to 
avoid interfering with branch prediction.

On devices that support BTI, this is observeable as a landing pad is 
required when branching with BR. The change fixes 
fate-hevc-hdr-vivid-metadata when on hardware with BTI support.
---8<---

// Martin


More information about the ffmpeg-devel mailing list