Christophe Leroy wrote:
Le 09/06/2021 à 11:00, Naveen N. Rao a écrit :
blrl corrupts the link stack. Instead use bctrl when making function
calls from BPF programs.
What's the link stack ? Is it the PPC64 branch predictor stack ?
c974809a26a13e ("powerpc/vdso: Avoid link stack corruption in
__get_datapage()") has a good write up on the link stack.
Reported-by: Anton Blanchard <anton@xxxxxxxxxx>
Signed-off-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
---
arch/powerpc/include/asm/ppc-opcode.h | 1 +
arch/powerpc/net/bpf_jit_comp32.c | 4 ++--
arch/powerpc/net/bpf_jit_comp64.c | 12 ++++++------
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index ac41776661e963..1abacb8417d562 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -451,6 +451,7 @@
#define PPC_RAW_MTLR(r) (0x7c0803a6 | ___PPC_RT(r))
#define PPC_RAW_MFLR(t) (PPC_INST_MFLR | ___PPC_RT(t))
#define PPC_RAW_BCTR() (PPC_INST_BCTR)
+#define PPC_RAW_BCTRL() (PPC_INST_BCTRL)
Can you use the numeric value instead of the PPC_INST_BCTRL, to avoid conflict with
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/4ca2bfdca2f47a293d05f61eb3c4e487ee170f1f.1621506159.git.christophe.leroy@xxxxxxxxxx/
Sure. I'll post a v2.
- Naveen