From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E67221F30404 for ; Thu, 28 Sep 2017 23:01:32 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP; 28 Sep 2017 23:04:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,451,1500966000"; d="scan'208";a="133464508" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 28 Sep 2017 23:04:47 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 28 Sep 2017 23:04:47 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 28 Sep 2017 23:04:47 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Fri, 29 Sep 2017 14:04:45 +0800 From: "Zeng, Star" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Fix assert issue on IA32 platform Thread-Index: AQHTOOWEOnIAagbB0kapjk7lQhDV06LLX8Aw Date: Fri, 29 Sep 2017 06:04:44 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B97CD2D@shsmsx102.ccr.corp.intel.com> References: <20170929054014.6136-1-jian.j.wang@intel.com> In-Reply-To: <20170929054014.6136-1-jian.j.wang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/CpuDxe: Fix assert issue on IA32 platform X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Sep 2017 06:01:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jian= J Wang Sent: Friday, September 29, 2017 1:40 PM To: edk2-devel@lists.01.org Cc: Kinney, Michael D ; Yao, Jiewen Subject: [edk2] [PATCH] UefiCpuPkg/CpuDxe: Fix assert issue on IA32 platfor= m This patch is to fix an assert issue during booting IA32 platforms such as = OvmfIa32 or Quark. This issue is caused by trying to access page table on a= platform without page table. A check is added to avoid the assert. Bug tracker: https://bugzilla.tianocore.org/show_bug.cgi?id=3D724 c: Star Zeng Cc: Jiewen Yao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- UefiCpuPkg/CpuDxe/CpuDxe.c | 48 ++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index = 4e8fa100e0..85a520079f 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -683,7 +683,7 @@ SetGcdMemorySpaceAttributes ( =20 **/ VOID -RefreshGcdMemoryAttributes ( +RefreshMemoryAttributesFromMtrr ( VOID ) { @@ -704,14 +704,9 @@ RefreshGcdMemoryAttributes ( UINT32 FirmwareVariableMtrrCount; UINT8 DefaultMemoryType; =20 - if (!IsMtrrSupported ()) { - return; - } - FirmwareVariableMtrrCount =3D GetFirmwareVariableMtrrCount (); ASSERT (FirmwareVariableMtrrCount <=3D MTRR_NUMBER_OF_VARIABLE_MTRR); =20 - mIsFlushingGCD =3D TRUE; MemorySpaceMap =3D NULL; =20 // @@ -862,11 +857,44 @@ RefreshGcdMemoryAttributes ( if (MemorySpaceMap !=3D NULL) { FreePool (MemorySpaceMap); } +} =20 - // - // Update page attributes - // - RefreshGcdMemoryAttributesFromPaging(); +/** + Check if paging is enabled or not. +**/ +BOOLEAN +IsPagingSupported ( + VOID + ) +{ + return ( + (AsmReadCr0 () & BIT31) !=3D 0 + && + (AsmReadCr4 () & BIT5) !=3D 0 + ); +} + +/** + Refreshes the GCD Memory Space attributes according to MTRRs and Paging. + + This function refreshes the GCD Memory Space attributes according to=20 + MTRRs and page tables. + +**/ +VOID +RefreshGcdMemoryAttributes ( + VOID + ) +{ + mIsFlushingGCD =3D TRUE; + + if (IsMtrrSupported ()) { + RefreshMemoryAttributesFromMtrr (); } + + if (IsPagingSupported ()) { + RefreshGcdMemoryAttributesFromPaging (); } =20 mIsFlushingGCD =3D FALSE; } -- 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel