From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ming.shao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 BFA5F21D2BF03 for ; Mon, 22 Jan 2018 01:08:19 -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 orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 01:13:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,396,1511856000"; d="scan'208";a="23620783" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 22 Jan 2018 01:13:44 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 01:13:44 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 01:13:44 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Mon, 22 Jan 2018 17:13:42 +0800 From: "Shao, Ming" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Shao, Ming" Thread-Topic: [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API Thread-Index: AQHTkCOOkrhc6znzY0C9DlXZfBF+JqN/okFg Date: Mon, 22 Jan 2018 09:13:41 +0000 Message-ID: <0D32B2537B667F42AD320D616D521AF738A402DC@shsmsx102.ccr.corp.intel.com> References: <20180118061359.351852-1-ruiyu.ni@intel.com> In-Reply-To: <20180118061359.351852-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjc1NGNlODYtMjMzOC00ODc4LWFmMzItZGZhNjEzOWJlYWZiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ6MGdhU1wvRzVcL2IzWWZhRG5jXC9rbHEyUzE2Z3Z0Y2JFR3lmaWhzWG5HbUlvUzRXY3k1M3g1VWpFbm1RM2pEdFBcLyJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch-set API 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: Mon, 22 Jan 2018 09:08:20 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by Shao Ming -Ming -----Original Message----- From: Ni, Ruiyu=20 Sent: Thursday, January 18, 2018 2:14 PM To: edk2-devel@lists.01.org Cc: Shao, Ming Subject: [PATCH] UefiCpuPkg/MtrrLib: Add comments to recommend to use batch= -set API MtrrSetMemoryAttributesInMtrrSettings() is a batch-set API. When setting multiple ranges of memory attributes, the single-set API (Mtrr= SetMemoryAttributeInMtrrSettings and MtrrSetMemoryAttribute) may fail, but = batch-set API may succeed. Add comments to recommend caller to use batch-set API when setting multiple= ranges. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Ming Shao --- UefiCpuPkg/Include/Library/MtrrLib.h | 10 ++++++++++ UefiCpuPkg/Library/M= trrLib/MtrrLib.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/UefiCpuPkg/Include/Library/MtrrLib.h b/UefiCpuPkg/Include/Libr= ary/MtrrLib.h index d56f1057e1..f82c27ea0c 100644 --- a/UefiCpuPkg/Include/Library/MtrrLib.h +++ b/UefiCpuPkg/Include/Library/MtrrLib.h @@ -157,6 +157,11 @@ GetFirmwareVariableMtrrCount ( @retval RETURN_OUT_OF_RESOURCES There are not enough system resources = to modify the attributes of the memory resource range. + Multiple memory range attributes setti= ng by calling this API multiple + times may fail with status RETURN_OUT_= OF_RESOURCES. It may not mean + the number of CPU MTRRs are too small = to set such memory attributes. + Pass the multiple memory range attribu= tes to one call of + MtrrSetMemoryAttributesInMtrrSettings(= ) may succeed. @retval RETURN_BUFFER_TOO_SMALL The fixed internal scratch buffer is t= oo small for MTRR calculation. Caller should use MtrrSetMemoryAttribu= tesInMtrrSettings() to specify external scratch buffer. @@ -354,6 +359,11 @@ MtrrGetDefaultMemoryType ( BaseAddress and Length cannot be modif= ied. @retval RETURN_OUT_OF_RESOURCES There are not enough system resources = to modify the attributes of the memory resource range. + Multiple memory range attributes setti= ng by calling this API multiple + times may fail with status RETURN_OUT_= OF_RESOURCES. It may not mean + the number of CPU MTRRs are too small = to set such memory attributes. + Pass the multiple memory range attribu= tes to one call of + MtrrSetMemoryAttributesInMtrrSettings(= ) may succeed. @retval RETURN_BUFFER_TOO_SMALL The fixed internal scratch buffer is t= oo small for MTRR calculation. Caller should use MtrrSetMemoryAttribu= tesInMtrrSettings() to specify external scratch buffer. diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index 2496d08ad4..dfce9a996b 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -2513,6 +2513,11 @@ Exit: BaseAddress and Length cannot be modif= ied. @retval RETURN_OUT_OF_RESOURCES There are not enough system resources = to modify the attributes of the memory resource range. + Multiple memory range attributes setti= ng by calling this API multiple + times may fail with status RETURN_OUT_= OF_RESOURCES. It may not mean + the number of CPU MTRRs are too small = to set such memory attributes. + Pass the multiple memory range attribu= tes to one call of + MtrrSetMemoryAttributesInMtrrSettings(= ) may succeed. @retval RETURN_BUFFER_TOO_SMALL The fixed internal scratch buffer is t= oo small for MTRR calculation. Caller should use MtrrSetMemoryAttribu= tesInMtrrSettings() to specify external scratch buffer. @@ -2561,6 +2566,11 @@ MtrrSetMemoryAttributeInMtrrSettings ( @retval RETURN_OUT_OF_RESOURCES There are not enough system resources = to modify the attributes of the memory resource range. + Multiple memory range attributes setti= ng by calling this API multiple + times may fail with status RETURN_OUT_= OF_RESOURCES. It may not mean + the number of CPU MTRRs are too small = to set such memory attributes. + Pass the multiple memory range attribu= tes to one call of + MtrrSetMemoryAttributesInMtrrSettings(= ) may succeed. @retval RETURN_BUFFER_TOO_SMALL The fixed internal scratch buffer is t= oo small for MTRR calculation. Caller should use MtrrSetMemoryAttribu= tesInMtrrSettings() to specify external scratch buffer. -- 2.15.1.windows.2