From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=pbonzini@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E82D3220D4BE9 for ; Thu, 16 Nov 2017 12:26:54 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 752946A7DA; Thu, 16 Nov 2017 20:31:04 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-65.ams2.redhat.com [10.36.117.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 859E6B32BA; Thu, 16 Nov 2017 20:31:01 +0000 (UTC) From: Paolo Bonzini To: edk2-devel@lists.01.org Cc: Laszlo Ersek , Ard Biesheuvel , Jordan Justen Date: Thu, 16 Nov 2017 21:30:57 +0100 Message-Id: <20171116203100.28085-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 16 Nov 2017 20:31:04 +0000 (UTC) Subject: [PATCH v3 0/3] OvmfPkg: save on I/O port accesses when the debug port is not in use X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 20:26:55 -0000 This is version 3 of the series to skip debug port I/O port writes when the debug port device wasn't added to the virtual machine. The differences from v2 are entirely cosmetic, and I'm including them at the end of this message for ease of review. Thanks, Paolo Paolo Bonzini (3): OvmfPkg: make PlatformDebugLibIoPort a proper BASE library OvmfPkg: create a separate PlatformDebugLibIoPort instance for SEC OvmfPkg: save on I/O port accesses when the debug port is not in use OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf | 3 ++- OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf | 52 +++++++++++++++++++++++++++++++++++++++++ OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c | 44 +++++++++++++++++++---------------- OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c | 48 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 241 insertions(+), 24 deletions(-) create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c -- 2.14.3 diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf index 65d8683f1f..de3c2f542b 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf @@ -21,7 +21,7 @@ [Defines] FILE_GUID = DF934DA3-CD31-49FE-AF50-B3C87C79325F MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = DebugLib + LIBRARY_CLASS = DebugLib|PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION CONSTRUCTOR = PlatformDebugLibIoPortConstructor # diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf index 93763d47dd..491c0318de 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf @@ -21,7 +21,7 @@ [Defines] FILE_GUID = CEB0D9D3-328F-4C24-8C02-28FA1986AE1B MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = DebugLib + LIBRARY_CLASS = DebugLib|SEC CONSTRUCTOR = PlatformRomDebugLibIoPortConstructor # diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h index c34ca9c72b..1f739b55d8 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.h @@ -17,7 +17,6 @@ #define __DEBUG_IO_PORT_DETECT_H__ #include -#include // // The constant value that is read from the debug I/O port @@ -30,7 +29,8 @@ PlatformDebugLibIoPortFound can call this function directly or cache the result. - @retval BOOLEAN TRUE if the debug I/O port device was detected. + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise **/ BOOLEAN @@ -44,7 +44,8 @@ PlatformDebugLibIoPortDetect ( calls this function instead of PlatformDebugLibIoPortDetect, to allow caching if possible. - @retval BOOLEAN TRUE if the debug I/O port device was detected. + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise **/ BOOLEAN diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c index 79486ac8a6..36cde54976 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c @@ -15,7 +15,6 @@ **/ #include -#include #include #include #include @@ -63,9 +62,10 @@ DebugPrint ( ASSERT (Format != NULL); // - // Do nothing if the global mask disables this message or the device is inactive + // Check if the global mask disables this message or the device is inactive // - if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0 || !PlatformDebugLibIoPortFound ()) { + if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0 || + !PlatformDebugLibIoPortFound ()) { return; } @@ -273,7 +273,8 @@ DebugPrintLevelEnabled ( /** Return the result of detecting the debug I/O port device. - @retval BOOLEAN TRUE if the debug I/O port device was detected. + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise **/ BOOLEAN diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c index 610987aca9..81c44eece9 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c @@ -14,7 +14,6 @@ **/ #include -#include #include "DebugLibDetect.h" // @@ -26,7 +25,7 @@ STATIC BOOLEAN mDebugIoPortFound = FALSE; This constructor function checks if the debug I/O port device is present, caching the result for later use. - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS. **/ RETURN_STATUS @@ -36,13 +35,14 @@ PlatformDebugLibIoPortConstructor ( ) { mDebugIoPortFound = PlatformDebugLibIoPortDetect(); - return EFI_SUCCESS; + return RETURN_SUCCESS; } /** Return the cached result of detecting the debug I/O port device. - @retval BOOLEAN TRUE if the debug I/O port device was detected. + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise **/ BOOLEAN diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c index f71b6567dc..b950919675 100644 --- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c +++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c @@ -14,13 +14,12 @@ **/ #include -#include #include "DebugLibDetect.h" /** - This constructor function does not have to do anything. + This constructor function does not have anything to do. - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS. **/ RETURN_STATUS @@ -29,13 +28,14 @@ PlatformRomDebugLibIoPortConstructor ( VOID ) { - return EFI_SUCCESS; + return RETURN_SUCCESS; } /** Return the result of detecting the debug I/O port device. - @retval BOOLEAN TRUE if the debug I/O port device was detected. + @retval TRUE if the debug I/O port device was detected. + @retval FALSE otherwise **/ BOOLEAN