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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0AA16C433EF for ; Thu, 12 May 2022 10:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:In-reply-to: Date:Subject:Cc:To:From:References:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jyc4w4n3T5UTj7f1jefLfBPPkL/gGsKNhPx1y29B0aE=; b=JdGXYsN4Okw9Ty cUUMN4MLgA9U/+VgslOFo5DvTnGNo7uoFrZs/IPakmgjkFDYD5jrIb7swwC8FQf2XSZ5BIdTbmbvI R79+uC+NeV+KCslbhkTcOVjncIK8b37sU7k8vR9X4sY83dRUg+F00mex38XP98oaxvNzDI3EJslLx VLjfV1zR1f/lbsc8EmbFAVQYbGa9zZWrotA6R8SBw4CbxPhfX9n7UBB8R8NoEJX34VTkVQZIIeQi0 xfL4AZEEL5jIpkGvfmGqvT+n7LYh/+P5haAEF0lC33YlAJA1lUWfqmzsSl2QxBdJGRf2Yy5hJ/wMN gccxG3nQfCM7HWVbA4Gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1np6Tk-00BSxS-8k; Thu, 12 May 2022 10:55:32 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1np6Th-00BSw5-0S for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 10:55:30 +0000 Received: by mail-ej1-x631.google.com with SMTP id z2so9437490ejj.3 for ; Thu, 12 May 2022 03:55:26 -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=Mw7Hr5LLWdM2Tg8FiRyg6+6m3ro433PdC0rqgatdNLke4AtN0kCitP9idBwtoXQBLn n2rJ5D58tE6U9ogesF0fX0RjgctwSKoDHW1GiTJe2ZUEl1eWgXoXDbnLdF5ITnNFzrDN ACuf8NSP3kT+B57MGK9NmKJ8SzZIu++4sOCx8ptafDo+aZkUcOCIYtEZ6OObQXej7jvG 8za9F9eBHbz3XWFF8yy67YfnRtUT+6fMZ4EzMgDJuY+1DJ/l8JEGwrEYtQIAIk+BQmjf N7QOO6GuqOIBA4nLECaFjEjTy6ZfIByJb44R3fPyFntZwRT1msQkDTYowmUxJZVbKR/U 6oTw== X-Gm-Message-State: AOAM533TQVJ2lHKjxLrCSrFDrfExOIte/SV7DgrK0MpnPgo6jOjna4Nk m0FB7ohysXDAtE7oUtOz6aP8Cg== X-Google-Smtp-Source: ABdhPJyMEDJyGYlUhPgucEhy64Eh9s0++xx90SftrGOnxuQHSGFNdfGoGpgBQc0SpQTahAATxncZkw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220512_035529_102675_F1EDD78A X-CRM114-Status: GOOD ( 17.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel