diff --git a/Changelog.md b/Changelog.md index 3fd9b68c..7f5aa202 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ OpenCore Changelog - Fixed regression for ACPI quirks `RebaseRegions` and `SyncTableIds` - Updated build process to provide stable and bleeding-edge versions of `EnableGop` - Implemented minor improvements in `PickerMode` `Apple` +- Improved filtering algorithm for `LogModules` option #### v0.9.1 - Fixed long comment printing for ACPI patches, thx @corpnewt diff --git a/Docs/Configuration.md5 b/Docs/Configuration.md5 index eeda2f2e..93cfc93a 100644 --- a/Docs/Configuration.md5 +++ b/Docs/Configuration.md5 @@ -1 +1 @@ -bb8e83abb7655428a8fb6fc902cc0373 +97c56a093dd641371080fd3594c39713 diff --git a/Docs/Configuration.pdf b/Docs/Configuration.pdf index faa5ddfb..7e122d4f 100644 Binary files a/Docs/Configuration.pdf and b/Docs/Configuration.pdf differ diff --git a/Docs/Configuration.tex b/Docs/Configuration.tex index dbbfeec6..425f2d4a 100755 --- a/Docs/Configuration.tex +++ b/Docs/Configuration.tex @@ -3889,6 +3889,9 @@ cat Kernel.panic | grep macOSProcessedStackshotData | \emph{Note 2}: Messages printed before the configuration of log protocol cannot be filtered. + \emph{Note 3}: To avoid missing key issues, warning and error log messages + are not filtered. + \item \texttt{SysReport}\\ \textbf{Type}: \texttt{plist\ boolean}\\ diff --git a/Docs/Differences/Differences.pdf b/Docs/Differences/Differences.pdf index 15b0fefa..97b455f0 100644 Binary files a/Docs/Differences/Differences.pdf and b/Docs/Differences/Differences.pdf differ diff --git a/Docs/Differences/Differences.tex b/Docs/Differences/Differences.tex index e1d9a054..8fb96e57 100644 --- a/Docs/Differences/Differences.tex +++ b/Docs/Differences/Differences.tex @@ -1,7 +1,7 @@ \documentclass[]{article} %DIF LATEXDIFF DIFFERENCE FILE -%DIF DEL PreviousConfiguration.tex Wed Apr 5 14:22:58 2023 -%DIF ADD ../Configuration.tex Sat May 6 18:57:47 2023 +%DIF DEL PreviousConfiguration.tex Fri May 5 21:18:04 2023 +%DIF ADD ../Configuration.tex Sun May 7 11:45:23 2023 \usepackage{lmodern} \usepackage{amssymb,amsmath} @@ -3960,7 +3960,11 @@ cat Kernel.panic | grep macOSProcessedStackshotData | \emph{Note 2}: Messages printed before the configuration of log protocol cannot be filtered. -\item + \DIFaddbegin \emph{\DIFadd{Note 3}}\DIFadd{: To avoid missing key issues, warning and error log messages + are not filtered. +} + +\DIFaddend \item \texttt{SysReport}\\ \textbf{Type}: \texttt{plist\ boolean}\\ \textbf{Failsafe}: \texttt{false}\\ diff --git a/Docs/Errata/Errata.pdf b/Docs/Errata/Errata.pdf index 5ea47e43..b4cd9a5d 100644 Binary files a/Docs/Errata/Errata.pdf and b/Docs/Errata/Errata.pdf differ diff --git a/Library/OcLogAggregatorLib/OcLog.c b/Library/OcLogAggregatorLib/OcLog.c index dad3ab2c..e92637ee 100644 --- a/Library/OcLogAggregatorLib/OcLog.c +++ b/Library/OcLogAggregatorLib/OcLog.c @@ -143,59 +143,67 @@ GetLogPath ( STATIC EFI_STATUS GetLogPrefix ( - IN CONST CHAR8 *FormatString, + IN CONST CHAR8 *FormattedString, OUT CHAR8 *Prefix ) { - UINTN MaxLength; - UINTN Index; - CHAR8 Curr; + UINTN Pos; + CHAR8 Char; - ASSERT (FormatString != NULL); + ASSERT (FormattedString != NULL); ASSERT (Prefix != NULL); - // - // If FormatString just starts with colon, it must be illegal. - // - if (*FormatString == ':') { - return EFI_NOT_FOUND; - } + Pos = 0; + while (TRUE) { + Char = FormattedString[Pos]; - MaxLength = MIN (AsciiStrLen (FormatString), OC_LOG_PREFIX_CHAR_MAX); - for (Index = 1; Index < MaxLength; ++Index) { - Curr = FormatString[Index]; + // + // If we reached end of string, then ':' was not found. + // + if (Char == '\0') { + return EFI_NOT_FOUND; + } // // Match the first occurrence of colon. // - if (Curr == ':') { + if (Char == ':') { + // + // If log string starts with colon, it must be illegal. + // + if (Pos == 0) { + return EFI_NOT_FOUND; + } + break; } + // + // If size of prefix would exceed OC_LOG_PREFIX_CHAR_MAX, then not found. + // + if (Pos == OC_LOG_PREFIX_CHAR_MAX) { + return EFI_NOT_FOUND; + } + // // Except for colon, a valid prefix must be either 0-9, or uppercase letter. // - if (!(IsAsciiNumber (Curr) || ((Curr >= 'A') && (Curr <= 'Z')))) { + if (!(IsAsciiNumber (Char) || ((Char >= 'A') && (Char <= 'Z')))) { return EFI_NOT_FOUND; } + + ++Pos; } - // - // If Index went through the end, then ':' was not found. - // - if (Index == MaxLength) { - return EFI_NOT_FOUND; - } - - CopyMem (Prefix, FormatString, Index); - Prefix[Index] = '\0'; + CopyMem (Prefix, FormattedString, Pos); + Prefix[Pos] = '\0'; return EFI_SUCCESS; } STATIC BOOLEAN IsPrefixFiltered ( - IN CONST CHAR8 *FormatString, + IN CONST CHAR8 *FormattedString, IN CONST OC_FLEX_ARRAY *FlexFilters OPTIONAL, IN BOOLEAN BlacklistFiltering ) @@ -205,16 +213,16 @@ IsPrefixFiltered ( EFI_STATUS Status; CHAR8 **Value; - ASSERT (FormatString != NULL); + ASSERT (FormattedString != NULL); // - // Do not filter without filters, of course. + // Do not filter without filters. // if (FlexFilters == NULL) { return FALSE; } - Status = GetLogPrefix (FormatString, Prefix); + Status = GetLogPrefix (FormattedString, Prefix); if (EFI_ERROR (Status)) { return FALSE; } @@ -225,14 +233,16 @@ IsPrefixFiltered ( if (AsciiStrCmp (Prefix, *Value) == 0) { // - // Upon matching, return TRUE (i.e. not to print logs) - // if blacklisted. + // Upon matching, return TRUE (i.e. not to print logs) if blacklisted. // return BlacklistFiltering; } } - return FALSE; + // + // Otherwise return default, depending on positive or negative filtering. + // + return !BlacklistFiltering; } STATIC @@ -241,6 +251,8 @@ InternalLogAddEntry ( IN OC_LOG_PRIVATE_DATA *Private, IN OC_LOG_PROTOCOL *OcLog, IN UINTN ErrorLevel, + IN CONST OC_FLEX_ARRAY *FlexFilters OPTIONAL, + IN BOOLEAN BlacklistFiltering, IN CONST CHAR8 *FormatString, IN VA_LIST Marker ) @@ -263,6 +275,15 @@ InternalLogAddEntry ( Marker ); + // + // Filter log after formatting string. Always log at WARN and ERROR level. + // + if ( ((ErrorLevel & (DEBUG_WARN | DEBUG_ERROR)) == 0) + && IsPrefixFiltered (Private->LineBuffer, Private->FlexFilters, Private->BlacklistFiltering)) + { + return EFI_SUCCESS; + } + // // Add Entry. // @@ -480,7 +501,6 @@ OcLogAddEntry ( { EFI_STATUS Status; OC_LOG_PRIVATE_DATA *Private; - BOOLEAN IsFiltered; ASSERT (OcLog != NULL); ASSERT (FormatString != NULL); @@ -494,14 +514,7 @@ OcLogAddEntry ( return EFI_SUCCESS; } - // - // Filter log. - // - Status = EFI_SUCCESS; - IsFiltered = IsPrefixFiltered (FormatString, Private->FlexFilters, Private->BlacklistFiltering); - if (!IsFiltered) { - Status = InternalLogAddEntry (Private, OcLog, ErrorLevel, FormatString, Marker); - } + Status = InternalLogAddEntry (Private, OcLog, ErrorLevel, Private->FlexFilters, Private->BlacklistFiltering, FormatString, Marker); if ( ((ErrorLevel & OcLog->HaltLevel) != 0) && (AsciiStrnCmp (FormatString, "\nASSERT_RETURN_ERROR", L_STR_LEN ("\nASSERT_RETURN_ERROR")) != 0)