public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Sami Mujawar <sami.mujawar@arm.com>, devel@edk2.groups.io
Cc: leif@nuviainc.com, lersek@redhat.com, Alexandru.Elisei@arm.com,
	Andre.Przywara@arm.com, Matteo.Carlini@arm.com,
	Laura.Moretta@arm.com, nd@arm.com
Subject: Re: [PATCH v3 04/15] ArmVirtPkg: Add kvmtool platform driver
Date: Thu, 25 Jun 2020 13:35:03 +0200	[thread overview]
Message-ID: <d1a25132-9b94-19f7-a846-cd52d60ba9dd@arm.com> (raw)
In-Reply-To: <20200624133458.61920-5-sami.mujawar@arm.com>

On 6/24/20 3:34 PM, Sami Mujawar wrote:
> Kvmtool is a virtual machine manager that enables
> hosting KVM guests. It essentially provides a
> virtual hardware platform for guest operating
> systems.
> 
> Kvmtool hands of a device tree containing the
> current hardware configuration to the firmware.
> 
> A standards-based operating system would use
> ACPI to consume the platform hardware
> information, while some operating systems may
> prefer to use Device Tree.
> 
> The KvmtoolPlatformDxe performs the platform
> actions like determining if the firmware should
> expose ACPI or the Device Tree based hardware
> description to the operating system.
> 
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> Acked-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>      v3:
>        - Don't use CpuDeadLoop()s in your drivers.                 [Ard]
>        - Returned error code instead of dead loop.                 [Sami]
>        - Installing a protocol on an image handle should not       [Ard]
>          ever fail. So just use ASSERT_EFI_ERROR().
>        - Added assert and returned status code.                    [Sami]
>          Ref: https://edk2.groups.io/g/devel/topic/74200911#59650
>      
>      v2:
>        - Updated according to review comments.                     [Sami]
>      
>      v1:
>        - Add kvmtool platform driver to support loading platform   [Sami]
>          specific information.
>        - Keep code to initialise the variable storage PCDs in the  [Laszlo]
>          platform-specific FVB driver.
>        - Document code derived from                                [Laszlo]
>          "ArmVirtPkg/PlatformHasAcpiDtDxe"
>          Ref: https://edk2.groups.io/g/devel/topic/30915278#30757
> 
>   ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c   | 85 ++++++++++++++++++++
>   ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf | 47 +++++++++++
>   2 files changed, 132 insertions(+)
> 
> diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..17a65bdff0c1a5851e45c2a9ede97f76236502e3
> --- /dev/null
> +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
> @@ -0,0 +1,85 @@
> +/** @file
> +
> +  The KvmtoolPlatformDxe performs the platform specific initialization like:
> +  - It decides if the firmware should expose ACPI or Device Tree-based
> +    hardware description to the operating system.
> +
> +  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Guid/VariableFormat.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DxeServicesTableLib.h>

You are missing MemoryAllocationLib here - either add it here, or remove 
it from LibraryClasses

> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiDriverEntryPoint.h>
> +#include <Protocol/FdtClient.h>
> +
> +/** Decide if the firmware should expose ACPI tables or Device Tree and
> +    install the appropriate protocol interface.
> +
> +  Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe",
> +        by dropping the word size check, and the fw_cfg check.
> +
> +  @param [in]  ImageHandle  Handle for this image.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_OUT_OF_RESOURCES    There was not enough memory to install the
> +                                  protocols.
> +  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
> +
> +**/
> +STATIC
> +EFI_STATUS
> +PlatformHasAcpiDt (
> +  IN EFI_HANDLE           ImageHandle
> +  )
> +{
> +  if (!PcdGetBool (PcdForceNoAcpi)) {
> +    // Expose ACPI tables
> +    return gBS->InstallProtocolInterface (
> +                  &ImageHandle,
> +                  &gEdkiiPlatformHasAcpiGuid,
> +                  EFI_NATIVE_INTERFACE,
> +                  NULL
> +                  );
> +  }
> +
> +  // Expose the Device Tree.
> +  return gBS->InstallProtocolInterface (
> +                &ImageHandle,
> +                &gEdkiiPlatformHasDeviceTreeGuid,
> +                EFI_NATIVE_INTERFACE,
> +                NULL
> +                );
> +}
> +
> +/** Entry point for Kvmtool Platform Dxe
> +
> +  @param [in]  ImageHandle  Handle for this image.
> +  @param [in]  SystemTable  Pointer to the EFI system table.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_OUT_OF_RESOURCES    There was not enough memory to install the
> +                                  protocols.
> +  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +KvmtoolPlatformDxeEntryPoint (
> +  IN EFI_HANDLE           ImageHandle,
> +  IN EFI_SYSTEM_TABLE     *SystemTable
> +  )
> +{
> +  EFI_STATUS                     Status;
> +
> +  Status = PlatformHasAcpiDt (ImageHandle);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return Status;
> +}
> diff --git a/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
> new file mode 100644
> index 0000000000000000000000000000000000000000..08a0fe5ce14469133479046385bdd48c22698639
> --- /dev/null
> +++ b/ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.inf
> @@ -0,0 +1,47 @@
> +#/** @file
> +#
> +#  The KvmtoolPlatformDxe performs the platform specific initialization like:
> +#  - It decides if the firmware should expose ACPI or Device Tree-based
> +#    hardware description to the operating system.
> +#
> +#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = KvmtoolPlatformDxe
> +  FILE_GUID                      = 7479CCCD-D721-442A-8C73-A72DBB886669
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = KvmtoolPlatformDxeEntryPoint
> +
> +[Sources]
> +  KvmtoolPlatformDxe.c
> +
> +[Packages]
> +  ArmVirtPkg/ArmVirtPkg.dec
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  DxeServicesTableLib
> +  MemoryAllocationLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +
> +[Guids]
> +  gEdkiiPlatformHasAcpiGuid       ## SOMETIMES_PRODUCES ## PROTOCOL
> +  gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL
> +
> +[Pcd]
> +  gArmVirtTokenSpaceGuid.PcdForceNoAcpi
> +
> +[Depex]
> +  TRUE
> 


  reply	other threads:[~2020-06-25 11:35 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 13:34 [PATCH v3 00/15] Kvmtool guest firmware support for Arm Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 01/15] PcAtChipsetPkg: Add MMIO Support to RTC driver Sami Mujawar
2020-06-25 11:24   ` Ard Biesheuvel
2020-06-29  2:36     ` [edk2-devel] " Guomin Jiang
2020-06-24 13:34 ` [PATCH v3 02/15] ArmVirtPkg: Add Kvmtool RTC Fdt Client Library Sami Mujawar
2020-06-25 11:31   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 03/15] ArmPlatformPkg: Dynamic flash variable base Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 04/15] ArmVirtPkg: Add kvmtool platform driver Sami Mujawar
2020-06-25 11:35   ` Ard Biesheuvel [this message]
2020-06-24 13:34 ` [PATCH v3 05/15] ArmVirtPkg: kvmtool platform memory map Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 06/15] ArmVirtPkg: Add Kvmtool NOR flash lib Sami Mujawar
2020-06-25  8:45   ` Philippe Mathieu-Daudé
2020-06-25 11:19     ` [edk2-devel] " Ard Biesheuvel
2020-06-25 11:41       ` Philippe Mathieu-Daudé
2020-06-25 11:38   ` Ard Biesheuvel
2020-06-25 17:33     ` Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation Sami Mujawar
2020-06-25 11:42   ` Ard Biesheuvel
2020-06-26  9:23     ` Julien Grall
2020-06-24 13:34 ` [PATCH v3 08/15] MdeModulePkg: Fix constructor invocation ordering Sami Mujawar
2020-06-25 13:51   ` Ard Biesheuvel
2020-06-26 13:22     ` Laszlo Ersek
2020-06-27 11:37       ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 09/15] ArmVirtPkg: GUID Hob for 16550 UART base address Sami Mujawar
2020-06-25 13:52   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 10/15] ArmVirtPkg: 16550 UART Platform hook library Sami Mujawar
2020-06-25 13:56   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib Sami Mujawar
2020-06-25 14:05   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 12/15] ArmVirtPkg: Support for kvmtool virtual platform Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-26 13:26     ` Laszlo Ersek
2020-06-24 13:34 ` [PATCH v3 13/15] ArmVirtPkg: Package dependency for MC146818 RTC Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 14/15] ArmVirtPkg: Add kvmtool to package dictionary Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 15/15] Maintainer.txt: Add Kvmtool platform reviewer Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d1a25132-9b94-19f7-a846-cd52d60ba9dd@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox