From: Jose E. Marchesi Date: Fri, 18 Aug 2023 12:05:00 +0000 (+0200) Subject: bpf: bump maximum frame size limit to 32767 bytes X-Git-Tag: basepoints/gcc-15~6815 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35b5762a740d4506d7acac65d0f8375640362492;p=thirdparty%2Fgcc.git bpf: bump maximum frame size limit to 32767 bytes This commit bumps the maximum stack frame size allowed for BPF functions to the maximum possible value. Tested in x86_64-linux-gnu host and target bpf-unknown-none. gcc/ChangeLog * config/bpf/bpf.opt (mframe-limit): Set default to 32767. gcc/testsuite/ChangeLog * gcc.target/bpf/frame-limit-1.c: New test. * gcc.target/bpf/frame-limit-2.c: Likewise. --- diff --git a/gcc/config/bpf/bpf.opt b/gcc/config/bpf/bpf.opt index 8e240d397e4c..efa0380ee3f6 100644 --- a/gcc/config/bpf/bpf.opt +++ b/gcc/config/bpf/bpf.opt @@ -38,7 +38,7 @@ Target RejectNegative InverseMask(BIG_ENDIAN) Generate little-endian eBPF. mframe-limit= -Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(512) +Target Joined RejectNegative UInteger IntegerRange(0, 32767) Var(bpf_frame_limit) Init(32767) Set a hard limit for the size of each stack frame, in bytes. mco-re diff --git a/gcc/testsuite/gcc.target/bpf/frame-limit-1.c b/gcc/testsuite/gcc.target/bpf/frame-limit-1.c new file mode 100644 index 000000000000..7843e04b5cea --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/frame-limit-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +/* The stack frame size is limited to 32767 bytes. */ + +int +foo () +{ + long data[4095]; + return 0; +} + +int +bar () +{ + long data[4096]; + return 0; +} /* { dg-error "stack limit" } */ diff --git a/gcc/testsuite/gcc.target/bpf/frame-limit-2.c b/gcc/testsuite/gcc.target/bpf/frame-limit-2.c new file mode 100644 index 000000000000..57f82e00567f --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/frame-limit-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mframe-limit=256" } */ + +int +foo () +{ + long data[32]; + return 0; +} + +int +bar () +{ + long data[33]; + return 0; +} /* { dg-error "stack limit" } */