RE: [EXTERNAL] Re: [PATCH] x86/Hyper-V: Support for free page reporting

From: Michael Kelley
Date: Fri May 22 2020 - 20:40:38 EST


From: Sunil Muthuswamy <sunilmut@xxxxxxxxxxxxx> Sent: Friday, May 22, 2020 9:40 AM
>
> > > + if (hv_do_hypercall(HV_EXT_CALL_QUERY_CAPABILITIES, NULL, cap) ==
> > > + HV_STATUS_SUCCESS)
> >
> > You're using the input page as the output parameter. Ideally we should
> > introduce hyperv_pcpu_output_arg page, but that would waste one page per
> > cpu just for this one call.
> >
> > So for now I think this setup is fine, but I would like to add the
> > following comment.
> >
> > /*
> > * Repurpose the input_arg page to accept output from Hyper-V for
> > * now because this is the only call that needs output from the
> > * hypervisor. It should be fixed properly by introducing an
> > * output_arg page once we have more places that require output.
> > */
>
> Sounds good. Will add it in v2.
>

Note that the only real requirement for the output parameter to hypercalls
is that it not cross a page boundary. Since '*cap' is only 64-bits, you can
declare it as a static variable or even as a local on the stack. It will
naturally be aligned (or can add __aligned(8) to be explicit??), so it won't
cross a page boundary. Then you can skip using the per-cpu input arg
altogether, along with the associated local_irq_save()/restore().

Michael