Re: [PATCH v2 06/17] x86/hyperv: allocate output arg pages if required

From: Wei Liu
Date: Fri Nov 13 2020 - 10:05:50 EST


On Thu, Nov 12, 2020 at 04:35:48PM +0100, Vitaly Kuznetsov wrote:
> Wei Liu <wei.liu@xxxxxxxxxx> writes:
[...]
> > @@ -209,14 +219,23 @@ static int hv_cpu_die(unsigned int cpu)
> > unsigned int new_cpu;
> > unsigned long flags;
> > void **input_arg;
> > - void *input_pg = NULL;
> > + void *pg;
> >
> > local_irq_save(flags);
> > input_arg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg);
> > - input_pg = *input_arg;
> > + pg = *input_arg;
> > *input_arg = NULL;
> > +
> > + if (hv_root_partition) {
> > + void **output_arg;
> > +
> > + output_arg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg);
> > + *output_arg = NULL;
> > + }
> > +
> > local_irq_restore(flags);
> > - free_page((unsigned long)input_pg);
> > +
> > + free_page((unsigned long)pg);
> >
>
> Hm, but in case we've allocated output_arg, don't we need to do
> free_pages((unsigned long)pg, 1);
>
> instead?

Indeed. This has been fixed with:

free_pages((unsigned long)pg, hv_root_partition ? 1 : 0);

Wei.