From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=vijayenthiran.subramaniam@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 21DD921962301 for ; Wed, 21 Nov 2018 07:29:23 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D8A7331A; Wed, 21 Nov 2018 07:29:23 -0800 (PST) Received: from usa.arm.com (a074939-lin.blr.arm.com [10.162.0.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 413F03F5CF; Wed, 21 Nov 2018 07:29:21 -0800 (PST) From: Vijayenthiran Subramaniam To: edk2-devel@lists.01.org, star.zeng@intel.com, jian.j.wang@intel.com, ruiyu.ni@intel.com Cc: Vijayenthiran Subramaniam Date: Wed, 21 Nov 2018 20:59:06 +0530 Message-Id: <20181121152906.11967-1-vijayenthiran.subramaniam@arm.com> X-Mailer: git-send-email 2.17.1 Subject: [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: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 X-List-Received-Date: Wed, 21 Nov 2018 15:29:24 -0000 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 --- Thanks for the review. I have made changes based on Laszlo's and Star's suggestions. - Vijayenthiran MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/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) != 0) { if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxAuthVariableSize - 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) != 0) { if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxVariableSize - 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->MaxVolatileVariableSize - 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