Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp95393pxb; Wed, 20 Oct 2021 17:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDnYbF38iUHqID3sAJ8kkxu5b/Nj1rE2sDpcnRdOQ771+voKcuk1ZVAbsia0zCQU/Z2vzX X-Received: by 2002:aa7:962c:0:b0:44d:437d:c032 with SMTP id r12-20020aa7962c000000b0044d437dc032mr1903136pfg.85.1634775753784; Wed, 20 Oct 2021 17:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634775753; cv=none; d=google.com; s=arc-20160816; b=0ganUaM6tncFaLXVbWIIOD88lnu01Rb7xIkXh85Z5fE73qqDppZSS/egb4C62JzEPF w6B1d7IueAZB7jC74dbf8a5KX5kqKJ1rqHqPdqLysEP5K5Z49BdgUZqrzQ+lGmHCuhMG NnOLLsRuinVFDs2tBxvhWV4pnfYdQ6BqTTF1/frb1Tc2N+2uXKdXzNSMeHUVsbw8EX8J QqDa63JKTCKlknKf8V7qZRheqo7poREGuVTxLVzfLr8plQfDZMydQ5WW5huZ0UWCXzYi VlCjpFYstX1cprGTB0A9T7UPoVTr5goEWFopLUkVKJNbCkhfmPBzbV7frX0XF84GmJVS G3PA== 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=Y9Y7hzxIeRjzddapp4B4sp40weziP9X+IKnwKSW55pQ=; b=X9iM1SvXK4F64HUDdXrGxioI9/4q/nYQSKlcDpi8+kiKUQJrMMWlP2/TPaUoQzrvQW 9htXtqWO96pS6HT/o6fgYxlOPUgpWLPM0prHuWyen5/XTMjuGyALBAm4cg5vhgNdN7H7 zfWq6tuoGT0UAO/HzdnkoIx4mThVEPPwuzs4c+gsnF21p267aPNA/cxQBqe+Q+w6504l HXPy4h0a1GHUGLMwtqPIqmENZ2a/MDonARLQMIY6oF5AhEiYxc4ZrYmj9xWZ0SC+vkzr xD7qKBFFV3E9iWs7G6CPMIXD6/E+yAd2EcVMeT/Jx4R+0w3cJ1vFxrpQkMsWJaQiWyS2 4DSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GlT5VaAv; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id on9si10653980pjb.64.2021.10.20.17.22.07; Wed, 20 Oct 2021 17:22:33 -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=@redhat.com header.s=mimecast20190719 header.b=GlT5VaAv; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbhJUAUa (ORCPT + 99 others); Wed, 20 Oct 2021 20:20:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25421 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbhJUAU3 (ORCPT ); Wed, 20 Oct 2021 20:20:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634775493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y9Y7hzxIeRjzddapp4B4sp40weziP9X+IKnwKSW55pQ=; b=GlT5VaAvAnnvr96/6E9XyoVLltUHvXWxlAMu/HRce0vb5WiIQTZ4WOlh35fGRBpj9twKBq P02VyI+c8YqvGlC7mudnElkv0XBz4bFT6IbQqum7OFsx+5h54CFDEHaSjub4GHGAZ6EP4V rO8a4jejxm1P8X6+M4EFMqs+1mh6GlI= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-5IDR6AnCNwe7YG1DiYUsKA-1; Wed, 20 Oct 2021 20:18:12 -0400 X-MC-Unique: 5IDR6AnCNwe7YG1DiYUsKA-1 Received: by mail-qt1-f200.google.com with SMTP id 59-20020aed2041000000b002a78c85c668so3283308qta.12 for ; Wed, 20 Oct 2021 17:18:12 -0700 (PDT) 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=Y9Y7hzxIeRjzddapp4B4sp40weziP9X+IKnwKSW55pQ=; b=lIRJT9JGiHR/nsf46eDUtbbYuiynxcjRhcUY9cl0gZ1GJbrU8hrJ8WvQlElF7XYxs/ EpA6aUgSR77jMpKoQ3FSbI0PjB0QfEHJ7oayzFef2SiwbnRMpJpX6RZo7X/fIORqB6K1 DAQMStsx024C01v8qybFt0AXT+UgVNSbQNbkcjnIzKJh4b50Eb6diO/Ihlij+PdU730i gpq7/VW9YI0e70TGWCAqOvX+TKHLSKZ7TRc7O4A3ATxudtkvXS1UosQr8IOUSfe3e1A6 lEdRtVvnUiqVTtWdI6/VXDliTSWJKaX+UOoU0bB0qfJhEs0Tx/PFwIiCaezZtsbHaNLC FeCA== X-Gm-Message-State: AOAM531U0NuOX4UfpPn0LXVy1VC3oiCHJalIcPIFQ5c659Px9yhHN4Et gS6A0lH45QYqxaI17SbFab6tMD2wq2ssvsAV0tVGYJogChWXRvr5u8RINryNCKky9SFhVrRM3DL z89IFtkw6S5AM3qAMSnoWJxIG X-Received: by 2002:ac8:183:: with SMTP id x3mr2726878qtf.270.1634775492170; Wed, 20 Oct 2021 17:18:12 -0700 (PDT) X-Received: by 2002:ac8:183:: with SMTP id x3mr2726864qtf.270.1634775491987; Wed, 20 Oct 2021 17:18:11 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id o16sm1122070qkp.1.2021.10.20.17.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 17:18:11 -0700 (PDT) Date: Wed, 20 Oct 2021 17:18:08 -0700 From: Josh Poimboeuf To: Alexei Starovoitov Cc: Peter Zijlstra , x86@kernel.org, andrew.cooper3@citrix.com, linux-kernel@vger.kernel.org, ndesaulniers@google.com, bpf@vger.kernel.org, daniel@iogearbox.net Subject: Re: [PATCH v2 14/14] bpf,x86: Respect X86_FEATURE_RETPOLINE* Message-ID: <20211021001808.3ng6qeggi5lfwx7k@treble> References: <20211020104442.021802560@infradead.org> <20211020105843.345016338@infradead.org> <20211021000753.kdxtjl3nzre2zshb@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211021000753.kdxtjl3nzre2zshb@ast-mbp.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 05:07:53PM -0700, Alexei Starovoitov wrote: > On Wed, Oct 20, 2021 at 12:44:56PM +0200, Peter Zijlstra wrote: > > + > > + if (cpu_feature_enabled(X86_FEATURE_RETPOLINE_AMD)) { > > + EMIT_LFENCE(); > > + EMIT2(0xFF, 0xE0 + reg); > > + } else if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) { > > + emit_jump(&prog, reg_thunk[reg], ip); > > + } else > > One more question. > What's a deal with AMD? I thought the retpoline is effective on it as well. > lfence is an optimization or retpoline turned out to be not enough > in some cases? Yes, it's basically an optimization. AMD recommends it presumably because it's quite a bit faster than a retpoline. According to AMD it shrinks the speculative execution window enough so that Spectre v2 isn't a threat. -- Josh