BPF stack limit

Hi,

I'm using Clang to compile C to eBPF, not to run in the Linux kernel, but in ubpf.

I occasionally encounter the error "Looks like the BPF stack limit of 512 bytes is exceeded". The limit seems to be hard-wired (llvm/lib/Target/BPF/BPFRegisterInfo.cpp):

   if (Offset <= -512) {

(I'm using "clang version 5.0.0 (trunk 294090)" built from SVN source. Checked it's still there in r298510.)

Is this an intrinsic limit of eBPF, or just one set by the kernel? If the latter, and since the kernel isn't the only place BPF could run, could an option be added to override it? (For the moment, I've just disabled the check and rebuilt. Plus there are still some changes to try with my code which might avoid the limit.)

Thanks,

Steven

cc Alex

From Alex: It’s indeed the kernel restriction and it’s a good idea to add a flag to make it configurable.

Igor