arch/parisc/net/bpf_jit_core.c

Source file repositories/reference/linux-study-clean/arch/parisc/net/bpf_jit_core.c

File Facts

System
Linux kernel
Corpus path
arch/parisc/net/bpf_jit_core.c
Extension
.c
Size
4360 bytes
Lines
193
Domain
Architecture Layer
Bucket
arch/parisc
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (ctx->ninsns == prev_ninsns) {
			if (jit_data->header)
				break;
			/* obtain the actual image size */
			extable_size = prog->aux->num_exentries *
				sizeof(struct exception_table_entry);
			prog_size = sizeof(*ctx->insns) * ctx->ninsns;

			jit_data->header =
				bpf_jit_binary_alloc(prog_size + extable_size,
						     &jit_data->image,
						     sizeof(long),
						     bpf_fill_ill_insns);
			if (!jit_data->header)
				goto out_err;

			ctx->insns = (u32 *)jit_data->image;
			/*
			 * Now, when the image is allocated, the image can
			 * potentially shrink more (auipc/jalr -> jal).
			 */
		}
		prev_ninsns = ctx->ninsns;
	}

	if (i == NR_JIT_ITERATIONS) {
		pr_err("bpf-jit: image did not converge in <%d passes!\n", i);
		if (jit_data->header)
			bpf_jit_binary_free(jit_data->header);
		goto out_err;
	}

	if (extable_size)
		prog->aux->extable = (void *)ctx->insns + prog_size;

skip_init_ctx:
	pass++;
	ctx->ninsns = 0;

	bpf_jit_build_prologue(ctx);
	if (build_body(ctx, extra_pass, NULL)) {
		bpf_jit_binary_free(jit_data->header);
		goto out_err;
	}
	bpf_jit_build_epilogue(ctx);

	if (HPPA_JIT_DEBUG || bpf_jit_enable > 1) {
		if (HPPA_JIT_DUMP)
			bpf_jit_dump(prog->len, prog_size, pass, ctx->insns);
		if (HPPA_JIT_REBOOT)
			{ extern int machine_restart(char *); machine_restart(""); }
	}

	if (!prog->is_func || extra_pass) {
		if (bpf_jit_binary_lock_ro(jit_data->header)) {
			bpf_jit_binary_free(jit_data->header);
			goto out_err;
		}
		bpf_flush_icache(jit_data->header, ctx->insns + ctx->ninsns);
	}

	prog->bpf_func = (void *)ctx->insns;
	prog->jited = 1;
	prog->jited_len = prog_size;

	if (!prog->is_func || extra_pass) {
		prologue_len = ctx->epilogue_offset - ctx->body_len;
		for (i = 0; i < prog->len; i++)
			ctx->offset[i] += prologue_len;
		bpf_prog_fill_jited_linfo(prog, ctx->offset);
out_offset:
		kfree(ctx->offset);
		kfree(jit_data);
		prog->aux->jit_data = NULL;
	}

	if (HPPA_JIT_REBOOT)
		{ extern int machine_restart(char *); machine_restart(""); }

	return prog;

out_err:
	if (extra_pass) {
		prog->bpf_func = NULL;
		prog->jited = 0;
		prog->jited_len = 0;
	}
	goto out_offset;
}

Annotation

Implementation Notes