Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1972781ybg; Thu, 30 Jul 2020 07:23:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwni3+uF/aSg8lloxZPyfzeKQpJsaLc4aIMbMJ4bxGWNPOuYRbYc/VHebrFJuTgCqt2XrkS X-Received: by 2002:a05:6402:1e2:: with SMTP id i2mr2833229edy.70.1596118988387; Thu, 30 Jul 2020 07:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596118988; cv=none; d=google.com; s=arc-20160816; b=ewTuNMoruDPaL1UBlmd0CbY/50MxMFdv1vQlZhycQL6kVtNBd0kIp4i1POtlwR+z8b TBu6gwB3iCEoMNQbHAaU+vMbEMa2nxgMy4BHMm/tpeZO6x4xwyj7pWES2ow8Fw81W7cq nfZR5991tpsw0/gv2n+3xg0+2O24vOqb46PXxfcnqaN/SQILFHwO/+zcUq2V9rsB4FUx 0jv9PB+sULjXsv+d6F1y91TCdiEUeJAG3WeixRNLNPOh22BYv8YjqI6L2DGY0qe7nsTC 7BmWOyBBeKcCOBGmcCU+zXuVuKKF/OfYBOjKhZ9HjNQaC3+lHBT0CZOT2z+RNDuMgSjV yuFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YwZxozNZBXDiR/2kRqLL1MaXDjLPic26w5gQoYGrfkM=; b=AcKThnFQtjnMTUbYJse6BJJWZHpDByNRMYlv1Da6vBRUgQAGk9yxR4Vm0zlIwsX5kR yH5wsq3cKrX3mc5Nn2OC/njQKXDMhwjYAbLHWu5elYwPanpwwWiwOr5cF6e61ZsupeyA 4Rv5sdSuXluQKx1SryYK7tNDQT4U0GGSalLZjFkFfIH/AmItnwNWFAOai8erfDc1K9xy AAngRgNkQWMpMBgtSs+U5wwyR07+1JupWHhAv/8/1Rqxz6cf0wdsLLqdl2uyRPG6UApL lL+4S4NFo0jo1jv/56sGSxoWN4CfbI+hd5ZG3/8n1cgpcfYhAkfw7C83P0djZuEGQQVe JfIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R7tGuqjD; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt10si2971020ejb.491.2020.07.30.07.22.44; Thu, 30 Jul 2020 07:23: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=@linaro.org header.s=google header.b=R7tGuqjD; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729273AbgG3OWd (ORCPT + 99 others); Thu, 30 Jul 2020 10:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgG3OWc (ORCPT ); Thu, 30 Jul 2020 10:22:32 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413CBC061575 for ; Thu, 30 Jul 2020 07:22:32 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id c16so7775641ejx.12 for ; Thu, 30 Jul 2020 07:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YwZxozNZBXDiR/2kRqLL1MaXDjLPic26w5gQoYGrfkM=; b=R7tGuqjD/vvCJ2904Vuec4iUJ6rFzusWXWJpA5X/dmo3kgYXJDkMmYeNILpJLVELhQ IAVW2EQA1kYDJ0mQVbVZ/ri+6eTjMHp7C0fwDl/HDXtSIamI0BGeYc+Na69ibjZfTR+k A43hfZYIvSuhBuw6gTrAUuz2MGPi0kClRbeqMBypGnTi7UtIDyfJfWxE69l/X0YJM87N MTV3qlKOPuB7n3Y0yYpW9nt3ndY4Wc/s/iYW81vulZijqz8/pLpbUe9h8ZxE73hNQsXz v9H9yTa9MF94xzDWteLRVawS/ekYrp4ZjUF2eDn4jSz+CCPVPTPzkBYtQRE46iqj4tpE lifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YwZxozNZBXDiR/2kRqLL1MaXDjLPic26w5gQoYGrfkM=; b=tx4hptA7JMyK0xGzsbBR6qc89cB1UgSJ+cTkL2Q/ujlWYD3dzZuWLiGggdN5xdGzqF 3csS+Uo4Kw8033qQwwpyy5tsQmVR9CKkwzpmp0lTDdL6WnVFZugoFqVdwudgKpgphlh5 xEkSo9qNIrggYqaBQnWT/xo6ymXNxpcylnCpFTGPRk9d+xhhZlpA4HEcG6uXhWTBr25/ OG0UDJ2DobLelQRK6a4a7OwYK8WBS+V20u1N2VILHdUG0FGSKsCh/v1qDJQKJj1nVLNH PUi74ffSSRgVPXtKOC+CXLwWb5sNCfs3rc7PP0vGTzfea4SvRkUpTgr0SSsy8mxJHEPs cYhg== X-Gm-Message-State: AOAM532B84Ofgoc1YLKJmssgNLVhBn7aQ1ehpUg5uoYFOXsB2dwQFmyo CTk3gY3TUTYk+sTMFS8SMTUnTg== X-Received: by 2002:a17:906:3e54:: with SMTP id t20mr2770755eji.471.1596118950795; Thu, 30 Jul 2020 07:22:30 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id x16sm6372795edr.52.2020.07.30.07.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2020 07:22:29 -0700 (PDT) Date: Thu, 30 Jul 2020 16:22:13 +0200 From: Jean-Philippe Brucker To: Qian Cai Cc: linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org, songliubraving@fb.com, andriin@fb.com, daniel@iogearbox.net, catalin.marinas@arm.com, john.fastabend@gmail.com, ast@kernel.org, zlim.lnx@gmail.com, kpsingh@chromium.org, yhs@fb.com, will@kernel.org, kafai@fb.com, sfr@canb.auug.org.au, linux-next@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 1/1] arm64: bpf: Add BPF exception tables Message-ID: <20200730142213.GB1529030@myrica> References: <20200728152122.1292756-1-jean-philippe@linaro.org> <20200728152122.1292756-2-jean-philippe@linaro.org> <20200730122855.GA3773@lca.pw> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="r5Pyd7+fXNt84Ff3" Content-Disposition: inline In-Reply-To: <20200730122855.GA3773@lca.pw> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 30, 2020 at 08:28:56AM -0400, Qian Cai wrote: > On Tue, Jul 28, 2020 at 05:21:26PM +0200, 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 will fail to compile on arm64, > > https://gitlab.com/cailca/linux-mm/-/blob/master/arm64.config > > arch/arm64/mm/extable.o: In function `fixup_exception': > arch/arm64/mm/extable.c:19: undefined reference to `arm64_bpf_fixup_exception' Thanks for the report, I attached a fix. Daniel, can I squash it and resend as v2 or is it too late? I'd be more confident if my patches sat a little longer on the list so arm64 folks have a chance to review them. This isn't my first silly mistake... Thanks, Jean --r5Pyd7+fXNt84Ff3 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-arm64-bpf-Fix-build-for-CONFIG_BPF_JIT.patch" From 17d0f041b57903cb2657dde15559cd1923498337 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Brucker Date: Thu, 30 Jul 2020 14:45:44 +0200 Subject: [PATCH] arm64: bpf: Fix build for !CONFIG_BPF_JIT Add a stub for arm64_bpf_fixup_exception() when CONFIG_BPF_JIT isn't enabled, and avoid the fixup in this case. Signed-off-by: Jean-Philippe Brucker --- arch/arm64/include/asm/extable.h | 9 +++++++++ arch/arm64/mm/extable.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/extable.h b/arch/arm64/include/asm/extable.h index bcee40df1586..840a35ed92ec 100644 --- a/arch/arm64/include/asm/extable.h +++ b/arch/arm64/include/asm/extable.h @@ -22,8 +22,17 @@ struct exception_table_entry #define ARCH_HAS_RELATIVE_EXTABLE +#ifdef CONFIG_BPF_JIT int arm64_bpf_fixup_exception(const struct exception_table_entry *ex, struct pt_regs *regs); +#else /* !CONFIG_BPF_JIT */ +static inline +int arm64_bpf_fixup_exception(const struct exception_table_entry *ex, + struct pt_regs *regs) +{ + return 0; +} +#endif /* !CONFIG_BPF_JIT */ extern int fixup_exception(struct pt_regs *regs); #endif diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c index 1f42991cacdd..eee1732ab6cd 100644 --- a/arch/arm64/mm/extable.c +++ b/arch/arm64/mm/extable.c @@ -14,7 +14,8 @@ int fixup_exception(struct pt_regs *regs) if (!fixup) return 0; - if (regs->pc >= BPF_JIT_REGION_START && + if (IS_ENABLED(CONFIG_BPF_JIT) && + regs->pc >= BPF_JIT_REGION_START && regs->pc < BPF_JIT_REGION_END) return arm64_bpf_fixup_exception(fixup, regs); -- 2.27.0 --r5Pyd7+fXNt84Ff3--