[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 22/27] x86/cpuid: Perform max_leaf calculations in guest_cpuid()



>>> On 05.01.17 at 16:02, <andrew.cooper3@xxxxxxxxxx> wrote:
> On 05/01/17 14:52, Jan Beulich wrote:
>>>>> On 05.01.17 at 15:28, <andrew.cooper3@xxxxxxxxxx> wrote:
>>> What else would you suggest?  One way or another (better shown in the
>>> context of the following patch), we need one block per union{} to apply
>>> max_leaf calculations and read the base data from p->$FOO.raw[$IDX].
>> Actually, perhaps a mixture: Inside the default case have
>>
>>     if ( leaf == 0x7 )
>>     {
>>         if ( subleaf > p->feat.max_subleaf )
>>             return;
>>     }
>>     else if ( leaf == 0xd)
>>     {
>>         if ( subleaf > ARRAY_SIZE(p->xstate.raw) )
>>             return;
>>     }
>>     if ( leaf > p->basic.max_leaf )
>>         return;
>>
>> Which (by making the last one if rather than else-if) also fixes an
>> issue I've spotted only now: So far you exclude leaves 7 and 0xd
>> from the basic.max_leaf checking. (And this way that check could
>> also go first.)
> 
> Very good point, although I still think I'd still prefer a logic block
> in this form inside a case 0 ... 0x3fffffff to avoid potential leakage
> if other logic changes.

Well, that's certainly fine with me.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.