tools/libxenguest: Fix max_extd_leaf calculation for legacy restore
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Jul 2021 17:37:57 +0000 (18:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Jul 2021 10:30:14 +0000 (11:30 +0100)
commit5fa174cbf54cc625a023b8e7170e359dd150c072
treeee3ebcac2609af6fb8c82db4c7f9dbc532efc9c9
parent74d044d51b19bb697eac5c3deafa140f6afafec8
tools/libxenguest: Fix max_extd_leaf calculation for legacy restore

0x1c is lower than any value which will actually be observed in
p->extd.max_leaf, but higher than the logical 9 leaves worth of extended data
on Intel systems, causing x86_cpuid_copy_to_buffer() to fail with -ENOBUFS.

Correct the calculation.

The problem was first noticed in c/s 34990446ca9 "libxl: don't ignore the
return value from xc_cpuid_apply_policy" but introduced earlier.

Fixes: 111c8c33a8a1 ("x86/cpuid: do not expand max leaves on restore")
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/libs/guest/xg_cpuid_x86.c