Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757736AbcCaRx0 (ORCPT ); Thu, 31 Mar 2016 13:53:26 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:43943 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755767AbcCaRxZ (ORCPT ); Thu, 31 Mar 2016 13:53:25 -0400 Subject: Re: [PATCH 4/4] samples/bpf: Enable powerpc support To: "Naveen N. Rao" , , References: <922f95fb5d16686367a66d2d4bd176149a87e9ad.1459423412.git.naveen.n.rao@linux.vnet.ibm.com> <28a3811d03f6e8f7dca989a4ade536bf9aa8c7ce.1459423412.git.naveen.n.rao@linux.vnet.ibm.com> CC: "David S . Miller" , Ananth N Mavinakayanahalli , Michael Ellerman , Daniel Borkmann , From: Alexei Starovoitov Message-ID: <56FD63F4.2010500@fb.com> Date: Thu, 31 Mar 2016 10:52:52 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <28a3811d03f6e8f7dca989a4ade536bf9aa8c7ce.1459423412.git.naveen.n.rao@linux.vnet.ibm.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-03-31_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1167 Lines: 29 On 3/31/16 4:25 AM, Naveen N. Rao wrote: > Add the necessary definitions for building bpf samples on ppc. > > Since ppc doesn't store function return address on the stack, modify how > PT_REGS_RET() and PT_REGS_FP() work. > > Also, introduce PT_REGS_IP() to access the instruction pointer. I have > fixed this to work with x86_64 and arm64, but not s390. > > Cc: Alexei Starovoitov > Cc: David S. Miller > Cc: Ananth N Mavinakayanahalli > Cc: Michael Ellerman > Signed-off-by: Naveen N. Rao > --- ... > + > +#ifdef __powerpc__ > +#define BPF_KPROBE_READ_RET_IP(ip, ctx) { (ip) = (ctx)->link; } > +#define BPF_KRETPROBE_READ_RET_IP(ip, ctx) BPF_KPROBE_READ_RET_IP(ip, ctx) > +#else > +#define BPF_KPROBE_READ_RET_IP(ip, ctx) \ > + bpf_probe_read(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx)) > +#define BPF_KRETPROBE_READ_RET_IP(ip, ctx) \ > + bpf_probe_read(&(ip), sizeof(ip), \ > + (void *)(PT_REGS_FP(ctx) + sizeof(ip))) makes sense, but please use ({ }) gcc extension instead of {} and open call to make sure that macro body is scoped.