public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, dwmw2@infradead.org
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [edk2-devel] [PATCH] ArmVirtPkg/XenAcpiPlatformDxe: Install FACS table from DT
Date: Wed, 14 Feb 2024 11:36:49 +0100	[thread overview]
Message-ID: <15446f23-6014-74b5-abdf-cbebda366f1a@redhat.com> (raw)
In-Reply-To: <881dd0a2558ecbdfa02c844722d8a1103ab97ab3.camel@infradead.org>

On 2/13/24 11:50, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> The FACS may still exist when the reduced hardware flag is set in FADT;
> it is optional. Since it contains the hardware signature field which
> indicates that a hibernated system should boot cleanly instead of
> attempting to resume, a platform may choose to expose it. Propagate it
> correctly.
> 
> Also avoid a NULL pointer dereference if the platform doesn't provide
> a DSDT.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>  .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.c   | 37 +++++++++++++++----
>  1 file changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c b/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c
> index 32c8b1e94ed2..3e6e5cb367d4 100644
> --- a/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c
> +++ b/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c
> @@ -128,10 +128,12 @@ InstallXenArmTables (
>    EFI_ACPI_DESCRIPTION_HEADER                   *Xsdt;
>    EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE     *FadtTable;
>    EFI_ACPI_DESCRIPTION_HEADER                   *DsdtTable;
> +  EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *FacsTable;
>  
>    XenAcpiRsdpStructurePtr = NULL;
>    FadtTable               = NULL;
>    DsdtTable               = NULL;
> +  FacsTable               = NULL;
>    TableHandle             = 0;
>    NumberOfTableEntries    = 0;
>  
> @@ -191,6 +193,8 @@ InstallXenArmTables (
>          FadtTable = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *)
>                      (UINTN)CurrentTablePointer;
>          DsdtTable = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)FadtTable->Dsdt;
> +        FacsTable = (EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)
> +                    (UINTN) FadtTable->FirmwareCtrl;
>        }
>      }
>    }
> @@ -198,14 +202,31 @@ InstallXenArmTables (
>    //
>    // Install DSDT table.
>    //
> -  Status = AcpiProtocol->InstallAcpiTable (
> -                           AcpiProtocol,
> -                           DsdtTable,
> -                           DsdtTable->Length,
> -                           &TableHandle
> -                           );
> -  if (EFI_ERROR (Status)) {
> -    return Status;
> +  if (DsdtTable != NULL) {
> +    Status = AcpiProtocol->InstallAcpiTable (
> +               AcpiProtocol,
> +               DsdtTable,
> +               DsdtTable->Length,
> +               &TableHandle
> +               );
> +    if (EFI_ERROR (Status)) {
> +      return Status;
> +    }
> +  }
> +
> +  //
> +  // Install FACS table.
> +  //
> +  if (FacsTable != NULL) {
> +    Status = AcpiProtocol->InstallAcpiTable (
> +               AcpiProtocol,
> +               FacsTable,
> +               FacsTable->Length,
> +               &TableHandle
> +               );
> +    if (EFI_ERROR (Status)) {
> +      return Status;
> +    }
>    }
>  
>    return EFI_SUCCESS;

I'm not a fan of InstallXenArmTables() not rolling back tables upon a
failure, but that wart predates this patch.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Can you please ping, after the edk2-stable202402 release, so we merge this?

Or -- given the NULL ptr deref fix in particular -- does this qualify
for merging during the hard feature freeze?

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115436): https://edk2.groups.io/g/devel/message/115436
Mute This Topic: https://groups.io/mt/104329932/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-02-14 10:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:50 [edk2-devel] [PATCH] ArmVirtPkg/XenAcpiPlatformDxe: Install FACS table from DT David Woodhouse
2024-02-14 10:36 ` Laszlo Ersek [this message]
2024-02-25 20:51 ` Laszlo Ersek

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=15446f23-6014-74b5-abdf-cbebda366f1a@redhat.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