From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E540DC433E0 for ; Thu, 30 Jul 2020 14:24:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFA6B20829 for ; Thu, 30 Jul 2020 14:24:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="S+V1MFaI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="R7tGuqjD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFA6B20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To :Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nZlX9DwHksJYxAklXR3rfO98a+RJC9/Yw8/C0yIg1+o=; b=S+V1MFaIAD8Tv7O8kbjsjnKzF ebwlJkG6TRdkmw6oRDDPW3wdNepEP9OYkpsYE5rkX4EZX07w2a6bKXz1TzinmdrOBITMKf9RTsZVg LdGvHcK1eYDl/CSbUCZe1vkXO8SGiOnVPkwaSSqBQaRWEJCzqdGxOX7gMYYLypE8vVketJraPIX0b sNp2Ykguacnj/BC8UES8lQz7kLy2w+IzyOAYg62j6UQXmCy1G7hb4q0yVCB7HryvfI2PV8knT7na3 l6vhXXW9ZjjuNsajxkyNzS/EPHve0imUy1N6BGEZUrLb0InMoywdZ9cJZfsjKKim1LnFuQM2oNehg G9fI4rP0w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k19S7-0003Ce-Lw; Thu, 30 Jul 2020 14:22:35 +0000 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k19S4-0003Bo-71 for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 14:22:34 +0000 Received: by mail-ej1-x644.google.com with SMTP id qc22so13373961ejb.4 for ; Thu, 30 Jul 2020 07:22:31 -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=T0Zua2FebRAKcUq7YqrwJv6Vb2Dkt9uc5sgubKE6SAxOnP070dBTRUjHB8wRVzfViS BUSP1xeM+cF7np9Fl2527ghaFmx41Bg2uQ6rLt3vH6NFxkKv3QY9SctzkO8rchifAJpP i6Ly+FwQJP97o86/0NkiAHD5FsFsY1vO6o0O4G86oC2IYSlB03DTXMWP2PgpDWThCX0F s2/WVPgYarzTTeuPvTAH4awbizUsTq2dVvNBU0n6wY1oF0NpxO2kMhk7Aq3PmJWswLUh K9MXJqFjen9nDG8DgzzfoEvEgEnBUD5BWd1l2oIjlDHyf9+pZuG2hzGX4PBX9x/uZE/p pWLg== X-Gm-Message-State: AOAM531kKflnMIy3Dc8/bKt6nc2JG9ATfb4wO/sPFUd7p/48VKOxiOvy jGQTrrTEdKFyxMX5pMA/qYYksA== X-Google-Smtp-Source: ABdhPJy7aqlSQaQrLHhofONaPZjwKauHbZHDGRXdQ92TUeggQySP4YNI9qe5tEKnlr5K8H51rOJFuQ== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_102232_941149_27F092BE X-CRM114-Status: GOOD ( 29.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sfr@canb.auug.org.au, songliubraving@fb.com, daniel@iogearbox.net, catalin.marinas@arm.com, john.fastabend@gmail.com, ast@kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, linux-next@vger.kernel.org, zlim.lnx@gmail.com, kpsingh@chromium.org, yhs@fb.com, bpf@vger.kernel.org, andriin@fb.com, kafai@fb.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --r5Pyd7+fXNt84Ff3--