netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Cc: David Miller <davem@davemloft.net>,
	Alexei Starovoitov <ast@plumgrid.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH net-next 2/5] s390/bpf: Fix multiple macro expansions
Date: Tue, 28 Jul 2015 20:13:41 -0700	[thread overview]
Message-ID: <1438139621.2529.31.camel@perches.com> (raw)
In-Reply-To: <1438092600-16221-3-git-send-email-holzheu@linux.vnet.ibm.com>

On Tue, 2015-07-28 at 16:09 +0200, Michael Holzheu wrote:
> The EMIT6_DISP_LH macro passes the "disp" parameter to the _EMIT6_DISP_LH
> macro. The _EMIT6_DISP_LH macro uses the "disp" parameter twice:
> 
>  unsigned int __disp_h = ((u32)disp) & 0xff000;
>  unsigned int __disp_l = ((u32)disp) & 0x00fff;
> 
> The EMIT6_DISP_LH is used several times with EMIT_CONST_U64() as "disp"
> parameter. Therefore always two constants are created per usage of
> EMIT6_DISP_LH.
> 
> Fix this and add variable "__disp" to avoid multiple expansions.
> 
> Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> ---
>  arch/s390/net/bpf_jit_comp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index 01ad166..de0f0bc 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -221,8 +221,9 @@ static inline void reg_set_seen(struct nbpf_jit *jit, u32 b1)
>  
>  #define EMIT6_DISP_LH(op1, op2, b1, b2, b3, disp)		\
>  ({								\
> +	int __disp = (disp);					\
>  	_EMIT6_DISP_LH(op1 | reg(b1, b2) << 16 |		\
> -		       reg_high(b3) << 8, op2, disp);		\
> +		       reg_high(b3) << 8, op2, __disp);		\
>  	REG_SET_SEEN(b1);					\
>  	REG_SET_SEEN(b2);					\
>  	REG_SET_SEEN(b3);					\

Perhaps it'd be better to change _EMIT6_DISP_LH
---
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 3a15baa..409e206 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -205,8 +205,9 @@ static inline void reg_set_seen(struct bpf_jit *jit,
u32 b1)
 
 #define _EMIT6_DISP_LH(op1, op2, disp)				\
 ({								\
-	unsigned int __disp_h = ((u32)disp) & 0xff000;		\
-	unsigned int __disp_l = ((u32)disp) & 0x00fff;		\
+	u32 _disp = (u32)disp;					\
+	unsigned int __disp_h = _disp & 0xff000;		\
+	unsigned int __disp_l = _disp & 0x00fff;		\
 	_EMIT6(op1 | __disp_l, op2 | __disp_h >> 4);		\
 })
 

  reply	other threads:[~2015-07-29  3:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 14:09 [PATCH net-next 0/5] s390/bpf: recache skb->data/hlen for skb_vlan_push/pop Michael Holzheu
2015-07-28 14:09 ` [PATCH net-next 1/5] s390/bpf: clear correct BPF accumulator register Michael Holzheu
2015-07-28 14:09 ` [PATCH net-next 2/5] s390/bpf: Fix multiple macro expansions Michael Holzheu
2015-07-29  3:13   ` Joe Perches [this message]
2015-07-29  8:32     ` Michael Holzheu
2015-07-28 14:09 ` [PATCH net-next 3/5] s390/bpf: increase BPF_SIZE_MAX Michael Holzheu
2015-07-28 14:09 ` [PATCH net-next 4/5] s390/bpf: Only clear A and X for converted BPF programs Michael Holzheu
2015-07-28 14:10 ` [PATCH net-next 5/5] s390/bpf: recache skb->data/hlen for skb_vlan_push/pop Michael Holzheu
2015-07-28 17:19   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438139621.2529.31.camel@perches.com \
    --to=joe@perches.com \
    --cc=ast@plumgrid.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).