[RFC PATCH v2 3/3] KVM: arm64: Enable errata based on migration target CPUs

Shameerali Kolothum Thodi shameerali.kolothum.thodi at huawei.com
Mon Oct 28 10:29:14 PDT 2024



> -----Original Message-----
> From: Oliver Upton <oliver.upton at linux.dev>
> Sent: Friday, October 25, 2024 2:37 AM
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi at huawei.com>
> Cc: kvmarm at lists.linux.dev; maz at kernel.org; catalin.marinas at arm.com;
> will at kernel.org; mark.rutland at arm.com; cohuck at redhat.com;
> eric.auger at redhat.com; yuzenghui <yuzenghui at huawei.com>; Wangzhou
> (B) <wangzhou1 at hisilicon.com>; jiangkunkun <jiangkunkun at huawei.com>;
> Jonathan Cameron <jonathan.cameron at huawei.com>; Anthony Jebson
> <anthony.jebson at huawei.com>; linux-arm-kernel at lists.infradead.org;
> Linuxarm <linuxarm at huawei.com>
> Subject: Re: [RFC PATCH v2 3/3] KVM: arm64: Enable errata based on
> migration target CPUs
> 
> nitpick: shortlog shouldn't use a KVM prefix if the patch isn't touching
> KVM.
> 
> On Thu, Oct 24, 2024 at 10:40:12AM +0100, Shameer Kolothum wrote:
> > If the Guest has migration target CPUs set, enable all errata
> > that are based on target MIDR/REVIDR.
> >
> > Also make sure we call the paravirt helper to retrieve migration
> > targets if any.
> >
> > Signed-off-by: Shameer Kolothum
> <shameerali.kolothum.thodi at huawei.com>
> 
> 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.
 
> 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);
}

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().

Thanks,
Shameer



More information about the linux-arm-kernel mailing list