From patchwork Wed Sep 2 09:17:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 7110171 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AA7799F32B for ; Wed, 2 Sep 2015 09:23:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D71E1205DB for ; Wed, 2 Sep 2015 09:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F35492042B for ; Wed, 2 Sep 2015 09:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753106AbbIBJX2 (ORCPT ); Wed, 2 Sep 2015 05:23:28 -0400 Received: from mga03.intel.com ([134.134.136.65]:35050 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbbIBJX0 (ORCPT ); Wed, 2 Sep 2015 05:23:26 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 02 Sep 2015 02:23:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,452,1437462000"; d="scan'208";a="636963544" Received: from xiao.sh.intel.com ([10.239.159.86]) by orsmga003.jf.intel.com with ESMTP; 02 Sep 2015 02:23:25 -0700 Subject: Re: commit 3c2e7f7de3 (KVM use NPT page attributes) causes boot failures To: Markus Trippelsdorf References: <20150901070856.GA430@x4> <20150901072741.GB20383@gmail.com> <20150901074449.GB430@x4> <20150901083856.GD25398@gmail.com> <20150901084444.GB421@x4> <20150901085627.GF6315@gmail.com> <20150901100417.GA424@x4> <55E5A157.5040403@linux.intel.com> <20150901135636.GA423@x4> <55E6273D.6080701@linux.intel.com> <20150902035040.GA420@x4> Cc: Ingo Molnar , Linus Torvalds , linux-kernel@vger.kernel.org, Peter Zijlstra , Thomas Gleixner , Andrew Morton , Mike Galbraith , Joerg Roedel , Paolo Bonzini , kvm@vger.kernel.org From: Xiao Guangrong Message-ID: <55E6BEB1.6080106@linux.intel.com> Date: Wed, 2 Sep 2015 17:17:37 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150902035040.GA420@x4> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 09/02/2015 11:50 AM, Markus Trippelsdorf wrote: > On 2015.09.02 at 06:31 +0800, Xiao Guangrong wrote: >> >> >> On 09/01/2015 09:56 PM, Markus Trippelsdorf wrote: >>> On 2015.09.01 at 21:00 +0800, Xiao Guangrong wrote: >>>> >>>> Did it trigger the BUG()/BUG_ON() in mtrr2protval()/fallback_mtrr_type()? >>>> If yes, could you please print the actual value out? >>> >>> It is the BUG() in fallback_mtrr_type(). I changed it to a printk and >>> it prints 1 for the value of mtrr. >>> >>> MTRR_TYPE_WRCOMB 1 >>> >> >> Then I suspect pat is not enabled in your box, could you please check >> CONFIG_X86_PAT is selected in your .config file, pat is shown in >> /proc/cpuid, "nopat" kernel parameter is used, and dmesg | grep PAT. > > No. PAT is of course enabled and booting is successful sometimes even > with the BUG() in allback_mtrr_type(). I suspect a setup (timing) issue. Thanks for your confirmation. > > markus@x4 linux % cat .config | grep X86_PAT > CONFIG_X86_PAT=y > markus@x4 linux % dmesg | grep PAT > [ 0.000000] x86/PAT: Configuration [0-7]: WB WC UC- UC WB WC UC- WT Strange, BP processor has already set WC to PAT1, however KVM does not read it out from PAT MSR on its local CPU. Hmm... PAT default values do not include WC, it seems initing PAT on SP has not finished after module_init()? Could please apply this diff and test it again? } --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 189e464..d9d3a30 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -884,6 +884,7 @@ static u8 fallback_mtrr_type(int mtrr) case MTRR_TYPE_WRPROT: return MTRR_TYPE_UC_MINUS; default: + printk("BUG in %s, mtrr = %d.\n", __FUNCTION__, mtrr); BUG(); } } @@ -907,6 +908,8 @@ static void build_mtrr2protval(void) * guest. */ rdmsrl(MSR_IA32_CR_PAT, pat); + printk("KVM PAT: 0x%llx.\n", pat); + for (i = 0; i < 8; i++) { u8 mtrr = pat >> (8 * i); @@ -914,10 +917,17 @@ static void build_mtrr2protval(void) mtrr2protval[mtrr] = __cm_idx2pte(i); } + for (i = 0; i < 8; i++) + printk("mtrr2protval[%d]:%x.\n", i, mtrr2protval[i]); + + for (i = 0; i < 8; i++) { if (mtrr2protval[i] == MTRR2PROTVAL_INVALID) { u8 fallback = fallback_mtrr_type(i); mtrr2protval[i] = mtrr2protval[fallback]; + if (mtrr2protval[i] == MTRR2PROTVAL_INVALID) + printk("BUG in %s, mtrr2protval[%d] = %x.\n", __FUNCTION__, i, mtrr2protval[i]); + BUG_ON(mtrr2protval[i] == MTRR2PROTVAL_INVALID); }