OvmfPkg/PlatformBootManagerLib: Avoid full 64-byte PCI header reads in BDS

VisitingAPciInstance() currently reads the entire 64-byte PCI_TYPE00
configuration header (16 32-bit reads per device) on every invocation of
VisitAllPciInstances(). Under virtualization (especially confidential
computing guests such as SEV-SNP and TDX where each config-space access
triggers a #VC/#VE exit to the VMM), reading all 16 DWORDs per device
across multiple BDS passes adds significant unnecessary exit overhead:

1. SetPciIntLine() only inspects the 1-byte InterruptPin register
   (PCI_INT_PIN_OFFSET, 0x3D). Convert SetPciIntLine() to a
   PROTOCOL_INSTANCE_CALLBACK invoked via VisitAllInstancesOfProtocol()
   that reads PCI_INT_PIN_OFFSET directly with a single 8-bit read,
   eliminating 15 config-space reads per PCI device during
   PciAcpiInitialization().
2. With SetPciIntLine() converted, all remaining VisitAllPciInstances()
   callbacks (DetectAndPreparePlatformPciDevicePath() and
   ConnectRecursivelyIfPciMassStorage()) only inspect fields within the
   16-byte PCI_DEVICE_INDEPENDENT_REGION (Pci.Hdr). Update
   VisitingAPciInstance() to read only sizeof (Pci.Hdr) / sizeof (UINT32)
   (4 DWORDs instead of 16) while zeroing the remainder of PCI_TYPE00.

Signed-off-by: Kevin Loughlin <kevinloughlin@google.com>
2 files changed