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=ruiyu.ni@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 46F6521F833B9 for ; Mon, 8 Jan 2018 19:30:47 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 19:35:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,334,1511856000"; d="scan'208";a="19407613" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 19:35:56 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Eric Dong , Star Zeng Date: Tue, 9 Jan 2018 11:35:51 +0800 Message-Id: <20180109033552.378192-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180109033552.378192-1-ruiyu.ni@intel.com> References: <20180109033552.378192-1-ruiyu.ni@intel.com> Subject: [PATCH 3/4] UefiCpuPkg/MtrrLib: Handle one setting request covering all memory X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 03:30:47 -0000 *SetMemoryAttribute*() API cannot handle the setting request that looks like <0, MAX_ADDRESS, Type>. The buggy parameter checking logic returns Unsupported for this case. The patch fixes the checking logic to handle such case. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Eric Dong Cc: Star Zeng --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index 566a4cb67b..54f703606b 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -2270,8 +2270,13 @@ MtrrSetMemoryAttributesInMtrrSettings ( goto Exit; } if (((Ranges[Index].BaseAddress & ~MtrrValidAddressMask) != 0) || - ((Ranges[Index].Length & ~MtrrValidAddressMask) != 0) + ((((Ranges[Index].BaseAddress + Ranges[Index].Length) & ~MtrrValidAddressMask) != 0) && + (Ranges[Index].BaseAddress + Ranges[Index].Length) != MtrrValidBitsMask + 1) ) { + // + // Either the BaseAddress or the Limit doesn't follow the alignment requirement. + // Note: It's still valid if Limit doesn't follow the alignment requirement but equals to MAX Address. + // Status = RETURN_UNSUPPORTED; goto Exit; } -- 2.15.1.windows.2