Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1040667pxb; Wed, 27 Oct 2021 18:02:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTJwcKI0VrPvkTidEJqBuK+okAxnhhNUk0kiOEA0yjbDa7NI6xaXManO05Uygp91mj8hPm X-Received: by 2002:a17:906:a986:: with SMTP id jr6mr1281580ejb.520.1635382969708; Wed, 27 Oct 2021 18:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635382969; cv=none; d=google.com; s=arc-20160816; b=CzwEqPENSicjLBT3GFTgT2+poobgR5EUm8vai2fybY1S3BtnED3QJHyYzHaaVgakc9 ngQdGIeRfZlJcgZuYcB5wGRnbNPsjG8Lsk9zcBXJgTKty2GrKhay4pq/TC6tfw318ne+ CnRBykM03mytaKIzKbUZF96niAaEfWqAlmUwucYWjkQbL92kA0Gu2UMf1euNgA9alcQJ WqRQniIK6sih6VEKMaFrBUTMw5URCppc3H5X8OJth/0dlREQA7KxM32k3KPnX3zwWF9k 4SxRtIFwgnQZ7cDB79/JdyUQ2aGIV73WHsctFPawpnbebEhZVC0Ge0KGTorctwasUsJb EhlQ== 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=iEOG28nJmfP1bsH+YqAtdLIw14lgxDm45I83x77EvMA=; b=XfiXN7ylr4fpmfnQlJVfbKnchhMQfiUaEYYiT9f2WGbcin48f7u9ZP9S6eyYTilVFH BdNoSgLhRN3rjJcJdN7hahUwVtxY0uI/LwZl4Zfd6a7qVdA773jgtp+rw8QNaqpPfwd8 neITfyxzzsHKm0J5Hpo3NgXcrXodOvpT7ifn/ouV+qnFJrnNd/xZ7UXUxKu1pQPU2IA9 F0y2OS1x+Sx9UE1mZ6a48BWUroQG2CIj5121K/sILqWsrjsfb0wSoQNkDKElnEv7YUPd LLZmZIwWvt1mysjwp3PgfASR871UpLSF51Yjk5NV1WM/rgePWHphjm9bKaPLciP7L0Nc wB+Q== 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 e10si1684177eja.731.2021.10.27.18.02.20; Wed, 27 Oct 2021 18:02:49 -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 S229612AbhJ1BCe (ORCPT + 99 others); Wed, 27 Oct 2021 21:02:34 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:26129 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbhJ1BCe (ORCPT ); Wed, 27 Oct 2021 21:02:34 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4HfnH018nsz1DHqv; Thu, 28 Oct 2021 08:58:04 +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:00:00 +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 08:59:58 +0800 Subject: Re: [PATCH bpf-next,v3] riscv, bpf: Add BPF exception tables To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= References: <20211027111822.3801679-1-tongtiangen@huawei.com> CC: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , Luke Nelson , Xi Wang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-riscv , LKML , Netdev , bpf From: tongtiangen Message-ID: Date: Thu, 28 Oct 2021 08:59:58 +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: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 0:55, 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! Exciting test result, Thanks! > > 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.: > > * 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 > > Feel free to add: > > Acked-by: Björn Töpel > >> v2: >> Modify according to Björn's comments, mainly removes redundant head files >> extable.h and some code style issues. >> >> arch/riscv/mm/extable.c | 19 +++- >> arch/riscv/net/bpf_jit.h | 1 + >> arch/riscv/net/bpf_jit_comp64.c | 185 +++++++++++++++++++++++++------- >> arch/riscv/net/bpf_jit_core.c | 19 ++-- >> 4 files changed, 177 insertions(+), 47 deletions(-) >> > > [...] > > Björn > . >