Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2330197pxf; Sat, 27 Mar 2021 08:27:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypgg8sBzRjqyG8jPQKYnA/InYYaui1e7IIfd2+IKkLLmrjr/91TOF1jedO8pOp5yaDetRN X-Received: by 2002:aa7:d347:: with SMTP id m7mr20316875edr.260.1616858828149; Sat, 27 Mar 2021 08:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616858828; cv=none; d=google.com; s=arc-20160816; b=ocHv9o4ozLSpYilNvvmqPJpk8/S4BRyyeJ6wEXakbunMI9Sqcta0qOJm52Cmy+iaZS qofjCJ9F3ypOAFOH2UP+DmcXhSuwr/jzloRwKXy2m0S0+zL1jDyPTfr5hOho1PwnF805 zbwlJktMoVtZVf5CCnsx5klbdoYJ49B2tqOX9ZcQjc5Vv2NlB/IUL9Pq4xeYDP8lEfPp KUDOQ3aTEvOtZ3cTFYmwH/3EYRjcIiTYwKhVPasOlE4SBtm9M4A54MpcrL6p80JTMUaL IpXdB7fzqvkmtVYjzbzgfznJufZ0AsSWZKX1W6ZDk2SWIlBpkEDiGNDCs0EC0vHWBnxk ViPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3nfaLcfvMwThD5Igi3QFoIdDn7FNudL9M+Vh7hiOmrk=; b=idwZfrBP58l6y3xABSA2nRpKIVzi+dembMO56Oezomdc5/1j70KdwtCxj/vNuwK0Lx A7IdAyiHL7O1kX7OViO8VwITkVzHWAZNwYv66Bk5OYDxoBW1uSGNFhcxxgy+nNCBlZi6 rEbcPdOa7vOc775NS/5sAxkXIXtqkvetcroH5CuRMAXGBMZbN/JxZJDMHOHqZmKytCL5 rCn6gBd6fVPd36LyZfWAOlQHFqJUelqulkIPm18c4i4SAuijRKacy8wcbY8osXvOtsrC Gpkm4NCHGIzmxUHh4oNeE4i/jbohDoVZv91+uMo8hvmE8JL7/dhHP016/jUPDmnc/vE5 NQNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AzFAeYM8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si9653530edd.510.2021.03.27.08.26.45; Sat, 27 Mar 2021 08:27:08 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AzFAeYM8; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbhC0PTk (ORCPT + 99 others); Sat, 27 Mar 2021 11:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbhC0PTU (ORCPT ); Sat, 27 Mar 2021 11:19:20 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7EF0C0613B1; Sat, 27 Mar 2021 08:19:19 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id 15so10868027ljj.0; Sat, 27 Mar 2021 08:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3nfaLcfvMwThD5Igi3QFoIdDn7FNudL9M+Vh7hiOmrk=; b=AzFAeYM8A8Dovwg96WQrnrrRON+5Qt+zy2GIt1lNc6QuTt+wecZpEBTGY3NCDiQapq 6OD1okrvqen9EdIFeD7tY99IO/aQaT//OR2oL85CDX5SMJdXUvsI1Cfkl5xvXMSj7luu +evytWD6UeMFhj11pHYYCSY8+yPHozKwPgK0ImtWCX9jK4OshCrZmBiw/XLuFnogmoV6 TXfSyX0Cgb6diM9upg8ZCaF61Jvqep17rNBFufjbRVXmIL0dAHPVzF/JwzL6mBqsN9Sr QTdD4mE9Ns0HgWbJqCAcRoJlKho9vUn9jgk88Z+Ebq0IklrVLEdaQwNJfpwf/YJpiLqm 6Gag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3nfaLcfvMwThD5Igi3QFoIdDn7FNudL9M+Vh7hiOmrk=; b=d4sy42TkANsKdgvgME3QVdrJUsYbvS+lbZ5OsIChkQI875AFJbIqcVpOspeWyA1uh3 qZH/V7qdRNPScYhZ1x0hF3OUOuEA/nYq3S5c+ni/5Dru5iyAMu/1mMpIM0RUgbNbY/44 LN70ukiBeyB8nDXcRkN4lO14MghDZ0qz0lHuZBx+uSV8RO64mB1pNEte3y6x4A229+rN O0AqhCArhZLkktzXrcsbCcrX2uTA/cbE4pHZDcRXfBeR7AX0yO+FHPM6UF/KvLFPcKO3 /6lGjf4Dtf5jvv61kP+Gs1+/SfyF5IDeChYTFmdy8FoRkXS1FqZ/dueMNGq6ZVlhBPdw /jmA== X-Gm-Message-State: AOAM530ptqmv8LZ1wEAJOAYByzwDJ5aUd3nkCSjb4zyzBOVBFExsW3O7 4+uWiF6hJH5Tr0qvSozaEyVdOUsmu0dkapM++iI= X-Received: by 2002:a2e:3608:: with SMTP id d8mr12475794lja.21.1616858358350; Sat, 27 Mar 2021 08:19:18 -0700 (PDT) MIME-Version: 1.0 References: <20210326124030.1138964-1-Jianlin.Lv@arm.com> In-Reply-To: From: Alexei Starovoitov Date: Sat, 27 Mar 2021 08:19:07 -0700 Message-ID: Subject: Re: [PATCH bpf-next] bpf: trace jit code when enable BPF_JIT_ALWAYS_ON To: Jianlin Lv Cc: bpf , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Alexander Viro , Andrey Ignatov , Dmitry Vyukov , Nicolas Dichtel , Kees Cook , Masahiro Yamada , Mahesh Bandewar , LKML , Network Development , "iecedge@gmail.com" , nd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 27, 2021 at 1:19 AM Jianlin Lv wrote: > > > On Fri, Mar 26, 2021 at 5:40 AM Jianlin Lv wrote: > > > > > > When CONFIG_BPF_JIT_ALWAYS_ON is enabled, the value of > > bpf_jit_enable > > > in /proc/sys is limited to SYSCTL_ONE. This is not convenient for deb= ugging. > > > This patch modifies the value of extra2 (max) to 2 that support > > > developers to emit traces on kernel log. > > > > > > Signed-off-by: Jianlin Lv > > > --- > > > net/core/sysctl_net_core.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c > > > index d84c8a1b280e..aa16883ac445 100644 > > > --- a/net/core/sysctl_net_core.c > > > +++ b/net/core/sysctl_net_core.c > > > @@ -386,7 +386,7 @@ static struct ctl_table net_core_table[] =3D { > > > .proc_handler =3D proc_dointvec_minmax_bpf_enable, > > > # ifdef CONFIG_BPF_JIT_ALWAYS_ON > > > .extra1 =3D SYSCTL_ONE, > > > - .extra2 =3D SYSCTL_ONE, > > > + .extra2 =3D &two, > > > > "bpftool prog dump jited" is much better way to examine JITed dumps. > > I'd rather remove bpf_jit_enable=3D2 altogether. > > In my case, I introduced a bug when I made some adjustments to the arm64 > jit macro A64_MOV(), which caused the SP register to be replaced by the > XZR register when building prologue, and the wrong value was stored in fp= , > which triggered a crash. > > This bug is likely to cause the instruction to access the BPF stack in > jited prog to trigger a crash. > I tried to use bpftool to debug, but bpftool crashed when I executed the > "bpftool prog show" command. > The syslog shown that bpftool is loading and running some bpf prog. > because of the bug in the JIT compiler, the bpftool execution failed. Right 'bpftool prog show' command is loading a bpf iterator prog, but you didn't need to use it to dump JITed code. "bpftool prog dump jited name my_prog" would have dumped it even when JIT is all buggy. > bpf_jit_disasm saved me, it helped me dump the jited image: > > echo 2> /proc/sys/net/core/bpf_jit_enable > modprobe test_bpf test_name=3D"SPILL_FILL" > ./bpf_jit_disasm -o > > So keeping bpf_jit_enable=3D2 is still very meaningful for developers who > try to modify the JIT compiler. sure and such JIT developers can compile the kernel without BPF_JIT_ALWAYS_ON just like you did. They can also insert printk, etc. bpf_jit_enable=3D2 was done long ago when there was no other way to see JITed code. Now we have proper apis. That =3D2 mode can and should be removed. > IMPORTANT NOTICE: The contents of this email and any attachments are conf= idential and may also be privileged. If you are not the intended recipient,= please notify the sender immediately and do not disclose the contents to a= ny other person, use it for any purpose, or store or copy the information i= n any medium. Thank you. please fix your email server/client/whatever. No patches will ever be accepted with such disclaimer.