Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp963511pxb; Wed, 27 Oct 2021 16:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8oUtQKITa18Hls00TlfdgnpO1n4wRFp5TKUbKhJsj8jPOrU6VtUgWIeUnu5fkaKih0iKX X-Received: by 2002:a17:907:961a:: with SMTP id gb26mr657029ejc.527.1635376410981; Wed, 27 Oct 2021 16:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635376410; cv=none; d=google.com; s=arc-20160816; b=e58q/FisrMau7wn6GY09YFx/T7ATc/+dIDDpRj/7QlPvUq2j325KCgnb0bNngk1DTJ YxozOCG9ujgn5/PvSEs0v0WzXNKLxfC+nbVYaCI1OVTbHBfPwBUu8qh91xiZXAeuuz/w Mg3upu+O4tF1zlRuHS+o1L77l0zWP6QzTSwWQAJVkxPpoJtQU89AeCqTES7P+iTN+8GY 4te9T/tx41iCOYe7DKVjgWeODUfuFuQ5ysNmP90LwpKojL7c0SpQ6f63wTMd94IGbqeN XwAmORvq5XYrXWC+J6LazdRC6uxCWeZxmhdg12hDYXKWmMwNWSUWOfiI5NlDCA2veuHN ydSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=WmcsE9eHSr5Bj7N8i6SNntSwg6lwYweWGlLvvuZ7vBk=; b=TW38ouz5IUbW0WmXW8cjZG5my1a5so9Ui1je5mxuGJq5m1pstqAmrbObGhU05j3HTU uLEHA9IBUwQwzRj4j7xY0wr5av6umxzNe6zO2+JkjGa70NoyoVxYkIaHMmBzxBinrwEq ZvLgmprLGaKe9fcBczxB6LJvLjei7ZzwUcZYAt5XK3/t3aYKzZ3PIA69nsx1fKuDYdmH 8NpW3yMdyFuKvog4EgkxwsZcatnKEpnlU4AOumMS6ZtBBj4G+20QCBseLn8kQEyFmgVd iOBuxkZs77qbX0TVdw5GaxgdnSOaIOjVy3IvHe9F9lnynwD8Yv1jE7UEjuHC5hG/2EV6 BtYQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt3si1913132ejc.659.2021.10.27.16.13.06; Wed, 27 Oct 2021 16:13:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbhJ0XNo (ORCPT + 99 others); Wed, 27 Oct 2021 19:13:44 -0400 Received: from www62.your-server.de ([213.133.104.62]:40952 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbhJ0XNm (ORCPT ); Wed, 27 Oct 2021 19:13:42 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mfs4W-000F2p-5m; Thu, 28 Oct 2021 01:11:04 +0200 Received: from [85.1.206.226] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfs4V-000GPT-Q9; Thu, 28 Oct 2021 01:11:03 +0200 Subject: Re: [PATCH bpf-next,v3] riscv, bpf: Add BPF exception tables To: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Tong Tiangen 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 References: <20211027111822.3801679-1-tongtiangen@huawei.com> From: Daniel Borkmann Message-ID: <15487721-b3de-73c7-5ef3-614c6da2f8cd@iogearbox.net> Date: Thu, 28 Oct 2021 01:11:03 +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: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.3/26335/Wed Oct 27 10:28:55 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, Daniel