tools/libx[cl]: Move processing loop down into xc_cpuid_set()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 12 Jun 2020 13:07:10 +0000 (14:07 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 17 Jun 2020 12:54:12 +0000 (13:54 +0100)
commit585c7f4317987b4e92a381d6178be238be4c9653
tree42b9d5cf49ced4254deb46e47c8199fc6aa1830c
parentc22ced93e167f56104111fcc414298c0cd2db3e9
tools/libx[cl]: Move processing loop down into xc_cpuid_set()

Currently, libxl__cpuid_legacy() passes each element of the policy list to
xc_cpuid_set() individually.  This is wasteful both in terms of the number of
hypercalls made, and the quantity of repeated merging/auditing work performed
by Xen.

Move the loop processing down into xc_cpuid_set(), which allows us to do one
set of hypercalls, rather than one per list entry.

In xc_cpuid_set(), obtain the full host, guest max and current policies to
begin with, and loop over the xend array, processing one leaf at a time.
Replace the linear search with a binary search, seeing as the serialised
leaves are sorted.

No change in behaviour from the guests point of view.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Paul Durrant <paul@xen.org>
tools/libxc/xc_cpuid_x86.c
tools/libxl/libxl_cpuid.c