Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp107435pxb; Mon, 25 Oct 2021 04:53:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFkVQuFPVdWEh5zg1klp1Zykj8ne5x37lFjm7nkEYhaJFCMWMHyeOtLGoRBtmry6H0MhRD X-Received: by 2002:a17:907:961a:: with SMTP id gb26mr499301ejc.527.1635162818007; Mon, 25 Oct 2021 04:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635162818; cv=none; d=google.com; s=arc-20160816; b=nTKLNbXbWFzKRAdJQhZ1xy6eQywNJkkQfWuZkhaYvESYjEAYMByLYka+FG5Tt0SCUF ORNhVOlgRngQjx2CFn55hoIcujKPHov+4iT8KeXMkludSnrPF7NFkqsFpZ0CApAE+u1w PxocMAfOcJcFFw+63OvhQ4rmqvQX7ZBT4O4I8Y3fwQ5GPiaKzlvgpuerdLEpMpe7y1Hd 3uQVvxCJ0iCP6gSOR1s+45cvAqTEv8Y8NMcd9NrS9ByOVyz+sk0/XbedAjfE3FKKD1UR FTfscDGE+SyfBjTCr9aHTXXwkQlgm1xLeHHhDeAaOby+yudl6mdg8Z4OvkyncixrIPUU Wsww== 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; bh=vSIGjfUFsTRw01dmIeU0ao7OzzLqc/Z8YlfVzWjdnGY=; b=x4hxV4qoLR+rcN3m3kIyrSXUvqYVX3owb14m46qQnnStOX+24sigPBKbHmOiZIXUeH QQ85ZkLZ15UB8hufTvpRZ7JBsP9Tjy8xkkIsYFJiZ6T/gZl3+tKJ39FZmB+0N0L1tsNJ 9wMihqS87uwVR/bimkoJir376sK9bBIM5e5NhNn+zJiRhYpDdoIX8yPPYbkjuVYziuca lJfvxrDtusuaoLU5eBS9qjddGMDZmGh7P/+tG1dbSWkt2EFhuOaEN7xf1VfxvNkEUtiv nr2P9+fWAyllHZloEy60KFxF8P06cCrn4Wc6Kw0AIBbiipi6e1fgl4PLXgWl3jmGH6Si zYVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si39107461edz.482.2021.10.25.04.53.15; Mon, 25 Oct 2021 04:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232900AbhJYLrI (ORCPT + 99 others); Mon, 25 Oct 2021 07:47:08 -0400 Received: from mga04.intel.com ([192.55.52.120]:37514 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbhJYLrH (ORCPT ); Mon, 25 Oct 2021 07:47:07 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10147"; a="228391476" X-IronPort-AV: E=Sophos;i="5.87,180,1631602800"; d="scan'208";a="228391476" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 04:44:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,180,1631602800"; d="scan'208";a="446195657" Received: from boxer.igk.intel.com (HELO boxer) ([10.102.20.173]) by orsmga006.jf.intel.com with ESMTP; 25 Oct 2021 04:44:42 -0700 Date: Mon, 25 Oct 2021 15:44:24 +0200 From: Maciej Fijalkowski To: Alexei Starovoitov Cc: Peter Zijlstra , Josh Poimboeuf , X86 ML , Andrew Cooper , LKML , Nick Desaulniers , Daniel Borkmann , bpf , Andrii Nakryiko Subject: Re: [PATCH v2 14/14] bpf,x86: Respect X86_FEATURE_RETPOLINE* Message-ID: References: <20211021000502.ltn5o6ji6offwzeg@ast-mbp.dhcp.thefacebook.com> <20211021223719.GY174703@worktop.programming.kicks-ass.net> <20211021233852.gbkyl7wpunyyq4y5@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 22, 2021 at 08:22:35AM -0700, Alexei Starovoitov wrote: > On Fri, Oct 22, 2021 at 4:33 AM Peter Zijlstra wrote: > > > > On Thu, Oct 21, 2021 at 04:42:12PM -0700, Alexei Starovoitov wrote: > > > > > Ahh. Right. It's potentially a different offset for every prog. > > > Let's put it into struct jit_context then. > > > > Something like this... > > Yep. Looks nice and clean to me. > > > - poke->tailcall_bypass = image + (addr - poke_off - X86_PATCH_SIZE); > > + poke->tailcall_bypass = ip + (prog - start); > > poke->adj_off = X86_TAIL_CALL_OFFSET; > > - poke->tailcall_target = image + (addr - X86_PATCH_SIZE); > > + poke->tailcall_target = ip + ctx->tail_call_direct_label - X86_PATCH_SIZE; > > This part looks correct too, but this is Daniel's magic. > He'll probably take a look next week when he comes back from PTO. > I don't recall which test exercises this tailcall poking logic. > It's only used with dynamic updates to prog_array. > insmod test_bpf.ko and test_verifier won't go down this path. Please run ./test_progs -t tailcalls from tools/testing/selftests/bpf and make sure that all of the tests are passing in there, especially the tailcall_bpf2bpf* subset. Thanks!