Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3266733imw; Mon, 11 Jul 2022 05:30:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/cYmflioPgJQ6azlS6aqAEBDaPVmOiXfxDgY3sqmrVIxbrSrStqzxYuB3fpAC4ws6eafg X-Received: by 2002:a62:fb02:0:b0:528:6697:eaaf with SMTP id x2-20020a62fb02000000b005286697eaafmr18417476pfm.75.1657542651432; Mon, 11 Jul 2022 05:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657542651; cv=none; d=google.com; s=arc-20160816; b=SkL0vcpdNRmfb7vTdYcik/l+viqJz01dN/CiprttV9A7ojp3rTLE4REg/KifV6nnuM A++qIVMDAnBlgRkosknu31cO3271A7Nm4aGxuR836wvbIgvhFv2EY5nk5qA0zn1l5ETv kIBpDyxdtfN1nk53gdaYVaYqtrOpvvRx98zKvRRPxLV4Cjkfe9b0xhj9iMBzqjL5dATi wZwe59a6poCvAULrb12gjhPe1lcBEeyaZSRJlTCXpBxWRV7XzhKYBiAPg9rw6gz0PUCb gS7gczhclqbHt4zWYdUfV/wdvC7sTw82LHayLkE1X3OJ3z5OGEY1vMUl/DYtQnk370Q+ d0uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BQEPX2oLS4VAKW2DD0EGpgirZ7z4jyQAcpaLby2W2Ts=; b=DlG+hX09659uYgMP7MlZtDF4y/f9ka88HwUGLgSXxQmOGyxtJkJbpyh6SPof6BsUPb YuER0mQaKiBhw72p0MXNgnCkvH4AjgiIu+kNpx5ZWVSzkjiAzRu8ovw7dX3WZxfHvG6B vPgYrJbAucGqo8/e0f3sU40miwYwzCS8itdJbTyegt8kfXXCM32PJiWcTDcqwGP9yQY3 C/YhX/1I7oqUp03H8+4MZcHfAnVjaR7U+QazHhyVGm3rDsPUCFE2oWW2ta0wkznCPGsc 5TRMnjE38////VRVptjSQk1aKzTyJua7kX9/QNyy7NXgYa+NltHF1LXIBRgfWWnHVWU/ wsVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bhB6lDed; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo4-20020a17090b1c8400b001efbdf44c12si16540495pjb.97.2022.07.11.05.30.39; Mon, 11 Jul 2022 05:30:51 -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=@linaro.org header.s=google header.b=bhB6lDed; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbiGKL6W (ORCPT + 99 others); Mon, 11 Jul 2022 07:58:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbiGKL6V (ORCPT ); Mon, 11 Jul 2022 07:58:21 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D008D32BBB for ; Mon, 11 Jul 2022 04:58:19 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id i128-20020a1c3b86000000b003a2ce31b4f8so4867812wma.1 for ; Mon, 11 Jul 2022 04:58:19 -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=BQEPX2oLS4VAKW2DD0EGpgirZ7z4jyQAcpaLby2W2Ts=; b=bhB6lDedVM5GCtm3RN67vsyj7pGah/TwUoSfOWdn7V8TyJdb5ImGupDVq4LfeiheP/ KOAscNuTWRp2WFA0yWg6PBhk4UflvQSCKtdrR/o8DmDJnusIQpGZ6X3sv8hq/HcnTaDl UtPSJxS5OjS6SFYzs67C1X9WJm5wy4Vg1T7GbPv+2+l8mJdvsv/0KEw799t1lHz+KPcl 2tUeYFJNL2DMko4SuvFPGuwDrxN3x+WMThq2y+xZ6IuXke/gdPqPJpkNJ5rXUe1N+twN zblYstSj4Q0P9QIlaE91xbdF6b9AYALeUc/uVmOc8QXcW+gRehj/bEfrOrWSY+4fibSw OCcA== 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=BQEPX2oLS4VAKW2DD0EGpgirZ7z4jyQAcpaLby2W2Ts=; b=6X82mAtFTArwUSLpl3q7V/XB1INq/HGAs6eZpJpZJGWGtINlUNTyeBOOj28ar/qztT 8pbja873FdNqnCu9vrygEjgBqyhjInQRmrWNH653uYqjN4clEOvnuNFGKuODcu7HMvD2 V/Zw4uYgdnGNkDJTdaPbDxl/P9f15rBpTgW1Dims257qPyWVSl7aj8JeYh3G27J+dOOW mFF5NR4h2fUI8v0lgZ3wqFQR1/wShdRMArhGW/lfPypJ3bWBxPBzG0IFFk4WtJTqovF+ 0HX7COofUGXUF3jEccqCh1t+crotNiMsmilyG/fZC9cKWXXLAxCUPz6msFlOeEGhkAea 6Utg== X-Gm-Message-State: AJIora9Ur4vUu0+30dg2yRULyDgxWk5mYqKqdMI1Nc5JWywouEfdciyF 8i2mJXUCUu19C/AfI/q2qH6W3w== X-Received: by 2002:a05:600c:1e10:b0:3a2:e35c:f5fb with SMTP id ay16-20020a05600c1e1000b003a2e35cf5fbmr10434045wmb.27.1657540698361; Mon, 11 Jul 2022 04:58:18 -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 ch9-20020a5d5d09000000b0021da4b6c6f7sm2898365wrb.40.2022.07.11.04.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 04:58:17 -0700 (PDT) Date: Mon, 11 Jul 2022 12:57:52 +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, Will Deacon , KP Singh , Mark Rutland , Catalin Marinas , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Zi Shen Lim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , "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 v7 4/4] bpf, arm64: bpf trampoline for arm64 Message-ID: References: <20220708093032.1832755-1-xukuohai@huawei.com> <20220708093032.1832755-5-xukuohai@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220708093032.1832755-5-xukuohai@huawei.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Fri, Jul 08, 2022 at 05:30:32AM -0400, Xu Kuohai wrote: > +static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_link *l, > + int args_off, int retval_off, int run_ctx_off, > + bool save_ret) > +{ > + u32 *branch; > + u64 enter_prog; > + u64 exit_prog; > + u8 r0 = bpf2a64[BPF_REG_0]; > + struct bpf_prog *p = l->link.prog; > + int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); > + > + if (p->aux->sleepable) { > + enter_prog = (u64)__bpf_prog_enter_sleepable; > + exit_prog = (u64)__bpf_prog_exit_sleepable; > + } else { > + enter_prog = (u64)__bpf_prog_enter; > + exit_prog = (u64)__bpf_prog_exit; > + } > + > + if (l->cookie == 0) { > + /* if cookie is zero, one instruction is enough to store it */ > + emit(A64_STR64I(A64_ZR, A64_SP, run_ctx_off + cookie_off), ctx); > + } else { > + emit_a64_mov_i64(A64_R(10), l->cookie, ctx); > + emit(A64_STR64I(A64_R(10), A64_SP, run_ctx_off + cookie_off), > + ctx); > + } > + > + /* save p to callee saved register x19 to avoid loading p with mov_i64 > + * each time. > + */ > + emit_addr_mov_i64(A64_R(19), (const u64)p, ctx); > + > + /* arg1: prog */ > + emit(A64_MOV(1, A64_R(0), A64_R(19)), ctx); > + /* arg2: &run_ctx */ > + emit(A64_ADD_I(1, A64_R(1), A64_SP, run_ctx_off), ctx); > + > + emit_call(enter_prog, ctx); > + > + /* if (__bpf_prog_enter(prog) == 0) > + * goto skip_exec_of_prog; > + */ > + branch = ctx->image + ctx->idx; > + emit(A64_NOP, ctx); > + > + /* save return value to callee saved register x20 */ > + emit(A64_MOV(1, A64_R(20), A64_R(0)), ctx); > + > + emit(A64_ADD_I(1, A64_R(0), A64_SP, args_off), ctx); > + if (!p->jited) > + emit_addr_mov_i64(A64_R(1), (const u64)p->insnsi, ctx); > + > + emit_call((const u64)p->bpf_func, ctx); > + > + /* store return value, which is held in r0 for JIT and in x0 > + * for interpreter. > + */ > + if (save_ret) > + emit(A64_STR64I(p->jited ? r0 : A64_R(0), A64_SP, retval_off), > + ctx); This should be only A64_R(0), not r0. r0 happens to equal A64_R(0) when jitted due to the way build_epilogue() builds the function at the moment, but we shouldn't rely on that. Apart from that, for the series Reviewed-by: Jean-Philippe Brucker