Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7474174rwp; Tue, 18 Jul 2023 16:20:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlH4MmZF4Yd1XQKmXv02j/MTjRq4S75thlPiQT7r3TapCtElcfpipHSDz77/XDgBLO9MxYZx X-Received: by 2002:a17:902:6942:b0:1b9:cca6:551b with SMTP id k2-20020a170902694200b001b9cca6551bmr2946387plt.7.1689722426901; Tue, 18 Jul 2023 16:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689722426; cv=none; d=google.com; s=arc-20160816; b=RFvzbz7gyro05qLqLge37pquprx12IY2k2ldFVauzmKd8qbhz/ECU/kEKwFxQGLA1c 2Joz2zStADtiMEvInYaLj0fCmwMFb9Ouf+i9RM7mpf0lOWBgVFom2C8EXAE5/rOCVLdN zq6EqN1O2pUp54LHJ0aZFNSvCvoiUXbVTpBqquaGkvBuGGuQplupSK8LK0YN2SzjOzr/ U67yWLRfAoDJdgCfrH1aX/Ops+VfXY94RhlPY+XuyJ66O/fe4xWhvQcfkMHm1pfgktii 9r8nUznenH789KVgEfJKK9Lhz41w/zvGeR4SNAytlE2CeUMf3CA8ayxUdpi78ecsD933 hmDg== 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=qNw+miDO+/vr2NteE7yqKqsKfjVHHAqT8sK5QSW7byk=; fh=1EP8uyrS9xsE3KzmsjINlvKg1ur5t3fSYB3EfQQ8S98=; b=a/iuUKa4Q7qctwONTG4zA719mObOSuJWxsywv8O6InEYyQMkajWRVhwjQHJDAQLwGX nHkP1vZIUKwxFhGs3HxLJSocZSG18UW8cf95a3PrYnYpo3VuNWCjq7BoibR/HzNeTsLx wxxeqfod3ycrPnNa2u8XlXMQLEP4MTj9xgITnZSxPQXnvwbtbQ3VpgLxXfVsrXDvYp7+ l0G/wJY+/mI7A3x9BMZTMPFlq7yEOM96h7dze8FOrKIVFG2XxbW3IT1aIzFcxl2b+V5+ osDCOR2QE3TO0Ac30uBnPr1aaeaN8UY1mKn7rhkFMPnYuDwLJ+rPlXKS50MMHjifbxkV 08hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=a2pYDJsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a170902b28500b001b3c7e6a8c0si2299900plr.531.2023.07.18.16.20.12; Tue, 18 Jul 2023 16:20:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=a2pYDJsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230246AbjGRW3E (ORCPT + 99 others); Tue, 18 Jul 2023 18:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjGRW3E (ORCPT ); Tue, 18 Jul 2023 18:29:04 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C79B1992; Tue, 18 Jul 2023 15:29:01 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b741cf99f8so96538271fa.0; Tue, 18 Jul 2023 15:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689719340; x=1692311340; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qNw+miDO+/vr2NteE7yqKqsKfjVHHAqT8sK5QSW7byk=; b=a2pYDJsFUytmjoOLHzZ3DLS49W/e3L2DLHxvs19CPUjUXpJGPXa1kBPo9kbCok3E2N rleryHy3KrwhRqfZfuMCFFA0CwpSm9SoD9EftpqygB90ifNsixKTV28ce8pZArirwEO7 45fx7Sunj4GM22bsLBHa6g/vljqN5bHzR52W0CCXsFYMNvlSyLih4Y/zmsDc6i2LR9nd IUDwqYwbYbsHzszrtkn4gMm7g5SWt2b+G8s5KyQV5iRXv/OYbN5dYl/UV3Zc/yXtBII/ 5GM00/htoFgEP1lnUEQbH3CqyXSt7e2ZaZIyAjSuFi9bpm4gGqwhmzvuYNKRYVOwHyK2 6BmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689719340; x=1692311340; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qNw+miDO+/vr2NteE7yqKqsKfjVHHAqT8sK5QSW7byk=; b=CEqSs9Z2cty0tgBwTxILDvHfaMq9v28s7wFoInYGvGs588LevWBjFo5W+12L26+8GH ZDcNDBXc0I2Pt44RB39D3RNKjCcQ3nBvSjBZ+UFYr0ywl1upEMfjmzceqh6/ckqaAJOf etwhhzLp7cIjWgQbaXPcYkH4UeB4jvvrup5uxWorpjKpOnzBFw84StlJhG3YQpwW0VrH g5/9liUZHauluHgzTT44FR+wyxxZyF2AsOTfaxUoqUDPQ1sjzEq4sKQsNbQzI5D7Padd hpvzeNWNCbynsUQFiHHio53Ul53dRcbRK/JV8X9pTwzLakUF85d7qujWzRAul7Lmkm5J LY1A== X-Gm-Message-State: ABy/qLadviuv1KT799yTWKlLrdUC2+YOEnzJ1AL7jcEQhxkIyplKF8HF Mk4pWEJjsYKoS57YOuGaVV/MeSc9ZVHsXh6LeJ0= X-Received: by 2002:a2e:9b82:0:b0:2b6:a827:164f with SMTP id z2-20020a2e9b82000000b002b6a827164fmr450914lji.10.1689719339348; Tue, 18 Jul 2023 15:28:59 -0700 (PDT) MIME-Version: 1.0 References: <168926677665.316237.9953845318337455525.stgit@ahduyck-xeon-server.home.arpa> In-Reply-To: From: Alexei Starovoitov Date: Tue, 18 Jul 2023 15:28:48 -0700 Message-ID: Subject: Re: [PATCH bpf] bpf, arm64: Fix BTI type used for freplace attached functions To: Xu Kuohai Cc: Alexander Duyck , bpf , linux-arm-kernel , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 15, 2023 at 2:03=E2=80=AFAM Xu Kuohai wrote: > > On 7/14/2023 12:49 AM, Alexander Duyck wrote: > > From: Alexander Duyck > > > > When running an freplace attached bpf program on an arm64 system w were > > seeing the following issue: > > Unhandled 64-bit el1h sync exception on CPU47, ESR 0x000000003600000= 3 -- BTI > > > > After a bit of work to track it down I determined that what appeared to= be > > happening is that the 'bti c' at the start of the program was somehow b= eing > > reached after a 'br' instruction. Further digging pointed me toward the > > fact that the function was attached via freplace. This in turn led me t= o > > build_plt which I believe is invoking the long jump which is triggering > > this error. > > > > To resolve it we can replace the 'bti c' with 'bti jc' and add a commen= t > > explaining why this has to be modified as such. > > > > Fixes: b2ad54e1533e ("bpf, arm64: Implement bpf_arch_text_poke() for ar= m64") > > Signed-off-by: Alexander Duyck > > --- > > arch/arm64/net/bpf_jit_comp.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_com= p.c > > index 145b540ec34f..ec2174838f2a 100644 > > --- a/arch/arm64/net/bpf_jit_comp.c > > +++ b/arch/arm64/net/bpf_jit_comp.c > > @@ -322,7 +322,13 @@ static int build_prologue(struct jit_ctx *ctx, boo= l ebpf_from_cbpf) > > * > > */ > > > > - emit_bti(A64_BTI_C, ctx); > > + /* bpf function may be invoked by 3 instruction types: > > + * 1. bl, attached via freplace to bpf prog via short jump > > + * 2. br, attached via freplace to bpf prog via long jump > > + * 3. blr, working as a function pointer, used by emit_call. > > + * So BTI_JC should used here to support both br and blr. > > + */ > > + emit_bti(A64_BTI_JC, ctx); > > LGTM. Thanks for the fixes. > > Acked-by: Xu Kuohai Applied. Thanks