OSDN Git Service

Revert "usb: dwc3: turn off VBUS when leaving host mode"
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / kernel / bpf / core.c
index 3fd76cf..eb52d11 100644 (file)
@@ -256,6 +256,7 @@ noinline u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
 }
 EXPORT_SYMBOL_GPL(__bpf_call_base);
 
+#ifndef CONFIG_BPF_JIT_ALWAYS_ON
 /**
  *     __bpf_prog_run - run eBPF program on a given context
  *     @ctx: is the data we are operating on
@@ -443,7 +444,7 @@ select_insn:
                DST = tmp;
                CONT;
        ALU_MOD_X:
-               if (unlikely(SRC == 0))
+               if (unlikely((u32)SRC == 0))
                        return 0;
                tmp = (u32) DST;
                DST = do_div(tmp, (u32) SRC);
@@ -462,7 +463,7 @@ select_insn:
                DST = div64_u64(DST, SRC);
                CONT;
        ALU_DIV_X:
-               if (unlikely(SRC == 0))
+               if (unlikely((u32)SRC == 0))
                        return 0;
                tmp = (u32) DST;
                do_div(tmp, (u32) SRC);
@@ -517,7 +518,7 @@ select_insn:
                struct bpf_map *map = (struct bpf_map *) (unsigned long) BPF_R2;
                struct bpf_array *array = container_of(map, struct bpf_array, map);
                struct bpf_prog *prog;
-               u64 index = BPF_R3;
+               u32 index = BPF_R3;
 
                if (unlikely(index >= array->map.max_entries))
                        goto out;
@@ -725,6 +726,13 @@ load_byte:
                return 0;
 }
 
+#else
+static unsigned int __bpf_prog_ret0(void *ctx, const struct bpf_insn *insn)
+{
+       return 0;
+}
+#endif
+
 bool bpf_prog_array_compatible(struct bpf_array *array,
                               const struct bpf_prog *fp)
 {
@@ -771,9 +779,23 @@ static int bpf_check_tail_call(const struct bpf_prog *fp)
  */
 int bpf_prog_select_runtime(struct bpf_prog *fp)
 {
+#ifndef CONFIG_BPF_JIT_ALWAYS_ON
        fp->bpf_func = (void *) __bpf_prog_run;
-
+#else
+       fp->bpf_func = (void *) __bpf_prog_ret0;
+#endif
+
+       /* eBPF JITs can rewrite the program in case constant
+        * blinding is active. However, in case of error during
+        * blinding, bpf_int_jit_compile() must always return a
+        * valid program, which in this case would simply not
+        * be JITed, but falls back to the interpreter.
+        */
        bpf_int_jit_compile(fp);
+#ifdef CONFIG_BPF_JIT_ALWAYS_ON
+       if (!fp->jited)
+               return -ENOTSUPP;
+#endif
        bpf_prog_lock_ro(fp);
 
        /* The tail call compatibility check can only be done at