From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-9102.amazon.com (smtp-fw-9102.amazon.com [207.171.184.29]) by mx.groups.io with SMTP id smtpd.web10.3204.1653619428709136930 for ; Thu, 26 May 2022 19:43:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=giU9dpOo; spf=pass (domain: amazon.de, ip: 207.171.184.29, mailfrom: prvs=139655964=graf@amazon.de) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1653619429; x=1685155429; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=JEmB9h9SInW4tt6N2lA5EuYSOTGjly9VBL5QfarCb8g=; b=giU9dpOotS6DJRqsTaX1c+h07DDahR3ROi3zwPAHAFNbxH6m3OUYm1lA w2UTGR2qDSotouYEwTm7V4eUiMPWsmFeAX3S0uqX9Olijfl3kQJYiLMRE bFwlW1/SSWg73MP9u6jpDkMx/Ty66lzieqiia6RGH6f0zePFpnI1gUdSO Q=; X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="222979723" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-ca048aa0.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-9102.sea19.amazon.com with ESMTP; 27 May 2022 02:43:32 +0000 Received: from EX13MTAUWC002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-ca048aa0.us-east-1.amazon.com (Postfix) with ESMTPS id 90E8D82218; Fri, 27 May 2022 02:43:29 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC002.ant.amazon.com (10.43.162.240) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:26 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.162.202) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:25 +0000 From: "Alexander Graf" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [PATCH 00/12] Introduce Bootlog DEBUG() output Date: Fri, 27 May 2022 04:43:05 +0200 Message-ID: <20220527024317.13476-1-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 MIME-Version: 1.0 X-Originating-IP: [10.43.162.202] X-ClientProxiedBy: EX13D35UWB003.ant.amazon.com (10.43.161.65) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I recently looked at improving the bootup performance of virtual machines and was amazed by the fact that there is no logging / tracing framework available that would give me a full picture of the Pre-OS phase including time stamps and boot loaders (such as grub) without writing data to the serial port - which taints all measurements. The only place that I did find was PerformanceLib, which creates an FPDT. I had 2 problems with that though: 1) Discoverability - The best debugging tools give you all information you need as quickly as possible. The sub table FBPT which contains performance data is very condensed: It contains a modules GUID and up to 24 bytes of text per entry. Entries are limited to 255 bytes. It also only logs load events by default, nothing as fancy as FS reads. 2) Ease of use - The best kernel engineers I know still use printk() and trace_printk() to identify issues: Because it's easy. You can quickly extract data into text and analyze later. 3) Extensability to other payloads - The FPDT infrastructure considers everything as owned by PerformanceLib. I would like to create a one stop place for arbitrary UEFI applications to also put performance measurement data. So I wrote a small configuration table (very similar to FPDT) that contains references to boot logs, each with an array of strings as well as time stamp. This patch set contains everything needed to set this up and hook it into the 2 main DebugLib implementations in virtual machines: Serial and DebugIO. That way, I can see every debug message after boot with time stamp included, with very little impact on boot time. I tried to see if I can call PERF_EVENT() instead of my Bootlog infrastructure, but was unsuccessful. Let's use this patch set to open the conversation on how to best move forward. Eventually, I want to be able to log into Linux, fetch a sysfs file and get a human readable, synchronized, time stamped log file with enough information that allow me to create at least a bug report against the actual firmware owner. Github: https://github.com/agraf/edk2/tree/bootlog-v1 Alex Alexander Graf (12): MdePkg: Add DebugBootlog header MdePkg: Add Null BaseDebugBootlog MdePkg: Add Fallback timer support for BaseDebugBootlog MdePkg: Add X86 timer support for BaseDebugBootlog MdePkg: Add ARM timer support for BaseDebugBootlog MdePkg: Add Pei phase BaseDebugBootlog MdePkg: Add Dxe phase BaseDebugBootlog MdePkg: Add BaseDebugLibBootlog Scripts: Add bootlog decyphering script BaseDebugLibSerialPort: Include BaseDebugBootlog in all dscs BaseDebugLibSerialPort: Emit messages to boot log OvmfPkg/PlatformDebugLibIoPort: Add Bootlog support ArmVirtPkg/ArmVirt.dsc.inc | 5 + BaseTools/Scripts/ShowDebugLog.py | 88 +++++ EmulatorPkg/EmulatorPkg.dsc | 3 + IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc | 1 + MdePkg/Include/Library/DebugBootlog.h | 141 +++++++ .../BaseDebugBootlog/BaseDebugBootlog.h | 43 +++ .../BaseDebugBootlog/BaseDebugBootlogLib.inf | 61 +++ .../BaseDebugBootlogLibPei.inf | 60 +++ .../BaseDebugBootlogNullLib.inf | 26 ++ .../Library/BaseDebugBootlog/DebugBootlog.c | 22 ++ .../BaseDebugBootlog/DebugBootlogArm.c | 32 ++ .../BaseDebugBootlog/DebugBootlogDxe.c | 349 ++++++++++++++++++ .../BaseDebugBootlog/DebugBootlogNotime.c | 31 ++ .../BaseDebugBootlog/DebugBootlogNull.c | 32 ++ .../BaseDebugBootlog/DebugBootlogPei.c | 36 ++ .../BaseDebugBootlog/DebugBootlogX86.c | 50 +++ .../BaseDebugLibBootlog.inf | 44 +++ .../BaseDebugLibBootlog.uni | 17 + MdePkg/Library/BaseDebugLibBootlog/DebugLib.c | 338 +++++++++++++++++ .../BaseDebugLibSerialPort.inf | 1 + .../Library/BaseDebugLibSerialPort/DebugLib.c | 22 +- MdePkg/MdePkg.dec | 29 ++ OvmfPkg/AmdSev/AmdSevX64.dsc | 10 + OvmfPkg/Bhyve/BhyveX64.dsc | 10 + OvmfPkg/CloudHv/CloudHvX64.dsc | 10 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 8 + .../Library/PlatformDebugLibIoPort/DebugLib.c | 23 +- .../PlatformDebugLibIoPort.inf | 1 + .../PlatformRomDebugLibIoPort.inf | 1 + .../PlatformRomDebugLibIoPortNocheck.inf | 1 + OvmfPkg/Microvm/MicrovmX64.dsc | 10 + OvmfPkg/OvmfPkgIa32.dsc | 10 + OvmfPkg/OvmfPkgIa32X64.dsc | 10 + OvmfPkg/OvmfPkgX64.dsc | 7 + OvmfPkg/OvmfXen.dsc | 1 + SourceLevelDebugPkg/SourceLevelDebugPkg.dsc | 1 + UefiPayloadPkg/UefiPayloadPkg.dsc | 1 + 37 files changed, 1526 insertions(+), 9 deletions(-) create mode 100755 BaseTools/Scripts/ShowDebugLog.py create mode 100644 MdePkg/Include/Library/DebugBootlog.h create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlog.h create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogLib.inf create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogLibPei.inf create mode 100644 MdePkg/Library/BaseDebugBootlog/BaseDebugBootlogNullLib.inf create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlog.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogArm.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogDxe.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogNotime.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogNull.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogPei.c create mode 100644 MdePkg/Library/BaseDebugBootlog/DebugBootlogX86.c create mode 100644 MdePkg/Library/BaseDebugLibBootlog/BaseDebugLibBootlog.inf create mode 100644 MdePkg/Library/BaseDebugLibBootlog/BaseDebugLibBootlog.uni create mode 100644 MdePkg/Library/BaseDebugLibBootlog/DebugLib.c -- 2.28.0.394.ge197136389 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879