On 05.01.2020 17:47, Wei Liu wrote:
> Hyper-V's input / output argument must be 8 bytes aligned an not cross
> page boundary. The easiest way to satisfy those requirements is to use
> percpu page.

I'm not sure "easiest" is really true here. Others could consider adding
__aligned() attributes as easy or even easier (by being even more
transparent to use sites). Could we settle on "One way ..."?

> @@ -83,14 +84,33 @@ static void __init setup_hypercall_page(void)
>      wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
>  }
>  
> +static void setup_hypercall_pcpu_arg(void)
> +{
> +    void *mapping;
> +
> +    mapping = alloc_xenheap_page();
> +    if ( !mapping )
> +        panic("Failed to allocate hypercall input page for %u\n",

"... for CPU%u\n" please.

> +              smp_processor_id());
> +
> +    this_cpu(hv_pcpu_input_arg) = mapping;

When offlining and then re-onlining a CPU, the prior page will be
leaked.

> --- a/xen/include/asm-x86/guest/hyperv.h
> +++ b/xen/include/asm-x86/guest/hyperv.h
> @@ -51,6 +51,8 @@ static inline uint64_t hv_scale_tsc(uint64_t tsc, uint64_t 
> scale,
>  
>  #ifdef CONFIG_HYPERV_GUEST
>  
> +#include <xen/percpu.h>
> +
>  #include <asm/guest/hypervisor.h>
>  
>  struct ms_hyperv_info {
> @@ -63,6 +65,8 @@ struct ms_hyperv_info {
>  };
>  extern struct ms_hyperv_info ms_hyperv;
>  
> +DECLARE_PER_CPU(void *, hv_pcpu_input_arg);

Will this really be needed outside of the file that defines it?

Also, while looking at this I notice that - despite my earlier
comment when giving the respective, sort-of-conditional ack -
there are (still) many apparently pointless __packed attributes
in hyperv-tlfs.h. Care to comment on this?

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to