audk/OvmfPkg/Library
Paolo Bonzini c09d957130 OvmfPkg: save on I/O port accesses when the debug port is not in use
When SEV is enabled, every debug message printed by OVMF to the
QEMU debug port traps from the guest to QEMU character by character
because "REP OUTSB" cannot be used by IoWriteFifo8.  Furthermore,
when OVMF is built with the DEBUG_VERBOSE bit (value 0x00400000)
enabled in "gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel", then the
OvmfPkg/IoMmuDxe driver, and the OvmfPkg/Library/BaseMemEncryptSevLib
library instance that is built into it, produce a huge amount of
log messages.  Therefore, in SEV guests, the boot time impact is huge
(about 45 seconds _additional_ time spent writing to the debug port).

While these messages are very useful for analyzing guest behavior,
most of the time the user won't be capturing the OVMF debug log.
In fact libvirt does not provide a method for configuring log capture;
users that wish to do this (or are instructed to do this) have to resort
to <qemu:arg>.

The debug console device provides a handy detection mechanism; when read,
it returns 0xE9 (which is very much unlike the 0xFF that is returned by
an unused port).  Use it to skip the possibly expensive OUT instructions
when the debug I/O port isn't plugged anywhere.

For SEC, the debug port has to be read before each full message.
However:

- if the debug port is available, then reading one byte before writing
a full message isn't tragic, especially because SEC doesn't print many
messages

- if the debug port is not available, then reading one byte instead of
writing a full message is still a win.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen (Intel address) <jordan.l.justen@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2017-11-17 18:35:12 +01:00
..
AcpiTimerLib OvmfPkg: determine PMBA value dependent on host bridge device ID 2016-05-17 20:48:39 +02:00
BaseMemEncryptSevLib OvmfPkg/BaseMemEncryptSevLib: fix typos in DEBUG messages 2017-09-01 14:20:37 +02:00
DxePciLibI440FxQ35 OvmfPkg: add DxePciLibI440FxQ35 2016-03-10 21:28:29 +01:00
EmuVariableFvbLib
LoadLinuxLib OvmfPkg: Make more use of ARRAY_SIZE() 2016-10-27 18:21:06 +02:00
LockBoxLib ArmVirtPkg, OvmfPkg: retire QemuFwCfgS3Enabled() from QemuFwCfgLib 2017-03-14 21:49:16 +01:00
NvVarsFileLib OvmfPkg: Remove superfluous return statements. 2017-01-19 10:28:40 +01:00
PciHostBridgeLib OvmfPkg: Make more use of ARRAY_SIZE() 2016-10-27 18:21:06 +02:00
PlatformBootManagerLib OvmfPkg/PlatformBootManagerLib: log informative message at DEBUG_INFO lvl 2017-09-11 22:39:32 +02:00
PlatformDebugLibIoPort OvmfPkg: save on I/O port accesses when the debug port is not in use 2017-11-17 18:35:12 +01:00
PlatformFvbLibNull
PlatformHasIoMmuLib OvmfPkg: Add PlatformHasIoMmuLib 2017-07-10 21:17:28 -07:00
PlatformSecureLib
QemuBootOrderLib OvmfPkg/QemuBootOrderLib: recognize "usb-storage" devices in XHCI ports 2017-09-22 14:54:35 +02:00
QemuFwCfgLib OvmfPkg/QemuFwCfgDxeLib: SEV: zero FW_CFG_DMA_ACCESS before decrypting it 2017-08-29 22:44:33 +02:00
QemuFwCfgS3Lib OvmfPkg/QemuFwCfgS3Lib: Fix VS tool chain build failure 2017-03-15 21:18:40 -07:00
ResetSystemLib OvmfPkg/ResetSystemLib: Implement ResetPlatformSpecific 2016-09-02 10:07:15 +08:00
SerializeVariablesLib OvmfPkg/SerializeVariablesLib: Relax check for the read-only variable 2016-05-26 13:21:36 +02:00
SmbiosVersionLib OvmfPkg/SmbiosVersionLib: eliminate unchecked PcdSetXX() calls 2016-10-25 10:46:19 +02:00
SmmCpuFeaturesLib OvmfPkg: SmmCpuFeaturesLib: customize state save map format 2015-11-30 18:46:42 +00:00
VirtioLib OvmfPkg/VirtioLib: change the parameter of VirtioAppendDesc() to UINT64 2017-08-25 10:42:19 +02:00
VirtioMmioDeviceLib OvmfPkg/Virtio: take RingBaseShift in SetQueueAddress() 2017-08-25 10:42:19 +02:00
XenConsoleSerialPortLib OvmfPkg/XenConsoleSerialPortLib: don't include <Uefi/UefiBaseType.h> 2016-10-26 12:03:39 +02:00
XenHypercallLib OvmfPkg/XenHypercallLib: enable virt extensions for ARM 2017-11-17 09:56:50 +00:00
XenIoMmioLib OvmfPkg/XenIoMmioLib: add missing MemoryAllocationLib dependency to INF 2016-04-13 17:26:06 +02:00