Re: [PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type

From: Paolo Bonzini
Date: Wed Jun 03 2015 - 03:57:31 EST




On 03/06/2015 04:12, Xiao Guangrong wrote:
>>
>> Perhaps just use type = MIN(type, curr_type), which also happens to get
>> WT vs. WB right? You can also add a
>>
>> BUILD_BUG_ON(MTRR_TYPE_WRTHROUGH > MTRR_TYPE_WRBACK);
>>
>> to ensure that the WT vs. WB precedence is correct.
>
> Only WT and WB are allowed to be overlapped here otherwise is
> "undefined behavior". For example if the types are MTRR_TYPE_WRPROT
> and MTRR_TYPE_WRTHROUGH, min() will get MTRR_TYPE_WRTHROUGH rather than
> "undefined behavior".

Choosing MTRR_TYPE_WRTHROUGH is one example of achieve undefined
behavior. Picking one type arbitrarily is just a different kind of
undefined behavior.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/