RE: [PATCH v3] hyperv: root partition faults writing to VP ASSIST MSR PAGE

From: Sunil Muthuswamy
Date: Tue Jul 27 2021 - 13:23:16 EST


> >> static int hv_cpu_init(unsigned int cpu)
> >> {
> >> + union hv_vp_assist_msr_contents msr;
> >> struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id()];
> >> int ret;
> >>
> >> @@ -54,27 +55,41 @@ static int hv_cpu_init(unsigned int cpu)
> >> if (!hv_vp_assist_page)
> >> return 0;
> >
> > Not related to this code, but I am not sure about the usefulness of this NULL check as
> > we have already accessed this pointer above. If it was NULL, things would already
> > blow up.
> >
> What I understood, hvp will point to "hv_vp_assist_page stack address + smp_processor_id()"
> So, we are good, and this NULL check is required, as in when we de-reference the location, later in the code, it may fault.
> Please do correct me if my understanding is wrong here. Thanks.
>

'hv_vp_assist_page' comes from the heap, there is nothing on the stack there. As I
mentioned previously, if 'hv_vp_assist_page' was NULL, we would have already
crashed by now, as we are accessing it above. So, the check here is useless in my opinion.
But, since this is code that this patch doesn't touch, its fine to leave it as is for this patch.
I was just pointing it out.

- Sunil