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=-7.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 7272DC433DF for ; Wed, 29 Jul 2020 17:29:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 463F5207F5 for ; Wed, 29 Jul 2020 17:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596043744; bh=HmukCrIYPvc9eXdlTyus9h4Qn/xgV4LD5QrrQcS2+8o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=i+4KXSndAzWEDcjozvruPPPVZFUBeAen54JI1MWz/cIh5ihh1lYJ6XulptBRFXZwY /xrdrea6R8vviuAjLiDYidFe+erCE3dcnqyHiDS2WIlcwCzPwbh+K1g1neFgA7kzfh RZQsXPP+jM496iZwLm9ozIl6RahviHgWZ3g4N3OA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgG2R3E (ORCPT ); Wed, 29 Jul 2020 13:29:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:38720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbgG2R3D (ORCPT ); Wed, 29 Jul 2020 13:29:03 -0400 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7B2620809 for ; Wed, 29 Jul 2020 17:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596043743; bh=HmukCrIYPvc9eXdlTyus9h4Qn/xgV4LD5QrrQcS2+8o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=zsUwXxhFxbC3TGVHZ39q2J4CqydNgM50w4EAfHwdyho37TqlsNEiFGaRF+U5udgYr Yh1aUQfjY5W3JrhiwJEonTPCejFa1qjwfkv1yRVKAfyhbgQfw9j5d5GXprzKddE8rk CMXKC3AOdrLTX9YMG+P/4cHn2qXCWRBOJhAxVIpc= Received: by mail-lj1-f177.google.com with SMTP id b25so25929550ljp.6 for ; Wed, 29 Jul 2020 10:29:02 -0700 (PDT) X-Gm-Message-State: AOAM530SEfYL3N5RlgSa59Udne5+ELxqJsapUjFs1ccfo+fGiizRN17/ YE1b2mUULq0FUq+vklL/n1vzx+yQb9q8xLP5kkw= X-Google-Smtp-Source: ABdhPJzSFcir31Ofb7O6Rgb5pjQQdXaXJZKcBTsr9jI/5zHUoNVxsvSQ/KFEUCT+DXGke/w8iA6ENHIfOoyf0GpUesU= X-Received: by 2002:a2e:7c14:: with SMTP id x20mr15597447ljc.41.1596043741122; Wed, 29 Jul 2020 10:29:01 -0700 (PDT) MIME-Version: 1.0 References: <20200728152122.1292756-1-jean-philippe@linaro.org> <20200728152122.1292756-2-jean-philippe@linaro.org> In-Reply-To: <20200728152122.1292756-2-jean-philippe@linaro.org> From: Song Liu Date: Wed, 29 Jul 2020 10:28:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 1/1] arm64: bpf: Add BPF exception tables To: Jean-Philippe Brucker Cc: linux-arm-kernel@lists.infradead.org, bpf , Catalin Marinas , Will Deacon , Daniel Borkmann , Alexei Starovoitov , zlim.lnx@gmail.com, Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh Content-Type: text/plain; charset="UTF-8" Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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 It is possible to add a selftest for this? I thought about this a little bit, but didn't get a good idea. Thanks, Song 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=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 DA007C433E0 for ; Wed, 29 Jul 2020 17:31:17 +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 A9198207F5 for ; Wed, 29 Jul 2020 17:31:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lb50yYyX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zsUwXxhF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9198207F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tRyolo+W/x/54JuLaXd6Djw2oAN0c4kTUTOP5rRcdwg=; b=lb50yYyXrApVuauElOgBJBM3C 2YOCIZimcimDsaCAbHT5f7ZoZviQDddHhOjaPXac1xUZBb2I9PcJEfaaMatT6NXB3zP7eKMaNWHKE /PCKOq0J8uvpXU7kBCdWqwazEZviSqy0/GC5wUp4j6xOBqsniLKW+wWqH6MKj/OciR2LLGxD/aBoC Nx1jp20iSWrTfKRiFHUejSX/POr7fsTR/6jBpdaIamX9e16kF434pc87dBwwI96lzbeV2a1LOqQbS /am5qvHDspQMTJvTGE4lgfzZ3/h/P8mJfTvsMFtVQroJFXLWENPhmmcSgMpje/ELAdgwklhTl3NFw 5CLb1F2EQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0pt5-0008P7-LO; Wed, 29 Jul 2020 17:29:07 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0pt2-0008Od-Ll for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2020 17:29:05 +0000 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8F1E21883 for ; Wed, 29 Jul 2020 17:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596043743; bh=HmukCrIYPvc9eXdlTyus9h4Qn/xgV4LD5QrrQcS2+8o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=zsUwXxhFxbC3TGVHZ39q2J4CqydNgM50w4EAfHwdyho37TqlsNEiFGaRF+U5udgYr Yh1aUQfjY5W3JrhiwJEonTPCejFa1qjwfkv1yRVKAfyhbgQfw9j5d5GXprzKddE8rk CMXKC3AOdrLTX9YMG+P/4cHn2qXCWRBOJhAxVIpc= Received: by mail-lj1-f180.google.com with SMTP id f5so25922281ljj.10 for ; Wed, 29 Jul 2020 10:29:02 -0700 (PDT) X-Gm-Message-State: AOAM532YJDeZq0k+H6hFHLlUXWQQIsexpQ9g+iqfdOywwwJsEVXrJAXp mCoC5U4LYhuicCQNyaZ2Y9rkROcOW1qbkhsmlIY= X-Google-Smtp-Source: ABdhPJzSFcir31Ofb7O6Rgb5pjQQdXaXJZKcBTsr9jI/5zHUoNVxsvSQ/KFEUCT+DXGke/w8iA6ENHIfOoyf0GpUesU= X-Received: by 2002:a2e:7c14:: with SMTP id x20mr15597447ljc.41.1596043741122; Wed, 29 Jul 2020 10:29:01 -0700 (PDT) MIME-Version: 1.0 References: <20200728152122.1292756-1-jean-philippe@linaro.org> <20200728152122.1292756-2-jean-philippe@linaro.org> In-Reply-To: <20200728152122.1292756-2-jean-philippe@linaro.org> From: Song Liu Date: Wed, 29 Jul 2020 10:28:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 1/1] arm64: bpf: Add BPF exception tables To: Jean-Philippe Brucker X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_132904_866481_7CB7FC9B X-CRM114-Status: GOOD ( 18.03 ) 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 , Daniel Borkmann , 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 It is possible to add a selftest for this? I thought about this a little bit, but didn't get a good idea. Thanks, Song _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel