Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1041952pxb; Wed, 27 Oct 2021 18:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYuwixuSXGtzmWOpFQb/zzhmVf9maKUAaUSu5tD9fhCSdyVvSVmvegaIW1SAgpQ7idWqev X-Received: by 2002:a17:906:64a:: with SMTP id t10mr1341241ejb.5.1635383067956; Wed, 27 Oct 2021 18:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635383067; cv=none; d=google.com; s=arc-20160816; b=VUqNo4jV9dDpzisOptmB80fDsaebCx4j2JYXWEdi3KlLze5PgeqM5QjjZcVZAMdpbA SWot41JmVWVipyi7t50EbJRnsbdzdXWLn6eO7cB5k110eHF60FVZnefAH5gGFnd88fSR jiZ0qCSe1Uy8vKcHMPwQXu+8okqAqAPxCxVZQQhhAtT94G+/SznN0KuYHIvjjnMcTSXj FlZ6/jX8NMgg2V3qjkSPWh9zY/SQ+WkngvsFdo3jSebz3n8WZH5yHfBJdlHbMUzFZkfv bwJI+KlHGlyPmBSAds7Kc3rrJEx9bLsEcthHJrfbecQF5R9HrVNLzXJZv3cgrjTQYxvH myGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=cuA+Oe4gWZtB5wt7KuN2s0tQtcC3Wvxu+fGoDmPD1pg=; b=LowJgMZIB+raimJG03HqZtT43kb8XAHKQT4ZqWB/dawWkpiX76fA/9Lznz+MPnPU9A 9OvFPttj/7FpoMQo+CExMncuZilO1o8LzCpt+1C8gVIqfx9YObhqItSy+Y/bq0PjmjFi 6ELGHf5sVqcZbT1HXg7BeBPux46kekvIovt/GoIGuFkun/ytxrxeoG2e4c9gQUkdYImO cMROvWWq677sv+LSKWzsZvkVmKlJKVMW0obOpQuRdOgYL2r+lG5+HdNxBCQnLng+NipL rF0FqgAppus35mo2B2gk/7k/PG8YJMftcdzgeFsXPzyrmbb/UQ75D+KgaCGezY1SY1hx r1Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cr12si2181207ejc.593.2021.10.27.18.04.05; Wed, 27 Oct 2021 18:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbhJ1BE1 (ORCPT + 99 others); Wed, 27 Oct 2021 21:04:27 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13983 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbhJ1BE1 (ORCPT ); Wed, 27 Oct 2021 21:04:27 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HfnKD3KrdzWtCr; Thu, 28 Oct 2021 09:00:00 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 28 Oct 2021 09:01:57 +0800 Received: from [10.174.179.234] (10.174.179.234) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 28 Oct 2021 09:01:55 +0800 Subject: Re: [PATCH bpf-next,v3] riscv, bpf: Add BPF exception tables To: Daniel Borkmann , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= References: <20211027111822.3801679-1-tongtiangen@huawei.com> <15487721-b3de-73c7-5ef3-614c6da2f8cd@iogearbox.net> CC: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , Luke Nelson , Xi Wang , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-riscv , LKML , Netdev , bpf From: tongtiangen Message-ID: <5c38b790-65e9-6ba2-75bd-121d6d51ab34@huawei.com> Date: Thu, 28 Oct 2021 09:01:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <15487721-b3de-73c7-5ef3-614c6da2f8cd@iogearbox.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/28 7:11, Daniel Borkmann wrote: > On 10/27/21 6:55 PM, Björn Töpel wrote: >> On Wed, 27 Oct 2021 at 13:03, Tong Tiangen 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 riscv 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. >>> >>> A more generic solution would add a "handler" field to the table entry, >>> like on x86 and s390. >>> >>> The same issue in ARM64 is fixed in: >>> commit 800834285361 ("bpf, arm64: Add BPF exception tables") >>> >>> Signed-off-by: Tong Tiangen >>> Tested-by: Pu Lehui >>> --- >>> v3: >>> Modify according to Björn's comments, mainly code optimization. >> >> Thank you! >> >> I ran this patch against the test_bpf.ko, and selftests/bpf -- no >> regressions, and after the patch is applied more tests passes. Yay! >> >> On a related note. The RISC-V selftests/bpf is in a pretty lousy >> state. I'll send a cleanup patch for them soonish. E.g.: > > Thanks for testing! > >> * RISC-V is missing in bpf_tracing.h (libbpf) >> * Some programs don't converge in 16 steps, I had to increase it to ~32 >> * The selftest/bpf Makefile needed some RV specific changes >> * ...a lot of tests still don't pass, and needs to be looked in to > > Sounds good, please ship them. ;) > >> Feel free to add: >> >> Acked-by: Björn Töpel > > Applied, thanks! Tong, if you have a chance, please follow up with Mark's > suggestion to align the extable infra to arm64/x86. Thanks, Mark's suggestion is good. I will improve this part if I have the opportunity. > > Thanks, > Daniel > . >