Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp387640rdg; Tue, 10 Oct 2023 13:19:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkBYSgJb7yX1hEM/TzFb+k9ZsFo8v45LDl4Pg2qATFq6kxf4mZ4HU2Vq/gzoshVW+ndocb X-Received: by 2002:a17:903:228c:b0:1b7:f64b:379b with SMTP id b12-20020a170903228c00b001b7f64b379bmr28227808plh.17.1696969168861; Tue, 10 Oct 2023 13:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696969168; cv=none; d=google.com; s=arc-20160816; b=mNczvQSr1GgeBq5Q1uRbeVM4txHOqXxU6gzRnEXNHggpw05GFDfd931zUnA31QHtmi vJIU5xf5rsQif/Wk+4nmjzkNVUozrdwZ5BzJIelRSBeWw8aK9U3HJYsOqkba4cdRctSu lndIt+pJNzK7a/Q0zH2tOwDGrUGtujv/AfscVxnR5wriz7HckRMttd6Giqm6CpdGx8fr ieuQIhEQdhF5j7vSRieq8Dpqllsp9ZaoPGuLnmIwBN+76cZKFX+ImxffgEHb/PE6sYBm 9cc4/mZywP+yBBiaQeNlUwTHRoLRBTPm42rHnNfPifqm4zLrVLA1sOCVfC/0yEZEzFzB CGmQ== 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=P7CqvgVSaF90a6XhbbZzfAH8rdJHnPzNi/32NYL1Biw=; fh=yXBcsD2KmditorKQ7BPae2LMAHb3dAzAjF2RyeLSvHs=; b=QIfHsTomWsRpYmvpjh6Uvh0URpRWbY0wU/r2CVBU3PoGe0VYuZ/XuvhFf96ynqnyR6 2BPE8Rr/qhHCH5if69wpfjs73yHm+aYwSE26oSuIfZGvxXmiXYYCTU1NRhk3xiS3cCDZ 82Y6BJ0hhlCMU5XPtGMrfaUaA4pbgkso0B7fyN+zxatZ/EZsvPUUGrkMgtvnu6eUd4Dh GvhoY76WYtNDvSmoKdsI24if4fTNzJm6yLUzwZR8kDdjw29WUsXMBMKC8Zip9RuQK8op 97YgmA3BV8j8IW+rd2sosjlKCOAJO6pGVL2R5LHVgELUZ3YPAQw3Gb2yru0SOP7azurE AnCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPQRw7dM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y22-20020a17090264d600b001c9af74feaesi123192pli.215.2023.10.10.13.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 13:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XPQRw7dM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3A9BF808987E; Tue, 10 Oct 2023 13:19:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbjJJUTS (ORCPT + 99 others); Tue, 10 Oct 2023 16:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbjJJUTR (ORCPT ); Tue, 10 Oct 2023 16:19:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 572CA93 for ; Tue, 10 Oct 2023 13:19:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6AC5C433C8; Tue, 10 Oct 2023 20:19:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696969155; bh=gfo9pncGhCc3KfWVYgKiKfPohTYEVL0puV5Yd+N8vBQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XPQRw7dMtDQ2hRCCCsb/nH816uSmuvFfYs4hKEY9J19XErOXvG1R0zT7ulViGPcwo xZ8hBgmARiHpMPjmOIQYvWBQPXAz5nrAaSkq/zDV8uFvB5O6O1t0uDsoO31HTInuWQ h6CkWOnw5WhIA3fJyTLvuYKJMS98K26PTCnjH63FqtjJ1GsmLuZoLEWyNqkw2zKAuw kLoD6SD1dlETneWlXozmxCGjgMkyujuiasTufBZ2Dr0YfXWCn/+2lLwoJfbIMZUj4e DBniQAB5ulUdnLxzIDG4qigHHDD4rroJ+EYCfvjX6jNgR9c8Gcirn1F0NolHLQZfqs o5pTY9eFHPQgg== Date: Tue, 10 Oct 2023 13:19:12 -0700 From: Josh Poimboeuf To: Borislav Petkov Cc: Peter Zijlstra , David Kaplan , x86@kernel.org, luto@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] Revert "x86/retpoline: Remove .text..__x86.return_thunk section" Message-ID: <20231010201912.7pjksbparssqu34k@treble> References: <20231010171020.462211-1-david.kaplan@amd.com> <20231010171020.462211-2-david.kaplan@amd.com> <20231010174833.GG14330@noisy.programming.kicks-ass.net> <20231010195721.p5pb273kevg7ydxz@treble> <20231010200429.GIZSWuTWSUM9aId7a6@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231010200429.GIZSWuTWSUM9aId7a6@fat_crate.local> X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 13:19:26 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 10:04:29PM +0200, Borislav Petkov wrote: > On Tue, Oct 10, 2023 at 12:57:21PM -0700, Josh Poimboeuf wrote: > > Also we could make objtool properly detect the non-relocated jump > > target. > > I was wondering about that... I guess it can compute the JMP target and > compare it to the address of __x86_return_thunk? Fine, you twisted my arm ;-) This seems to do the trick. Lemme write up a proper patch. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e308d1ba664e..6cbc9812a36e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1610,6 +1610,11 @@ static int add_jump_destinations(struct objtool_file *file) return -1; } + if (jump_dest->sym && jump_dest->sym->return_thunk) { + add_return_call(file, insn, true); + continue; + } + /* * Cross-function jump. */