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.93; helo=mga11.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 D6D2A21A07A82 for ; Tue, 20 Nov 2018 17:47:45 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2018 17:47:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,259,1539673200"; d="scan'208";a="282850706" Received: from shzintpr04.sh.intel.com (HELO [10.253.24.20]) ([10.239.4.101]) by fmsmga006.fm.intel.com with ESMTP; 20 Nov 2018 17:47:43 -0800 To: Laszlo Ersek , Vijayenthiran Subramaniam , edk2-devel@lists.01.org, jian.j.wang@intel.com, ruiyu.ni@intel.com References: <20181120103805.18637-1-vijayenthiran.subramaniam@arm.com> From: "Zeng, Star" Cc: star.zeng@intel.com Message-ID: Date: Wed, 21 Nov 2018 09:47:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Subject: Re: [PATCH] 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: Wed, 21 Nov 2018 01:47:46 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 2018/11/20 19:17, Laszlo Ersek wrote: > On 11/20/18 11:38, Vijayenthiran Subramaniam wrote: >> Print debug messages if size of the VariableName plus DataSize exceeds >> Max(Auth|Voltaile)VariableSize bytes. The messages will be useful if any >> platform 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 >> --- >> MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> index 8e8db71bd201..db54fa4412c0 100644 >> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >> @@ -3234,14 +3234,20 @@ VariableServiceSetVariable ( >> // >> if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) { >> if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ()) { >> + DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds MaxAuthVariableSize.\n", >> + __FUNCTION__, VariableName)); >> return EFI_INVALID_PARAMETER; >> } >> } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) { >> if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ()) { >> + DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds MaxVariableSize.\n", >> + __FUNCTION__, VariableName)); >> return EFI_INVALID_PARAMETER; >> } >> } else { >> if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ()) { >> + DEBUG ((DEBUG_ERROR, "%a: Size of (%s) variable + DataSize exceeds MaxVolatileVariableSize.\n", >> + __FUNCTION__, VariableName)); >> return EFI_INVALID_PARAMETER; >> } >> } >> > > You could make this more useful as well -- again, *if* the package > maintainers agree with the new log messages --; namely, the vendor GUID, > DataSize, and the limit in question should / could all be logged. I agree to add these debug messages. I also think Laszlo's suggestion is good. So, how about having the debug message like below? DEBUG (( DEBUG_ERROR, "%a: %s:%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 () )); Thanks, Star > > Thanks > Laszlo >