[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <414a9a72-f0a1-5ba4-fc4b-a2f10d881328@iogearbox.net>
Date: Fri, 28 Sep 2018 15:41:56 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Joe Stringer <joe@...d.net.nz>
Cc: netdev@...r.kernel.org, ast@...nel.org, john.fastabend@...il.com,
tgraf@...g.ch, kafai@...com, nitin.hande@...il.com,
mauricio.vasquez@...ito.it
Subject: Re: [PATCHv3 bpf-next 01/12] bpf: Add iterator for spilled registers
On 09/28/2018 01:26 AM, Joe Stringer wrote:
> Add this iterator for spilled registers, it concentrates the details of
> how to get the current frame's spilled registers into a single macro
> while clarifying the intention of the code which is calling the macro.
>
> Signed-off-by: Joe Stringer <joe@...d.net.nz>
> Acked-by: Alexei Starovoitov <ast@...nel.org>
> ---
> include/linux/bpf_verifier.h | 11 +++++++++++
> kernel/bpf/verifier.c | 16 +++++++---------
> 2 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
> index b42b60a83e19..af262b97f586 100644
> --- a/include/linux/bpf_verifier.h
> +++ b/include/linux/bpf_verifier.h
> @@ -131,6 +131,17 @@ struct bpf_verifier_state {
> u32 curframe;
> };
>
> +#define __get_spilled_reg(slot, frame) \
> + (((slot < frame->allocated_stack / BPF_REG_SIZE) && \
> + (frame->stack[slot].slot_type[0] == STACK_SPILL)) \
> + ? &frame->stack[slot].spilled_ptr : NULL)
> +
> +/* Iterate over 'frame', setting 'reg' to either NULL or a spilled register. */
> +#define for_each_spilled_reg(iter, frame, reg) \
> + for (iter = 0, reg = __get_spilled_reg(iter, frame); \
> + iter < frame->allocated_stack / BPF_REG_SIZE; \
> + iter++, reg = __get_spilled_reg(iter, frame))
> +
(Just a very small nit: please make sure this has a bpf_ prefix given this
is a global kernel header.)
Powered by blists - more mailing lists