Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

patch llvm and kernel net-next #33

Closed
williamtu opened this issue Feb 17, 2017 · 0 comments
Closed

patch llvm and kernel net-next #33

williamtu opened this issue Feb 17, 2017 · 0 comments

Comments

@williamtu
Copy link
Contributor

the latest LLVM will also check the 512 byte BPF stack size. So we fails earlier at compiling the object instead of loading to verifier. Patch llvm and kernel net-next to 4096.

diff --git a/lib/Target/BPF/BPFRegisterInfo.cpp b/lib/Target/BPF/BPFRegisterInfo.cpp
index 7925bee..2636acb 100644
--- a/lib/Target/BPF/BPFRegisterInfo.cpp
+++ b/lib/Target/BPF/BPFRegisterInfo.cpp
@@ -44,7 +44,7 @@ BitVector BPFRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
 
 static void WarnSize(int Offset, MachineFunction &MF, DebugLoc& DL)
 {
-  if (Offset <= -512) {
+  if (Offset <= -4096) {
       auto F = MF.getFunction();
       DiagnosticInfoUnsupported DiagStackSize(*F,
           "Looks like the BPF stack limit of 512 bytes is exceeded. "

patch kernel net-next

--- a/arch/x86/net/bpf_jit.S
+++ b/arch/x86/net/bpf_jit.S
@@ -19,7 +19,7 @@
  */
 #define SKBDATA        %r10
 #define SKF_MAX_NEG_OFF    $(-0x200000) /* SKF_LL_OFF from filter.h */
-#define MAX_BPF_STACK (512 /* from filter.h */ + \
+#define MAX_BPF_STACK (4096 /* from filter.h */ + \
        32 /* space for rbx,r13,r14,r15 */ + \
        8 /* space for skb_copy_bits */)
 
diff --git a/include/linux/filter.h b/include/linux/filter.h
index e4eb254..fb532fc 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -55,7 +55,8 @@ struct bpf_prog_aux;
 #define MAX_BPF_JIT_REG                (MAX_BPF_REG + 1)
 
 /* BPF program can access up to 512 bytes of stack space. */
-#define MAX_BPF_STACK  512
+//#define MAX_BPF_STACK        512
+#define MAX_BPF_STACK  4096
 
 #define BPF_TAG_SIZE   8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant