[RFC PATCH v2 3/3] KVM: arm64: Enable errata based on migration target CPUs
Oliver Upton
oliver.upton at linux.dev
Tue Oct 29 21:33:26 PDT 2024
Hey Shameer,
On Mon, Oct 28, 2024 at 05:29:14PM +0000, Shameerali Kolothum Thodi wrote:
> > I don't know if you saw my suggestion on v1 [*], but it'd be great if we
> > can hide the array of implementations from users of is_midr_in_range()
> > and friends.
>
> I did see your suggestion but my bad, misunderstood it and thought that you are
> referring to _midr_range() functions in cpu_errata.c only.
Ah, no worries. And yeah, for this to be a general solution we're going
to need to cover all our bases where MIDR checks are used.
> > There's other junk keyed off MIDR (e.g. Spectre) that also needs to be
> > aware of all the implementations where the VM might run. The easiest way
> > to do that is to stop using a caller-provided MIDR and have
> > is_midr_in_range() either walk the array of implementations or read
> > MIDR_EL1.
>
> So the suggestion is to use something like this?
>
> bool is_midr_in_range(struct midr_range const *range)
> {
> int i;
>
> for (i = 0; i < errata_migrn_target_num; i++) {
> if (midr_is_cpu_model_range(errata_migrn_target_cpus[i].midr,
> range->model,
> range->rv_min, range->rv_max))
> return true;
> }
>
> return midr_is_cpu_model_range(read_cpuid_id(), range->model,
> range->rv_min, range->rv_max);
> }
Yep, pretty much like that. Except that the guest should either use the
values from the hypercall *or* the value of MIDR_EL1, not both.
> Or do we need some kind of hint to these functions to specify which
> MIDR to use? I think there are at least couple of places where it looks like
> it make sense to do the checking against MIDR_EL1 only.
> (eg: has_neoverse_n1_erratum_1542419().
I don't think we need a hint or anything. The fact that the hypervisor
is exposing this hypercall interface indicates the MIDR of the
implementation the vCPU currently runs on is subject to change.
So the concept of a per-CPU erratum is completely out of the window, and
every CPU is subject to the errata of every implementation advertised by
the hypervisor.
--
Thanks,
Oliver
More information about the linux-arm-kernel
mailing list