linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	netdev@vger.kernel.org, Matt Evans <matt@ozlabs.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@fb.com>,
	Denis Kirjanov <kda@linux-powerpc.org>,
	Paul Mackerras <paulus@samba.org>,
	"David S. Miller" <davem@davemloft.net>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Subject: Re: [PATCH] ppc: Fix BPF JIT for ABIv2
Date: Wed, 22 Jun 2016 15:18:10 +1000	[thread overview]
Message-ID: <1466572690.19785.4.camel@ellerman.id.au> (raw)
In-Reply-To: <20160617130042.GO3516@indiana.gru.redhat.com>

On Fri, 2016-06-17 at 10:00 -0300, Thadeu Lima de Souza Cascardo wrote:
> From a984dc02b6317a1d3a3c2302385adba5227be5bd Mon Sep 17 00:00:00 2001
> From: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
> Date: Wed, 15 Jun 2016 13:22:12 -0300
> Subject: [PATCH] ppc: Fix BPF JIT for ABIv2
> 
> ABIv2 used for ppc64le does not use function descriptors. Without this patch,
> whenever BPF JIT is enabled, we get a crash as below.
> 
...

> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
> index 889fd19..28b89ed 100644
> --- a/arch/powerpc/net/bpf_jit.h
> +++ b/arch/powerpc/net/bpf_jit.h
> @@ -70,7 +70,7 @@ DECLARE_LOAD_FUNC(sk_load_half);
>  DECLARE_LOAD_FUNC(sk_load_byte);
>  DECLARE_LOAD_FUNC(sk_load_byte_msh);
>  
> -#ifdef CONFIG_PPC64
> +#if defined(CONFIG_PPC64) && (!defined(_CALL_ELF) || _CALL_ELF != 2)
>  #define FUNCTION_DESCR_SIZE	24
>  #else
>  #define FUNCTION_DESCR_SIZE	0
> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index 2d66a84..035b887 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -664,7 +664,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
>  
>  	if (image) {
>  		bpf_flush_icache(code_base, code_base + (proglen/4));
> -#ifdef CONFIG_PPC64
> +#if defined(CONFIG_PPC64) && (!defined(_CALL_ELF) || _CALL_ELF != 2)
>  		/* Function descriptor nastiness: Address + TOC */
>  		((u64 *)image)[0] = (u64)code_base;
>  		((u64 *)image)[1] = local_paca->kernel_toc;


Confirmed that even with this patch we still crash:

  # echo 1 > /proc/sys/net/core/bpf_jit_enable
  # modprobe test_bpf
  BPF filter opcode 0020 (@3) unsupported
  BPF filter opcode 0020 (@2) unsupported
  BPF filter opcode 0020 (@0) unsupported
  Unable to handle kernel paging request for data at address 0xd0000000054f65e8
  Faulting instruction address: 0xc0000000008765f8
  cpu 0x0: Vector: 300 (Data Access) at [c0000000034f3480]
      pc: c0000000008765f8: skb_copy_bits+0x158/0x330
      lr: c00000000008fb7c: bpf_slow_path_byte+0x28/0x54
      sp: c0000000034f3700
     msr: 800000010280b033
     dar: d0000000054f65e8
   dsisr: 40000000
    current = 0xc0000001f857d8d0
    paca    = 0xc000000007b80000	 softe: 0	 irq_happened: 0x01
      pid   = 2993, comm = modprobe
  Linux version 4.7.0-rc3-00055-g9497a1c1c5b4-dirty (michael@ka3.ozlabs.ibm.com) () #30 SMP Wed Jun 22 15:06:58 AEST 2016
  enter ? for help
  [c0000000034f3770] c00000000008fb7c bpf_slow_path_byte+0x28/0x54
  [c0000000034f37e0] d000000007bb004c
  [c0000000034f3900] d000000005331668 test_bpf_init+0x5fc/0x7f8 [test_bpf]
  [c0000000034f3a30] c00000000000b628 do_one_initcall+0x68/0x1d0
  [c0000000034f3af0] c0000000009beb24 do_init_module+0x90/0x240
  [c0000000034f3b80] c0000000001642bc load_module+0x206c/0x22f0
  [c0000000034f3d30] c0000000001648b0 SyS_finit_module+0x120/0x180
  [c0000000034f3e30] c000000000009260 system_call+0x38/0x108
  --- Exception: c01 (System Call) at 00003fff7ffa2db4


cheers

  parent reply	other threads:[~2016-06-22  5:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07 13:32 [PATCH 0/6] eBPF JIT for PPC64 Naveen N. Rao
2016-06-07 13:32 ` [PATCH 1/6] ppc: bpf/jit: Fix/enhance 32-bit Load Immediate implementation Naveen N. Rao
2016-06-07 13:32 ` [PATCH 2/6] ppc: bpf/jit: Optimize 64-bit Immediate loads Naveen N. Rao
2016-06-07 13:32 ` [PATCH 3/6] ppc: bpf/jit: Introduce rotate immediate instructions Naveen N. Rao
2016-06-07 13:32 ` [PATCH 4/6] ppc: bpf/jit: A few cleanups Naveen N. Rao
2016-06-07 13:32 ` [PATCH 5/6] ppc: bpf/jit: Isolate classic BPF JIT specifics into a separate header Naveen N. Rao
2016-06-07 13:32 ` [PATCH 6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF Naveen N. Rao
2016-06-07 22:56   ` Alexei Starovoitov
2016-06-08 17:17     ` Naveen N. Rao
2016-06-09  3:19   ` Nilay Vaish
2016-06-09  6:07     ` Naveen N. Rao
2016-06-17 12:53   ` [6/6] " Michael Ellerman
2016-06-17 13:00     ` [PATCH] ppc: Fix BPF JIT for ABIv2 Thadeu Lima de Souza Cascardo
2016-06-19 17:49       ` Naveen N. Rao
2016-06-20 18:56         ` Thadeu Lima de Souza Cascardo
2016-06-21  8:58           ` Naveen N. Rao
2016-06-21 11:15             ` Michael Ellerman
2016-06-21 14:47               ` Thadeu Lima de Souza Cascardo
2016-06-21 15:45                 ` Alexei Starovoitov
2016-06-22  4:06                   ` Michael Ellerman
2016-06-22  7:12                 ` Naveen N. Rao
2016-06-22 14:57                   ` Naveen N. Rao
2016-06-22  5:20             ` Michael Ellerman
2016-06-22  5:18       ` Michael Ellerman [this message]
2016-06-19 17:36     ` [6/6] ppc: ebpf/jit: Implement JIT compiler for extended BPF Naveen N. Rao
2016-06-20 23:38       ` Michael Ellerman
2016-06-21  6:58         ` Naveen N. Rao
2016-06-21 11:04           ` Michael Ellerman
2016-06-22  7:06             ` Naveen N. Rao
2016-06-22 10:37   ` [PATCH 6/6] " Michael Ellerman
2016-06-22 12:32     ` Naveen N. Rao
2016-06-11  5:47 ` [PATCH 0/6] eBPF JIT for PPC64 David Miller
2016-06-13  5:40   ` Naveen N. Rao
2016-06-18  4:57     ` mpe

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=1466572690.19785.4.camel@ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=ananth@in.ibm.com \
    --cc=ast@fb.com \
    --cc=cascardo@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kda@linux-powerpc.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=matt@ozlabs.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulus@samba.org \
    /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).