Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Default initialize external memwords.
details: https://anonhg.NetBSD.org/src/rev/12528c2336ba
branches: trunk
changeset: 796919:12528c2336ba
user: alnsn <alnsn%NetBSD.org@localhost>
date: Wed Jun 25 13:53:40 2014 +0000
description:
Default initialize external memwords.
This change doesn't affect performance of valid bpf kernel programs
because bpf_filter_ext() checks that all memwords are initialized
explicitly.
diffstat:
sys/net/bpfjit.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diffs (82 lines):
diff -r 30c644fd6c46 -r 12528c2336ba sys/net/bpfjit.c
--- a/sys/net/bpfjit.c Wed Jun 25 13:10:27 2014 +0000
+++ b/sys/net/bpfjit.c Wed Jun 25 13:53:40 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpfjit.c,v 1.17 2014/06/25 11:58:15 alnsn Exp $ */
+/* $NetBSD: bpfjit.c,v 1.18 2014/06/25 13:53:40 alnsn Exp $ */
/*-
* Copyright (c) 2011-2014 Alexander Nasonov.
@@ -31,9 +31,9 @@
#include <sys/cdefs.h>
#ifdef _KERNEL
-__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.17 2014/06/25 11:58:15 alnsn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpfjit.c,v 1.18 2014/06/25 13:53:40 alnsn Exp $");
#else
-__RCSID("$NetBSD: bpfjit.c,v 1.17 2014/06/25 11:58:15 alnsn Exp $");
+__RCSID("$NetBSD: bpfjit.c,v 1.18 2014/06/25 13:53:40 alnsn Exp $");
#endif
#include <sys/types.h>
@@ -1594,6 +1594,10 @@
bpf_memword_init_t initmask;
int nscratches, ncopfuncs;
+ /* memory store location for initial zero initialization */
+ sljit_si mem_reg;
+ sljit_sw mem_off;
+
/* a list of jumps to out-of-bound return from a generated function */
struct sljit_jump **ret0;
size_t ret0_size, ret0_maxsize;
@@ -1665,7 +1669,10 @@
goto fail;
}
- if (extwords != 0) {
+ if (extwords == 0) {
+ mem_reg = SLJIT_MEM1(SLJIT_LOCALS_REG);
+ mem_off = offsetof(struct bpfjit_stack, mem);
+ } else {
/* copy "mem" argument from bpf_args to bpfjit_stack */
status = sljit_emit_op1(compiler,
SLJIT_MOV_P,
@@ -1681,12 +1688,11 @@
BJ_TMP1REG, 0);
if (status != SLJIT_SUCCESS)
goto fail;
+
+ mem_reg = SLJIT_MEM1(BJ_TMP1REG);
+ mem_off = 0;
}
- status = load_buf_buflen(compiler);
- if (status != SLJIT_SUCCESS)
- goto fail;
-
/*
* Exclude pre-initialised external memory words but keep
* initialization statuses of A and X registers in case
@@ -1703,9 +1709,7 @@
/* M[i] = 0; */
status = sljit_emit_op1(compiler,
SLJIT_MOV_UI,
- SLJIT_MEM1(SLJIT_LOCALS_REG),
- offsetof(struct bpfjit_stack, mem) +
- i * sizeof(uint32_t),
+ mem_reg, mem_off + i * sizeof(uint32_t),
SLJIT_IMM, 0);
if (status != SLJIT_SUCCESS)
goto fail;
@@ -1732,6 +1736,10 @@
goto fail;
}
+ status = load_buf_buflen(compiler);
+ if (status != SLJIT_SUCCESS)
+ goto fail;
+
for (i = 0; i < insn_count; i++) {
if (insn_dat[i].unreachable)
continue;
Home |
Main Index |
Thread Index |
Old Index