public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, ard.biesheuvel@arm.com
Cc: leif@nuviainc.com, graeme.gregory@linaro.org, tanmay.jagdale@linaro.org
Subject: Re: [edk2-devel] [PATCH] ArmPkg/PlatformBootManagerLib: reject 'default' parity and stop bit count
Date: Tue, 19 May 2020 12:00:02 +0200	[thread overview]
Message-ID: <6f410b08-f868-8b38-60fd-2b863a89658e@redhat.com> (raw)
In-Reply-To: <20200518171148.6113-1-ard.biesheuvel@arm.com>

On 05/18/20 19:11, Ard Biesheuvel wrote:
> In the ArmPkg version of PlatformBootManagerLib, we construct a
> serial device path based on the default settings for baud rate,
> parity and the number of stop bits, to ensure that a serial console
> is available even on the very first boot.
> 
> This assumes that PcdUartDefaultParity or PcdUartDefaultStopBits are
> not set to '0', meaning 'the default', as there is no default for
> these when constructing a device path.
> 
> So add a couple of ASSERT()s to make sure that we catch this condition,
> since it otherwise ignores the bogus device path silently, which is
> rather tedious to debug,.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> ---
>  ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> index e6e788e0f107..a030d510aa62 100644
> --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -583,6 +583,8 @@ PlatformBootManagerBeforeConsole (
>    //
>    // Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
>    //
> +  ASSERT (FixedPcdGet8 (PcdUartDefaultParity) > 0);
> +  ASSERT (FixedPcdGet8 (PcdUartDefaultStopBits) > 0);
>    ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4);
>    CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
>  
> 

Given that these are fixed PCDs, I'd recommend STATIC_ASSERT(). We've
recently put STATIC_ASSERT() to use (in "OvmfPkg/MptScsiDxe/MptScsi.c")
in combination with a fixed PCD:

  STATIC_ASSERT (
    FixedPcdGet8 (PcdMptScsiMaxTargetLimit) < 255,
    "Req supports 255 targets only (max target is 254)"
    );

Just an idea of course; if that's out of scope for now, I have nothing
against this patch.

Thanks,
Laszlo


  parent reply	other threads:[~2020-05-19 10:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 17:11 [PATCH] ArmPkg/PlatformBootManagerLib: reject 'default' parity and stop bit count Ard Biesheuvel
2020-05-18 17:18 ` Leif Lindholm
2020-05-19 10:00 ` Laszlo Ersek [this message]
2020-05-19 11:15   ` [edk2-devel] " Leif Lindholm
2020-05-20  9:16     ` Sami Mujawar
2020-05-19 12:12   ` 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=6f410b08-f868-8b38-60fd-2b863a89658e@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