Skip to content
Snippets Groups Projects
Select Git revision
  • 51778776358f9d083fd732f99f2206639c705b45
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS
  • openEuler-22.03-LTS-Ascend
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.5.0
  • 5.10.0-123.0.0
  • 5.10.0-60.63.0
  • 5.10.0-60.62.0
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
33 results

bpf_jit_comp64.c

Blame
  • bpf_jit_comp64.c 29.01 KiB
    /*
     * bpf_jit_comp64.c: eBPF JIT compiler
     *
     * Copyright 2016 Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
     *		  IBM Corporation
     *
     * Based on the powerpc classic BPF JIT compiler by Matt Evans
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * as published by the Free Software Foundation; version 2
     * of the License.
     */
    #include <linux/moduleloader.h>
    #include <asm/cacheflush.h>
    #include <asm/asm-compat.h>
    #include <linux/netdevice.h>
    #include <linux/filter.h>
    #include <linux/if_vlan.h>
    #include <asm/kprobes.h>
    #include <linux/bpf.h>
    
    #include "bpf_jit64.h"
    
    static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
    {
    	memset32(area, BREAKPOINT_INSTRUCTION, size/4);
    }
    
    static inline void bpf_flush_icache(void *start, void *end)
    {
    	smp_wmb();
    	flush_icache_range((unsigned long)start, (unsigned long)end);
    }
    
    static inline bool bpf_is_seen_register(struct codegen_context *ctx, int i)
    {
    	return (ctx->seen & (1 << (31 - b2p[i])));
    }
    
    static inline void bpf_set_seen_register(struct codegen_context *ctx, int i)
    {
    	ctx->seen |= (1 << (31 - b2p[i]));
    }
    
    static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
    {
    	/*
    	 * We only need a stack frame if:
    	 * - we call other functions (kernel helpers), or
    	 * - the bpf program uses its stack area
    	 * The latter condition is deduced from the usage of BPF_REG_FP
    	 */
    	return ctx->seen & SEEN_FUNC || bpf_is_seen_register(ctx, BPF_REG_FP);
    }
    
    /*
     * When not setting up our own stackframe, the redzone usage is:
     *
     *		[	prev sp		] <-------------
     *		[	  ...       	] 		|
     * sp (r1) --->	[    stack pointer	] --------------
     *		[   nv gpr save area	] 6*8
     *		[    tail_call_cnt	] 8
     *		[    local_tmp_var	] 8
     *		[   unused red zone	] 208 bytes protected
     */
    static int bpf_jit_stack_local(struct codegen_context *ctx)
    {
    	if (bpf_has_stack_frame(ctx))