From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CCFFC433DF for ; Wed, 29 Jul 2020 21:29:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6368206D7 for ; Wed, 29 Jul 2020 21:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgG2V3s (ORCPT ); Wed, 29 Jul 2020 17:29:48 -0400 Received: from www62.your-server.de ([213.133.104.62]:39626 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2V3s (ORCPT ); Wed, 29 Jul 2020 17:29:48 -0400 Received: from sslproxy03.your-server.de ([88.198.220.132]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1k0tdw-0006LB-BM; Wed, 29 Jul 2020 23:29:44 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0tdw-000LCe-1p; Wed, 29 Jul 2020 23:29:44 +0200 Subject: Re: [PATCH bpf-next 1/1] arm64: bpf: Add BPF exception tables To: Song Liu , Jean-Philippe Brucker Cc: linux-arm-kernel@lists.infradead.org, bpf , Catalin Marinas , Will Deacon , Alexei Starovoitov , zlim.lnx@gmail.com, Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh References: <20200728152122.1292756-1-jean-philippe@linaro.org> <20200728152122.1292756-2-jean-philippe@linaro.org> From: Daniel Borkmann Message-ID: <4791872a-9f7e-1c1c-392c-8b68a13091e3@iogearbox.net> Date: Wed, 29 Jul 2020 23:29:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.3/25888/Wed Jul 29 16:57:45 2020) Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 7/29/20 7:28 PM, Song Liu wrote: > On Tue, Jul 28, 2020 at 8:37 AM Jean-Philippe Brucker > wrote: >> >> When a tracing BPF program attempts to read memory without using the >> bpf_probe_read() helper, the verifier marks the load instruction with >> the BPF_PROBE_MEM flag. Since the arm64 JIT does not currently recognize >> this flag it falls back to the interpreter. >> >> Add support for BPF_PROBE_MEM, by appending an exception table to the >> BPF program. If the load instruction causes a data abort, the fixup >> infrastructure finds the exception table and fixes up the fault, by >> clearing the destination register and jumping over the faulting >> instruction. >> >> To keep the compact exception table entry format, inspect the pc in >> fixup_exception(). A more generic solution would add a "handler" field >> to the table entry, like on x86 and s390. >> >> Signed-off-by: Jean-Philippe Brucker > > This patch looks good to me. > > Acked-by: Song Liu +1, applied, thanks a lot! > It is possible to add a selftest for this? I thought about this a > little bit, but > didn't get a good idea. Why not adding a test_verifier.c test case which calls into bpf_get_current_task() to fetch pointer to current and then read out some field via BPF_PROBE_MEM which should then succeed on x86/s390x/arm64 but be skipped on the other archs? Jean-Philippe, could you look into following up with such test case(s)? Thanks, Daniel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C192AC433E0 for ; Wed, 29 Jul 2020 21:31:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A2E7206D7 for ; Wed, 29 Jul 2020 21:31:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tJb3hQUo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A2E7206D7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=iogearbox.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FaUzQ7oN0trSxC8Z3vVHxBpMxd75FR0GvXzvTDLTuXM=; b=tJb3hQUo+AMfi+nOXVIMGplGH QwetbRUCw8MP6SFRtA26Qif+5433zozWgVMcfdSZb18Ks/RFfNVGNiOVT8KBiUAe3U1O8CjS9rxw4 jE8o1nwH/9v9/UgI9T+2yPdVgYRzOpBXENkGCPVBuNDCcdkTWvpLUYkHp48aIgUZrsbJidR2LFa5a QcWcg4RHL+rh9xXilw0pXKdj59zxfp1aTQ6Vgc6nj35nF8XKlw84Djs2fJeFwvybif9ElxIG3XUEk p1isQOktiY+Zw6XXKvXPt8Lm8yS/+H2p+9pB50VCere0bNzEMMDjvNydDMJ35CHsVHizP3V3ZD5PG +L1n3C/ig==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0te6-0002sB-3N; Wed, 29 Jul 2020 21:29:54 +0000 Received: from www62.your-server.de ([213.133.104.62]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0te0-0002rQ-Li for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2020 21:29:49 +0000 Received: from sslproxy03.your-server.de ([88.198.220.132]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1k0tdw-0006LB-BM; Wed, 29 Jul 2020 23:29:44 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k0tdw-000LCe-1p; Wed, 29 Jul 2020 23:29:44 +0200 Subject: Re: [PATCH bpf-next 1/1] arm64: bpf: Add BPF exception tables To: Song Liu , Jean-Philippe Brucker References: <20200728152122.1292756-1-jean-philippe@linaro.org> <20200728152122.1292756-2-jean-philippe@linaro.org> From: Daniel Borkmann Message-ID: <4791872a-9f7e-1c1c-392c-8b68a13091e3@iogearbox.net> Date: Wed, 29 Jul 2020 23:29:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.3/25888/Wed Jul 29 16:57:45 2020) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_172948_871459_0ACD6185 X-CRM114-Status: GOOD ( 18.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , Andrii Nakryiko , Catalin Marinas , John Fastabend , Alexei Starovoitov , zlim.lnx@gmail.com, KP Singh , Yonghong Song , bpf , Will Deacon , Martin KaFai Lau , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/29/20 7:28 PM, Song Liu wrote: > On Tue, Jul 28, 2020 at 8:37 AM Jean-Philippe Brucker > wrote: >> >> When a tracing BPF program attempts to read memory without using the >> bpf_probe_read() helper, the verifier marks the load instruction with >> the BPF_PROBE_MEM flag. Since the arm64 JIT does not currently recognize >> this flag it falls back to the interpreter. >> >> Add support for BPF_PROBE_MEM, by appending an exception table to the >> BPF program. If the load instruction causes a data abort, the fixup >> infrastructure finds the exception table and fixes up the fault, by >> clearing the destination register and jumping over the faulting >> instruction. >> >> To keep the compact exception table entry format, inspect the pc in >> fixup_exception(). A more generic solution would add a "handler" field >> to the table entry, like on x86 and s390. >> >> Signed-off-by: Jean-Philippe Brucker > > This patch looks good to me. > > Acked-by: Song Liu +1, applied, thanks a lot! > It is possible to add a selftest for this? I thought about this a > little bit, but > didn't get a good idea. Why not adding a test_verifier.c test case which calls into bpf_get_current_task() to fetch pointer to current and then read out some field via BPF_PROBE_MEM which should then succeed on x86/s390x/arm64 but be skipped on the other archs? Jean-Philippe, could you look into following up with such test case(s)? Thanks, Daniel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel