Re: [PATCH V4 12/15] x86/hyper-v: Add HvFlushGuestAddressList hypercall support

From: Paolo Bonzini
Date: Mon Oct 15 2018 - 06:30:19 EST


On 13/10/2018 16:54, lantianyu1986@xxxxxxxxx wrote:
>
> +static int fill_flush_list(union hv_gpa_page_range gpa_list[],
> + int offset, u64 start_gfn, u64 pages)

Pass the entire struct hv_guest_mapping_flush_list to this function,
it's simpler and it hides the gpa_list argument from
range->parse_flush_list_func.

> + if (!range->flush_list)
> + gpa_n = fill_flush_list(flush->gpa_list, gpa_n,
> + range->start_gfn, range->pages);
> + else if (range->parse_flush_list_func)
> + gpa_n = range->parse_flush_list_func(flush->gpa_list, gpa_n,
> + range->flush_list, fill_flush_list);
> + else

You are making the code more complicated in order to avoid making
fill_flush_list public. Just make it public and always go through the
parse_flush_list_func case. In fact:

- make parse_flush_list_func an argument of hyperv_flush_guest_mapping_range

- drop struct hyperv_tlb_range completely, instead just pass a void* to
hyperv_flush_guest_mapping_range and pass it back to the callback. The
void * can point to the start_gfn/pages pair, it can be the flush_list,
or anything else.

Paolo