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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E61C3C433F5 for ; Thu, 21 Oct 2021 00:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCF56611C7 for ; Thu, 21 Oct 2021 00:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231315AbhJUAUa (ORCPT ); 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-Google-Smtp-Source: ABdhPJxQH+mIBiVII1WLYqbEa5sUX+3H1BU4XLVzKDhQhE2Xyezhpp8g8l/1LyqVY4fTY3HsiriTTw== 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