Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp993672iob; Fri, 13 May 2022 18:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyua7K++De3n9NZKwNe+A2lbxbq+COe8abXkeAkhUIBhU8yxzufWPaenLMXB3+B6oVo9GfI X-Received: by 2002:a05:600c:19cc:b0:394:8dc2:a23b with SMTP id u12-20020a05600c19cc00b003948dc2a23bmr17269697wmq.182.1652493393936; Fri, 13 May 2022 18:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652493393; cv=none; d=google.com; s=arc-20160816; b=UPLHCYoZn3xk6di/BqoGT7vrp428ioot1l5NzuxHY0e3lDBwL2DhlVmCfFrg1cU+Ub CVnxeaOcWoRmiAwUutDnNmFGph5A0Ozs6qG9swCO8+C8XzVRPJLx3TDcpiQlvhVkpjTS d+tK285xgsZmN62dMB6J47gki8LFANbdCMHyPb9sSC8r7gn/WG75TlW7DuMzo1ZvuaCX imA5CQIapgKBkK/qZW1xo5xTmLym5O3I+6xY43KrVKQ0VGitMU1NSXNIO3Bjq6zfqQGh FPfCWlZA1c7YBH86/OPJW5pqM2gQbICIcXUQW4ydtjt8NMxnC1zukDeIetBKEMRo8pzL RmXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=Iwqqdpj/sCrfAf59NaNACtGSTRtAyJeA5sSf5Q8LpGQ=; b=j427HX5xYZhW50Kp0voaP7rix8WB1+AFBiknjXhGYKDI/CnFcGVxdnXhRI0IoZT/Mt g3ze6u4gkOglxoJi7pWpzuZ8Xhy02rkpRT7bKDProuv7WjWmEOmBtGStS/jmthU1R8BG 181Ev1LhKyUUsi3ubWdU9qzHY+scKkasldrNjpXgUO6eB0ubObAoDrJtgmUw6fafsEpU Rfq1ewbjRflcQwRi4fz4lHx7zrgofRyzDIiGvUt1Dgww2wz02R7tOXAbZVIDfeq4J78+ kTEHmer5zwV0b1+Qe1Eh27kbZtS+p5DxfctV6wRc+Isda9W1/3/8STUV94ZDpdyTvvqa woJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b="RD/cJqYl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i11-20020a5d584b000000b0020c646c404asi3459482wrf.845.2022.05.13.18.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:56:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b="RD/cJqYl"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EEA3346394F; Fri, 13 May 2022 17:19:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352884AbiELKzl (ORCPT + 99 others); Thu, 12 May 2022 06:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352864AbiELKz2 (ORCPT ); Thu, 12 May 2022 06:55:28 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2336B6D95F for ; Thu, 12 May 2022 03:55:27 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id i27so9394417ejd.9 for ; Thu, 12 May 2022 03:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version; bh=Iwqqdpj/sCrfAf59NaNACtGSTRtAyJeA5sSf5Q8LpGQ=; b=RD/cJqYlBYTnZgehRgve3MmDT02PYH0d0jFIKcdNePCxuFtfrzHeL8I0dT95rbUGLD jaSKkMYjaWTSLcQ+lPaD98uG4IUjWd8v9P/2ImVWe7cvfWDZnjacKKm+1TIzpX3PPCJb u51vcrC2TjaM7nDHHN4Qc/5yuUUyZCZP2wB8k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version; bh=Iwqqdpj/sCrfAf59NaNACtGSTRtAyJeA5sSf5Q8LpGQ=; b=Hup0Qc27z1HW+248nQ+CajT1/hqPCOyhvFyRzAN0h1ja07Fj8L6N8174CU8KSC5Tzd xAKCQlHiSV2Tv7u/JF/iivuFDDw7o387mK9FpCjNDoorcYw9qZay9BK+ONKkTfy6hgrm qB0q2uBnW8nT68uEkwwatRBAwnZAMGtyAVoNxaE7MWD2lfUtvNz4BH/utFBMF1zSWwzd q319waOkr1Y3Fogd5LQLO4DaWQFSPa2mgK/JunuC4gzFJWd7hfeE+Zj2PcWEnpfaXsvY EdaYiBmWJBH5zsgr4hvALxRRlurA2YRSV7xESGVGd89jr6o1t1KSEePtKSSgBLipmHrC CJxQ== X-Gm-Message-State: AOAM531t0HLfdy7Z6efSzjnvhaDEk6TCDT8E1pxU0qoLuBIlYICnV7mM Rp5mljZ2hy5VYt0TKZMnnrM3VA== X-Received: by 2002:a17:906:cb97:b0:6f3:c671:a337 with SMTP id mf23-20020a170906cb9700b006f3c671a337mr29293611ejb.93.1652352925651; Thu, 12 May 2022 03:55:25 -0700 (PDT) Received: from cloudflare.com (79.184.128.236.ipv4.supernova.orange.pl. [79.184.128.236]) by smtp.gmail.com with ESMTPSA id s4-20020a170906a18400b006f52dbc192bsm2043862ejy.37.2022.05.12.03.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 03:55:25 -0700 (PDT) References: <20220424154028.1698685-1-xukuohai@huawei.com> <20220424154028.1698685-6-xukuohai@huawei.com> <87ilqdobl1.fsf@cloudflare.com> <5fb30cc0-dcf6-75ec-b6fa-38be3e99dca6@huawei.com> User-agent: mu4e 1.6.10; emacs 27.2 From: Jakub Sitnicki To: Xu Kuohai Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Catalin Marinas , Will Deacon , Steven Rostedt , Ingo Molnar , Daniel Borkmann , Alexei Starovoitov , Zi Shen Lim , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, hpa@zytor.com, Shuah Khan , Jakub Kicinski , Jesper Dangaard Brouer , Mark Rutland , Pasha Tatashin , Ard Biesheuvel , Daniel Kiss , Steven Price , Sudeep Holla , Marc Zyngier , Peter Collingbourne , Mark Brown , Delyan Kratunov , Kumar Kartikeya Dwivedi Subject: Re: [PATCH bpf-next v3 5/7] bpf, arm64: Support to poke bpf prog Date: Thu, 12 May 2022 12:54:07 +0200 In-reply-to: <5fb30cc0-dcf6-75ec-b6fa-38be3e99dca6@huawei.com> Message-ID: <87wneryq8z.fsf@cloudflare.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, May 11, 2022 at 11:12 AM +08, Xu Kuohai wrote: > On 5/10/2022 5:36 PM, Jakub Sitnicki wrote: >> On Sun, Apr 24, 2022 at 11:40 AM -04, Xu Kuohai wrote: [...] >>> @@ -281,12 +290,15 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf) >>> * >>> */ >>> >>> + if (IS_ENABLED(CONFIG_ARM64_BTI_KERNEL)) >>> + emit(A64_BTI_C, ctx); >> >> I'm no arm64 expert, but this looks like a fix for BTI. >> >> Currently we never emit BTI because ARM64_BTI_KERNEL depends on >> ARM64_PTR_AUTH_KERNEL, while BTI must be the first instruction for the >> jump target [1]. Am I following correctly? >> >> [1] https://lwn.net/Articles/804982/ >> > > Not quite correct. When the jump target is a PACIASP instruction, no > Branch Target Exception is generated, so there is no need to insert a > BTI before PACIASP [2]. > > In order to attach trampoline to bpf prog, a MOV and NOP are inserted > before the PACIASP, so BTI instruction is required to avoid Branch > Target Exception. > > The reason for inserting NOP before PACIASP instead of after PACIASP is > that no call frame is built before entering trampoline, so there is no > return address on the stack and nothing to be protected by PACIASP. > > [2] > https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/BTI--Branch-Target-Identification-?lang=en That makes sense. Thanks for the explanation!