From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web11.2962.1589235192644822920 for ; Mon, 11 May 2020 15:13:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RQfS41XT; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589235191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FhhQsercHYUIU1+D4RA6K3Z6ha3kfDqDYji+e1C0HC4=; b=RQfS41XTafyYWrJ6MerJ+jyghgrui6PUpqAgee761kiyoZiDueiKDT7YUg8jx6P/kENFp6 jfawNrtFyUVCWPQR1429XurLpnuVIbVQmFyrhWjS4kYoqrz0BV3w85cZzi1iugRZWM76F2 MIcJnTl+X48lnux5A9mlrqWamDTeF0k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-504-SLAnRaL3OnmSuTKc76O9kA-1; Mon, 11 May 2020 18:12:58 -0400 X-MC-Unique: SLAnRaL3OnmSuTKc76O9kA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D590100A614; Mon, 11 May 2020 22:12:57 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-11.ams2.redhat.com [10.36.113.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id A01FE38E; Mon, 11 May 2020 22:12:56 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH V4 26/27] MdePkg: Introduce assertion on constraint debug mask bit From: "Laszlo Ersek" To: devel@edk2.groups.io, cheptsov@ispras.ru References: <20200511154121.3878-1-cheptsov@ispras.ru> <20200511154121.3878-27-cheptsov@ispras.ru> Message-ID: <363c9bd0-b139-af7f-3c5d-65e494650591@redhat.com> Date: Tue, 12 May 2020 00:12:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 05/11/20 22:58, Laszlo Ersek wrote: > On 05/11/20 17:41, Vitaly Cheptsov wrote: >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054 >> >> This bit allows to control assertion on constrain violation. (1) Ugh, sorry, my point (1) was going to be about out two instances of the same typo: s/constrain/constraint/ in (a) the commit message, and (b) in the ASSERT_CONSTRAINT macro's documentation, below. Thanks & sorry for the mixup Laszlo >> >> Signed-off-by: Vitaly Cheptsov >> --- >> MdePkg/Include/Library/DebugCommonLib.h | 18 ++++++++++++++++++ >> MdePkg/Include/Library/DebugLib.h | 18 ++++++++++++++++++ >> MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c | 20 ++++++++++++++++++++ >> MdePkg/MdePkg.dec | 3 ++- >> 4 files changed, 58 insertions(+), 1 deletion(-) >> >> diff --git a/MdePkg/Include/Library/DebugCommonLib.h b/MdePkg/Include/Library/DebugCommonLib.h >> index 31249f91fa..3dc906d02a 100644 >> --- a/MdePkg/Include/Library/DebugCommonLib.h >> +++ b/MdePkg/Include/Library/DebugCommonLib.h >> @@ -21,6 +21,7 @@ >> #define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08 >> #define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10 >> #define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20 >> +#define DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED 0x40 >> >> // >> // Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint() >> @@ -135,6 +136,23 @@ DebugClearMemoryEnabled ( >> ); >> >> >> +/** >> + Returns TRUE if ASSERT_CONSTRAINT() macro is enabled. >> + >> + This function returns TRUE if the DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of >> + PcdDebugProperyMask is set. Otherwise, FALSE is returned. >> + >> + @retval TRUE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask is set. >> + @retval FALSE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask is clear. >> + >> +**/ >> +BOOLEAN >> +EFIAPI >> +DebugAssertConstraintEnabled ( >> + VOID >> + ); >> + >> + >> /** >> Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel. >> >> diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h >> index a38e0e2904..ea38522ae3 100644 >> --- a/MdePkg/Include/Library/DebugLib.h >> +++ b/MdePkg/Include/Library/DebugLib.h >> @@ -212,6 +212,24 @@ DebugClearMemory ( >> #define ASSERT(Expression) >> #endif >> >> + >> +/** >> + Macro that calls ASSERT when constrain assertions are enabled. >> + >> + If DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask is set, >> + then this macro evaluates to an ASSERT macro passing in the original Expression. >> + >> + @param Expression Boolean expression. >> + >> +**/ >> +#define ASSERT_CONSTRAINT(Expression) \ >> + do { \ >> + if (DebugAssertConstraintEnabled ()) { \ >> + ASSERT (Expression); \ >> + } \ >> + } while (FALSE) >> + >> + >> /** >> Macro that calls DebugPrint(). >> >> diff --git a/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c b/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c >> index 2291fb5382..870f9ceec5 100644 >> --- a/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c >> +++ b/MdePkg/Library/BaseDebugCommonLib/DebugCommonLib.c >> @@ -93,6 +93,26 @@ DebugClearMemoryEnabled ( >> } >> >> >> +/** >> + Returns TRUE if ASSERT_CONSTRAINT() macro is enabled. >> + >> + This function returns TRUE if the DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of >> + PcdDebugProperyMask is set. Otherwise, FALSE is returned. >> + >> + @retval TRUE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask is set. >> + @retval FALSE The DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED bit of PcdDebugProperyMask is clear. >> + >> +**/ >> +BOOLEAN >> +EFIAPI >> +DebugAssertConstraintEnabled ( >> + VOID >> + ) >> +{ >> + return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_CONSTRAINT_ENABLED) != 0); >> +} >> + >> + >> /** >> Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel. >> >> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec >> index a121b9ecab..63003357d6 100644 >> --- a/MdePkg/MdePkg.dec >> +++ b/MdePkg/MdePkg.dec >> @@ -2136,9 +2136,10 @@ [PcdsFixedAtBuild,PcdsPatchableInModule] >> # BIT3 - Enable Clear Memory.
>> # BIT4 - Enable BreakPoint as ASSERT.
>> # BIT5 - Enable DeadLoop as ASSERT.
>> + # BIT6 - Treat constrait violations as ASSERT.
>> # @Prompt Debug Property. >> # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0 >> - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005 >> + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000045 >> >> ## This flag is used to control the print out Debug message.

>> # BIT0 - Initialization message.
>> > > (2) The "MdePkg/MdePkg.uni" file update from patch#1 belongs here, IMO. > > Otherwise, the patch looks OK to me. > > Thanks > Laszlo >