Re: [PATCH 2/3] x86/bugs: Add a separate config for missing mitigation

From: Pawan Gupta
Date: Tue Jan 23 2024 - 19:07:14 EST


On Tue, Jan 23, 2024 at 07:05:47AM -0800, Breno Leitao wrote:
> On Mon, Jan 22, 2024 at 12:58:21PM -0800, Pawan Gupta wrote:
> > On Thu, Jan 18, 2024 at 09:32:12AM -0800, Breno Leitao wrote:
> > > +config MITIGATION_RETBLEED
> > > + bool "Mitigate RETBleed hardware bug"
> > > + depends on CPU_SUP_INTEL || (CPU_SUP_AMD && MITIGATION_UNRET_ENTRY)
> >
> > Atleast on Intel CPUs, Retbleed mitigation is meaningless without
> > spectre-v2 being mitigated, shouldn't this depend on MITIGATION_SPECTRE_V2?
>
> I suppose it is the same for AMD, right?

AMD's retbleed problem and mitigation is a bit different, it has to do
with Branch Type Confusion(BTC). I am not sure if it is possible to
mitigate it without spectre-v2 mitigation. Someone from AMD should be
able to clarify. Looking at the code it appears the dependency is on
CONFIG_CPU_UNRET_ENTRY or CONFIG_CPU_IBPB_ENTRY being set:

retbleed_select_mitigation()
{
..
case RETBLEED_CMD_AUTO:
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY))
retbleed_mitigation = RETBLEED_MITIGATION_UNRET;
else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY) && boot_cpu_has(X86_FEATURE_IBPB))
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
}

> So, I suppose it should be something as:
>
> depends on (MITIGATION_SPECTRE_V2 && (CPU_SUP_INTEL || (CPU_SUP_AMD && MITIGATION_UNRET_ENTRY))
>
> Is this better?
>
> Thanks!