From patchwork Thu Mar 31 11:20:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64756 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp93351lbc; Thu, 31 Mar 2016 04:20:25 -0700 (PDT) X-Received: by 10.66.157.129 with SMTP id wm1mr2171037pab.159.1459423225076; Thu, 31 Mar 2016 04:20:25 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id s73si13585320pfs.11.2016.03.31.04.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Mar 2016 04:20:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F3DE71A1FE5; Thu, 31 Mar 2016 04:20:54 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9FB251A1FD8 for ; Thu, 31 Mar 2016 04:20:53 -0700 (PDT) Received: by mail-wm0-x22d.google.com with SMTP id p65so110185073wmp.0 for ; Thu, 31 Mar 2016 04:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JmHDIO6fLqIyqW92kVSbwUAthzQDbwexw4H7b2baABc=; b=NO4y1boCyYiPtoHPBb7xHs1wEpJN8Jvaopea5K+RqqgJr26prLJfIRtfBEyKqwuLE0 WB/S5wHO3O9SnUngDI6ZiqtA2LOoh3YxbYhPW1fVcx3rxiwxtdVUyojSI7E1x7D1PC03 atujJ/u9PbE8/xApn3YhIMOPMlTUaXdgb0nlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JmHDIO6fLqIyqW92kVSbwUAthzQDbwexw4H7b2baABc=; b=eUdZrzT45+Rm1qvgmKMpGAFfKRXs9CniFLUULRC/clwwFdnCPwsPpcJt/5fbiYcCK0 oaDqL3G4iZy7dUtvepvbLU/mfnLjHoTP3Da2g3kuIRK0omZSmeHhSu5ZUCn3KP3HxD5a rI3p7tNoyOGzJsU9p5k94Kgr91dzEIBUiCkcY+HeHilIDoPogWQEhJO5BoMCBOQ25vRs mqNgBUn/1tfVpdXiZiMERFrUrRZK6hUrZbZ4TGd9XDlxVaznmbhBB2BN29PogExLPnXI daXgLTmoUk3Yc/b8iV8Joqu7EfjENSIco2YB2NIRA/rOtygX476rdslal8LDYYMof5dx aEEw== X-Gm-Message-State: AD7BkJKGqOxR8d3bkB9vikTyhFZByTZBpPmSk7L7EQim2CVgadpnIEO/GEr8nUcabRTfhh+D X-Received: by 10.28.128.83 with SMTP id b80mr15778065wmd.6.1459423221706; Thu, 31 Mar 2016 04:20:21 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id uq10sm8514726wjc.38.2016.03.31.04.20.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Mar 2016 04:20:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Thu, 31 Mar 2016 13:20:15 +0200 Message-Id: <1459423216-2415-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459423216-2415-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459423216-2415-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 1/2] ArmVirtPkg/VirtFdtDxe: make installation of FDT as config table option X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- ArmVirtPkg/ArmVirtPkg.dec | 9 +++ ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c | 67 +++++++++++--------- ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf | 3 + 3 files changed, 48 insertions(+), 31 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 89e8448a8443..c67d7aa678e1 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -98,3 +98,12 @@ [PcdsFeatureFlag] # 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|0x00000010 diff --git a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c index 437b2a879216..d3043fa9b877 100644 --- a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.c @@ -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 (HavePci) { + 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. // - // 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. + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeBase); + ASSERT_EFI_ERROR (Status); + // - // 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. + // 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. // - 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; } diff --git a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf index ee2503ac4a7e..f807bf76bb4b 100644 --- a/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmVirtPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -73,6 +73,9 @@ [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration +[FeaturePcd] + gArmVirtTokenSpaceGuid.PcdPureAcpiBoot + [Protocols] gEfiDevicePathProtocolGuid