Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1830522pxb; Fri, 22 Oct 2021 08:27:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeUO4ZAjEFSZC0Dt4mbnTLBQeJxoV3cKNRN9EgnhDkXDTYs8uENTwiqCi2CQaxt1iqvlGq X-Received: by 2002:a17:906:a1da:: with SMTP id bx26mr285936ejb.558.1634916441534; Fri, 22 Oct 2021 08:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634916441; cv=none; d=google.com; s=arc-20160816; b=xWP8UhGEcY/JAt2NRB0KK+ElnjWXIrooLRfPLoG7IxbQBE2nU1QX3FxTiXf3b+w2CL OJkmR3UKxLCKB0RwSNmXpzrZLnOU9pnQvT0NOxIRAezAAtwuqzl3Nk7lY3CltbdyDzD9 buu/HaDARdOb79RjCSkP5MELelifyoZlnSsy4qUTz1cuJ89OVUQBIHnIvTKMlCWSLVgf XQX92GEMYesijPyWY25T0UFz65TZguqm3DB+yVnwpAF+XuohHUWQjvGgh38PbAAmo07V s1+APtnhmxKXC17XmgZuNl1OLmkfTMXHpbuTT474IOu8+jqEg/Pqwvd4/KImSMPxq+JR Lq1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xPV0SOtCu/yXKv9zO0cN5aVANicEEw9KJSfvSTImqto=; b=UDA0eKEScdehD9fwRVcP3Ewjfj9yGKxaMAhHiL8Cy1iwPNe9Y0+uwSZ2HVAkDOKZ7U 7EZ5vgN3tKNjaXcak3Kk6XZn+1Xdc7tR+G3Rl8tDmwbf7Xihr05EQ+kaIhERkerM+jDR 5BIGc3SphVNfPWRBUMs4OkuApHQS/YAFX9vW1mJf493MJBqyMVU3c7n8rdKZ7HwMZgvk TBp+3VGxlmpe5Rbdf17K89TCi8twoSpQI4jUbRpyR5J366xpX6MtyoFZ/JzpaIez2IJW Zw5DrHHXGqWEL73j3DqZremmHROp2bCuKRQJppYwvVTHdiz0c4HZ10z/w18vmKhK97fy Royw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=odNLzMLx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg22si13702621ejc.776.2021.10.22.08.26.57; Fri, 22 Oct 2021 08:27:21 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=odNLzMLx; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233245AbhJVPZF (ORCPT + 99 others); Fri, 22 Oct 2021 11:25:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233173AbhJVPZF (ORCPT ); Fri, 22 Oct 2021 11:25:05 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4665C061764; Fri, 22 Oct 2021 08:22:47 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id 187so3906904pfc.10; Fri, 22 Oct 2021 08:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xPV0SOtCu/yXKv9zO0cN5aVANicEEw9KJSfvSTImqto=; b=odNLzMLxZ9cAj4JdTtszB5nuwSJQknxM58RXmUAmEbRnKRq5XeMMiGZfSL30dtee5t 7erSp1G5t14ZGy2ezAOXvelO8ml166elpjbizNaaZmlymRP6seFlkhne8hp0UnE3yX1Q V5ILKSLMERmRJSgp76ROGkgOL2N5HyWkIJgNuEdltV9iRRfc58AnXmK4KeXiUHv0zV1C KAkfPpT13X/+/qjMIlkgQvVFr41QuKZsbMpaLNbzlHjo2mpvgTJFBu3vQ3Ij+LP83e3G IRrD1YwkgW5vT0T3eXb14Ph5UuSB6OmfrfcjVSJzuvndd2LVvl/tqiQk2iCGHLTULl5v KfSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xPV0SOtCu/yXKv9zO0cN5aVANicEEw9KJSfvSTImqto=; b=UjByS1gE8NhNaBR8CayYLf9rcI7Hu85sBI55dkvMN/+lWUqN5ylnXKoQhNmYHdHPAn ooeeRWD+6KlGodUhRPDjXQXbqlZOVRfEKr/eQR46eEyrewlBRsyysUHfbQeB+Apnz53D EzvHJ9+3y+Y5noVCek+m9a/arG/60y81y7vM6rR5Vqw3DBPnpCmT9vxbLnmyzK8KbEtE KQzgS+miI20FSGUEsjkPaGiuGnl9Rrsjd3V7COyGbd3KbrDqbiTSRP6U0BVGniX4lsgn NIaLxJbEivnGkTWONxLHPZVZMZvVF4vWyIbC8Gccz15MrfY7/CMry+Qd+zzAWPuL2z5I f8lg== X-Gm-Message-State: AOAM532ISJva6u7vNYiFO+LcVqiUq490JFCsO9XvMZv2wGNhqfx3OIav tSYdUA/ISgCaonWj6BxWBpOxTkOrX8MoHcr3CjM= X-Received: by 2002:a63:374c:: with SMTP id g12mr275892pgn.35.1634916167065; Fri, 22 Oct 2021 08:22:47 -0700 (PDT) MIME-Version: 1.0 References: <20211020104442.021802560@infradead.org> <20211020105843.345016338@infradead.org> <20211021000502.ltn5o6ji6offwzeg@ast-mbp.dhcp.thefacebook.com> <20211021223719.GY174703@worktop.programming.kicks-ass.net> <20211021233852.gbkyl7wpunyyq4y5@treble> In-Reply-To: From: Alexei Starovoitov Date: Fri, 22 Oct 2021 08:22:35 -0700 Message-ID: Subject: Re: [PATCH v2 14/14] bpf,x86: Respect X86_FEATURE_RETPOLINE* To: Peter Zijlstra Cc: Josh Poimboeuf , X86 ML , Andrew Cooper , LKML , Nick Desaulniers , Daniel Borkmann , bpf , Andrii Nakryiko Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.