Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbbFCH51 (ORCPT ); Wed, 3 Jun 2015 03:57:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32783 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752610AbbFCH5V (ORCPT ); Wed, 3 Jun 2015 03:57:21 -0400 Message-ID: <556EB35C.6040601@redhat.com> Date: Wed, 03 Jun 2015 09:57:16 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Xiao Guangrong CC: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type References: <1432983566-15773-1-git-send-email-guangrong.xiao@linux.intel.com> <1432983566-15773-8-git-send-email-guangrong.xiao@linux.intel.com> <556C22FC.50505@redhat.com> <556E6270.2060701@linux.intel.com> In-Reply-To: <556E6270.2060701@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 926 Lines: 26 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/