Date   

[PATCH 40/43] OvmfPkg/SmbiosPlatformDxe: declare InstallAllStructures() in header file

Laszlo Ersek
 

Add an extern declaration for the InstallAllStructures() function to the
"SmbiosPlatformDxe.h" header file. (The leading comment block and the
prototype are simply copied from "SmbiosPlatformDxe.c".)

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 7a0bdbb2911f..0ae2556fe800 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -8,12 +8,23 @@

**/

#ifndef SMBIOS_PLATFORM_DXE_H_
#define SMBIOS_PLATFORM_DXE_H_

+/**
+ Install all structures from the given SMBIOS structures block
+
+ @param TableAddress SMBIOS tables starting address
+
+**/
+EFI_STATUS
+InstallAllStructures (
+ IN UINT8 *TableAddress
+ );
+
/**
Locates and extracts the QEMU SMBIOS table data if present in fw_cfg

@return Address of extracted QEMU SMBIOS data

**/
--
2.19.1.3.g30247aa5d201


[PATCH 39/43] OvmfPkg/SmbiosPlatformDxe: split GetXenSmbiosTables() decl. to new header

Laszlo Ersek
 

Move the declaration of the GetXenSmbiosTables() function to a new header
file called "XenSmbiosPlatformDxe.h". (The only declaration that remains
in "SmbiosPlatformDxe.h" for now is that of GetQemuSmbiosTables().)

Modify the pattern in "Maintainers.txt" so that the new file be covered in
the "OvmfPkg: Xen-related modules" section.

This patch is best viewed with "git show --no-renames".

Cc: Andrew Fish <afish@apple.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 1 +
Maintainers.txt | 2 +-
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 14 --------------
OvmfPkg/SmbiosPlatformDxe/{ArmXen.c => XenSmbiosPlatformDxe.h} | 20 ++++++++++----------
OvmfPkg/SmbiosPlatformDxe/ArmXen.c | 2 +-
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 1 +
OvmfPkg/SmbiosPlatformDxe/X86Xen.c | 2 +-
7 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 6063c0c9f609..140fa16ac135 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -24,12 +24,13 @@ [Defines]
#

[Sources]
Qemu.c
SmbiosPlatformDxe.c
SmbiosPlatformDxe.h
+ XenSmbiosPlatformDxe.h

[Sources.IA32, Sources.X64]
X86Xen.c

[Sources.ARM, Sources.AARCH64]
ArmXen.c
diff --git a/Maintainers.txt b/Maintainers.txt
index e5f419e67f0c..751477e8e62a 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -499,13 +499,13 @@ F: OvmfPkg/Library/XenConsoleSerialPortLib/
F: OvmfPkg/Library/XenHypercallLib/
F: OvmfPkg/Library/XenIoMmioLib/
F: OvmfPkg/Library/XenPlatformLib/
F: OvmfPkg/Library/XenRealTimeClockLib/
F: OvmfPkg/OvmfXen.*
F: OvmfPkg/OvmfXenElfHeaderGenerator.c
-F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
+F: OvmfPkg/SmbiosPlatformDxe/*Xen*
F: OvmfPkg/XenAcpiPlatformDxe/
F: OvmfPkg/XenBusDxe/
F: OvmfPkg/XenIoPciDxe/
F: OvmfPkg/XenIoPvhDxe/
F: OvmfPkg/XenPlatformPei/
F: OvmfPkg/XenPvBlkDxe/
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index ad42a326418c..7a0bdbb2911f 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -8,26 +8,12 @@

**/

#ifndef SMBIOS_PLATFORM_DXE_H_
#define SMBIOS_PLATFORM_DXE_H_

-#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_ENTRY_POINT
-
-/**
- Locates the Xen SMBIOS data if it exists
-
- @return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data
-
-**/
-SMBIOS_TABLE_ENTRY_POINT *
-GetXenSmbiosTables (
- VOID
- );
-
-
/**
Locates and extracts the QEMU SMBIOS table data if present in fw_cfg

@return Address of extracted QEMU SMBIOS data

**/
diff --git a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.h
similarity index 56%
copy from OvmfPkg/SmbiosPlatformDxe/ArmXen.c
copy to OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.h
index c2847f905303..850a8b662cd5 100644
--- a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c
+++ b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.h
@@ -1,28 +1,28 @@
/** @file
- Detect Xen SMBIOS data on ARM / AARCH64.
+ This driver installs SMBIOS information for OVMF on Xen

- Copyright (C) 2015, Red Hat, Inc.
+ Copyright (C) 2021, Red Hat, Inc.
Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent
+
**/

-#include "SmbiosPlatformDxe.h"
+#ifndef XEN_SMBIOS_PLATFORM_DXE_H_
+#define XEN_SMBIOS_PLATFORM_DXE_H_
+
+#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_ENTRY_POINT

/**
Locates the Xen SMBIOS data if it exists

@return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data

**/
SMBIOS_TABLE_ENTRY_POINT *
GetXenSmbiosTables (
VOID
- )
-{
- //
- // Not implemented yet.
- //
- return NULL;
-}
+ );
+
+#endif
diff --git a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c b/OvmfPkg/SmbiosPlatformDxe/ArmXen.c
index c2847f905303..3dd849bbc0b4 100644
--- a/OvmfPkg/SmbiosPlatformDxe/ArmXen.c
+++ b/OvmfPkg/SmbiosPlatformDxe/ArmXen.c
@@ -5,13 +5,13 @@
Copyright (c) 2011, Bei Guan <gbtju85@gmail.com>
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent
**/

-#include "SmbiosPlatformDxe.h"
+#include "XenSmbiosPlatformDxe.h"

/**
Locates the Xen SMBIOS data if it exists

@return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 757bec879e4a..f280a1852ddd 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -12,12 +12,13 @@
#include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
#include <Library/MemoryAllocationLib.h> // FreePool()
#include <Library/UefiBootServicesTableLib.h> // gBS
#include <Protocol/Smbios.h> // EFI_SMBIOS_PROTOCOL

#include "SmbiosPlatformDxe.h"
+#include "XenSmbiosPlatformDxe.h"

#define TYPE0_STRINGS \
"EFI Development Kit II / OVMF\0" /* Vendor */ \
"0.0.0\0" /* BiosVersion */ \
"02/06/2015\0" /* BiosReleaseDate */
//
diff --git a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c b/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
index e0b1b29f80db..0acedf8995da 100644
--- a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
+++ b/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
@@ -9,13 +9,13 @@
**/

#include <Library/BaseLib.h> // AsciiStrnCmp()
#include <Library/HobLib.h> // GetFirstGuidHob()
#include <Pi/PiHob.h> // EFI_HOB_GUID_TYPE

-#include "SmbiosPlatformDxe.h"
+#include "XenSmbiosPlatformDxe.h"

#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
#define XEN_SMBIOS_PHYSICAL_END 0x000F0000

