Re: [Xen-devel] [PATCH v3 09/11] x86/xen: use capabilities instead of fake cpuid values for xsave
From: Juergen Gross
Date: Tue Apr 18 2017 - 07:57:02 EST
On 18/04/17 12:02, Andrew Cooper wrote:
> On 18/04/17 07:31, Juergen Gross wrote:
>> @@ -281,22 +274,24 @@ static bool __init xen_check_mwait(void)
>> return false;
>> #endif
>> }
>> -static void __init xen_init_cpuid_mask(void)
>> +
>> +static bool __init xen_check_xsave(void)
>> {
>> - unsigned int ax, bx, cx, dx;
>> - unsigned int xsave_mask;
>> + unsigned int err, eax, edx;
>>
>> - ax = 1;
>> - cx = 0;
>> - cpuid(1, &ax, &bx, &cx, &dx);
>> + /* Test OSXSAVE capability via xgetbv instruction. */
>
> The code is fine, but this comment isn't going to be any help to people
> reading this code in 6 months time.
>
> How about this:
>
> "Xen 4.0 and older accidentally leaked the host XSAVE flag into guest
> view, despite not being able to support guests using the functionality.
> Probe for the actual availability of XSAVE by seeing whether xgetbv
> executes successfully or raises #UD."
I'll update the comment.
> Everything else is fine, so Reviewed-by: Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>
Thanks,
Juergen