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.136; helo=mga12.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 86A202119488A for ; Thu, 22 Nov 2018 17:56:08 -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 fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2018 17:56:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,268,1539673200"; d="scan'208";a="108588283" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 22 Nov 2018 17:56:07 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 22 Nov 2018 17:56:07 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 22 Nov 2018 17:56:07 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.84]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.161]) with mapi id 14.03.0415.000; Fri, 23 Nov 2018 09:56:05 +0800 From: "Zeng, Star" To: Vijayenthiran Subramaniam , "edk2-devel@lists.01.org" , "Wang, Jian J" , "Ni, Ruiyu" CC: "Zeng, Star" Thread-Topic: [PATCH v2] MdeModulePkg/Variable: add debug logs in VariableServiceSetVariable Thread-Index: AQHUga8BTT11I+LQa0y0LTrUC+f2JKVa+RYAgAGi2QA= Date: Fri, 23 Nov 2018 01:56:04 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB048310401F4589@shsmsx102.ccr.corp.intel.com> References: <20181121152906.11967-1-vijayenthiran.subramaniam@arm.com> <0C09AFA07DD0434D9E2A0C6AEB048310401F4088@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB048310401F4088@shsmsx102.ccr.corp.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 v2] MdeModulePkg/Variable: add debug logs in VariableServiceSetVariable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2018 01:56:08 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Pushed at a90c7df7edeec375edee99bc9b116406543b9959. Thanks, Star -----Original Message----- From: Zeng, Star=20 Sent: Thursday, November 22, 2018 8:57 AM To: Vijayenthiran Subramaniam ; edk2-dev= el@lists.01.org; Wang, Jian J ; Ni, Ruiyu Cc: Zeng, Star Subject: RE: [PATCH v2] MdeModulePkg/Variable: add debug logs in VariableSe= rviceSetVariable Reviewed-by: Star Zeng -----Original Message----- From: Vijayenthiran Subramaniam [mailto:vijayenthiran.subramaniam@arm.com]= =20 Sent: Wednesday, November 21, 2018 11:29 PM To: edk2-devel@lists.01.org; Zeng, Star ; Wang, Jian J= ; Ni, Ruiyu Cc: Vijayenthiran Subramaniam Subject: [PATCH v2] MdeModulePkg/Variable: add debug logs in VariableServic= eSetVariable Print debug messages if size of the VariableName plus DataSize exceeds Max(= Auth|Voltaile)VariableSize bytes. The messages will be useful if any platfo= rm specific value of Max(Auth|Voltaile)VariableSize PCDs have to be changed= . Cc: Star Zeng Cc: Jian J Wang Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Vijayenthiran Subramaniam --- Thanks for the review. I have made changes based on Laszlo's and Star's sug= gestions. - Vijayenthiran MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 30 +++++++++++++++= +++++ 1 file changed, 30 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index 8e8db71bd201..d100b1dcc552 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -3234,14 +3234,44 @@ VariableServiceSetVariable ( // if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) !=3D 0) { if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->Ma= xAuthVariableSize - GetVariableHeaderSize ()) { + DEBUG ((DEBUG_ERROR, + "%a: Failed to set variable '%s' with Guid %g\n", + __FUNCTION__, VariableName, VendorGuid)); + DEBUG ((DEBUG_ERROR, + "NameSize(0x%x) + PayloadSize(0x%x) > " + "MaxAuthVariableSize(0x%x) - HeaderSize(0x%x)\n", + StrSize (VariableName), PayloadSize, + mVariableModuleGlobal->MaxAuthVariableSize, + GetVariableHeaderSize () + )); return EFI_INVALID_PARAMETER; } } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) !=3D 0) { if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->Ma= xVariableSize - GetVariableHeaderSize ()) { + DEBUG ((DEBUG_ERROR, + "%a: Failed to set variable '%s' with Guid %g\n", + __FUNCTION__, VariableName, VendorGuid)); + DEBUG ((DEBUG_ERROR, + "NameSize(0x%x) + PayloadSize(0x%x) > " + "MaxVariableSize(0x%x) - HeaderSize(0x%x)\n", + StrSize (VariableName), PayloadSize, + mVariableModuleGlobal->MaxVariableSize, + GetVariableHeaderSize () + )); return EFI_INVALID_PARAMETER; } } else { if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->Ma= xVolatileVariableSize - GetVariableHeaderSize ()) { + DEBUG ((DEBUG_ERROR, + "%a: Failed to set variable '%s' with Guid %g\n", + __FUNCTION__, VariableName, VendorGuid)); + DEBUG ((DEBUG_ERROR, + "NameSize(0x%x) + PayloadSize(0x%x) > " + "MaxVolatileVariableSize(0x%x) - HeaderSize(0x%x)\n", + StrSize (VariableName), PayloadSize, + mVariableModuleGlobal->MaxVolatileVariableSize, + GetVariableHeaderSize () + )); return EFI_INVALID_PARAMETER; } } -- 2.17.1