All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: "Markus Armbruster" <armbru@redhat.com>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Eric Blake" <eblake@redhat.com>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Eduardo Habkost" <eduardo@habkost.net>
Subject: Re: [PATCH v3] hw/uefi: add "info firmware-log" + "query-firmware-log" monitor commands
Date: Mon, 13 Oct 2025 12:43:31 +0200	[thread overview]
Message-ID: <87bjmb6q0c.fsf@pond.sub.org> (raw)
In-Reply-To: <3flcrys75wbso64zpfbika46klfbg7khbrtug3avrpfixaxmo5@vuidk7ktxnpi> (Gerd Hoffmann's message of "Mon, 13 Oct 2025 11:19:33 +0200")

Gerd Hoffmann <kraxel@redhat.com> writes:

> On Fri, Oct 10, 2025 at 01:41:35PM +0200, Markus Armbruster wrote:
>> Gerd Hoffmann <kraxel@redhat.com> writes:
>> 
>> > Starting with the edk2-stable202508 tag OVMF (and ArmVirt too) have
>> > optional support for logging to a memory buffer.  There is guest side
>> > support -- for example in linux kernels v6.17+ -- to read that buffer.
>> > But that might not helpful if your guest stops booting early enough that
>> > guest tooling can not be used yet.  So host side support to read that
>> > log buffer is a useful thing to have.
>> >
>> > This patch implements both qmp and hmp monitor commands to read the
>> > firmware log.
>> 
>> So this is just for EDK2, at least for now.
>
> Yes.
>
>> > +    char                 FirmwareVersion[128];
>> > +} MEM_DEBUG_LOG_HDR;
>> 
>> I understand this is a (close to) literal copy from EDK2, and adjusting
>> it to QEMU style would be a bad idea.
>> 
>> > +
>> > +
>> > +/* ----------------------------------------------------------------------- */
>> > +/* qemu monitor command                                                    */
>> > +
>> > +typedef struct {
>> > +    uint64_t             Magic1;
>> > +    uint64_t             Magic2;
>> > +} MEM_DEBUG_LOG_MAGIC;
>> 
>> Unusual capitalization for a typedef name.  Why?  To emphasize the
>> relation to MEM_DEBUG_LOG_HDR?
>
> Yes.

Okay.

>> > +    if (header.DebugLogSize > MiB) {
>> > +        /* default size is 128k (32 pages), allow up to 1M */
>> > +        error_setg(errp, "firmware log: log buffer is too big");
>> 
>> [*] We limit the buffer to 1MiB.  No objection to the size.
>> 
>> What do you mean by "default" in "default size"?  Is the size
>> configurable in EDK2?
>
> Yes, there is an option for that.
>
>> Should we try to cope more gracefully with oversized log buffers?  It's
>> a ring buffer.  What about silently reading the latest 1MiB then?
>> Behaves just as if the ring buffer was 1MiB.
>
> See below.
>
>> > +# @log: Firmware debug log, in base64 encoding.
>> 
>> Can this have a partial line at the beginning and/or the end?
>
> Yes.

Partial lines can be troublesome, in particular when complete lines
start with a prefix in a known format.  If avoiding them isn't
practical, we should at least document.

>> > +#
>> > +# Since: 10.2
>> > +##
>> > +{ 'struct': 'FirmwareLog',
>> > +  'data': { '*version': 'str',
>> > +            '*log': 'str' } }
>> 
>> These aren't actually optional with the current code.  See [**] above.
>> I guess you make them optional just in case some other firmware can
>> provide only one of them.
>
> We could also make both mandatory.  There is always the option to return
> an empty string ...

Yes.  Loses the distinction between "firmware doesn't support this" and
"firmware supports this, but it happens to be empty right now".  Do we
care?

>> > +##
>> > +# @query-firmware-log:
>> > +#
>> > +# Find firmware memory log buffer in guest memory, return content.
>> 
>> Should we mention this is implemented only for EDK2 at this time?
>> 
>> Have you considered an optional size argument to retrieve the tail of
>> the log?
>
> I'll have a look.  If we implement the 1MB cap suggested above we would
> get that (almost) for free.
>
> take care,
>   Gerd

Thanks!



  reply	other threads:[~2025-10-13 10:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10  7:10 [PATCH v3] hw/uefi: add "info firmware-log" + "query-firmware-log" monitor commands Gerd Hoffmann
2025-10-10  9:12 ` Daniel P. Berrangé
2025-10-10  9:27   ` Gerd Hoffmann
2025-10-10  9:31     ` Daniel P. Berrangé
2025-10-13  8:42       ` Gerd Hoffmann
2025-10-10 11:41 ` Markus Armbruster
2025-10-10 17:36   ` Markus Armbruster
2025-10-10 20:23     ` Dr. David Alan Gilbert
2025-10-11  4:43       ` Markus Armbruster
2025-10-11  9:29     ` Markus Armbruster
2025-10-13  9:19   ` Gerd Hoffmann
2025-10-13 10:43     ` Markus Armbruster [this message]
2025-10-13 11:47       ` Gerd Hoffmann
2025-10-10 20:36 ` Dr. David Alan Gilbert
2025-10-13 11:55   ` Gerd Hoffmann
2025-10-13 13:12     ` Dr. David Alan Gilbert
2025-10-13 19:11 ` Philippe Mathieu-Daudé
2025-10-14 13:02   ` Daniel P. Berrangé

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-all 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=87bjmb6q0c.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wangyanan55@huawei.com \
    --cc=zhao1.liu@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.