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 9D751C433EF for ; Fri, 8 Jul 2022 08:29:53 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oopPahZXoiaI+eFwucl5cOUF/zsEC87hiePLvdQSuU4=; b=pSdSSTU6UpU3H7 JgkmTnEWpYlj+7OK/QTEOo++hDsgphX75+Ly3bgLs5uibcmzlKVuenCiTHDuxpMXujDop0etMim/R RDUJeFAHI5imDCTDTgwBQ0C1iCb3+dvICmU3hhKAzUxvwparqgZbvwyKTEVD2GPqxm24P8q9I1/d0 71W8B72c+Zg6lrFZgJIXFK+M7zQKx6lddXMc76LEOAJmz3ijE4Yjk7r7ODvMk/okuKPbEl2+cmA5J lNCSUSptHY+U0AHFH9ACyuUjJclKZyb5lv+o7YjfLlhRZQ7buEqXUckC7bMAdd4KUggTwDvEIguih n2uSns/rYeM/haEheh6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9jLi-002XXh-Ht; Fri, 08 Jul 2022 08:28:32 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9jJh-002Wjw-Uj for linux-arm-kernel@lists.infradead.org; Fri, 08 Jul 2022 08:26:27 +0000 Received: by mail-wm1-x329.google.com with SMTP id r129-20020a1c4487000000b003a2d053adcbso697671wma.4 for ; Fri, 08 Jul 2022 01:26:25 -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=/OVTFWFueCRPCSOvGcnm5qhmYMmcAYT2qYgKyKk2GrU=; b=QayVImNEczOhK0XOfo/Un1TkE91WIaEh4vd5WGqaoap8Zp3zXyX1dE2P6RqQrpT1XS oy1BzMte5WWi0qpuvNFLbedtjg2n7Za2D4EYGowA6pIDEJpZATtjx7KTCqtGGcRO+0Hm w4Ot42GczZ1AqfqjZNrfsIYwRBv4+h7ReSSB9exmjeAS3NcLvVOm3Cp0vlKsBAUZLeK4 3U0QqPn/SGSigUG8o6BjBZ/4XRXPETHIM0smmMd84MTwqwWFc+HDBmhlrFEZT6wwwNtr wRf5occqwIOBxSXFsjoS+goTKLITad0wByayOqYY9Tj1R8PO6+gn4sR8T1ZFngyCv/Yb FUxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/OVTFWFueCRPCSOvGcnm5qhmYMmcAYT2qYgKyKk2GrU=; b=QudcCxBrJ33Qom0+okMSBDGzAl9nlDIiFs0cwuyASPF8xkIStD8qp7htx/S8B5hnP2 q8DzBAioKnhBGcklVuH8VEPdS2zPpI6ybL2HmBSWI2dcd9bGgCu5I/EkFDyaZv04ri0U N2ZPnVDbbczfoSrTx3Dp7ZUdjCnRqFq73dmBw/kYdidjQTC2uJZHqjyZtk0X0VklGicV GGAeIgNyXu0OQiSGw0VqfQdip49/nhlMQND77qiYzyZRxCCFFl5jlqm1sjUdXZqNaSaJ RQ9jdWgMt3eHLcCJ8UDCEv04RIsp3PpWzN9ngGvVEeIyu/ymnV60I3U5HMRXyfn1rb++ lFag== X-Gm-Message-State: AJIora/1CB1uwtUnp7aZSYrpcvIGzQTBSrmGFrTY9eP7eSN0I9wLZwHC xPfMJDg8oHbVPjBTF24TPa1bFg== X-Google-Smtp-Source: AGRyM1v4J522/CsbJ15YeUOvSaWI8hyF/D8ynhoDdCisWlk5JSxaXP8LbE/H1oMLQMyP+D4lTEzv7Q== X-Received: by 2002:a05:600c:3491:b0:3a0:4d4a:2e2d with SMTP id a17-20020a05600c349100b003a04d4a2e2dmr9448093wmq.4.1657268783790; Fri, 08 Jul 2022 01:26:23 -0700 (PDT) Received: from myrica (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id l1-20020a7bc441000000b003a2cf1535aasm1403895wmi.17.2022.07.08.01.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 01:26:23 -0700 (PDT) Date: Fri, 8 Jul 2022 09:25:58 +0100 From: Jean-Philippe Brucker To: Xu Kuohai Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Mark Rutland , Catalin Marinas , Will Deacon , 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 , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Jakub Kicinski , Jesper Dangaard Brouer , Russell King , James Morse , Hou Tao , Jason Wang Subject: Re: [PATCH bpf-next v6 3/4] bpf, arm64: Impelment bpf_arch_text_poke() for arm64 Message-ID: References: <20220625161255.547944-1-xukuohai@huawei.com> <20220625161255.547944-4-xukuohai@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220708_012626_083656_87021F09 X-CRM114-Status: GOOD ( 15.86 ) 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 Fri, Jul 08, 2022 at 10:41:46AM +0800, Xu Kuohai wrote: > >> +/* generated prologue: > >> + * bti c // if CONFIG_ARM64_BTI_KERNEL > >> + * mov x9, lr > >> + * nop // POKE_OFFSET > >> + * paciasp // if CONFIG_ARM64_PTR_AUTH_KERNEL > > > > Any reason for the change regarding BTI and pointer auth? We used to put > > 'bti c' at the function entry if (BTI && !PA), or 'paciasp' if (BTI && PA), > > because 'paciasp' is an implicit BTI. > > > > Assuming paciasp is the first instruction if (BTI && PA), when a > trampoline with BPF_TRAMP_F_CALL_ORIG flag attached, we'll encounter the > following scenario. > > bpf_prog: > paciasp // LR1 > mov x9, lr > bl ----> trampoline: > .... > mov x10, > blr x10 > | > CALL_ORIG_entry: | > bti c <------------------| > stp x29, lr, [sp, #- 16]! > ... > autiasp // LR2 > ret > > Because LR1 and LR2 are not equal, the autiasp will fail! > > To make this scenario work properly, the first instruction should be > 'bti c'. Right my mistake, this layout is also what GCC generates for normal kernel functions when (BTI && PA), so it makes sense to use the same Thanks, Jean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel