ArmVirtPkg/VirtFdtDxe: make installation of FDT as config table optional

The arm64 kernel is hardwired to prefer DT over ACPI, unless 'acpi=force'
is passed on the kernel command line. The only other way to force the
kernel to use ACPI is not to pass an FDT to it in the first place. So
introduce a PCD that inhibits the installation of the QEMU supplied FDT
as a configuration table.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Ard Biesheuvel 2016-03-31 13:00:07 +02:00
parent 5eae4ff002
commit 7a63d29151
3 changed files with 48 additions and 31 deletions

View File

@ -98,3 +98,12 @@
# The default is to turn off the kludge; DSC's can selectively enable it.
#
gArmVirtTokenSpaceGuid.PcdKludgeMapPciMmioAsCached|FALSE|BOOLEAN|0x00000006
#
# Pure ACPI boot
#
# Inhibit installation of the FDT as a configuration table if this feature
# PCD is TRUE. Otherwise, the OS is presented with both a DT and an ACPI
# description of the platform, and it is up to the OS to choose.
#
gArmVirtTokenSpaceGuid.PcdPureAcpiBoot|FALSE|BOOLEAN|0x0000000a

View File

@ -317,9 +317,6 @@ InitializeVirtFdtDxe (
return EFI_NOT_FOUND;
}
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeBase);
ASSERT_EFI_ERROR (Status);
DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, DeviceTreeBase));
RtcNode = -1;
@ -571,39 +568,47 @@ InitializeVirtFdtDxe (
}
}
//
// UEFI takes ownership of the RTC hardware, and exposes its functionality
// through the UEFI Runtime Services GetTime, SetTime, etc. This means we
// need to disable it in the device tree to prevent the OS from attaching its
// device driver as well.
//
if ((RtcNode != -1) &&
fdt_setprop_string (DeviceTreeBase, RtcNode, "status",
"disabled") != 0) {
DEBUG ((EFI_D_WARN, "Failed to set PL031 status to 'disabled'\n"));
}
if (!FeaturePcdGet (PcdPureAcpiBoot)) {
//
// Only install the FDT as a configuration table if we want to leave it up
// to the OS to decide whether it prefers ACPI over DT.
//
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeBase);
ASSERT_EFI_ERROR (Status);
if (HavePci) {
//
// Set the /chosen/linux,pci-probe-only property to 1, so that the PCI
// setup we will perform in the firmware is honored by the Linux OS,
// rather than torn down and done from scratch. This is generally a more
// sensible approach, and aligns with what ACPI based OSes do in general.
// UEFI takes ownership of the RTC hardware, and exposes its functionality
// through the UEFI Runtime Services GetTime, SetTime, etc. This means we
// need to disable it in the device tree to prevent the OS from attaching its
// device driver as well.
//
// In case we are exposing an emulated VGA PCI device to the guest, which
// may subsequently get exposed via the Graphics Output protocol and
// driven as an efifb by Linux, we need this setting to prevent the
// framebuffer from becoming unresponsive.
//
Node = fdt_path_offset (DeviceTreeBase, "/chosen");
if (Node < 0) {
Node = fdt_add_subnode (DeviceTreeBase, 0, "/chosen");
if ((RtcNode != -1) &&
fdt_setprop_string (DeviceTreeBase, RtcNode, "status",
"disabled") != 0) {
DEBUG ((EFI_D_WARN, "Failed to set PL031 status to 'disabled'\n"));
}
if (Node < 0 ||
fdt_setprop_u32 (DeviceTreeBase, Node, "linux,pci-probe-only", 1) < 0) {
DEBUG ((EFI_D_WARN, "Failed to set /chosen/linux,pci-probe-only property\n"));
if (HavePci) {
//
// Set the /chosen/linux,pci-probe-only property to 1, so that the PCI
// setup we will perform in the firmware is honored by the Linux OS,
// rather than torn down and done from scratch. This is generally a more
// sensible approach, and aligns with what ACPI based OSes do in general.
//
// In case we are exposing an emulated VGA PCI device to the guest, which
// may subsequently get exposed via the Graphics Output protocol and
// driven as an efifb by Linux, we need this setting to prevent the
// framebuffer from becoming unresponsive.
//
Node = fdt_path_offset (DeviceTreeBase, "/chosen");
if (Node < 0) {
Node = fdt_add_subnode (DeviceTreeBase, 0, "/chosen");
}
if (Node < 0 ||
fdt_setprop_u32 (DeviceTreeBase, Node, "linux,pci-probe-only", 1) < 0) {
DEBUG ((EFI_D_WARN, "Failed to set /chosen/linux,pci-probe-only property\n"));
}
}
}
return EFI_SUCCESS;
}

View File

@ -73,6 +73,9 @@
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
[FeaturePcd]
gArmVirtTokenSpaceGuid.PcdPureAcpiBoot
[Protocols]
gEfiDevicePathProtocolGuid