Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759165AbcDAOm7 (ORCPT ); Fri, 1 Apr 2016 10:42:59 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:60215 "EHLO e23smtp08.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751587AbcDAOm5 (ORCPT ); Fri, 1 Apr 2016 10:42:57 -0400 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: naveen.n.rao@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;netdev@vger.kernel.org Date: Fri, 1 Apr 2016 20:11:31 +0530 From: "Naveen N. Rao" To: Alexei Starovoitov Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, "David S . Miller" , Daniel Borkmann Subject: Re: [PATCH 4/4] samples/bpf: Enable powerpc support Message-ID: <20160401144131.GG17907@naverao1-tp.ibm.com> References: <922f95fb5d16686367a66d2d4bd176149a87e9ad.1459423412.git.naveen.n.rao@linux.vnet.ibm.com> <28a3811d03f6e8f7dca989a4ade536bf9aa8c7ce.1459423412.git.naveen.n.rao@linux.vnet.ibm.com> <56FD63F4.2010500@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56FD63F4.2010500@fb.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16040114-0029-0000-0000-0000453599A6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1360 Lines: 35 On 2016/03/31 10:52AM, Alexei Starovoitov wrote: > On 3/31/16 4:25 AM, Naveen N. Rao wrote: > ... > >+ > >+#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. To be sure I understand this right, do you mean something like this? + +#ifdef __powerpc__ +#define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; }) +#define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP +#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))); }) +#endif + Thanks, Naveen