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

Re: [Xen-devel] [PATCH v6 09/10] x86/hvm: Add SMAP support to HVM guest



>>> On 07.05.14 at 12:46, <andrew.cooper3@xxxxxxxxxx> wrote:
> On 07/05/14 09:19, Feng Wu wrote:
>> @@ -360,13 +362,26 @@ static inline bool_t hvm_vcpu_has_smep(void)
>>  
>>      hvm_cpuid(0, &eax, NULL, NULL, NULL);
>>  
>> -    if (eax < 7)
>> +    if ( eax < 7 )
>>          return 0;
>>  
>>      hvm_cpuid(7, NULL, &ebx, NULL, NULL);
>>      return !!(ebx & cpufeat_mask(X86_FEATURE_SMEP));
>>  }
>>  
>> +static inline bool_t hvm_vcpu_has_smap(void)
>> +{
>> +    unsigned int eax, ebx;
>> +
>> +    hvm_cpuid(0, &eax, NULL, NULL, NULL);
>> +
>> +    if ( eax < 7 )
>> +        return 0;
>> +
>> +    hvm_cpuid(0x7, NULL, &ebx, NULL, NULL);
> 
> I have just noticed a bug here and in hvm_vcpu_have_smep().  CPUID.0x7
> takes a count of 0 for the feature leaf.  You should not rely on the
> default value of dummy inside hvm_cpuid() for this call to work
> correctly, so need to explicitly pass ecx.

While I'm fine with this being made more explicit, I don't think it's a bug
(not even a latent one) to rely on the default sub-leaf being zero.

Jan


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


 


Rackspace

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