]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/PlatformHasAcpiDtDxe: don't expose DT if QEMU provides ACPI
authorLaszlo Ersek <lersek@redhat.com>
Fri, 17 Mar 2017 16:50:24 +0000 (17:50 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 28 Mar 2017 12:18:47 +0000 (14:18 +0200)
This will let QEMU's "-no-acpi" option exclusively expose DT vs. ACPI to
the guest. Showing both is never needed (it is actually detrimental to the
adoption of standards, such as SBSA / SBBR).

* Without "-no-acpi", the firmware logs (from PlatformHasAcpiDtDxe)

> Found FwCfg @ 0x9020008/0x9020000
> Found FwCfg DMA @ 0x9020010
> InstallProtocolInterface: [EdkiiPlatformHasAcpi] 0

plus the usual messages. Later the guest kernel logs

> [    0.000000] efi:  SMBIOS 3.0=0x13bdb0000  ACPI 2.0=0x138440000
>                      MEMATTR=0x13a675018

before it lists the ACPI tables one by one.

In addition, in the guest, the "/sys/firmware/devicetree/*" shell pattern
matches no files, while the "/sys/firmware/acpi/tables/*" pattern matches
the ACPI tables.

* With "-no-acpi", the firmware logs:

> PlatformHasAcpiDtDxe | Found FwCfg @ 0x9020008/0x9020000
> PlatformHasAcpiDtDxe | Found FwCfg DMA @ 0x9020010
> PlatformHasAcpiDtDxe | InstallProtocolInterface:
> PlatformHasAcpiDtDxe | [EdkiiPlatformHasDeviceTree] 0
> FdtClientDxe         | OnPlatformHasDeviceTree: exposing DTB @
> FdtClientDxe         | 0x13FFBF000 to OS
> ...
> DXE_CORE             | Driver [AcpiTableDxe] was discovered but not
> DXE_CORE             | loaded!!
> DXE_CORE             | Driver [QemuFwCfgAcpiPlatform] was discovered but
> DXE_CORE             | not loaded!!
> ...
> RamDiskDxe           | RamDiskAcpiCheck: Cannot locate the EFI ACPI
> RamDiskDxe           | Table Protocol, unable to publish RAM disks to
> RamDiskDxe           | NFIT.

(BootGraphicsResourceTableDxe's ReadyToBoot callback --
InstallBootGraphicsResourceTable() -- handles the lack of
EFI_ACPI_TABLE_PROTOCOL silently.) Later the guest kernel logs

> [    0.000000] efi:  SMBIOS 3.0=0x13bdb0000  MEMATTR=0x138caa018

In addition, in the guest, the "/sys/firmware/devicetree/*" shell pattern
matches the directory "/sys/firmware/devicetree/base", which contains a
large number of DT nodes, while the "/sys/firmware/acpi/tables/*" pattern
matches no files.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1430262
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf

index a718ce1b5a7b28fe690aa5360813f6a3cc9f007d..8932dacabec5e72a82db7b10af87daae502941b3 100644 (file)
@@ -17,7 +17,7 @@
 #include <Guid/PlatformHasDeviceTree.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
+#include <Library/QemuFwCfgLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 \r
 EFI_STATUS\r
@@ -27,18 +27,27 @@ PlatformHasAcpiDt (
   IN EFI_SYSTEM_TABLE *SystemTable\r
   )\r
 {\r
-  EFI_STATUS Status;\r
-\r
-  Status = EFI_SUCCESS;\r
+  EFI_STATUS           Status;\r
+  FIRMWARE_CONFIG_ITEM FwCfgItem;\r
+  UINTN                FwCfgSize;\r
 \r
   //\r
   // If we fail to install any of the necessary protocols below, the OS will be\r
   // unbootable anyway (due to lacking hardware description), so tolerate no\r
   // errors here.\r
   //\r
-  // Always make ACPI available on 64-bit systems.\r
-  //\r
-  if (MAX_UINTN == MAX_UINT64) {\r
+  if (MAX_UINTN == MAX_UINT64 &&\r
+      !EFI_ERROR (\r
+         QemuFwCfgFindFile (\r
+           "etc/table-loader",\r
+           &FwCfgItem,\r
+           &FwCfgSize\r
+           )\r
+         )) {\r
+    //\r
+    // Only make ACPI available on 64-bit systems, and only if QEMU generates\r
+    // (a subset of) the ACPI tables.\r
+    //\r
     Status = gBS->InstallProtocolInterface (\r
                     &ImageHandle,\r
                     &gEdkiiPlatformHasAcpiGuid,\r
@@ -48,21 +57,21 @@ PlatformHasAcpiDt (
     if (EFI_ERROR (Status)) {\r
       goto Failed;\r
     }\r
+\r
+    return Status;\r
   }\r
 \r
   //\r
-  // Expose the Device Tree unless PcdPureAcpiBoot is set.\r
+  // Expose the Device Tree otherwise.\r
   //\r
-  if (!FeaturePcdGet (PcdPureAcpiBoot)) {\r
-    Status = gBS->InstallProtocolInterface (\r
-                    &ImageHandle,\r
-                    &gEdkiiPlatformHasDeviceTreeGuid,\r
-                    EFI_NATIVE_INTERFACE,\r
-                    NULL\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      goto Failed;\r
-    }\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &ImageHandle,\r
+                  &gEdkiiPlatformHasDeviceTreeGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    goto Failed;\r
   }\r
 \r
   return Status;\r
index 2450500b3f0e05ada0677b77348f5049654ee24d..4466bead57c27866663543a5f33334655a519692 100644 (file)
   PlatformHasAcpiDtDxe.c\r
 \r
 [Packages]\r
-  ArmVirtPkg/ArmVirtPkg.dec\r
   EmbeddedPkg/EmbeddedPkg.dec\r
   MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
   BaseLib\r
   DebugLib\r
-  PcdLib\r
+  QemuFwCfgLib\r
   UefiBootServicesTableLib\r
   UefiDriverEntryPoint\r
 \r
@@ -40,8 +40,5 @@
   gEdkiiPlatformHasAcpiGuid       ## SOMETIMES_PRODUCES ## PROTOCOL\r
   gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL\r
 \r
-[FeaturePcd]\r
-  gArmVirtTokenSpaceGuid.PcdPureAcpiBoot ## CONSUMES\r
-\r
 [Depex]\r
   TRUE\r