Messages in this thread |  | | Date | Wed, 03 Jun 2015 09:57:16 +0200 | From | Paolo Bonzini <> | Subject | Re: [PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type |
| |
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
|  |