Re: [PATCH v2] x86/bugs: Restructure ITS mitigation

From: Ingo Molnar
Date: Sat May 17 2025 - 09:20:00 EST



* Dave Hansen <dave.hansen@xxxxxxxxx> wrote:

> On 5/16/25 12:32, David Kaplan wrote:
> > Restructure the ITS mitigation to use select/update/apply functions like
> > the other mitigations.
> >
> > There is a particularly complex interaction between ITS and Retbleed as CDT
> > (Call Depth Tracking) is a mitigation for both, and either its=stuff or
> > retbleed=stuff will attempt to enable CDT.
> >
> > retbleed_update_mitigation() runs first and will check the necessary
> > pre-conditions for CDT if either ITS or Retbleed stuffing is selected. If
> > checks pass and ITS stuffing is selected, it will select stuffing for
> > Retbleed as well.
> >
> > its_update_mitigation() runs after and will either select stuffing if
> > retbleed stuffing was enabled, or fall back to the default (aligned thunks)
> > if stuffing could not be enabled.
> >
> > Enablement of CDT is done exclusively in retbleed_apply_mitigation().
> > its_apply_mitigation() is only used to enable aligned thunks.
>
> This seems to be explaining what is going on, but there isn't a clear
> problem that this is fixing.
>
> Why does this need restructuring?

All other mitigations have the following methods:

static void __init bhi_select_mitigation(void);
static void __init bhi_update_mitigation(void);
static void __init bhi_apply_mitigation(void);

(The _update() method is optional.)

Except the freshly added ITS mitigation breaks this pattern, which has
all this functionality in a single function:

static void __init its_select_mitigation(void);

David's patch refactors the recently added ITS code to follow the
existing pattern of all the other mitigation methods:

static void __init its_select_mitigation(void);
static void __init its_update_mitigation(void);
static void __init its_apply_mitigation(void);

This makes it easier to read if you know the other mitigations already,
and makes it easier to maintain going forward.

Thanks,

Ingo