Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp814053rdb; Fri, 25 Aug 2023 01:40:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdmmc7Zqdy7RlzEjgLKrAV0mn+2V4RsxndPOCuVwLLqaW1HidYCTcQmFPeGODIkEuF0tVE X-Received: by 2002:a17:906:9bf6:b0:99d:eabc:2ed with SMTP id de54-20020a1709069bf600b0099deabc02edmr14274252ejc.32.1692952829138; Fri, 25 Aug 2023 01:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692952829; cv=none; d=google.com; s=arc-20160816; b=lUnyB4aEyXXEqoHLAUhZEab0j5wJifvQRg62igy7LoZ3lXNfrJdlgN7wAZwIwrr4h8 Z5E/7SlQqG3ZSj1MJ0UWJfLXzILow0U2Pti717Ufh6dyKquKxMJFMTU4A6K+cmkcH5x2 dj1ho3xYBA2dib5LYrF5FiEc6edFgAOAFi2SXjtNhYNhby7atNskctjbqSCyaths84AP D1t3PkgdXKzplMMCILkebNQzn1+gx1JGncn/HukZJQGApIwR2Q/VlK1cYSRqArSaB13M xoc6I5zlIv45gxGq0MAtT17+GpBvFKNsQPpfioaNUnVTR1DGfndfV2WPJIfrLS/Y0Y4o SXjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qyMbTVVDN6g2ZTSNefL8VxrKPSnq+vkMr6H30dP/rLU=; fh=ZwaEcDYNCnlh+U7YxZ1LCEcet9pcdhSkEX0cCEOksvY=; b=tpqK3rZw3/rEeARPThTelyJl5swWfLvSjvXzwvCpPsjX/eig8ny1HBapPGGw2lCQ9K PsrAtGFKZzYxQOI3+C+DzZKZ1Qu7v/aaag9OfmNILbNOJfOOgIk/oXpSy7P9VKW5pO7g MZIy/O3yJt/q95ngYlid5IPoHZ/Y3M34XrkBvhma8IqMgSBOIpmcWjC2dNXzflFa7cwr jE2jZV22SHJ9MMYy+ZaRiFtX04gNrIk2Z043NOWA7vVYYnu7HmBRX+QPUfVBcN0WiJwB htGdGKbgkeYxAi3bLXavgEqQ6LAFZvMdKeJsFVlzoOStOnie54lcIX0lMMmigVViPSl7 Gbfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P5K8Twwt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a170906089100b0099d6d4c11d4si690679eje.782.2023.08.25.01.40.00; Fri, 25 Aug 2023 01:40:29 -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=@kernel.org header.s=k20201202 header.b=P5K8Twwt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240878AbjHYHCq (ORCPT + 99 others); Fri, 25 Aug 2023 03:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242478AbjHYHCL (ORCPT ); Fri, 25 Aug 2023 03:02:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7443419A1 for ; Fri, 25 Aug 2023 00:02:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 56B1D647DE for ; Fri, 25 Aug 2023 07:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56170C433C7; Fri, 25 Aug 2023 07:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692946928; bh=vKe6g7DJFD+sOe7LW8LR2j3xCIXy2maEKLpUAkuZCqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5K8Twwtv99Li0/mBq1RaSXRL8jGmVrCRPB/2Vz4K0tN/A7hmMZ8JfJ+vDPRNffaZ BVfTmHXdE42MngiGiAz2WBiVqCjmB9ZdvhUE6J1DemJNDtH7V/LndFbrSiz/IGCmwj vJnTpE3NWDzc0O36UN9uFThinOD6tIjd1cDnipdXdwHryH8fX06hFVNacCAIUnRO46 hcW3nlh3eOgKmtYmivLfCNU0msIi5O+iJP7ObA0zsVgSesV/Bkw8p6ImaL4enJvoUY 7tYfuQe56Eg+H7TurQPrXVZKgNVuCtUIjMZfUg314trd11TgGwBfknK44tR56q141v yYLrh83Ue1kRw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Peter Zijlstra , Babu Moger , Paolo Bonzini , Sean Christopherson , David.Kaplan@amd.com, Andrew Cooper , Nikolay Borisov , gregkh@linuxfoundation.org, Thomas Gleixner Subject: [PATCH 11/23] x86/srso: Fix unret validation dependencies Date: Fri, 25 Aug 2023 00:01:42 -0700 Message-ID: <6d3818c914d04684ec9a01397b0ef229c93d5fdf.1692919072.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 CONFIG_CPU_SRSO isn't dependent on CONFIG_CPU_UNRET_ENTRY (AMD Retbleed), so the two features are independently configurable. Fix several issues for the (presumably rare) case where CONFIG_CPU_SRSO is enabled but CONFIG_CPU_UNRET_ENTRY isn't. Fixes: fb3bd914b3ec ("x86/srso: Add a Speculative RAS Overflow mitigation") Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/nospec-branch.h | 4 ++-- include/linux/objtool.h | 3 ++- scripts/Makefile.vmlinux_o | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index c55cc243592e..197ff4f4d1ce 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -271,7 +271,7 @@ .Lskip_rsb_\@: .endm -#ifdef CONFIG_CPU_UNRET_ENTRY +#if defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_SRSO) #define CALL_UNTRAIN_RET "call entry_untrain_ret" #else #define CALL_UNTRAIN_RET "" @@ -312,7 +312,7 @@ .macro UNTRAIN_RET_FROM_CALL #if defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_IBPB_ENTRY) || \ - defined(CONFIG_CALL_DEPTH_TRACKING) + defined(CONFIG_CALL_DEPTH_TRACKING) || defined(CONFIG_CPU_SRSO) VALIDATE_UNRET_END ALTERNATIVE_3 "", \ CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \ diff --git a/include/linux/objtool.h b/include/linux/objtool.h index 03f82c2c2ebf..b5440e7da55b 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -130,7 +130,8 @@ * it will be ignored. */ .macro VALIDATE_UNRET_BEGIN -#if defined(CONFIG_NOINSTR_VALIDATION) && defined(CONFIG_CPU_UNRET_ENTRY) +#if defined(CONFIG_NOINSTR_VALIDATION) && \ + (defined(CONFIG_CPU_UNRET_ENTRY) || defined(CONFIG_CPU_SRSO)) .Lhere_\@: .pushsection .discard.validate_unret .long .Lhere_\@ - . diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 0edfdb40364b..25b3b587d37c 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -37,7 +37,8 @@ objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y) vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret) +vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \ + $(if $(or $(CONFIG_CPU_UNRET_ENTRY),$(CONFIG_CPU_SRSO)), --unret) objtool-args = $(vmlinux-objtool-args-y) --link -- 2.41.0