Christophe Leroy wrote:


Le 06/01/2022 à 12:45, Naveen N. Rao a écrit :
Pad instructions emitted for BPF_CALL so that the number of instructions
generated does not change for different function addresses. This is
especially important for calls to other bpf functions, whose address
will only be known during extra pass.

In first pass, 'image' is NULL and we emit the 4 instructions sequence already, so the code won't grow after first pass, it can only shrink.

Right, but this patch addresses the scenario where the function address is only provided during the extra pass. So, even though we will not write past the end of the BPF image, the emitted instructions can still be wrong.


On PPC32, a huge effort is made to minimise the situations where 'bl' cannot be used, see commit 2ec13df16704 ("powerpc/modules: Load modules closer to kernel text")

And if you take the 8xx for instance, a NOP a just like any other instruction, it takes one cycle.

If it is absolutely needed, then I'd prefer we use an out-of-line trampoline for the unlikely case and use 'bl' to that trampoline.

Yes, something like that will be nice to do, but we will still need this patch for -stable.

The other option is to redo the whole JIT during the extra pass, but only if we can ensure that we have provisioned for the maximum image size.


- Naveen

Reply via email to