From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBDE82DCBE8 for ; Fri, 23 May 2025 01:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963234; cv=none; b=mRKayy66KjzK+YRpK6lBJmJAgY6b+iE0Z9gUIB9Dycig5oG17bMBnYnClBEWPucoPNP2H2zBfu4zRU3z0uksPwIkjj3zAtv77JA2yuf9aVdLpm0YdRSbmtvwahV+nL/KU/aR8g+Y6CQUFxBrERpm7M77VIfIEbFFFS9dHJADw0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963234; c=relaxed/simple; bh=hZF+K4C+8YMX2yIrXGyw419gmW2PPyReux4bOncG09o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LSOsJ9TcOM2Fm/Gj/O+IMZ5e+g3mycigpaGMPcrF5jQWCWBWgPwp1woM+wC6/GpsxI3aEoqHN8kds5uq4636yFK/JEGFa8uTj1SRnSd5bD+Z2P1WhjoBvAPUyx18+zmGtsfXEtRlADL3YSq4VuF5qGyDdWjsyx3irOtGJSTUfr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=G7zUr8dL; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="G7zUr8dL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963233; x=1779499233; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hZF+K4C+8YMX2yIrXGyw419gmW2PPyReux4bOncG09o=; b=G7zUr8dLpjQENc8/GqmUa7yaA4YPpwhJoXt2m+cbT6NMQgpQ+J/sEyCQ qGwzvXSu7C/L5pBZoyqZPp900OU9QlKKiUpXQTn8OhvwauhQynW/9zYdi VKK7nIYk19iIgsSQKJcxxTEwoWews6D4QjphuVJszD/5v+mW5likcAi2v L9Xlb/QpElDykKkXzitbUavxwCvpGp+/fNEqL9qxomeBXV4UdeUVYDh5d qG1o9A0+lOVAHhveisu+wOrHIVcsJi4MFvik/A463eFrGKorJRbZT8DRY 2Clbfs7MOBQ8jG2wO3UmZk8vJKel3nWcxsbf57ONmxQGfqNiF+NeQ4a3W A==; X-CSE-ConnectionGUID: 6wmL2XKfTy6rSZM6mmOybg== X-CSE-MsgGUID: rMrVgwu6RwepiwV8FD66ZQ== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="49128351" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="49128351" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:20:32 -0700 X-CSE-ConnectionGUID: PVlI8ayCRWOGN88B6fkWCA== X-CSE-MsgGUID: 2cJbA49VQbK0Odt2wqwtUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="140724632" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:20:32 -0700 Date: Thu, 22 May 2025 18:20:31 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Borislav Petkov Subject: [PATCH v3 1/7] x86/retbleed: Avoid AUTO after the select step Message-ID: <20250522-eibrs-fix-v3-1-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Retbleed select function leaves the mitigation to AUTO in some cases. Moreover, the update function can also set the mitigation to AUTO. This is inconsistent with other mitigations and requires explicit handling of AUTO at the end of update step. Make sure a mitigation gets selected in the select step, and do not change it to AUTO in the update step. When no mitigation can be selected leave it to NONE, which is what AUTO was getting changed to in the end. Suggested-by: Borislav Petkov Signed-off-by: Pawan Gupta Acked-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/bugs.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 7f94e6a5497d9a2d312a76095e48d6b364565777..53649df2c4d66c6bd3aa34dec69= af9df253bccfc 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1247,6 +1247,14 @@ static void __init retbleed_select_mitigation(void) retbleed_mitigation =3D RETBLEED_MITIGATION_IBPB; else retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; + } else if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_INTEL) { + /* Final mitigation depends on spectre-v2 selection */ + if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) + retbleed_mitigation =3D RETBLEED_MITIGATION_EIBRS; + else if (boot_cpu_has(X86_FEATURE_IBRS)) + retbleed_mitigation =3D RETBLEED_MITIGATION_IBRS; + else + retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } } =20 @@ -1255,9 +1263,6 @@ static void __init retbleed_update_mitigation(void) if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off()) return; =20 - if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_NONE) - goto out; - /* * retbleed=3Dstuff is only allowed on Intel. If stuffing can't be used * then a different mitigation will be selected below. @@ -1268,7 +1273,7 @@ static void __init retbleed_update_mitigation(void) its_mitigation =3D=3D ITS_MITIGATION_RETPOLINE_STUFF) { if (spectre_v2_enabled !=3D SPECTRE_V2_RETPOLINE) { pr_err("WARNING: retbleed=3Dstuff depends on spectre_v2=3Dretpoline\n"); - retbleed_mitigation =3D RETBLEED_MITIGATION_AUTO; + retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } else { if (retbleed_mitigation !=3D RETBLEED_MITIGATION_STUFF) pr_info("Retbleed mitigation updated to stuffing\n"); @@ -1294,15 +1299,11 @@ static void __init retbleed_update_mitigation(void) if (retbleed_mitigation !=3D RETBLEED_MITIGATION_STUFF) pr_err(RETBLEED_INTEL_MSG); } - /* If nothing has set the mitigation yet, default to NONE. */ - if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_AUTO) - retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } -out: + pr_info("%s\n", retbleed_strings[retbleed_mitigation]); } =20 - static void __init retbleed_apply_mitigation(void) { bool mitigate_smt =3D false; --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 870A52566 for ; Fri, 23 May 2025 01:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963250; cv=none; b=CadzTCnX1ZbLxDwn+f80RT0aQ1TjP5UuAK7pnU45UnRNeiDwAh52mDhzrgRJc5uMAfU0JSg82UqDpNxjdVUVdI3t8InJcR7WsE/5HacoB5DnAOT/5CV1hpwCFLEMcyIGn9VQOUPsmfEJT8M+QCL+C14QOmh6fiArTiHMGMREb5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963250; c=relaxed/simple; bh=N2zSwnsNcY6iN7PCWXdFwhNxq+FFO6jtPQrEfpompIw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nGB341dckiL+jVW/TieBMt6cBBUoBI/BYe3UmVluxInDpkFEngU1ueltRSesCGSdi8pADMX4QmC2Odwjh9KQM+Q5THDYLV9DEgKUPqZMTN1KrJ4Iz7VdHCgvE9ArWAFeixfpB6UFx8rQA963UifTftcUk60ngeF72Ck+j8GY0Y8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ELry7+pn; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ELry7+pn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963248; x=1779499248; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=N2zSwnsNcY6iN7PCWXdFwhNxq+FFO6jtPQrEfpompIw=; b=ELry7+pnOma+W2OguE6S9EFASkrkGsCAx7n2DkH+2lHn3OQ54SZf0vN/ QabzXS+jM6ZAaFlgVpm5k2f+XhHSAi5LP3f+uArARwLUHCZZuRDBW7egv 8hHUNa5BzZKLBVxL9BXF0Fn+jz5BNLOniMVzazghsSDCo7RDFSjS9zJ69 fL66lIZsncJEQj7cUwZG4C+ExyrwogHFzYG+ML8T1N5IWxSNztEF9r+B1 KOcImNk/3WKNzUpG9HbBQrsrg4o5psLTEtXt3xyHmw69mSNNF9PIwISeM Zino//BiWJvuuehPSzERB9S6Lswk7Vp9+pONNqX2fqov62DbX7BrqRxYL w==; X-CSE-ConnectionGUID: 30tL6czMQzm5PLsgLQaf9g== X-CSE-MsgGUID: Mf/iJkCxT9q25nUcYCObkg== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="49128363" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="49128363" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:20:48 -0700 X-CSE-ConnectionGUID: 4I++Fr35TCq0h32sxiQZAg== X-CSE-MsgGUID: KmK7VqcrQcWC2c6Cb2Gy4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="140685424" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:20:47 -0700 Date: Thu, 22 May 2025 18:20:47 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Nikolay Borisov Subject: [PATCH v3 2/7] x86/retbleed: Simplify the =stuff checks Message-ID: <20250522-eibrs-fix-v3-2-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify the nested checks, remove redundant print and comment. Reviewed-by: Nikolay Borisov Signed-off-by: Pawan Gupta Acked-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/bugs.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 53649df2c4d66c6bd3aa34dec69af9df253bccfc..94d0de3e61aec32b3b67c8d21f8= 9a8c67b93dff3 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1263,24 +1263,16 @@ static void __init retbleed_update_mitigation(void) if (!boot_cpu_has_bug(X86_BUG_RETBLEED) || cpu_mitigations_off()) return; =20 - /* - * retbleed=3Dstuff is only allowed on Intel. If stuffing can't be used - * then a different mitigation will be selected below. - * - * its=3Dstuff will also attempt to enable stuffing. - */ - if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_STUFF || - its_mitigation =3D=3D ITS_MITIGATION_RETPOLINE_STUFF) { - if (spectre_v2_enabled !=3D SPECTRE_V2_RETPOLINE) { - pr_err("WARNING: retbleed=3Dstuff depends on spectre_v2=3Dretpoline\n"); - retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; - } else { - if (retbleed_mitigation !=3D RETBLEED_MITIGATION_STUFF) - pr_info("Retbleed mitigation updated to stuffing\n"); + /* ITS can also enable stuffing */ + if (its_mitigation =3D=3D ITS_MITIGATION_RETPOLINE_STUFF) + retbleed_mitigation =3D RETBLEED_MITIGATION_STUFF; =20 - retbleed_mitigation =3D RETBLEED_MITIGATION_STUFF; - } + if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_STUFF && + spectre_v2_enabled !=3D SPECTRE_V2_RETPOLINE) { + pr_err("WARNING: retbleed=3Dstuff depends on spectre_v2=3Dretpoline\n"); + retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } + /* * Let IBRS trump all on Intel without affecting the effects of the * retbleed=3D cmdline option except for call depth based stuffing --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADF652DCBE2 for ; Fri, 23 May 2025 01:21:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963265; cv=none; b=jb0QkEjJ/oUGNiSXx8X6UxkmyZRoD2bKr1xh4eyEgk/EiJTWxb1gW2+tsESoFISRD45Ck9AATuseWg9oYkYjdjpEL0mZ5o3Himgyj0APNpUE8Drl/0+38mZylfIOaWDCRZ0+ekvoF34EG+PTf0i7o94XNPnE1TfZQnfHbDdRM6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963265; c=relaxed/simple; bh=/yHFI/+O3XKAIOaAmu2yff73xOQf/jodOB52m4se3Kc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=deouPdZRJqJ2U04L/3CHnhUz0JLL0Wn4kYC0fW3iROYNCjXM0TnozmRSVouN0L8V8ULIaGwbpbrE1gjHxcKrYDjSFBnog9KzYYPk/GnKiprmBhQcUP2pjcNjoqE6LKRmJegwKWGX9sDd1XDBzYUxZfrGWsqBFWkh4DtENnIGeAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RUCTstHr; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RUCTstHr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963264; x=1779499264; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/yHFI/+O3XKAIOaAmu2yff73xOQf/jodOB52m4se3Kc=; b=RUCTstHrgDOwyVOUwOgf7DtS2i39oLGTfbnwguA/9Gdbj9enX6LNJpcO DgA3OJgBNslEPZIwB/9LjLIqPnn1F0UCSuvfLwRlAe2mAt3f3KLDUWuRa jfIOfoZZF3yU6ohck5ChR/A69mcoxrkssh7wvIdbvObFdzNjBYNKH6J5M sgYAcsy/sGH2EJuShRa5DJW3SN6Jn0rXrZ4axF5fEVKyj6r5Ed71t82Ia UoQ7GnY8Xo1ih2sILa5nABeVz/Bvf9psunmaQwlrCFPW/hjUQBJ04xJ7r KVzLoSsc+8EbVWeV3Wd699Vg1uTPvZeFHixmz7iH3mczZzayVcqiYsTX6 w==; X-CSE-ConnectionGUID: rkdhAyjrTUihbxNlZWzG7Q== X-CSE-MsgGUID: N9rhMYrvRc6hLsu/upIYdQ== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="49128376" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="49128376" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:03 -0700 X-CSE-ConnectionGUID: jijugcAcRo6Jg2EbKvG9ZQ== X-CSE-MsgGUID: 0L1M5TgbTLWOT6TTG/t6zQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="140685437" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:03 -0700 Date: Thu, 22 May 2025 18:21:02 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v3 3/7] x86/bugs: Exit early if return thunk is already set Message-ID: <20250522-eibrs-fix-v3-3-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the exact same return thunk is already set, avoid the warning and exit early. This is to prepare for ITS to also set CDT return thunk independent of retbleed. Signed-off-by: Pawan Gupta Reviewed-by: Nikolay Borisov --- arch/x86/kernel/cpu/bugs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 94d0de3e61aec32b3b67c8d21f89a8c67b93dff3..354593065025fd7c5727e955d76= 523777b3da9ee 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -113,6 +113,9 @@ void (*x86_return_thunk)(void) __ro_after_init =3D __x8= 6_return_thunk; =20 static void __init set_return_thunk(void *thunk) { + if (thunk =3D=3D x86_return_thunk) + return; + if (x86_return_thunk !=3D __x86_return_thunk) pr_warn("x86/bugs: return thunk changed\n"); =20 --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D6222DCBE9 for ; Fri, 23 May 2025 01:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963282; cv=none; b=XR4nLSzMydBmzC07gARZagWyglty9zWQ1MqMaGxXkAytFj16qRcHI0C++/25m/wNpNxLHbsiyq8mmkPGGYE93lshC0kxNSs+m2zLrmTv8OVdWemBUcidedyaBQ0RykRuNRvC/qultMTzc+J5UrX7pom51DsVF4ifiE5mvYU9PAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963282; c=relaxed/simple; bh=w0txYmP34P0IcuajJSUgB4w0i/NMu0DT6MjHFWhdUzk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fBMaLqyPpgC5GvDn8zv67R/s4UcO5zfBd/hwqBgNTEWG0SgLS1Rv3GlbACcOngHbJygxVB0+PvcF+Zq2lfVc375BHoeDUfWk1ipFpnq8Ok+hdJEzkbaMIQ/ApuCWAiQlVIguDqBXkwn/JGVEK46ztRNJSTy6dwicQw2Kjg1oifs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=APaUqFSp; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="APaUqFSp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963281; x=1779499281; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=w0txYmP34P0IcuajJSUgB4w0i/NMu0DT6MjHFWhdUzk=; b=APaUqFSpzx/Glpq0B7mquk7feioECF7gG7mxk48FrMylaHUGI2X4qLrR 3UIQwJbSAJ2sLFcpj7/f7D2VAfadgbdzDRlIF47QaFotfK80akold/KcA 3phwL4BBPgFuHvs3C4A4+QReKE9G+LjyvsThh4ijXHENWiT0GSx0tyDtH 0g1AX3jIaTZ2A6SpZsyFcoalDne60OSY5xBFYuBWB2c0tUKV3cBuUx1Y7 aE5nYWG5Vhdi53DzzO4iUFn3iLTTEm+hZy1qyh8m8/lzZoJZgOE8lZ+BE sictL/aHI7yljM+NIOgxGPsXv0mC+DGD97fnwkgZuUcQiQWsp5YIJo1bC A==; X-CSE-ConnectionGUID: LGIaqCJ8Ry28BzbzNZl45Q== X-CSE-MsgGUID: DJrNo2iLSUyXgsAgn3eiKg== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="49909114" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="49909114" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:19 -0700 X-CSE-ConnectionGUID: 9aaF8ZtbRQmxvG45wjpyiw== X-CSE-MsgGUID: XijRW6SIRyalFd70vq3rxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="146098429" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:18 -0700 Date: Thu, 22 May 2025 18:21:18 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Nikolay Borisov Subject: [PATCH v3 4/7] x86/its: Use switch/case to apply mitigation Message-ID: <20250522-eibrs-fix-v3-4-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare to apply stuffing mitigation in its_apply_mitigation(). This is currently only done via retbleed mitigation. Also using switch/case makes it evident that mitigation mode like VMEXIT_ONLY doesn't need any special handling. Reviewed-by: Nikolay Borisov Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/bugs.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 354593065025fd7c5727e955d76523777b3da9ee..aa51fa8d6e8c8f7b2f5020fdb2e= 44a274badc0e7 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1472,15 +1472,21 @@ static void __init its_update_mitigation(void) =20 static void __init its_apply_mitigation(void) { + switch (its_mitigation) { + case ITS_MITIGATION_OFF: + case ITS_MITIGATION_AUTO: + case ITS_MITIGATION_VMEXIT_ONLY: /* its=3Dstuff forces retbleed stuffing and is enabled there. */ - if (its_mitigation !=3D ITS_MITIGATION_ALIGNED_THUNKS) - return; - - if (!boot_cpu_has(X86_FEATURE_RETPOLINE)) - setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS); + case ITS_MITIGATION_RETPOLINE_STUFF: + break; + case ITS_MITIGATION_ALIGNED_THUNKS: + if (!boot_cpu_has(X86_FEATURE_RETPOLINE)) + setup_force_cpu_cap(X86_FEATURE_INDIRECT_THUNK_ITS); =20 - setup_force_cpu_cap(X86_FEATURE_RETHUNK); - set_return_thunk(its_return_thunk); + setup_force_cpu_cap(X86_FEATURE_RETHUNK); + set_return_thunk(its_return_thunk); + break; + } } =20 #undef pr_fmt --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 111B82DCBE2 for ; Fri, 23 May 2025 01:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963296; cv=none; b=nl1vFzq3sflMNK+LRXAPu+G28FDNa9PajAvMrbwqhJo3m2P2yOQbyi8wR4GDtAL8pIfMTZ4AT4u1X/ye2v6ZRMzSEQj4htvj7Aer3YrkjQj7P7Kw3QmUq57zMbXoani2Q0U3D6Awn1mn/uT0c3Y+BYB+RY9W0Jv7kR5HTNg1dOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963296; c=relaxed/simple; bh=Qr1RxzvDZ19LZ3ciBesARWFHqbFxDdJf2R9q0eWmNlc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YC1PXv46Qroi0S92iMp2JK4U09WYV4oLOr14ofJCbWQ91vWQmZ4h0q46GFQ0+W++MpVx69GCr3LY+qVbi/HQ0ZfMUPGSuQlN690XcQzRirnu6G7efi8h52DkeFlAE5aAoVxkqKfoeKR9iFGIg+4WAy+TqLla1lJUT5YVBzo2xhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aQWF4Fom; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aQWF4Fom" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963295; x=1779499295; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Qr1RxzvDZ19LZ3ciBesARWFHqbFxDdJf2R9q0eWmNlc=; b=aQWF4FomFA+SavB7p1w84tnST2H5MBO9yrmlxwV/Pd1v+WMns42eWHVV d3Ng0dNUIacgfmGJQmyZAQd3/pVcCSn9qoTcfA0L7BgZSNh0RsbhPP/jv j/wHFblTbAOrpXZJaQp8PPMiFT/XaCl7ffYrVCMZkCA/wYjZT1UVbOXu+ SOnuM8i9cYGCF8JL+n2QVrxixQzJ0ImJISx94a4ta1UI/ZgsxhVf1IB6+ JEeth1MtvM6tV/L6GCs7EDvmFczJGKcZnykfVhkhzZYCBBbV2Jbb8HdMD GxTxDJwA8bjQGD1RkMwrICort1oohlLyV59YLgToVw2GxUdB4c3ji68HJ Q==; X-CSE-ConnectionGUID: Eyw2AFG+RlOxTDrtZR5c+w== X-CSE-MsgGUID: PX+iLUi8TgqIOlQqCJjdOw== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="49909133" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="49909133" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:35 -0700 X-CSE-ConnectionGUID: 8v+zf87cRLu10c+6ueM6Ig== X-CSE-MsgGUID: 0MZRJ404QZ+Om29mhD1wXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="146098487" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:34 -0700 Date: Thu, 22 May 2025 18:21:33 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v3 5/7] x86/retbleed: Introduce cdt_possible() Message-ID: <20250522-eibrs-fix-v3-5-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation to allow ITS to also enable stuffing a.k.a. Call Depth Tracking(CDT) independently of retbleed, introduce a helper cdt_possible(). Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/bugs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index aa51fa8d6e8c8f7b2f5020fdb2e44a274badc0e7..7cf2b6e42b70b665842de5a3a96= e10a356d343c9 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1123,6 +1123,19 @@ early_param("nospectre_v1", nospectre_v1_cmdline); =20 enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =3D SPECTRE_= V2_NONE; =20 +/* Depends on spectre_v2 mitigation selected already */ +static inline bool cdt_possible(enum spectre_v2_mitigation mode) +{ + if (!IS_ENABLED(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) || + !IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)) + return false; + + if (mode =3D=3D SPECTRE_V2_RETPOLINE) + return true; + + return false; +} + #undef pr_fmt #define pr_fmt(fmt) "RETBleed: " fmt =20 @@ -1271,7 +1284,7 @@ static void __init retbleed_update_mitigation(void) retbleed_mitigation =3D RETBLEED_MITIGATION_STUFF; =20 if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_STUFF && - spectre_v2_enabled !=3D SPECTRE_V2_RETPOLINE) { + !cdt_possible(spectre_v2_enabled)) { pr_err("WARNING: retbleed=3Dstuff depends on spectre_v2=3Dretpoline\n"); retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB3602DCBE2 for ; Fri, 23 May 2025 01:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963312; cv=none; b=P2wS0BJx3J50v+PRUP5lpJUP2q7nbujybiGOubOsNoSs/n99vjXW00CjtN81u1wHOkpq7UeXWIlVqvnT6eTSiloykZn+Iblu8iBTeN1+cBRV/vYQv7kZMSBrBZsokHVtSmuvAbx1dSjPtp9R8zYcleB/ZsRoYTANubDKpgfu7Bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963312; c=relaxed/simple; bh=EGNfvm8HxbIrRIgCr3ULkmuxiqPn3f6PmZHSWQ2iTbw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GjtEW6/faEtSJlCj7smCXPDptAoegiQLf0uRq9HJEQAYWfDTdtzdtc28iCMSBGRYqzxJRRLFpTGzegAQ2BTXOY1fVHpGnE+ZuuSNPQFnnKWP/0CUE+sjBSE1i1YVNZ/4YafhFdDgW/3VdHLh66rhMZrXd4IwLoUzOX4S3uR9574= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Xakkota8; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Xakkota8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963311; x=1779499311; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=EGNfvm8HxbIrRIgCr3ULkmuxiqPn3f6PmZHSWQ2iTbw=; b=Xakkota8fIz9YHTvFJefKWrFHv9OejTAjPj0Zje0BaO+i9msXojgXMCp zpViKFZNu5LxhdMxRVJ0ikQkP94W7Yr3FmWRZEvk7BaTCWx415gTHbLjT /U2c34KUaO3DLYWjd3iL69fBGnBWWp4RP3iNBA7mev/Du7Axmf+aqIVfu j3TulF9D9brbw34JRIlfERNE9DvSSrOvOJAfhsVXq1hdcv5hO7HQjN4yy iNN5MEn9lbrsvQrZLmwqb8RzOxE8ahc0Pw0NbM5mDyNN9UrSnvYXZk2rh wScuAmisafZO+bPW7PRe9M1TksAwH/SyPdbc8L1+kEY2Swdf+wzrTuir5 Q==; X-CSE-ConnectionGUID: 5iI/NmwmTIGVhvcVzbFe3Q== X-CSE-MsgGUID: 5Ch/jk3qS8ON7Jj0CfjYFA== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="50123739" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="50123739" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:50 -0700 X-CSE-ConnectionGUID: W3xam50xQjivgT7l4EBC+g== X-CSE-MsgGUID: /Q5shulPSgSai4gkgphz4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="141406504" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:21:50 -0700 Date: Thu, 22 May 2025 18:21:49 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v3 6/7] x86/its: Remove =stuff dependency on retbleed Message-ID: <20250522-eibrs-fix-v3-6-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow ITS to enable stuffing independent of retbleed. The dependency is only on retpoline. It is a valid case for retbleed to be mitigated by eIBRS while ITS deploys stuffing at the same time. Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/bugs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 7cf2b6e42b70b665842de5a3a96e10a356d343c9..3d56e258876234b802b6682050c= 46917a6cf7401 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1471,13 +1471,8 @@ static void __init its_update_mitigation(void) break; } =20 - /* - * retbleed_update_mitigation() will try to do stuffing if its=3Dstuff. - * If it can't, such as if spectre_v2!=3Dretpoline, then fall back to - * aligned thunks. - */ if (its_mitigation =3D=3D ITS_MITIGATION_RETPOLINE_STUFF && - retbleed_mitigation !=3D RETBLEED_MITIGATION_STUFF) + !cdt_possible(spectre_v2_enabled)) its_mitigation =3D ITS_MITIGATION_ALIGNED_THUNKS; =20 pr_info("%s\n", its_strings[its_mitigation]); @@ -1489,8 +1484,6 @@ static void __init its_apply_mitigation(void) case ITS_MITIGATION_OFF: case ITS_MITIGATION_AUTO: case ITS_MITIGATION_VMEXIT_ONLY: - /* its=3Dstuff forces retbleed stuffing and is enabled there. */ - case ITS_MITIGATION_RETPOLINE_STUFF: break; case ITS_MITIGATION_ALIGNED_THUNKS: if (!boot_cpu_has(X86_FEATURE_RETPOLINE)) @@ -1499,6 +1492,11 @@ static void __init its_apply_mitigation(void) setup_force_cpu_cap(X86_FEATURE_RETHUNK); set_return_thunk(its_return_thunk); break; + case ITS_MITIGATION_RETPOLINE_STUFF: + setup_force_cpu_cap(X86_FEATURE_RETHUNK); + setup_force_cpu_cap(X86_FEATURE_CALL_DEPTH); + set_return_thunk(call_depth_return_thunk); + break; } } =20 --=20 2.34.1 From nobody Wed Dec 17 04:17:06 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D3BA2566 for ; Fri, 23 May 2025 01:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963328; cv=none; b=b77gCCCzfuKVIeV/pJSAuvHrsOeNLgmh70q2as1wtbg1hW0Njy4OCsaoLTCzxqUYDZ0fDHANUJI9LA9u0iGKUk80eFOfDJtQOKUa/1RLPWHwS29y+CHu2v6DTT2H7dLNOwu0Q2Y3d12qpQRefxECiMQ78j+Gh3nWcwBuaKLHIoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747963328; c=relaxed/simple; bh=L7bd4x1lk8ZYaiLXLsQwQzFBwF2tkSryqhjycbW/pG0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NF+kyCiaTmXoxV9zwrTdwMIFfHcyY514YmEh+5iZqZwrnmwtsudNIKA/tYa9HvQ9LjJqPWwaqZh5W8hZIB8NJtdO9LDAFL2V3vSO/xzfBSXegs8g8G1wxrJRsFWCOq/3BQknQMT/xOQcfzT6yqGLjFkFO3unYkBbZWL0t63ExoE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KSp2iU7m; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KSp2iU7m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1747963327; x=1779499327; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=L7bd4x1lk8ZYaiLXLsQwQzFBwF2tkSryqhjycbW/pG0=; b=KSp2iU7mdnN9gCCUFhSjjeyVxegX5h/fDrxqgLTErZYGt0KEcE8emec8 7L/ZUq0Gb0+Xb8aEsXbrWPhJawhalnkPARtJOMipeLXF91U4WQlaJbw6o UV0JSFQQP+u5c4UWIgYMmZh76wTdnEquuOY6+ktKjgvdFYqi3CXfpPQWh KPsbgxYp6WDEk19KpvRt+mewn1gnzOjqnvTYw1jQ3IiiRosm7yszyg119 RA8iPfU68wOGY8seKmZ8jdrB/F/5nYfLHu7sIv+v/jDCE0EGs+K/JqHxY PKm9KN6sjW7DT4gaN59Rteb1EnD71nfgbV7awY6EdyKGbLl5zBkTsVIxg Q==; X-CSE-ConnectionGUID: 2gZu63LtQl6UJUFW1gvH3A== X-CSE-MsgGUID: icNYcqhFQSyVf19EHiXFlQ== X-IronPort-AV: E=McAfee;i="6700,10204,11441"; a="50123752" X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="50123752" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:22:05 -0700 X-CSE-ConnectionGUID: cJcvBMzuSMO2yV+2MfDWWA== X-CSE-MsgGUID: BMILx6lxQN+Yyiru/Vcbyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,307,1739865600"; d="scan'208";a="141406536" Received: from lindenmc-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.24]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2025 18:22:06 -0700 Date: Thu, 22 May 2025 18:22:04 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v3 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Message-ID: <20250522-eibrs-fix-v3-7-12704e291e1e@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250522-eibrs-fix-v3-0-12704e291e1e@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After a recent restructuring of ITS mitigation, RSB stuffing can no longer be enabled in eIBRS+Retpoline mode. Before ITS, retbleed mitigation only allowed stuffing when eIBRS was not enabled. This was perfectly fine since eIBRS mitigates retbleed. However, RSB stuffing mitigation for ITS is still needed with eIBRS. The restructuring solely relies on retbleed to deploy stuffing, and does not allow it when eIBRS is enabled. This behavior is different from what was before the restructuring. Fix it by allowing stuffing in eIBRS+retpoline mode also. Fixes: 8c57ca583ebf ("x86/bugs: Restructure ITS mitigation") Closes: https://lore.kernel.org/lkml/20250519235101.2vm6sc5txyoykb2r@desk/ Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/bugs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 3d56e258876234b802b6682050c46917a6cf7401..66c64dc2d14f5584b892286f060= 598595fd67ce0 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1130,7 +1130,8 @@ static inline bool cdt_possible(enum spectre_v2_mitig= ation mode) !IS_ENABLED(CONFIG_MITIGATION_RETPOLINE)) return false; =20 - if (mode =3D=3D SPECTRE_V2_RETPOLINE) + if (mode =3D=3D SPECTRE_V2_RETPOLINE || + mode =3D=3D SPECTRE_V2_EIBRS_RETPOLINE) return true; =20 return false; @@ -1285,7 +1286,7 @@ static void __init retbleed_update_mitigation(void) =20 if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_STUFF && !cdt_possible(spectre_v2_enabled)) { - pr_err("WARNING: retbleed=3Dstuff depends on spectre_v2=3Dretpoline\n"); + pr_err("WARNING: retbleed=3Dstuff depends on retpoline\n"); retbleed_mitigation =3D RETBLEED_MITIGATION_NONE; } =20 @@ -1458,6 +1459,7 @@ static void __init its_update_mitigation(void) its_mitigation =3D ITS_MITIGATION_OFF; break; case SPECTRE_V2_RETPOLINE: + case SPECTRE_V2_EIBRS_RETPOLINE: /* Retpoline+CDT mitigates ITS */ if (retbleed_mitigation =3D=3D RETBLEED_MITIGATION_STUFF) its_mitigation =3D ITS_MITIGATION_RETPOLINE_STUFF; --=20 2.34.1