Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1115944rwl; Thu, 10 Aug 2023 06:46:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoIRzTbWfiwckmg6GBBHLVaUSHldepbm7zmv0uaAG8DXQFeiwtjIYkFdeu8ip1FeEW0wu4 X-Received: by 2002:a17:90b:b08:b0:262:d6cb:3567 with SMTP id bf8-20020a17090b0b0800b00262d6cb3567mr2204506pjb.26.1691675211301; Thu, 10 Aug 2023 06:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691675211; cv=none; d=google.com; s=arc-20160816; b=aJw3uH68c59z81ZvO/sjFPpjYcPixgG59ZfEOQ7K4E0JbuLhYByGrmKUBcQdSYQ8qq gU9P1qPNCsxmnBD34zTXfCj0dCDs1GG2POvTlJ9QHzyC4Z8YMtOOGiHUB3QEgbocVknY E0pedcDDUtjYvHnBZFI2uDpM7tLAxEyMqnFwawkWyp9rwMhDdxgCG4JVcXIxJAWd9J8v UBh0wDVKEv2TPRGfTJgepbT9zdXe7GasX3KV8o7D91ViPIGOHmgc7NKcM59jlz/33G53 QqfBP5JMQnd7dkZjp5y478R9OdDq4KrbrKITJ4OadSnQVFdC0B6Dgh05faPPpKzLIhTN XEYA== 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=wyn7xRMIPnfCMl/9EnypSLvyJ+97kCNC26SaBpa02q8=; fh=q1rMKtT0TvfYK8yUnr0+BAEMMC41cpNrlcKMm0ARVCE=; b=OqJ/QHPB5fOFMzG7Sk33SFB2KVWp+k/q3/HPg+W2T9SQRNRlbGwdYlXQlqsaI5DuRH 6rlj843QabkyYSmZeVTrY+l4zxYlWDuTpQGNAdHvbBNg2z9PPWs3A6odWowguP7ORQTz 5K0wQ0OT3pItdg84OOocVToSzmEaMnd+14MhppaRhmMXzGKHNs5HFTdTnF3iizqQmcAC 4n5oMhgkPFoczC4qfGlQwYME4R6QJGx+9m3uZS5RFkE/y5kOaGpRfR2MfRyH9pqWtiHw ugbDM7ZLhTu3mp3QaDZXiBxkaIVDl4EjlNGXXYJaxjFfH++EKSKZ9ZWbECP5vt5ACbga cMsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="URIyCn/i"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a17090a598200b0025eeb3cc4b2si1529357pji.9.2023.08.10.06.46.39; Thu, 10 Aug 2023 06:46: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=@infradead.org header.s=desiato.20200630 header.b="URIyCn/i"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbjHJNCl (ORCPT + 99 others); Thu, 10 Aug 2023 09:02:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjHJNCj (ORCPT ); Thu, 10 Aug 2023 09:02:39 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61A602691 for ; Thu, 10 Aug 2023 06:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=wyn7xRMIPnfCMl/9EnypSLvyJ+97kCNC26SaBpa02q8=; b=URIyCn/i9pIh+CGtqdvj6DhIaX Wjv3gXd5Z9w84N6Y+9wPXG8eO+Oa1ODTGdIZI1fMVZUKCbOjJ1ZYoxH7HNrm29k7lk278W3yMaOg/ vL/5YF4dQZ1SQGD9H1x/6rZri/sVy4SO1A9pduCKJ1PBSFiZZzuuBlPPrG0fYJ58fTQTZgQtnbuZD m8TwXxoG2jue0pYHozFlrnewuV/oruQNZQ9/Cr2TIxZCslVmiTun19zGqFvwYIZrDLCnMlsk6GD5g qlQDJXQoiRCkgnMNr4Q2iYYine6bEHZonpRLviNadcbkpaO+jJ6g1at/SxhznP9dXWpbmRf8y5aNv rPXM8xTg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qU5J8-006Vsf-1j; Thu, 10 Aug 2023 13:02:30 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 2F4F830003A; Thu, 10 Aug 2023 15:02:30 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1345D2077633F; Thu, 10 Aug 2023 15:02:30 +0200 (CEST) Date: Thu, 10 Aug 2023 15:02:29 +0200 From: Peter Zijlstra To: Andrew.Cooper3@citrix.com Cc: Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org, David.Kaplan@amd.com, gregkh@linuxfoundation.org Subject: Re: [RFC][PATCH 12/17] x86/cpu: Rename original retbleed return thunk Message-ID: <20230810130229.GA212435@hirez.programming.kicks-ass.net> References: <20230809071218.000335006@infradead.org> <20230809072201.259675763@infradead.org> <20230809142031.jkj4pa2mhccrdmmd@treble> <20230809142255.GQ212435@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 Thu, Aug 10, 2023 at 12:06:17PM +0100, Andrew.Cooper3@citrix.com wrote: > On 09/08/2023 3:22 pm, Peter Zijlstra wrote: > > On Wed, Aug 09, 2023 at 10:20:31AM -0400, Josh Poimboeuf wrote: > >> On Wed, Aug 09, 2023 at 09:12:30AM +0200, Peter Zijlstra wrote: > >>> +++ b/tools/objtool/check.c > >>> @@ -455,7 +455,12 @@ static int decode_instructions(struct ob > >>> return -1; > >>> } > >>> > >>> - if (func->return_thunk || !strcmp(func->name, "srso_safe_ret") || func->alias != func) > >>> + /* > >>> + * Both zen_return_thunk() and srso_safe_ret() are embedded inside > >>> + * another instruction and objtool doesn't grok that. Skip validating them. > >>> + */ > >>> + if (!strcmp(func->name, "zen_return_thunk") || > >>> + !strcmp(func->name, "srso_safe_ret") || func->alias != func) > >> Hm, speaking of renaming they should probably be called > >> retbleed_return_thunk() and srso_return_thunk(). > > Yes, clearly naming is better in daylight. Let me regex that. > > btc_*, not retbleed_*. > > That way it matches the terminology you'll find in the AMD whitepaper > about what's going on, and there's already an entirely different issue > called Retbleed. So BTC as a whole is the fact that AMD predicts the type of an instruction and then picks a predictor to predict the target of that instruction, no? The retbleed issue is that BTC is used to trick the thing into thinking the RET is not a return but an indirect branch (type confusion) and then pick the BTB predictor for a target, which got trained to point at targer of choice. The SRSO thing employs the same type confusion to train the RSB/RAP and have RET, now correctly predicted to be a RET and using said RSB/RAP, to jump to target of choice. So in that regards, I don't think BTC is a good name for the thing.