@@ -18,6 +18,7 @@ use guestmem::GuestMemory;
18
18
use guestmem:: GuestMemoryError ;
19
19
use inspect:: Inspect ;
20
20
use std:: borrow:: Cow ;
21
+ use std:: collections:: BTreeMap ;
21
22
use std:: fmt:: Debug ;
22
23
use std:: mem:: size_of;
23
24
use thiserror:: Error ;
@@ -43,6 +44,16 @@ pub const MAX_LOG_BUFFER_SIZE: u32 = 0x400000; // 4MB
43
44
/// Maximum allowed size of a single message
44
45
pub const MAX_MESSAGE_LENGTH : u16 = 0x1000 ; // 4KB
45
46
47
+ // Suppress logs that contain these known error/warning messages.
48
+ // These messages are the result of known issues with our UEFI firmware that do
49
+ // not seem to affect the guest.
50
+ // TODO: Fix UEFI to resolve this errors/warnings
51
+ const SUPPRESS_LOGS : [ & str ; 3 ] = [
52
+ "WARNING: There is mismatch of supported HashMask (0x2 - 0x7) between modules" ,
53
+ "that are linking different HashInstanceLib instances!" ,
54
+ "ConvertPages: failed to find range" ,
55
+ ] ;
56
+
46
57
/// Represents a processed log entry from the EFI diagnostics buffer
47
58
#[ derive( Debug , Clone ) ]
48
59
pub struct EfiDiagnosticsLog < ' a > {
@@ -320,11 +331,7 @@ impl DiagnosticsServices {
320
331
let mut bytes_read: usize = 0 ;
321
332
let mut entries_processed: usize = 0 ;
322
333
323
- // Defines how to handle completed messages
324
- let mut process_complete_log = |log : EfiDiagnosticsLog < ' _ > | {
325
- log_handler ( log) ;
326
- entries_processed += 1 ;
327
- } ;
334
+ let mut suppressed_logs = BTreeMap :: new ( ) ;
328
335
329
336
// Process the buffer slice until all entries are processed
330
337
while !buffer_slice. is_empty ( ) {
@@ -349,13 +356,26 @@ impl DiagnosticsServices {
349
356
350
357
// Handle completed messages (ending with '\n')
351
358
if !entry. message . is_empty ( ) && entry. message . ends_with ( '\n' ) {
352
- process_complete_log ( EfiDiagnosticsLog {
353
- debug_level,
354
- ticks : time_stamp,
355
- phase,
356
- message : accumulated_message. trim_end_matches ( & [ '\r' , '\n' ] [ ..] ) ,
357
- } ) ;
359
+ let mut suppress = false ;
360
+ for log in SUPPRESS_LOGS {
361
+ if accumulated_message. contains ( log) {
362
+ suppressed_logs
363
+ . entry ( log)
364
+ . and_modify ( |c| * c += 1 )
365
+ . or_insert ( 1 ) ;
366
+ suppress = true ;
367
+ }
368
+ }
369
+ if !suppress {
370
+ log_handler ( EfiDiagnosticsLog {
371
+ debug_level,
372
+ ticks : time_stamp,
373
+ phase,
374
+ message : accumulated_message. trim_end_matches ( & [ '\r' , '\n' ] [ ..] ) ,
375
+ } ) ;
376
+ }
358
377
is_accumulating = false ;
378
+ entries_processed += 1 ;
359
379
}
360
380
361
381
// Update bytes read and move to the next entry
@@ -372,12 +392,17 @@ impl DiagnosticsServices {
372
392
373
393
// Process any remaining accumulated message
374
394
if is_accumulating && !accumulated_message. is_empty ( ) {
375
- process_complete_log ( EfiDiagnosticsLog {
395
+ log_handler ( EfiDiagnosticsLog {
376
396
debug_level,
377
397
ticks : time_stamp,
378
398
phase,
379
399
message : accumulated_message. trim_end_matches ( & [ '\r' , '\n' ] [ ..] ) ,
380
400
} ) ;
401
+ entries_processed += 1 ;
402
+ }
403
+
404
+ for ( substring, count) in suppressed_logs {
405
+ tracelimit:: warn_ratelimited!( substring, count, "suppressed logs" )
381
406
}
382
407
383
408
// Print summary statistics
0 commit comments