From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, cheptsov@ispras.ru
Subject: Re: [edk2-devel] [PATCH V4 26/27] MdePkg: Introduce assertion on constraint debug mask bit
Date: Mon, 11 May 2020 22:58:45 +0200 [thread overview]
Message-ID: <e303dc2b-2521-0e14-6065-d558aa418e57@redhat.com> (raw)
In-Reply-To: <20200511154121.3878-27-cheptsov@ispras.ru>
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.
>
> Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
> ---
> 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.<BR>
> # BIT4 - Enable BreakPoint as ASSERT.<BR>
> # BIT5 - Enable DeadLoop as ASSERT.<BR>
> + # BIT6 - Treat constrait violations as ASSERT.<BR>
> # @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.<BR><BR>
> # BIT0 - Initialization message.<BR>
>
(2) The "MdePkg/MdePkg.uni" file update from patch#1 belongs here, IMO.
Otherwise, the patch looks OK to me.
Thanks
Laszlo
next prev parent reply other threads:[~2020-05-11 20:58 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 15:40 [PATCH V4 00/27] Disabling safe string constraint assertions Vitaly Cheptsov
2020-05-11 15:40 ` [PATCH V4 01/27] MdePkg: Introduce DebugCommonLib interface and BaseDebugCommonLib Vitaly Cheptsov
2020-05-11 20:37 ` [edk2-devel] " Laszlo Ersek
2020-05-11 20:42 ` Laszlo Ersek
2020-05-11 15:40 ` [PATCH V4 02/27] UnitTestFrameworkPkg: Add support for DebugCommonLib Vitaly Cheptsov
2020-05-11 15:40 ` [PATCH V4 03/27] MdePkg: " Vitaly Cheptsov
2020-05-11 15:40 ` [PATCH V4 04/27] MdeModulePkg: " Vitaly Cheptsov
2020-05-11 15:40 ` [PATCH V4 05/27] ArmPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 06/27] ArmPlatformPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 07/27] ArmVirtPkg: " Vitaly Cheptsov
2020-05-11 20:42 ` [edk2-devel] " Laszlo Ersek
2020-05-11 15:41 ` [PATCH V4 08/27] CryptoPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 09/27] DynamicTablesPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 10/27] EmbeddedPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 11/27] EmulatorPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 12/27] FatPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 13/27] FmpDevicePkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 14/27] IntelFsp2Pkg: " Vitaly Cheptsov
2020-05-12 0:49 ` [edk2-devel] " Chiu, Chasel
2020-05-11 15:41 ` [PATCH V4 15/27] IntelFsp2WrapperPkg: " Vitaly Cheptsov
2020-05-12 0:47 ` [edk2-devel] " Chiu, Chasel
2020-05-11 15:41 ` [PATCH V4 16/27] OvmfPkg: " Vitaly Cheptsov
2020-05-11 20:49 ` [edk2-devel] " Laszlo Ersek
2020-05-11 15:41 ` [PATCH V4 17/27] NetworkPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 18/27] ShellPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 19/27] SecurityPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 20/27] PcAtChipsetPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 21/27] SignedCapsulePkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 22/27] SourceLevelDebugPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 23/27] StandaloneMmPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 24/27] UefiCpuPkg: " Vitaly Cheptsov
2020-05-11 20:52 ` [edk2-devel] " Laszlo Ersek
2020-05-11 15:41 ` [PATCH V4 25/27] UefiPayloadPkg: " Vitaly Cheptsov
2020-05-11 15:41 ` [PATCH V4 26/27] MdePkg: Introduce assertion on constraint debug mask bit Vitaly Cheptsov
2020-05-11 20:58 ` Laszlo Ersek [this message]
2020-05-11 22:12 ` [edk2-devel] " Laszlo Ersek
2020-05-11 15:41 ` [PATCH V4 27/27] MdePkg: Use assertion on constraint violation bit in SafeString Vitaly Cheptsov
2020-05-11 21:04 ` [edk2-devel] " Laszlo Ersek
2020-05-11 22:40 ` [PATCH V4 00/27] Disabling safe string constraint assertions Michael D Kinney
2020-05-12 9:50 ` Laszlo Ersek
2020-05-12 17:03 ` Vitaly Cheptsov
2020-05-12 18:18 ` [edk2-devel] " Michael D Kinney
2020-05-12 18:57 ` Vitaly Cheptsov
2020-05-13 17:59 ` Liming Gao
2020-05-13 18:37 ` Vitaly Cheptsov
2020-05-13 9:16 ` Laszlo Ersek
2020-05-13 14:41 ` [EXTERNAL] " Bret Barkelew
2020-05-13 20:14 ` Brian J. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e303dc2b-2521-0e14-6065-d558aa418e57@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox