Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp164667rdb; Wed, 18 Oct 2023 23:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhvSEftv/He+5pFzCTR6S49sxs7sA85kidaAFKBZSHQ+U4F62qSB9Hq8KlqSGKfeR9MSor X-Received: by 2002:aa7:88d0:0:b0:6bd:71e3:b647 with SMTP id k16-20020aa788d0000000b006bd71e3b647mr1285836pff.19.1697698784401; Wed, 18 Oct 2023 23:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697698784; cv=none; d=google.com; s=arc-20160816; b=Tnz11O99UF367S6r8ztu96A23XB9hgXnI2xSQ4TGktD2rurhmYGx6padZmcmDaLmDC aPh6MQZKheiFT+tOKz7xXTWR/ZCPsKmMJWMUAt/ARPh6lLfj006jx4LxZs+uMPTgzbUR LreO/lB2lrQUS/vMI57lUfHykgJPBBQbiUaV1vSqMuzeHy9HEhyifeGpfgblKQMOaKdz u4uRvoYD7wsyFUK54KNMV79yf5/Qeo+PUdI++zqnKs7GJTPHdgP7IICAva2zeCHUcOXS qqvhu/8O/wdljwsTKOrskvxelaIHZHRJB1bML9TQ2pfDISveoxvPBfubNRV49RI8UmpW SZXA== 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=CO8NyldiyvTHJw6SoQLStUI7H6pbAmjUNmUL6bZV1Xs=; fh=ryNl978v0qTqD2R+xUvvqKb6xbCiYXTSd64Ar2Y696I=; b=cv9qW3mBwAvZDZmYFH+oVvYjFlihO4WzA1NcwKq+43twCtkUXy2/TEjMca7ikOs84I kb/omgiTd+8+r4T8Yrce0Dl2HcLpP4/3imPQWljtGu+Ra2DF6jGzegnbYxk+B72FxHTd qjh4vbSO8wNhDx7oQRgGn9+Fp3VrxAm7CMyOfC0JIF/BnAiQU6DdTixxxcCY9CwlN6/8 qINXuaiWNFc1GnjhqWBWFaZdo/pfZqddAX8FIqrjlbBrcsBt5acNIIJJFC6T6j6k+i+w kri5G3HOqKjx0qAfm+GD9nUooNegPwgxZjNzZh+OgW45M6AfAxE/zF1qhTDZwWjDXE1u hqoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kwygLwJO; 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 y8-20020aa79ae8000000b006b8b194005fsi5465739pfp.256.2023.10.18.23.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 23:59:44 -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=kwygLwJO; 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 C4B688182EDE; Wed, 18 Oct 2023 23:59:40 -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 S232791AbjJSG7d (ORCPT + 99 others); Thu, 19 Oct 2023 02:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232583AbjJSG7c (ORCPT ); Thu, 19 Oct 2023 02:59:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084BC11D; Wed, 18 Oct 2023 23:59:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E466C433C7; Thu, 19 Oct 2023 06:59:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697698770; bh=jgNes3/dT6qKmEnlevXgPZqbntb+vPAwbcCbjHyY8U4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kwygLwJO3XbLTgcbM9Qz1EB1Wt/1qOltdOvDGM5b2r1Gf0HaD4XTjQk6RhIvrcbCO eK7dvRvk/XI7cSTt7+poHJAClNnlXwJsedpE5dBc6pNADJ0s8YugOl+08Sku5cfRCX OWX0LwKsJLIUipsDV4ji9lpDrSTC10JfdCoFhl8CqmJ4YdppbxSdhPhM1aqEf8BUDF kkuWwSmFT8oYCII8p8pLYENo6KY/803ZadNY09ofr8vZfdK9ux1au6Zm/Zynt0SMzg ZzcuzJ7ffBAzU+SUNb5ADzavmldv25vtEqkkXW1YYpG3lMLJ7iuXz2/jFStOTbvE+H 0BmiU7GhRwY5g== Date: Wed, 18 Oct 2023 23:59:28 -0700 From: Josh Poimboeuf To: Borislav Petkov Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org, David Kaplan , "Peter Zijlstra (Intel)" , x86@kernel.org, David Howells Subject: Re: [tip: x86/bugs] x86/retpoline: Ensure default return thunk isn't used at runtime Message-ID: <20231019065928.mrvhtfaya22p2uzw@treble> References: <20231012141031.GHZSf+V1NjjUJTc9a9@fat_crate.local> <169713303534.3135.10558074245117750218.tip-bot2@tip-bot2> <20231018132352.GBZS/caGJ8Wk9kmTbg@fat_crate.local> <20231018151245.GCZS/17QhDGe7q6K+w@fat_crate.local> <20231018155433.z4auwckr5s27wnig@treble> <20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local> <20231018203747.GJZTBCG7mv5HL4w6CC@fat_crate.local> <20231019063527.iwgyioxi2gznnshp@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231019063527.iwgyioxi2gznnshp@treble> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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]); Wed, 18 Oct 2023 23:59:41 -0700 (PDT) On Wed, Oct 18, 2023 at 11:35:30PM -0700, Josh Poimboeuf wrote: > On Wed, Oct 18, 2023 at 10:37:47PM +0200, Borislav Petkov wrote: > > +++ b/arch/x86/kernel/alternative.c > > @@ -748,14 +748,20 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) > > continue; > > > > op = insn.opcode.bytes[0]; > > - if (op == JMP32_INSN_OPCODE) > > + if (op == JMP32_INSN_OPCODE || op == JMP8_INSN_OPCODE) > > dest = addr + insn.length + insn.immediate.value; > > I can recreate (with my GCC 12) by disabling CONFIG_CALL_DEPTH_TRACKING > and CONFIG_CPU_SRSO, which puts __x86_return_thunk() close enough to the > retpolines to enable the two-byte JMP in the last retpoline. And then > booting with spectre_v2=retpoline. > > (Then to force two-byte JMPs for more retpolines, I cheated and just > moved __x86_return_thunk() to right after the retpolines.) > > Your WARN patch didn't seem to fix the no-output hang for me, maybe due > to recursive warnings? > > I was able to get more output by changing the WARN to (ahem) WARN_ONCE, > but it's still getting into some kind of stack corruption. Full output > below. I haven't had a chance to look further, but it's worrisome that > even the WARN_ONCE isn't being recovered from. > > Regardless of if we revert e92626af3234 ("x86/retpoline: Remove > .text..__x86.return_thunk section"), or do the above patch, we still > need to figure out why even WARN_ONCE() would be borking things. > > Off to bed... One last idea, since the return thunk is used everywhere (even non-ABI compliant functions) it might be possible the "call check_thunks" (and its call to warn_printk) is clobbering some registers which some code (exception handling entry code?) doesn't appreciate. FWIW, I changed to a WARN_ON_ONCE and it booted fine. -- Josh