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.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 DDEBC21B02822 for ; Wed, 21 Nov 2018 16:57:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2018 16:57:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,263,1539673200"; d="scan'208";a="88273741" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 21 Nov 2018 16:57:05 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 21 Nov 2018 16:57:05 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 21 Nov 2018 16:57:04 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.84]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.199]) with mapi id 14.03.0415.000; Thu, 22 Nov 2018 08:57:03 +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+RYA Date: Thu, 22 Nov 2018 00:57:02 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB048310401F4088@shsmsx102.ccr.corp.intel.com> References: <20181121152906.11967-1-vijayenthiran.subramaniam@arm.com> In-Reply-To: <20181121152906.11967-1-vijayenthiran.subramaniam@arm.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: Thu, 22 Nov 2018 00:57:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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