Re: [PATCH 3/3] x86/Viridian: fold duplicate vpset retrieval code

2021-11-18 Thread Durrant, Paul

On 18/11/2021 13:14, Jan Beulich wrote:

hvcall_{flush,ipi}_ex() use more almost identical code than what was
isolated into hv_vpset_to_vpmask(). Move that code there as well, to
have just one instance of it. This way all of HV_GENERIC_SET_SPARSE_4K
processing now happens in a single place.

Signed-off-by: Jan Beulich 


Reviewed-by: Paul Durrant 



Re: [PATCH 3/3] x86/Viridian: fold duplicate vpset retrieval code

2021-11-18 Thread Andrew Cooper
On 18/11/2021 13:14, Jan Beulich wrote:
> --- a/xen/arch/x86/hvm/viridian/viridian.c
> +++ b/xen/arch/x86/hvm/viridian/viridian.c
> @@ -643,6 +647,18 @@ static int hv_vpset_to_vpmask(const stru
>  {
>  uint64_t bank_mask;
>  unsigned int vp, bank = 0;
> +size_t size = sizeof(*set->bank_contents) * hv_vpset_nr_banks(set);
> +
> +if ( offsetof(typeof(*vpset), set.bank_contents[0]) + size >
> + sizeof(*vpset) )
> +{
> +ASSERT_UNREACHABLE();
> +return -EINVAL;
> +}
> +
> +if ( hvm_copy_from_guest_phys(>bank_contents, bank_gpa,
> +  size) != HVMTRANS_okay)

Minor style issue - closing bracket.  I see it was a preexisting issue
from the old code.

~Andrew