/**
Validates the SMBIOS entry point structure
--
2.19.1.3.g30247aa5d201


[PATCH 38/43] OvmfPkg/SmbiosPlatformDxe: locate SMBIOS protocol in InstallAllStructures()

Laszlo Ersek
 

Locate the SMBIOS protocol internally to the InstallAllStructures()
function. This has no performance impact (InstallAllStructures() is only
called once), but moving the code from the entry point function makes the
latter smaller. And that will be useful when we split the entry point
function to two versions.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 30 +++++++++-----------
1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 6d73173aa512..757bec879e4a 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -92,27 +92,38 @@ SmbiosTableLength (
}


/**
Install all structures from the given SMBIOS structures block

- @param Smbios SMBIOS protocol
@param TableAddress SMBIOS tables starting address

**/
EFI_STATUS
InstallAllStructures (
- IN EFI_SMBIOS_PROTOCOL *Smbios,
IN UINT8 *TableAddress
)
{
+ EFI_SMBIOS_PROTOCOL *Smbios;
EFI_STATUS Status;
SMBIOS_STRUCTURE_POINTER SmbiosTable;
EFI_SMBIOS_HANDLE SmbiosHandle;
BOOLEAN NeedSmbiosType0;

+ //
+ // Find the SMBIOS protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID**)&Smbios
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
SmbiosTable.Raw = TableAddress;
if (SmbiosTable.Raw == NULL) {
return EFI_INVALID_PARAMETER;
}

NeedSmbiosType0 = TRUE;
@@ -173,41 +184,28 @@ EFIAPI
SmbiosTablePublishEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
- EFI_SMBIOS_PROTOCOL *Smbios;
SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure;
UINT8 *SmbiosTables;

- //
- // Find the SMBIOS protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiSmbiosProtocolGuid,
- NULL,
- (VOID**)&Smbios
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
Status = EFI_NOT_FOUND;
//
// Add Xen or QEMU SMBIOS data if found
//
EntryPointStructure = GetXenSmbiosTables ();
if (EntryPointStructure != NULL) {
SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress;
} else {
SmbiosTables = GetQemuSmbiosTables ();
}

if (SmbiosTables != NULL) {
- Status = InstallAllStructures (Smbios, SmbiosTables);
+ Status = InstallAllStructures (SmbiosTables);

//
// Free SmbiosTables if allocated by Qemu (i.e., NOT by Xen):
//
if (EntryPointStructure == NULL) {
FreePool (SmbiosTables);
--
2.19.1.3.g30247aa5d201


[PATCH 37/43] OvmfPkg/SmbiosPlatformDxe: return EFI_NOT_FOUND if there is no SMBIOS data

Laszlo Ersek
 

According to the function-top comment, SmbiosTablePublishEntry() is
supposed to return an error code if no SMBIOS data is found, from either
GetXenSmbiosTables() or GetQemuSmbiosTables(). Currently the function
returns EFI_SUCCESS in this case however (propagated from
gBS->LocateProtocol()). Make the return code match the documentation.

(This issue is not too important, but it gets in the way of splitting the
entry point function next.)

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 9bfc9f14f1a5..6d73173aa512 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -189,12 +189,13 @@ SmbiosTablePublishEntry (
(VOID**)&Smbios
);
if (EFI_ERROR (Status)) {
return Status;
}

+ Status = EFI_NOT_FOUND;
//
// Add Xen or QEMU SMBIOS data if found
//
EntryPointStructure = GetXenSmbiosTables ();
if (EntryPointStructure != NULL) {
SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress;
--
2.19.1.3.g30247aa5d201


[PATCH 36/43] OvmfPkg/SmbiosPlatformDxe: clean up #includes and INF #includes

Laszlo Ersek
 

- Sort all sections in the INF file.

- Remove unused packages (MdeModulePkg) and lib classes (BaseMemoryLib)
from the INF file.

- Restrict some lib classes (BaseLib, HobLib) and GUIDs (gEfiXenInfoGuid)
to IA32 and X64, in the INF file; only the IA32/X64 Xen implementation
requires these.

- Don't make "SmbiosPlatformDxe.h" #include everything just as a
convenience. Spell out directly needed #includes in every file (annotate
each with an example identifier consumed), drop unused #includes.

- Keep #includes sorted.

- Remove the leading underscore from the #include guard macro name in
"SmbiosPlatformDxe.h".

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 20 ++++++++++----------
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 15 +++------------
OvmfPkg/SmbiosPlatformDxe/Qemu.c | 8 +++++---
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 6 ++++++
OvmfPkg/SmbiosPlatformDxe/X86Xen.c | 6 ++++--
5 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 8b56d90cf805..6063c0c9f609 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -21,44 +21,44 @@ [Defines]
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64
#

[Sources]
- SmbiosPlatformDxe.h
- SmbiosPlatformDxe.c
Qemu.c
+ SmbiosPlatformDxe.c
+ SmbiosPlatformDxe.h

[Sources.IA32, Sources.X64]
X86Xen.c

[Sources.ARM, Sources.AARCH64]
ArmXen.c

[Packages]
MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec

[LibraryClasses]
- UefiBootServicesTableLib
- BaseMemoryLib
- BaseLib
- UefiDriverEntryPoint
DebugLib
- HobLib
- QemuFwCfgLib
MemoryAllocationLib
PcdLib
+ QemuFwCfgLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[LibraryClasses.IA32, LibraryClasses.X64]
+ BaseLib
+ HobLib

[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated

[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED

-[Guids]
+[Guids.IA32, Guids.X64]
gEfiXenInfoGuid

[Depex]
gEfiSmbiosProtocolGuid

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 21aa916d7784..ad42a326418c 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -5,25 +5,16 @@
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

-#ifndef _SMBIOS_PLATFORM_DXE_H_
-#define _SMBIOS_PLATFORM_DXE_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/Smbios.h>
-#include <IndustryStandard/SmBios.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
+#ifndef SMBIOS_PLATFORM_DXE_H_
+#define SMBIOS_PLATFORM_DXE_H_

+#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_ENTRY_POINT

/**
Locates the Xen SMBIOS data if it exists

@return SMBIOS_TABLE_ENTRY_POINT Address of Xen SMBIOS data

diff --git a/OvmfPkg/SmbiosPlatformDxe/Qemu.c b/OvmfPkg/SmbiosPlatformDxe/Qemu.c
index e34658238123..fcfc3e33c28c 100644
--- a/OvmfPkg/SmbiosPlatformDxe/Qemu.c
+++ b/OvmfPkg/SmbiosPlatformDxe/Qemu.c
@@ -3,16 +3,18 @@

Copyright (C) 2014, Gabriel L. Somlo <somlo@cmu.edu>

SPDX-License-Identifier: BSD-2-Clause-Patent
**/

+#include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
+#include <Library/MemoryAllocationLib.h> // AllocatePool()
+#include <Library/PcdLib.h> // PcdGetBool()
+#include <Library/QemuFwCfgLib.h> // QemuFwCfgFindFile()
+
#include "SmbiosPlatformDxe.h"
-#include <Library/QemuFwCfgLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>

/**
Locates and extracts the QEMU SMBIOS data if present in fw_cfg

@return Address of extracted QEMU SMBIOS data

diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 7991a19dc9c6..9bfc9f14f1a5 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -5,12 +5,18 @@
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

+#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_TYPE0
+#include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
+#include <Library/MemoryAllocationLib.h> // FreePool()
+#include <Library/UefiBootServicesTableLib.h> // gBS
+#include <Protocol/Smbios.h> // EFI_SMBIOS_PROTOCOL
+
#include "SmbiosPlatformDxe.h"

#define TYPE0_STRINGS \
"EFI Development Kit II / OVMF\0" /* Vendor */ \
"0.0.0\0" /* BiosVersion */ \
"02/06/2015\0" /* BiosReleaseDate */
diff --git a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c b/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
index bead810efddb..e0b1b29f80db 100644
--- a/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
+++ b/OvmfPkg/SmbiosPlatformDxe/X86Xen.c
@@ -5,15 +5,17 @@
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

+#include <Library/BaseLib.h> // AsciiStrnCmp()
+#include <Library/HobLib.h> // GetFirstGuidHob()
+#include <Pi/PiHob.h> // EFI_HOB_GUID_TYPE
+
#include "SmbiosPlatformDxe.h"
-#include <Library/HobLib.h>
-#include <Guid/XenInfo.h>

#define XEN_SMBIOS_PHYSICAL_ADDRESS 0x000EB000
#define XEN_SMBIOS_PHYSICAL_END 0x000F0000

/**
Validates the SMBIOS entry point structure
--
2.19.1.3.g30247aa5d201


[PATCH 35/43] OvmfPkg/PciHostBridgeLibScan: clean up file names and file-top comments

Laszlo Ersek
 

Rename "XenSupport.c" to "ScanForRootBridges.c", after the main function
in it.

Update the file-top comments; refer to both Bhyve and Xen.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf | 4 ++--
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h | 3 ++-
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c | 2 +-
OvmfPkg/Library/PciHostBridgeLibScan/{XenSupport.c => ScanForRootBridges.c} | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
index 199db4cbbd19..a2ac5f93d193 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
@@ -1,8 +1,8 @@
## @file
-# OVMF's instance of the PCI Host Bridge Library.
+# OVMF's instance of the PCI Host Bridge Library, for Bhyve and Xen guests.
#
# Copyright (C) 2016-2021, Red Hat, Inc.
# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -24,13 +24,13 @@ [Defines]
# VALID_ARCHITECTURES = IA32 X64 EBC
#

[Sources]
PciHostBridge.h
PciHostBridgeLib.c
- XenSupport.c
+ ScanForRootBridges.c

[Packages]
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
index 582b7929aff2..cb05220161d7 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
@@ -1,8 +1,9 @@
/** @file
- Header file of OVMF instance of PciHostBridgeLib.
+ OVMF's instance of the PCI Host Bridge Library, for Bhyve and Xen guests;
+ internal declarations.

Copyright (C) 2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
index f0166e0f7279..ac8d1033df24 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
@@ -1,8 +1,8 @@
/** @file
- OVMF's instance of the PCI Host Bridge Library.
+ OVMF's instance of the PCI Host Bridge Library, for Bhyve and Xen guests.

Copyright (C) 2016-2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
similarity index 96%
rename from OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
rename to OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
index edf993e82dcc..a6126a1aea52 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c
@@ -1,8 +1,8 @@
/** @file
- Scan the entire PCI bus for root bridges to support OVMF above Xen.
+ Scan the entire PCI bus for root bridges to support OVMF on Bhyve and Xen.

Copyright (C) 2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

--
2.19.1.3.g30247aa5d201


[PATCH 34/43] OvmfPkg/PciHostBridgeLibScan: remove PcdOvmfHostBridgePciDevId

Laszlo Ersek
 

The "OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf"
instance is used in the following platforms in edk2:

OvmfPkg/Bhyve/BhyveX64.dsc
OvmfPkg/OvmfXen.dsc

Neither Bhyve nor Xen provide a Q35 board, therefore the expression

PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID

always evaluates to TRUE, in the PciHostBridgeLibScan instance.

Replace the expression with constant TRUE, eliminating the PCD dependency.

(In effect, this reports that the root bridge being registered does not
support extended PCI config space.)

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf | 4 ----
OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c | 4 +---
2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
index 1ba880be6782..199db4cbbd19 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
@@ -36,12 +36,8 @@ [Packages]

[LibraryClasses]
BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
- PcdLib
PciHostBridgeUtilityLib
PciLib
-
-[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
index a4a61e5836e0..edf993e82dcc 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
@@ -6,18 +6,16 @@

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <IndustryStandard/Pci.h> // EFI_PCI_COMMAND_IO_SPACE
-#include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVICE_ID
#include <Library/BaseLib.h> // DisableInterrupts()
#include <Library/BaseMemoryLib.h> // ZeroMem()
#include <Library/DebugLib.h> // ASSERT()
#include <Library/MemoryAllocationLib.h> // ReallocatePool()
-#include <Library/PcdLib.h> // PcdGet16()
#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APERTURE
#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilityInitRoot...
#include <Library/PciLib.h> // PciRead32()
#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_ISA_IO

#include "PciHostBridge.h"
@@ -452,13 +450,13 @@ ScanForRootBridges (
(*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE),
RootBridges
);
ASSERT (RootBridges != NULL);
PciHostBridgeUtilityInitRootBridge (
Attributes, Attributes, 0,
- FALSE, PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
+ FALSE, TRUE /* NoExtendedConfigSpace */,
(UINT8) PrimaryBus, (UINT8) SubBus,
&Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,
&RootBridges[*NumberOfRootBridges]
);
RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;
//
--
2.19.1.3.g30247aa5d201


[PATCH 33/43] OvmfPkg/PciHostBridgeLibScan: remove QEMU (fw_cfg) support

Laszlo Ersek
 

The "OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf"
instance is used in the following platforms in edk2:

OvmfPkg/Bhyve/BhyveX64.dsc
OvmfPkg/OvmfXen.dsc

Both platforms define "PcdPciDisableBusEnumeration" with Fixed-at-Build
access method, and TRUE value. Remove the PCD from the
PciHostBridgeLibScan instance, and everything else that is useful only
when the PCD is FALSE.

In practice, this removes the PciHostBridgeUtilityGetRootBridges()
function call, which is based on fw-cfg; see
"OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c".

(Note that the dependency on PciHostBridgeUtilityLib remains in place,
given that the PciHostBridgeLibScan instance continues using lower-level
functions from the library that do not depend on fw-cfg.)

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf | 7 ---
OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c | 63 +-------------------
2 files changed, 2 insertions(+), 68 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
index 46859388870f..1ba880be6782 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
@@ -41,14 +41,7 @@ [LibraryClasses]
MemoryAllocationLib
PcdLib
PciHostBridgeUtilityLib
PciLib

[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
- gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
- gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
- gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
- gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
- gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
- gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
index 6c2acc9f99bc..f0166e0f7279 100644
--- a/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
@@ -4,26 +4,17 @@
Copyright (C) 2016-2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/
-#include <IndustryStandard/Pci.h> // PCI_MAX_BUS
-#include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVIC...
-#include <Library/BaseMemoryLib.h> // ZeroMem()
-#include <Library/PcdLib.h> // PcdGet64()
-#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APE...
+#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE
#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilit...
-#include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...
-#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...

#include "PciHostBridge.h"

-STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
-
-
/**
Return all the root bridge instances in an array.

@param Count Return the count of root bridge instances.

@return All the root bridge instances in an array.
@@ -33,63 +24,13 @@ STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
PCI_ROOT_BRIDGE *
EFIAPI
PciHostBridgeGetRootBridges (
UINTN *Count
)
{
- UINT64 Attributes;
- UINT64 AllocationAttributes;
- PCI_ROOT_BRIDGE_APERTURE Io;
- PCI_ROOT_BRIDGE_APERTURE Mem;
- PCI_ROOT_BRIDGE_APERTURE MemAbove4G;
-
- if (PcdGetBool (PcdPciDisableBusEnumeration)) {
- return ScanForRootBridges (Count);
- }
-
- ZeroMem (&Io, sizeof (Io));
- ZeroMem (&Mem, sizeof (Mem));
- ZeroMem (&MemAbove4G, sizeof (MemAbove4G));
-
- Attributes = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO |
- EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO |
- EFI_PCI_ATTRIBUTE_ISA_IO_16 |
- EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |
- EFI_PCI_ATTRIBUTE_VGA_MEMORY |
- EFI_PCI_ATTRIBUTE_VGA_IO_16 |
- EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
-
- AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
- if (PcdGet64 (PcdPciMmio64Size) > 0) {
- AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
- MemAbove4G.Base = PcdGet64 (PcdPciMmio64Base);
- MemAbove4G.Limit = PcdGet64 (PcdPciMmio64Base) +
- PcdGet64 (PcdPciMmio64Size) - 1;
- } else {
- CopyMem (&MemAbove4G, &mNonExistAperture, sizeof (mNonExistAperture));
- }
-
- Io.Base = PcdGet64 (PcdPciIoBase);
- Io.Limit = PcdGet64 (PcdPciIoBase) + (PcdGet64 (PcdPciIoSize) - 1);
- Mem.Base = PcdGet64 (PcdPciMmio32Base);
- Mem.Limit = PcdGet64 (PcdPciMmio32Base) + (PcdGet64 (PcdPciMmio32Size) - 1);
-
- return PciHostBridgeUtilityGetRootBridges (
- Count,
- Attributes,
- AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
- 0,
- PCI_MAX_BUS,
- &Io,
- &Mem,
- &MemAbove4G,
- &mNonExistAperture,
- &mNonExistAperture
- );
+ return ScanForRootBridges (Count);
}


/**
Free the root bridge instances array returned from
PciHostBridgeGetRootBridges().
--
2.19.1.3.g30247aa5d201


[PATCH 32/43] OvmfPkg/PciHostBridgeLib: remove Bhyve and Xen support

Laszlo Ersek
 

The "OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf" instance is
used by the following platforms in edk2:

OvmfPkg/AmdSev/AmdSevX64.dsc
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc

All these platforms statically inherit PcdPciDisableBusEnumeration=FALSE
from "MdeModulePkg.dec". Remove the the PCD and everything that depends on
it from the PciHostBridgeLib instance. Namely, remove the logic that
determines the root bridge apertures by (a) scanning the entire bus,
device and function number space, and (b) parsing the BAR values that were
pre-set by the Bhyve or Xen machinery.

"XenSupport.c" used to be listed explicitly in "Maintainers.txt", remove
it from that spot too.

Cc: Andrew Fish <afish@apple.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 7 -
Maintainers.txt | 1 -
OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h | 13 -
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 6 -
OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 471 --------------------
5 files changed, 498 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
index 622780888472..f9f182557453 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -22,32 +22,25 @@ [Defines]
# tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#

[Sources]
- PciHostBridge.h
PciHostBridgeLib.c
- XenSupport.c

[Packages]
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec

[LibraryClasses]
- BaseLib
BaseMemoryLib
- DebugLib
- MemoryAllocationLib
PcdLib
PciHostBridgeUtilityLib
- PciLib

[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
diff --git a/Maintainers.txt b/Maintainers.txt
index a273409a923f..e5f419e67f0c 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -490,13 +490,12 @@ F: OvmfPkg/Include/Guid/XenInfo.h
F: OvmfPkg/Include/IndustryStandard/Xen/
F: OvmfPkg/Include/Library/XenHypercallLib.h
F: OvmfPkg/Include/Library/XenIoMmioLib.h
F: OvmfPkg/Include/Library/XenPlatformLib.h
F: OvmfPkg/Include/Protocol/XenBus.h
F: OvmfPkg/Include/Protocol/XenIo.h
-F: OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
F: OvmfPkg/Library/PciHostBridgeLibScan/
F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
F: OvmfPkg/Library/XenConsoleSerialPortLib/
F: OvmfPkg/Library/XenHypercallLib/
F: OvmfPkg/Library/XenIoMmioLib/
F: OvmfPkg/Library/XenPlatformLib/
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h
deleted file mode 100644
index a2e4d8696281..000000000000
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/** @file
- Header file of OVMF instance of PciHostBridgeLib.
-
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-PCI_ROOT_BRIDGE *
-ScanForRootBridges (
- UINTN *NumberOfRootBridges
-);
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 6db91fb7e20c..835efffccaf5 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -13,14 +13,12 @@
#include <Library/PcdLib.h> // PcdGet64()
#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APE...
#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilit...
#include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...
#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...

-#include "PciHostBridge.h"
-
STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };


/**
Return all the root bridge instances in an array.

@@ -39,16 +37,12 @@ PciHostBridgeGetRootBridges (
UINT64 Attributes;
UINT64 AllocationAttributes;
PCI_ROOT_BRIDGE_APERTURE Io;
PCI_ROOT_BRIDGE_APERTURE Mem;
PCI_ROOT_BRIDGE_APERTURE MemAbove4G;

- if (PcdGetBool (PcdPciDisableBusEnumeration)) {
- return ScanForRootBridges (Count);
- }
-
ZeroMem (&Io, sizeof (Io));
ZeroMem (&Mem, sizeof (Mem));
ZeroMem (&MemAbove4G, sizeof (MemAbove4G));

Attributes = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO |
EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO |
diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
deleted file mode 100644
index 07c498dd0ea2..000000000000
--- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+++ /dev/null
@@ -1,471 +0,0 @@
-/** @file
- Scan the entire PCI bus for root bridges to support OVMF above Xen.
-
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <IndustryStandard/Pci.h> // EFI_PCI_COMMAND_IO_SPACE
-#include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVICE_ID
-#include <Library/BaseLib.h> // DisableInterrupts()
-#include <Library/BaseMemoryLib.h> // ZeroMem()
-#include <Library/DebugLib.h> // ASSERT()
-#include <Library/MemoryAllocationLib.h> // ReallocatePool()
-#include <Library/PcdLib.h> // PcdGet16()
-#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APERTURE
-#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilityInitRoot...
-#include <Library/PciLib.h> // PciRead32()
-#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_ISA_IO
-
-#include "PciHostBridge.h"
-
-STATIC
-VOID
-PcatPciRootBridgeBarExisted (
- IN UINTN Address,
- OUT UINT32 *OriginalValue,
- OUT UINT32 *Value
- )
-{
- //
- // Preserve the original value
- //
- *OriginalValue = PciRead32 (Address);
-
- //
- // Disable timer interrupt while the BAR is probed
- //
- DisableInterrupts ();
-
- PciWrite32 (Address, 0xFFFFFFFF);
- *Value = PciRead32 (Address);
- PciWrite32 (Address, *OriginalValue);
-
- //
- // Enable interrupt
- //
- EnableInterrupts ();
-}
-
-#define PCI_COMMAND_DECODE ((UINT16)(EFI_PCI_COMMAND_IO_SPACE | \
- EFI_PCI_COMMAND_MEMORY_SPACE))
-STATIC
-VOID
-PcatPciRootBridgeDecodingDisable (
- IN UINTN Address
- )
-{
- UINT16 Value;
-
- Value = PciRead16 (Address);
- if (Value & PCI_COMMAND_DECODE) {
- PciWrite16 (Address, Value & ~(UINT32)PCI_COMMAND_DECODE);
- }
-}
-
-STATIC
-VOID
-PcatPciRootBridgeParseBars (
- IN UINT16 Command,
- IN UINTN Bus,
- IN UINTN Device,
- IN UINTN Function,
- IN UINTN BarOffsetBase,
- IN UINTN BarOffsetEnd,
- IN PCI_ROOT_BRIDGE_APERTURE *Io,
- IN PCI_ROOT_BRIDGE_APERTURE *Mem,
- IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G
-
-)
-{
- UINT32 OriginalValue;
- UINT32 Value;
- UINT32 OriginalUpperValue;
- UINT32 UpperValue;
- UINT64 Mask;
- UINTN Offset;
- UINT64 Base;
- UINT64 Length;
- UINT64 Limit;
- PCI_ROOT_BRIDGE_APERTURE *MemAperture;
-
- // Disable address decoding for every device before OVMF starts sizing it
- PcatPciRootBridgeDecodingDisable (
- PCI_LIB_ADDRESS (Bus, Device, Function, PCI_COMMAND_OFFSET)
- );
-
- for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) {
- PcatPciRootBridgeBarExisted (
- PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
- &OriginalValue, &Value
- );
- if (Value == 0) {
- continue;
- }
- if ((Value & BIT0) == BIT0) {
- //
- // IO Bar
- //
- if (Command & EFI_PCI_COMMAND_IO_SPACE) {
- Mask = 0xfffffffc;
- Base = OriginalValue & Mask;
- Length = ((~(Value & Mask)) & Mask) + 0x04;
- if (!(Value & 0xFFFF0000)) {
- Length &= 0x0000FFFF;
- }
- Limit = Base + Length - 1;
-
- if (Base < Limit) {
- if (Io->Base > Base) {
- Io->Base = Base;
- }
- if (Io->Limit < Limit) {
- Io->Limit = Limit;
- }
- }
- }
- } else {
- //
- // Mem Bar
- //
- if (Command & EFI_PCI_COMMAND_MEMORY_SPACE) {
-
- Mask = 0xfffffff0;
- Base = OriginalValue & Mask;
- Length = Value & Mask;
-
- if ((Value & (BIT1 | BIT2)) == 0) {
- //
- // 32bit
- //
- Length = ((~Length) + 1) & 0xffffffff;
-
- MemAperture = Mem;
- } else {
- //
- // 64bit
- //
- Offset += 4;
- PcatPciRootBridgeBarExisted (
- PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
- &OriginalUpperValue,
- &UpperValue
- );
-
- Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32);
- Length = Length | LShiftU64 ((UINT64) UpperValue, 32);
- Length = (~Length) + 1;
-
- if (Base < BASE_4GB) {
- MemAperture = Mem;
- } else {
- MemAperture = MemAbove4G;
- }
- }
-
- Limit = Base + Length - 1;
- if (Base < Limit) {
- if (MemAperture->Base > Base) {
- MemAperture->Base = Base;
- }
- if (MemAperture->Limit < Limit) {
- MemAperture->Limit = Limit;
- }
- }
- }
- }
- }
-}
-
-STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };
-
-PCI_ROOT_BRIDGE *
-ScanForRootBridges (
- UINTN *NumberOfRootBridges
- )
-{
- UINTN PrimaryBus;
- UINTN SubBus;
- UINT8 Device;
- UINT8 Function;
- UINTN NumberOfDevices;
- UINTN Address;
- PCI_TYPE01 Pci;
- UINT64 Attributes;
- UINT64 Base;
- UINT64 Limit;
- UINT64 Value;
- PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, *MemAperture;
- PCI_ROOT_BRIDGE *RootBridges;
- UINTN BarOffsetEnd;
-
-
- *NumberOfRootBridges = 0;
- RootBridges = NULL;
-
- //
- // After scanning all the PCI devices on the PCI root bridge's primary bus,
- // update the Primary Bus Number for the next PCI root bridge to be this PCI
- // root bridge's subordinate bus number + 1.
- //
- for (PrimaryBus = 0; PrimaryBus <= PCI_MAX_BUS; PrimaryBus = SubBus + 1) {
- SubBus = PrimaryBus;
- Attributes = 0;
-
- ZeroMem (&Io, sizeof (Io));
- ZeroMem (&Mem, sizeof (Mem));
- ZeroMem (&MemAbove4G, sizeof (MemAbove4G));
- Io.Base = Mem.Base = MemAbove4G.Base = MAX_UINT64;
- //
- // Scan all the PCI devices on the primary bus of the PCI root bridge
- //
- for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {
-
- for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
-
- //
- // Compute the PCI configuration address of the PCI device to probe
- //
- Address = PCI_LIB_ADDRESS (PrimaryBus, Device, Function, 0);
-
- //
- // Read the Vendor ID from the PCI Configuration Header
- //
- if (PciRead16 (Address) == MAX_UINT16) {
- if (Function == 0) {
- //
- // If the PCI Configuration Read fails, or a PCI device does not
- // exist, then skip this entire PCI device
- //
- break;
- } else {
- //
- // If PCI function != 0, VendorId == 0xFFFF, we continue to search
- // PCI function.
- //
- continue;
- }
- }
-
- //
- // Read the entire PCI Configuration Header
- //
- PciReadBuffer (Address, sizeof (Pci), &Pci);
-
- //
- // Increment the number of PCI device found on the primary bus of the
- // PCI root bridge
- //
- NumberOfDevices++;
-
- //
- // Look for devices with the VGA Palette Snoop enabled in the COMMAND
- // register of the PCI Config Header
- //
- if ((Pci.Hdr.Command & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) != 0) {
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
- }
-
- BarOffsetEnd = 0;
-
- //
- // PCI-PCI Bridge
- //
- if (IS_PCI_BRIDGE (&Pci)) {
- //
- // Get the Bus range that the PPB is decoding
- //
- if (Pci.Bridge.SubordinateBus > SubBus) {
- //
- // If the subordinate bus number of the PCI-PCI bridge is greater
- // than the PCI root bridge's current subordinate bus number,
- // then update the PCI root bridge's subordinate bus number
- //
- SubBus = Pci.Bridge.SubordinateBus;
- }
-
- //
- // Get the I/O range that the PPB is decoding
- //
- Value = Pci.Bridge.IoBase & 0x0f;
- Base = ((UINT32) Pci.Bridge.IoBase & 0xf0) << 8;
- Limit = (((UINT32) Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
- if (Value == BIT0) {
- Base |= ((UINT32) Pci.Bridge.IoBaseUpper16 << 16);
- Limit |= ((UINT32) Pci.Bridge.IoLimitUpper16 << 16);
- }
- if (Base < Limit) {
- if (Io.Base > Base) {
- Io.Base = Base;
- }
- if (Io.Limit < Limit) {
- Io.Limit = Limit;
- }
- }
-
- //
- // Get the Memory range that the PPB is decoding
- //
- Base = ((UINT32) Pci.Bridge.MemoryBase & 0xfff0) << 16;
- Limit = (((UINT32) Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
- if (Base < Limit) {
- if (Mem.Base > Base) {
- Mem.Base = Base;
- }
- if (Mem.Limit < Limit) {
- Mem.Limit = Limit;
- }
- }
-
- //
- // Get the Prefetchable Memory range that the PPB is decoding
- // and merge it into Memory range
- //
- Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;
- Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
- Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
- << 16) | 0xfffff;
- MemAperture = &Mem;
- if (Value == BIT0) {
- Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);
- Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
- MemAperture = &MemAbove4G;
- }
- if (Base < Limit) {
- if (MemAperture->Base > Base) {
- MemAperture->Base = Base;
- }
- if (MemAperture->Limit < Limit) {
- MemAperture->Limit = Limit;
- }
- }
-
- //
- // Look at the PPB Configuration for legacy decoding attributes
- //
- if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA)
- == EFI_PCI_BRIDGE_CONTROL_ISA) {
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
- }
- if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA)
- == EFI_PCI_BRIDGE_CONTROL_VGA) {
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
- if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16)
- != 0) {
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
- }
- }
-
- BarOffsetEnd = OFFSET_OF (PCI_TYPE01, Bridge.Bar[2]);
- } else {
- //
- // Parse the BARs of the PCI device to get what I/O Ranges, Memory
- // Ranges, and Prefetchable Memory Ranges the device is decoding
- //
- if ((Pci.Hdr.HeaderType & HEADER_LAYOUT_CODE) == HEADER_TYPE_DEVICE) {
- BarOffsetEnd = OFFSET_OF (PCI_TYPE00, Device.Bar[6]);
- }
- }
-
- PcatPciRootBridgeParseBars (
- Pci.Hdr.Command,
- PrimaryBus,
- Device,
- Function,
- OFFSET_OF (PCI_TYPE00, Device.Bar),
- BarOffsetEnd,
- &Io,
- &Mem, &MemAbove4G
- );
-
- //
- // See if the PCI device is an IDE controller
- //
- if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE,
- PCI_CLASS_MASS_STORAGE_IDE)) {
- if (Pci.Hdr.ClassCode[0] & 0x80) {
- Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
- }
- if (Pci.Hdr.ClassCode[0] & 0x01) {
- Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
- }
- if (Pci.Hdr.ClassCode[0] & 0x04) {
- Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
- }
- }
-
- //
- // See if the PCI device is a legacy VGA controller or
- // a standard VGA controller
- //
- if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||
- IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)
- ) {
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
- }
-
- //
- // See if the PCI Device is a PCI - ISA or PCI - EISA
- // or ISA_POSITIVE_DECODE Bridge device
- //
- if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
- if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA ||
- Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA ||
- Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) {
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
- Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
- }
- }
-
- //
- // If this device is not a multi function device, then skip the rest
- // of this PCI device
- //
- if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {
- break;
- }
- }
- }
-
- //
- // If at least one PCI device was found on the primary bus of this PCI
- // root bridge, then the PCI root bridge exists.
- //
- if (NumberOfDevices > 0) {
- RootBridges = ReallocatePool (
- (*NumberOfRootBridges) * sizeof (PCI_ROOT_BRIDGE),
- (*NumberOfRootBridges + 1) * sizeof (PCI_ROOT_BRIDGE),
- RootBridges
- );
- ASSERT (RootBridges != NULL);
- PciHostBridgeUtilityInitRootBridge (
- Attributes, Attributes, 0,
- FALSE, PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
- (UINT8) PrimaryBus, (UINT8) SubBus,
- &Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,
- &RootBridges[*NumberOfRootBridges]
- );
- RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;
- //
- // Increment the index for the next PCI Root Bridge
- //
- (*NumberOfRootBridges)++;
- }
- }
-
- return RootBridges;
-}
--
2.19.1.3.g30247aa5d201


[PATCH 31/43] OvmfPkg/OvmfXen: consume PciHostBridgeLibScan

Laszlo Ersek
 

Switch the OvmfXen platform from the "OvmfPkg/PciHostBridgeLib" instance
to the "OvmfPkg/PciHostBridgeLibScan" instance. Currently this is a no-op
functionally; we'll customize the "PciHostBridgeLibScan" instance later.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/OvmfXen.dsc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 2d32c5734fa7..0986d9f5c356 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -554,13 +554,13 @@ [Components]
OvmfPkg/XenTimerDxe/XenTimerDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
- PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
}
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
--
2.19.1.3.g30247aa5d201


[PATCH 30/43] OvmfPkg/Bhyve: consume PciHostBridgeLibScan

Laszlo Ersek
 

Switch the Bhyve platform from the "OvmfPkg/PciHostBridgeLib" instance to
the "OvmfPkg/PciHostBridgeLibScan" instance. Currently this is a no-op
functionally; we'll customize the "PciHostBridgeLibScan" instance later.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Bhyve/BhyveX64.dsc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 30a99e2a3425..d8792812ab21 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -663,13 +663,13 @@ [Components]
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
- PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
}
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
<LibraryClasses>
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
--
2.19.1.3.g30247aa5d201


[PATCH 29/43] OvmfPkg/PciHostBridgeLibScan: create from PciHostBridgeLib

Laszlo Ersek
 

Create an almost verbatim copy of the
"OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf" library instance.

The new PciHostBridgeLibScan instance will ultimately duplicate a
negligible amount of code from the original, and will be used by the Bhyve
and OvmfXen platforms.

List the new driver in "Maintainers.txt", in the "OvmfPkg: bhyve-related
modules" and "OvmfPkg: Xen-related modules" sections.

This patch should be reviewed with "git show --find-copies-harder".

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/{PciHostBridgeLib/PciHostBridgeLib.inf => PciHostBridgeLibScan/PciHostBridgeLibScan.inf} | 6 +++---
Maintainers.txt | 2 ++
OvmfPkg/Library/{PciHostBridgeLib => PciHostBridgeLibScan}/PciHostBridge.h | 1 +
OvmfPkg/Library/{PciHostBridgeLib => PciHostBridgeLibScan}/PciHostBridgeLib.c | 2 +-
OvmfPkg/Library/{PciHostBridgeLib => PciHostBridgeLibScan}/XenSupport.c | 1 +
5 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
similarity index 84%
copy from OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
copy to OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
index 622780888472..46859388870f 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLibScan.inf
@@ -1,21 +1,21 @@
## @file
# OVMF's instance of the PCI Host Bridge Library.
#
-# Copyright (C) 2016, Red Hat, Inc.
+# Copyright (C) 2016-2021, Red Hat, Inc.
# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##

[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = PciHostBridgeLib
- FILE_GUID = 9F2BC05E-51EA-4AED-9A3E-7699641734E8
+ BASE_NAME = PciHostBridgeLibScan
+ FILE_GUID = c93f2411-9bf5-4894-b552-67fae0c3d291
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PciHostBridgeLib

#
# The following information is for reference only and not required by the build
diff --git a/Maintainers.txt b/Maintainers.txt
index be40a1d6f2b6..a273409a923f 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -432,12 +432,13 @@ OvmfPkg: bhyve-related modules
F: OvmfPkg/Bhyve/
F: OvmfPkg/Include/IndustryStandard/Bhyve.h
F: OvmfPkg/Include/Library/BhyveFwCtlLib.h
F: OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.c
F: OvmfPkg/Library/AcpiTimerLib/BaseAcpiTimerLibBhyve.inf
F: OvmfPkg/Library/BhyveFwCtlLib/
+F: OvmfPkg/Library/PciHostBridgeLibScan/
F: OvmfPkg/Library/PlatformBootManagerLibBhyve/
F: OvmfPkg/Library/ResetSystemLib/BaseResetShutdownBhyve.c
F: OvmfPkg/Library/ResetSystemLib/BaseResetSystemLibBhyve.inf
R: Rebecca Cran <rebecca@bsdio.com>
R: Peter Grehan <grehan@freebsd.org>

@@ -490,12 +491,13 @@ F: OvmfPkg/Include/IndustryStandard/Xen/
F: OvmfPkg/Include/Library/XenHypercallLib.h
F: OvmfPkg/Include/Library/XenIoMmioLib.h
F: OvmfPkg/Include/Library/XenPlatformLib.h
F: OvmfPkg/Include/Protocol/XenBus.h
F: OvmfPkg/Include/Protocol/XenIo.h
F: OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+F: OvmfPkg/Library/PciHostBridgeLibScan/
F: OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
F: OvmfPkg/Library/XenConsoleSerialPortLib/
F: OvmfPkg/Library/XenHypercallLib/
F: OvmfPkg/Library/XenIoMmioLib/
F: OvmfPkg/Library/XenPlatformLib/
F: OvmfPkg/Library/XenRealTimeClockLib/
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
similarity index 83%
copy from OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h
copy to OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
index a2e4d8696281..582b7929aff2 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridge.h
@@ -1,9 +1,10 @@
/** @file
Header file of OVMF instance of PciHostBridgeLib.

+ Copyright (C) 2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
similarity index 95%
copy from OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
copy to OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
index 6db91fb7e20c..6c2acc9f99bc 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/PciHostBridgeLib.c
@@ -1,10 +1,10 @@
/** @file
OVMF's instance of the PCI Host Bridge Library.

- Copyright (C) 2016, Red Hat, Inc.
+ Copyright (C) 2016-2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/
#include <IndustryStandard/Pci.h> // PCI_MAX_BUS
diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
similarity index 96%
copy from OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
copy to OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
index 07c498dd0ea2..a4a61e5836e0 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLibScan/XenSupport.c
@@ -1,9 +1,10 @@
/** @file
Scan the entire PCI bus for root bridges to support OVMF above Xen.

+ Copyright (C) 2021, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

--
2.19.1.3.g30247aa5d201


[PATCH 28/43] OvmfPkg/PciHostBridgeLib: consolidate #includes and INF file sections #includes

Laszlo Ersek
 

- In every C file, list every necessary public #include individually, with
an example identifier that's actually consumed.

- Place all public #includes first, all module-private #includes second.
Separate them with a single empty line. Keep each section sorted in
itself.

- Sort all sections in the INF file, except [Defines].

- Add unlisted lib classes.

- Remove unnecessary #include directives, add unlisted #include
directives.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 7 +++---
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 22 +++++++-----------
OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 24 +++++++++-----------
3 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
index 4610a0c1490b..622780888472 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
@@ -22,32 +22,33 @@ [Defines]
# tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#

[Sources]
+ PciHostBridge.h
PciHostBridgeLib.c
XenSupport.c
- PciHostBridge.h

[Packages]
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec

[LibraryClasses]
+ BaseLib
BaseMemoryLib
DebugLib
MemoryAllocationLib
PcdLib
PciHostBridgeUtilityLib
PciLib

[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 7d9fb0fb293a..6db91fb7e20c 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -4,29 +4,23 @@
Copyright (C) 2016, Red Hat, Inc.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/
-#include <PiDxe.h>
+#include <IndustryStandard/Pci.h> // PCI_MAX_BUS
+#include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVIC...
+#include <Library/BaseMemoryLib.h> // ZeroMem()
+#include <Library/PcdLib.h> // PcdGet64()
+#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APE...
+#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilit...
+#include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...
+#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...

-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Q35MchIch9.h>
-
-#include <Protocol/PciHostBridgeResourceAllocation.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PciHostBridgeLib.h>
-#include <Library/PciHostBridgeUtilityLib.h>
#include "PciHostBridge.h"

-
STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };


/**
Return all the root bridge instances in an array.

diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
index 9ef39f01821b..07c498dd0ea2 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
@@ -3,27 +3,25 @@

Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/
-#include <PiDxe.h>

-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Q35MchIch9.h>
+#include <IndustryStandard/Pci.h> // EFI_PCI_COMMAND_IO_SPACE
+#include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVICE_ID
+#include <Library/BaseLib.h> // DisableInterrupts()
+#include <Library/BaseMemoryLib.h> // ZeroMem()
+#include <Library/DebugLib.h> // ASSERT()
+#include <Library/MemoryAllocationLib.h> // ReallocatePool()
+#include <Library/PcdLib.h> // PcdGet16()
+#include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APERTURE
+#include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilityInitRoot...
+#include <Library/PciLib.h> // PciRead32()
+#include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_ISA_IO

-#include <Protocol/PciHostBridgeResourceAllocation.h>
-#include <Protocol/PciRootBridgeIo.h>
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PciHostBridgeLib.h>
-#include <Library/PciHostBridgeUtilityLib.h>
-#include <Library/PciLib.h>
#include "PciHostBridge.h"

STATIC
VOID
PcatPciRootBridgeBarExisted (
IN UINTN Address,
--
2.19.1.3.g30247aa5d201


[PATCH 27/43] OvmfPkg/IncompatiblePciDeviceSupportDxe: remove PcdPciDisableBusEnumeration

Laszlo Ersek
 

At this point, the IncompatiblePciDeviceSupportDxe driver is included in
the following platforms in edk2:

OvmfPkg/AmdSev/AmdSevX64.dsc
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc

All those platforms inherit FALSE for "PcdPciDisableBusEnumeration" from
"MdeModulePkg.dec".

This makes the PcdGetBool() call in the entry point of the driver
superfluous; remove it. Clean up now unused dependencies in the INF file
as well.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf | 2 --
OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c | 10 +++-------
2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
index f08b6f4bd4b4..c3e6bb944791 100644
--- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
+++ b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
@@ -17,13 +17,12 @@ [Defines]
ENTRY_POINT = DriverInitialize

[Sources]
IncompatiblePciDeviceSupport.c

[Packages]
- MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec

[LibraryClasses]
DebugLib
MemoryAllocationLib
@@ -33,11 +32,10 @@ [LibraryClasses]

[Protocols]
gEfiIncompatiblePciDeviceSupportProtocolGuid ## SOMETIMES_PRODUCES
gEfiLegacyBiosProtocolGuid ## NOTIFY

[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## CONSUMES
gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size ## CONSUMES

[Depex]
TRUE
diff --git a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
index 53c768167de9..db1532f10934 100644
--- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
+++ b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c
@@ -263,20 +263,16 @@ DriverInitialize (
{
EFI_STATUS Status;
EFI_EVENT Event;
VOID *Registration;

//
- // If the PCI Bus driver is not supposed to allocate resources, then it makes
- // no sense to install a protocol that influences the resource allocation.
+ // If there is no 64-bit PCI MMIO aperture, then 64-bit MMIO BARs have to be
+ // allocated under 4 GB unconditionally.
//
- // Similarly, if there is no 64-bit PCI MMIO aperture, then 64-bit MMIO BARs
- // have to be allocated under 4 GB unconditionally.
- //
- if (PcdGetBool (PcdPciDisableBusEnumeration) ||
- PcdGet64 (PcdPciMmio64Size) == 0) {
+ if (PcdGet64 (PcdPciMmio64Size) == 0) {
return EFI_UNSUPPORTED;
}

//
// Otherwise, create a protocol notify to see if a CSM is present. (With the
// CSM absent, the PCI Bus driver won't have to worry about allocating 64-bit
--
2.19.1.3.g30247aa5d201


[PATCH 26/43] OvmfPkg/Bhyve: remove IncompatiblePciDeviceSupport DXE driver

Laszlo Ersek
 

The entry point function of "OvmfPkg/IncompatiblePciDeviceSupportDxe",
namely DriverInitialize()
[OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c],
bails out immediately if "PcdPciDisableBusEnumeration" is TRUE.

The Bhyve platform statically assigns this PCD TRUE. Thus, remove the
driver from the Bhyve platform.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Bhyve/BhyveX64.dsc | 1 -
OvmfPkg/Bhyve/BhyveX64.fdf | 1 -
2 files changed, 2 deletions(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 896b62881bdb..30a99e2a3425 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -660,13 +660,12 @@ [Components]
}

MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
- OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.fdf b/OvmfPkg/Bhyve/BhyveX64.fdf
index f4050c4934b7..3eff36dac18f 100644
--- a/OvmfPkg/Bhyve/BhyveX64.fdf
+++ b/OvmfPkg/Bhyve/BhyveX64.fdf
@@ -207,13 +207,12 @@ [FV.DXEFV]
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
-INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
--
2.19.1.3.g30247aa5d201


Re: [PATCH 24/43] OvmfPkg/Bhyve: make "PcdPciDisableBusEnumeration" Fixed-at-Build

Rebecca Cran
 

On 5/26/21 2:14 PM, Laszlo Ersek wrote:
The Bhyve platform specifies the dynamic access method for
"PcdPciDisableBusEnumeration" needlessly.

After the DSC file sets the PCD to TRUE by default, the PCD is never
written again. In particular, the
"OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf" file references the PCD
superfluously.

Make the PCD Fixed-At-Build, and remove the PCD reference from the INF
file.

(Note that further simplifications are possible in
"OvmfPkg/Bhyve/AcpiPlatformDxe", but those are out of scope for this patch
series.)

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Bhyve/BhyveX64.dsc | 2 +-
OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 7d9e88040000..896b62881bdb 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -428,12 +428,13 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
[PcdsFixedAtBuild]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0
@@ -526,13 +527,12 @@ [PcdsDynamicDefault]
# ($(SMM_REQUIRE) == FALSE)
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0
diff --git a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
index 12203e9f804d..739d63098b1e 100644
--- a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
@@ -83,13 +83,12 @@ [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask
gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy

Reviewed-by: Rebecca Cran <rebecca@bsdio.com>


[PATCH 25/43] OvmfPkg/OvmfXen: remove IncompatiblePciDeviceSupport DXE driver

Laszlo Ersek
 

The entry point function of "OvmfPkg/IncompatiblePciDeviceSupportDxe",
namely DriverInitialize()
[OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c],
bails out immediately if "PcdPciDisableBusEnumeration" is TRUE.

The OvmfXen platform statically assigns this PCD TRUE. Thus, remove the
driver from the OvmfXen platform.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/OvmfXen.dsc | 1 -
OvmfPkg/OvmfXen.fdf | 1 -
2 files changed, 2 deletions(-)

diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 779bcc3f8b9a..2d32c5734fa7 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -551,13 +551,12 @@ [Components]
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf

MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
OvmfPkg/XenTimerDxe/XenTimerDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuDxe/CpuDxe.inf
- OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf
index 8daa000de46a..9acc7c93b98b 100644
--- a/OvmfPkg/OvmfXen.fdf
+++ b/OvmfPkg/OvmfXen.fdf
@@ -298,13 +298,12 @@ [FV.DXEFV]
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
INF OvmfPkg/XenTimerDxe/XenTimerDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
--
2.19.1.3.g30247aa5d201


Re: [PATCH 17/43] OvmfPkg/Bhyve/AcpiPlatformDxe: fix file path typo in comment

Rebecca Cran
 

On 5/26/21 2:14 PM, Laszlo Ersek wrote:

The built-in ACPI tables for Bhyve are located in the
"OvmfPkg/Bhyve/AcpiTables" module, not in the "OvmfPkg/AcpiTables" module.
Correct the typo in a code comment.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
index d5c78c61d5ad..9ccdb4d91cd1 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
@@ -129,13 +129,13 @@ LocateFvInstanceWithTables (
Find ACPI tables in an FV and install them.
This is now a fall-back path. Normally, we will search for tables provided
by the VMM first.
If that fails, we use this function to load the ACPI tables from an FV. The
- sources for the FV based tables is located under OvmfPkg/AcpiTables.
+ sources for the FV based tables is located under OvmfPkg/Bhyve/AcpiTables.
@param AcpiTable Protocol instance pointer
**/
EFI_STATUS
EFIAPI
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>


[PATCH 24/43] OvmfPkg/Bhyve: make "PcdPciDisableBusEnumeration" Fixed-at-Build

Laszlo Ersek
 

The Bhyve platform specifies the dynamic access method for
"PcdPciDisableBusEnumeration" needlessly.

After the DSC file sets the PCD to TRUE by default, the PCD is never
written again. In particular, the
"OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf" file references the PCD
superfluously.

Make the PCD Fixed-At-Build, and remove the PCD reference from the INF
file.

(Note that further simplifications are possible in
"OvmfPkg/Bhyve/AcpiPlatformDxe", but those are out of scope for this patch
series.)

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/Bhyve/BhyveX64.dsc | 2 +-
OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 7d9e88040000..896b62881bdb 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -428,12 +428,13 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE

[PcdsFixedAtBuild]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|0
@@ -526,13 +527,12 @@ [PcdsDynamicDefault]
# ($(SMM_REQUIRE) == FALSE)
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0
diff --git a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
index 12203e9f804d..739d63098b1e 100644
--- a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
@@ -83,13 +83,12 @@ [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd
gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask
gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy
--
2.19.1.3.g30247aa5d201


[PATCH 23/43] OvmfPkg: drop PcdPciDisableBusEnumeration from the AmdSev platform

Laszlo Ersek
 

With the Xen-dependent PcdSetBoolS() call removed from
OvmfPkg/PlatformPei, the "AmdSevX64.dsc" platform never writes
"PcdPciDisableBusEnumeration". This means we don't need a dynamic default
for the PCD in the DSC file; it could be declared Fixed-at-Build.

However, because the PCD's default value in "MdeModulePkg.dec" is FALSE,
remove the (same-value) platform default altogether.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
OvmfPkg/AmdSev/AmdSevX64.dsc | 1 -
1 file changed, 1 deletion(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 9e7c459e9a8b..1d487befae08 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -532,13 +532,12 @@ [PcdsFixedAtBuild]
[PcdsDynamicDefault]
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0
--
2.19.1.3.g30247aa5d201

8401 - 8420 of 84037