From nobody Sat Oct 11 04:07:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 180F6221562 for ; Wed, 11 Jun 2025 17:29:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662946; cv=none; b=U6+c6wr/DTJ44OYBURhMWMMlWjiAxwdRXGQuI4Yq/KDq6IK30ZwLSdoymLuedj9MbVaJ2dmQrr1MkQp7x8n/ni3/OHZuJQkj0kRnO4x7JkL8lAmje1NLKEXjbqrOYVeLKcGoQTnkV5psfvLpVW1UAUqHOwEpKrYqyRlFBpWvOtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662946; c=relaxed/simple; bh=7dpv+UFGtwZrM6XSMTUgKpKz4FPWSIEhZU89Ce2+58o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iLVRuf2+OmuN0HRoHQJ/I1XsqVxtVDo0VbTRLH1HbKLwWUvY7E6q5Z9vE5tVyh4fOxMhLHLbIpvAPhJWnJIjr+Be2oD50WDS+Rqf66YcA2X9tkqfjH33ZANMYWPwc9aMY+aMZ7//XSXrQXVfDVLW8hDCTnbjZg/ynssdYcncFzQ= 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=gx62Uz98; arc=none smtp.client-ip=192.198.163.15 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="gx62Uz98" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749662945; x=1781198945; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=7dpv+UFGtwZrM6XSMTUgKpKz4FPWSIEhZU89Ce2+58o=; b=gx62Uz98TJpjx7+8QTUDVZVbvQWkyJEhjfer1hW7DZmRa8wdk3ym51P3 7T60AK/ScS71ULw8mV92Be6DvjYAzRBYnkus2U0e+qkGnlZZHr+xH0Yjy DPS9j4kO+/ByYP2OklSYo5V4JuFny08j0/gtcM6brc2kBLIOsI7awb1vg xOQHO038dIioN5WUWF3XuWmkw5fohHO0whPcsTCetWQGMKUxX6gsK0mWv SqoeK6FhL4ZQ3WkbjiPpfsyfthApEbPU2JZjCGk9mtIiIzIiH1+PkX3By IxKGowlG12gPZWDcKtgWo80kYA1JA5lhJrvff31BDFC0IZSXT0BdJ9GaI w==; X-CSE-ConnectionGUID: YcmQlEwSS3SOJ5oNtX5DFA== X-CSE-MsgGUID: FlGLxF5rTBque8p8Dwlsvw== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="51961454" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="51961454" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:01 -0700 X-CSE-ConnectionGUID: CTV7Qh6cTtqfHk3CXLTqnw== X-CSE-MsgGUID: wuC24KyNTTSrlhpxCNOk/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="147158525" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:01 -0700 Date: Wed, 11 Jun 2025 10:29:00 -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 v4 1/7] x86/retbleed: Avoid AUTO after the select step Message-ID: <20250611-eibrs-fix-v4-1-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 Acked-by: Borislav Petkov (AMD) Signed-off-by: Pawan Gupta --- 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 Sat Oct 11 04:07:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 75AAC2046A6 for ; Wed, 11 Jun 2025 17:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662959; cv=none; b=hKS9+l0kAOfD59XMf/gl0yfijW09nSQSbnMnFtBrnRTVSxZN3OD3r+S7VytWk5wEaxtyMXMpNlRxW3MTQPWslbEDpGQaBXCsaVF5X7AwfyAe782CQdfxBvReih8z9Wb0obxv2FwHUA5z7tuURnYuVO/pUnAk+N/X4dorvMARBOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662959; c=relaxed/simple; bh=yeVFmiZES5grJGugM77Upm7BOodcgl2QIbyrfHzbqKo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rxoYnohEMBULfsAHXM9Y0w68R8fkOo1n4yO1dcKnt/C4ITb44beJNhi/nnvgmGMJYtKyU+UaJdARTiZaoSxnpoLz984G5Z76EfCQWVByUKoVZMeNWxFNyFktVGYwf+2MTgQaVVUkciprfv3iem5LuWX6cIocuUzNZMn5TscLZhE= 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=MUkIB3dX; arc=none smtp.client-ip=192.198.163.12 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="MUkIB3dX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749662957; x=1781198957; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=yeVFmiZES5grJGugM77Upm7BOodcgl2QIbyrfHzbqKo=; b=MUkIB3dXDP6on1DbDgiN7vCEEgFShbnzAgy44hJUuO/Vyz5kh5BnckK0 DAApU+GSHMX/6d1+QpV816UCfjuAuUDUsI2tP2oXXp7BI3wCmtlO27qHR elOPVryzj2oDQqHQWaFfuTXnLePs3kILCq4PAxMqHhLLJ0CpElqHXx8hb qAdLD0othUCQR7z06Jr6uxeqlqQVyqLprWaCp07eNPkQtEcqOHzK9w4Af 1APCjMLWs+nc8vZ+QzpllzUbHccmKWg+LQrSWUbv1x+h9obu6vU+pCY17 fGniCPdseOkf+N2/gkWVv348QhrG8nCznEExE5sWMVvbE2uoVv5LjMNKx Q==; X-CSE-ConnectionGUID: HcfQ4GjgRe64MBMxjdwL4g== X-CSE-MsgGUID: ZG1uGF+dRVGK7cWIV6L6tg== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="55611751" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="55611751" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:16 -0700 X-CSE-ConnectionGUID: bczaPzSDTZmsFf2jiaX/LQ== X-CSE-MsgGUID: Ab1gDdW7Q8CgmUUgtjZ1Ng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="148166463" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:16 -0700 Date: Wed, 11 Jun 2025 10:29:15 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Nikolay Borisov , "Borislav Petkov (AMD)" Subject: [PATCH v4 2/7] x86/retbleed: Simplify the =stuff checks Message-ID: <20250611-eibrs-fix-v4-2-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 Acked-by: Borislav Petkov (AMD) Signed-off-by: Pawan Gupta --- 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 Sat Oct 11 04:07:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 358512046A6 for ; Wed, 11 Jun 2025 17:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662974; cv=none; b=Y3ddPRz5+6ERLyqxOjpxgF0AfasdVuFwmkne+5Nhad/n+h/u8FLOgP+neReJYtQ38gQaskXp739L9tD6oDcVOyFtqvbh5bUYhwjjnOMVx0E0V7F1yXOP1+DibVgDlvjL3EyrUxBl2OFV7E8zYvsjizl0uhy4avPD5Abro7cNdY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662974; c=relaxed/simple; bh=XlirVStJyp27HTjzZL8NXGgIh9P9fk+Fj9BTIVpT8bE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hraA/Jc1n47cuksK+RLjsF3FsV/wh0Vd/16TneM5APeBT4HiUBOJVKjEsqQbggwuKfbccaWwT1XjJnM3z4Jc+W3LRN+7u63xcmMqCosq45lcvaxi5fBxHbMM2yCa8k4GpivpjNXiluXX3nJJb3Ii6PyUmpuqe0nsfPSnBI7Pxtw= 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=WAJTzExi; arc=none smtp.client-ip=192.198.163.12 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="WAJTzExi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749662973; x=1781198973; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=XlirVStJyp27HTjzZL8NXGgIh9P9fk+Fj9BTIVpT8bE=; b=WAJTzExiM1buO38ML1n4+4HPLHtaOTEWxsGJFvFxpCnUBXh0Dy3wFx+t LQaTHa0vN8qyeNZu2CEL3xmxoVnU0cZyLk8fosv7GEPhu9aP7xGe4CoA3 hYKWAGuPbN1P9lU0R56eLiZ8LhztQHH/vGmDIN6b2rMiJkJCrUiy7xCbD 3srHEbtBRWtqZwnNDDd3O8MupmR9b/KS0RADLC7oVVsiXUx0WHwjViam5 rokF+f+55SZ/rGrcNfLguCO27iC7JX20vM/k92EJzF+27M1+F9qiS2Pio FKLOOz0RY/SnDx1uSJ1j/hc65p+UZmiDZaNZcf14CJYw+L8vJHKraufNF g==; X-CSE-ConnectionGUID: oeFdt8VwS36eeq7T1pBirA== X-CSE-MsgGUID: pgHGaEZ6REi457FOew2JDg== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="55611795" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="55611795" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:32 -0700 X-CSE-ConnectionGUID: qHBM9yx+T+64jEmavjwhHA== X-CSE-MsgGUID: JzzYVMnSSKOpVmyqlFd2qA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="148166549" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:32 -0700 Date: Wed, 11 Jun 2025 10:29: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 v4 3/7] x86/bugs: Avoid warning when overriding return thunk Message-ID: <20250611-eibrs-fix-v4-3-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@linux.intel.com> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The purpose of the warning is to prevent an unexpected change to the return thunk mitigation. However, there are legitimate cases where the return thunk is intentionally set more than once. For example, ITS and SRSO both can set the return thunk after retbleed has set it. In both the cases retbleed is still mitigated. Replace the warning with an info about the active return thunk. Suggested-by: Borislav Petkov Signed-off-by: Pawan Gupta --- arch/x86/kernel/cpu/bugs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 94d0de3e61aec32b3b67c8d21f89a8c67b93dff3..20696abd1bef90aaf852fef1299= b93d27c1f4da6 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -113,10 +113,9 @@ void (*x86_return_thunk)(void) __ro_after_init =3D __x= 86_return_thunk; =20 static void __init set_return_thunk(void *thunk) { - if (x86_return_thunk !=3D __x86_return_thunk) - pr_warn("x86/bugs: return thunk changed\n"); - x86_return_thunk =3D thunk; + + pr_info("active return thunk: %ps\n", thunk); } =20 /* Update SPEC_CTRL MSR and its cached copy unconditionally */ --=20 2.34.1 From nobody Sat Oct 11 04:07:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 BE32C221567 for ; Wed, 11 Jun 2025 17:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662990; cv=none; b=GJAxXdZGOKq0l/paQXg+l67Vx5inkyWLYvb8/oxpxGbze1wSRC3KYPivFqHORp/zcaO/LQ+cC0rYTHEsdE/N2ZFXrJgLLfR5VVsXiFYirPNt1rYOMfRMtsv7nFnso66j9LN1HT09hxLC9QLnBcz07DhIHnQOk/vAaQewHb77rgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749662990; c=relaxed/simple; bh=dEpqGjT6bNIiZJ8h4oYLhbc+RWX85PqZvoydqyxIKHQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WKz6Zf1t9STBXpKg0+1vdFLSy04s+Xxr8XR+rQOcvjRuW42rGGaNz4dPR7KPYsDFq7VqbopZuVsIeEiBLm0zA9geoIuWEzttEQCLqWwnHvmH4antEQ0fJQYczn9uYuFH1PDuQMpbV0uvJmCW+2AfS8xp+E35fbRwQumU+AvwoLk= 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=TAhW9bkK; arc=none smtp.client-ip=192.198.163.10 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="TAhW9bkK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749662989; x=1781198989; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=dEpqGjT6bNIiZJ8h4oYLhbc+RWX85PqZvoydqyxIKHQ=; b=TAhW9bkKDFzsfvd4SKLDTStfWXZqYQU3hDV97QRzIewFKVFBJ5JWLKgM yzLSIRTWvkKXdwcexXmYMDERnIP89DDsz7bMMTWRzatXE9/Dn2mMA75Kv 5Cb3ItJfHiPjj7YrMGQPc82aS43DEMm5d3AxoO/z6H+ZfG9pV8AbBw2zt Egn6XTppdAoZ6dX4uvWVqpUZoC/o0HkC/tUVxAblK1qoRpKIrLsDHsHlo HMTQFS04JDqJf2f9Van3ZEQNuBWcYxuQgczhZ4BchcKg4lZItuD6mygvT xtE2fVrgpMq3Zg3igyBDxasvt1CQPIXA49Su4slyhRi3SWPlmCD3pdF1f A==; X-CSE-ConnectionGUID: TU9dA/6AQnmnfV/mUNlX9g== X-CSE-MsgGUID: IZ2PcfnkT+iNBzFOCsxFxg== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="63163269" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="63163269" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:48 -0700 X-CSE-ConnectionGUID: spWk6ZywTUOIkxKul8vKtg== X-CSE-MsgGUID: m4jrAQc6RiOPoWfRj5HZRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="152251776" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:29:48 -0700 Date: Wed, 11 Jun 2025 10:29: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 v4 4/7] x86/its: Use switch/case to apply mitigation Message-ID: <20250611-eibrs-fix-v4-4-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 20696abd1bef90aaf852fef1299b93d27c1f4da6..e861e8884d6b5e16f08d5bda0f4= 7d5056d26c1f4 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1468,15 +1468,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 Sat Oct 11 04:07:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 48923221735 for ; Wed, 11 Jun 2025 17:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663005; cv=none; b=KZ7F+gLTAjc8JtoaRekX4w9wAS3+eVs63GmRVCGyikrVFseBxFI+ndrchJTZXuBavqF6AMj5XvHok20OwJ//gAYIcyKr3hpt7p//dnngVKaPHwmDSVfFjWiHP0U3sOtntz13z3Bxc+Wqlc2tmmnMm05KDrD6PJDMKrY6Pj9Bppc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663005; c=relaxed/simple; bh=yrL5SjkstpuqnV5rjKtSwKY2CB671I1HlxHx9bFwhNE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qnx4lN4GoaMtQf0HawgM+1UCr5UmHKO9aIHDid6FbTDgCoGd+yxrE2MKXNjb4/TJC8zdMYJNeTSJUlbe+RVzWXkiLO0pT6EuLmzoUCs069iw3lCL4sie1gPCkeWz5JWC7ecLDdgvdcC0qC7EoRypyNFdolFKE5R/q67b6F/Y9zQ= 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=PwLEeC5Q; arc=none smtp.client-ip=192.198.163.15 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="PwLEeC5Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749663004; x=1781199004; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=yrL5SjkstpuqnV5rjKtSwKY2CB671I1HlxHx9bFwhNE=; b=PwLEeC5QrLPDnLOZzeGNUomvBWSBKAjo8Q+u4bV4tYrH7Cw7d1edrDJi rtxE8bFpjR8+87SrOoqS6NK9t/OlEkj8jE7SvRJkCkSOFDxq2p8pMSN0b qF+TvcjsBkvInoLc+4QcfE3aZ+sqYOGVo4ZMQGX+E7eE8MzFM/+PVXBG0 5cYslh9cFtEtfO8juabrTQ1+FKDA6xgNaRU9ckTYZmz6ceQ2imSQsUm+g F2a1bnujGu1WRkb3RizIjxsZbHqX9ZSXU0xn2ptTeBS0fNd+3wNh1fmYu fuSqd02qgZ45QhXcxE5ZT1DE/LJWXAp4giG+01wabHUmh4LyxG7cd+AEM A==; X-CSE-ConnectionGUID: 0Hha/zOZRbusfXaFSs7zLQ== X-CSE-MsgGUID: AKlAVs4JSjiM6JBjWHKNpQ== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="51961680" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="51961680" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:04 -0700 X-CSE-ConnectionGUID: +K9KfOo5TQSqe7JOIGURqA== X-CSE-MsgGUID: TyICe5qVSXGE1poGlQjkUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="147140738" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:03 -0700 Date: Wed, 11 Jun 2025 10:30:03 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v4 5/7] x86/retbleed: Introduce cdt_possible() Message-ID: <20250611-eibrs-fix-v4-5-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 e861e8884d6b5e16f08d5bda0f47d5056d26c1f4..387610ad222d4dbd196bfb21914= 5510a37979d73 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1119,6 +1119,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 @@ -1267,7 +1280,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 Sat Oct 11 04:07:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 8859522422F for ; Wed, 11 Jun 2025 17:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663021; cv=none; b=eDnVActeYs2yxxOrtcPTb/ibgq4vHy3ENIhlmHhm+GD+fPAEQri0l8WSSMPT0GTJ1lqpxisRK5BY/SC8M6ExYl+ERJJSvyctbfNBxE9pbFAHfs00jMfy8cUAYKawkKch57B/xCdEH+NPhcNL5BDtvLTZ0KbjYQ+YXvvhcrJmlcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663021; c=relaxed/simple; bh=rhrfi7/7yEe9fGSTl6wltk5sJXQ8B3zVgDESowf09cQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tkO9hkj0AC5mJtOTs4DqVKzYgHWkFHFXV7oOhZiSGHqMDBNfRAbXTqSgbdWvhWqHYOWhMyh42hBQSubvgc4ua3cqKIs9QJfRIQ68RiKMBkuG42RYCknBTz7xNn6JMNT0U7mSAUoI4BZdAktkSlCy+tBKUZltebN1a2X5DMVfTyY= 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=M2/kUrNj; arc=none smtp.client-ip=192.198.163.17 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="M2/kUrNj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749663020; x=1781199020; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=rhrfi7/7yEe9fGSTl6wltk5sJXQ8B3zVgDESowf09cQ=; b=M2/kUrNjGqo7gD6LpdzeMsCarJ/y6u18rHin4ea2GiBRCnjTYsp2a5Zz OYnJQE80dcbOVCXEP26zhiHr4QCYZ0R1dhi6VGFePkOuL8ccuKxoIXXZL gYEaoA93aDHj/lq6/lmiuqPcZaJFH99KnFSRi/Dr900x5AfUGn4ao3S4r 1UhBP0tkHNn/39u8PbZePSebUq/aANWAhkmMjWCU/n2Yd68sVhxFtKZ+X AwcHww9n3f2gc8VCYxjgOxtdJSPHCPPmgub/4cKX6aDbRz4eYdd/vyE58 FjiwpceFW3MIOck+vQHvZiaOK1caMbNZra3GH5ctHFX70LF1Cr/KUPxnp A==; X-CSE-ConnectionGUID: gKnZ1KY6TLGpqaN3VNNuxw== X-CSE-MsgGUID: FxaOLthVTmmHfufY2yicSQ== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="51732970" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="51732970" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:19 -0700 X-CSE-ConnectionGUID: IlChh2tUSaisxD/S1RHj0g== X-CSE-MsgGUID: oJhMY3pdQIeFakoSSYZmCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="178168599" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:19 -0700 Date: Wed, 11 Jun 2025 10:30:18 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v4 6/7] x86/its: Remove =stuff dependency on retbleed Message-ID: <20250611-eibrs-fix-v4-6-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 387610ad222d4dbd196bfb219145510a37979d73..31f3db0a514ea3d6e2513c0f6e0= 72b84e0117f08 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1467,13 +1467,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]); @@ -1485,8 +1480,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)) @@ -1495,6 +1488,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 Sat Oct 11 04:07:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 1EFBB1E25F2 for ; Wed, 11 Jun 2025 17:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663036; cv=none; b=oNbkPjSy1Dr9zA2LuV0dSdqkMfvDYNX3P6cxJwZ5jyxWOwsQuMwI3wnCt4K9PPzJlvqA0fVFEHPnPqZgDNwGjvJgt0ogTDb7o+yFK9NSFBdB1G+QVNV0MbM5De15aKIPMnlBs3461ZDhQy154z9Q1cpcRDYYBPoYpb1eSNv7U98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749663036; c=relaxed/simple; bh=vNRGRinhyFToBiOjC7wbVvh1/gHG9xRZS8Ltocc5jv4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=so3XylmUPosZutboHq/CvWx4BSTHwup+cDB2vpyXgAHclvSleh6EzVyWYG85YVOh4nAWn1xImzmIWZB+cEOjioenRIoiYE2F5s0klcDabK4vIn/df08j9rwwRXLz+o4q+cUJNUF3Z8SbJElbEwkC3230gExWRJyylOac93IkQ2U= 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=cnvC3JY6; arc=none smtp.client-ip=192.198.163.15 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="cnvC3JY6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749663035; x=1781199035; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vNRGRinhyFToBiOjC7wbVvh1/gHG9xRZS8Ltocc5jv4=; b=cnvC3JY68259g/1uaKwF3jjVikr9CBy4YrUZxBTeyI5DsOCUW/qpz5tv dWXBvUbzREj2RUCC2+mUPG6yIUZoQSKOxIiVH2HKr0/dwWyEH2ut6dyRc tzNJ6m50PcQ83/TL977XPM81svYsuof2jXT4dM24FGOj3nEKQSPEOdmS8 Xh9OJt2O4ELKXG5dwsb2PtDEOV47DjGj+EOONpTZtBmshefjWK2uinD9x dLbe/xEqwZtLUl/VzN/3tRUdeq6nmrppMdxJ0I0T8Ny4ZZv2ixQfveYG0 3GUxmaiPVyXrRltbgZK/ipsJfgynDD783Sq8eIHBgQ/cGduD1loBxpe/L g==; X-CSE-ConnectionGUID: YpJHk1oWSZiA/H6eUXa5bQ== X-CSE-MsgGUID: MSa8634XRVit8s660y43sg== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="51961822" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="51961822" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:35 -0700 X-CSE-ConnectionGUID: 9AjrZvgJR6aSO7MjIj5UPQ== X-CSE-MsgGUID: sTQr29vbRCS2PatI7x5bIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="147140881" Received: from chhatrar-mobl.amr.corp.intel.com (HELO desk) ([10.125.146.46]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 10:30:34 -0700 Date: Wed, 11 Jun 2025 10:30:33 -0700 From: Pawan Gupta To: x86@kernel.org Cc: David Kaplan , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Josh Poimboeuf Subject: [PATCH v4 7/7] x86/its: Allow stuffing in eIBRS+retpoline mode also Message-ID: <20250611-eibrs-fix-v4-7-5ff86cac6c61@linux.intel.com> X-Mailer: b4 0.14.2 References: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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: <20250611-eibrs-fix-v4-0-5ff86cac6c61@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 31f3db0a514ea3d6e2513c0f6e072b84e0117f08..bdef2c9aa1b8b85a8e0ee7c959e= a7afde81d443e 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -1126,7 +1126,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; @@ -1281,7 +1282,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 @@ -1454,6 +1455,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