From: "Lendacky, Thomas via groups.io" <thomas.lendacky=amd.com@groups.io>
To: Laszlo Ersek <lersek@redhat.com>,
devel@edk2.groups.io, kraxel@redhat.com
Cc: Jiewen Yao <jiewen.yao@intel.com>,
Erdem Aktas <erdemaktas@google.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Michael Roth <michael.roth@amd.com>, Min Xu <min.m.xu@intel.com>,
Oliver Steffen <osteffen@redhat.com>
Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/ResetVector: send post codes to qemu debug console
Date: Wed, 24 Jan 2024 13:55:36 -0600 [thread overview]
Message-ID: <f072287a-4399-4ff7-b63f-72dc9f556530@amd.com> (raw)
In-Reply-To: <4d8b55a7-0898-4ab3-90d0-394b3bd533de@amd.com>
On 1/24/24 13:24, Tom Lendacky wrote:
> On 1/24/24 10:47, Laszlo Ersek wrote:
>> On 1/24/24 16:31, Gerd Hoffmann wrote:
>>> Neat when doing ResetVector coding.
>>>
>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>> ---
>>> OvmfPkg/ResetVector/DebugCon.asm | 43 +++++++++++++++++++++++++++
>>> OvmfPkg/ResetVector/ResetVector.nasmb | 2 +-
>>> 2 files changed, 44 insertions(+), 1 deletion(-)
>>> create mode 100644 OvmfPkg/ResetVector/DebugCon.asm
>>>
>>> diff --git a/OvmfPkg/ResetVector/DebugCon.asm
>>> b/OvmfPkg/ResetVector/DebugCon.asm
>>> new file mode 100644
>>> index 000000000000..9c57d1a52c75
>>> --- /dev/null
>>> +++ b/OvmfPkg/ResetVector/DebugCon.asm
>>> @@ -0,0 +1,43 @@
>>> +;------------------------------------------------------------------------------
>>> +; @file
>>> +; qemu debug console support macros (based on serial port macros)
>>> +;
>>> +; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
>>> +; SPDX-License-Identifier: BSD-2-Clause-Patent
>>> +;
>>> +;------------------------------------------------------------------------------
>>> +
>>> +%macro outToDebugPort 1
>>> + mov dx, 0x402
>>> + mov al, %1
>>> + out dx, al
>>> +%endmacro
>>> +
>>> +%macro debugShowCharacter 1
>>> + outToDebugPort %1
>>> +%endmacro
>>> +
>>> +%macro debugShowHexDigit 1
>>> + %if (%1 < 0xa)
>>> + debugShowCharacter BYTE ('0' + (%1))
>>> + %else
>>> + debugShowCharacter BYTE ('a' + ((%1) - 0xa))
>>> + %endif
>>> +%endmacro
>>> +
>>> +%macro debugNewline 0
>>> + debugShowCharacter `\r`
>>> + debugShowCharacter `\n`
>>> +%endmacro
>>> +
>>> +%macro debugShowPostCode 1
>>> + debugShowHexDigit (((%1) >> 4) & 0xf)
>>> + debugShowHexDigit ((%1) & 0xf)
>>> + debugNewline
>>> +%endmacro
>>> +
>>> +BITS 16
>>> +
>>> +%macro debugInitialize 0
>>> + ; not required
>>> +%endmacro
>>> diff --git a/OvmfPkg/ResetVector/ResetVector.nasmb
>>> b/OvmfPkg/ResetVector/ResetVector.nasmb
>>> index 5832aaa8abf7..f1655ddfcde3 100644
>>> --- a/OvmfPkg/ResetVector/ResetVector.nasmb
>>> +++ b/OvmfPkg/ResetVector/ResetVector.nasmb
>>> @@ -41,7 +41,7 @@
>>> %elifdef DEBUG_SERIAL
>>> %include "SerialDebug.asm"
>>> %else
>>> - %include "DebugDisabled.asm"
>>> + %include "DebugCon.asm"
>>> %endif
>>> %include "Ia32/SearchForBfvBase.asm"
>>
>> (1) How much output does this produce? Trapping to QEMU for every single
>> character written to the debug console is very slow. If it only produces
>> a few bytes, that should be OK.
>>
>> (2) debugInitialize could actually be put to use; the presence of the
>> QEMU debug console is detectable. We'd need to allocate a single byte
>> somewhere, detect the console in debugInitialize, save the result in
>> that byte, then check the byte in debugShowPostCode. Eliminates even
>> those few (?) traps if there is no debug console configured.
>>
>> (3) I'm already hating myself for asking about this, but... is there a
>> way for only customizing debugInitialize and debugShowCharacter? The
>> rest is common with "SerialDebug.asm", and I wish I hadn't had to review
>> those (unchanged) macros, they make my eyes bleed :/
>>
>> Anyway, if you think any of these (or all of these!) means too much
>> work, I'm OK with the patch going-in as is.
>
> My concern would be around SEV-ES/SEV-SNP guest usage. The in and out
> instruction will generate a #VC and would require a #VC handler to be in
> place.
>
> I'm pretty sure this will cause issues for those types of guests, but it
> might be a few days before I can get to it to verify. @Gerd, were you able
> to test this with those types of guests?
Had a meeting get canceled and so got a chance to test this. As I thought,
this causes SEV-ES/SEV-SNP guest failures.
Thanks,
Tom
>
> Thanks,
> Tom
>
>>
>> I'm a bit concerned about (1), TBH.
>>
>> Laszlo
>>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114352): https://edk2.groups.io/g/devel/message/114352
Mute This Topic: https://groups.io/mt/103933942/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-24 19:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-24 15:31 [edk2-devel] [PATCH 1/1] OvmfPkg/ResetVector: send post codes to qemu debug console Gerd Hoffmann
2024-01-24 16:47 ` Laszlo Ersek
2024-01-24 19:24 ` Lendacky, Thomas via groups.io
2024-01-24 19:55 ` Lendacky, Thomas via groups.io [this message]
2024-01-25 1:43 ` Erdem Aktas via groups.io
2024-01-25 7:50 ` Gerd Hoffmann
2024-01-25 19:47 ` Laszlo Ersek
2024-01-26 13:25 ` Gerd Hoffmann
2024-01-29 11:22 ` 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=f072287a-4399-4ff7-b63f-72dc9f556530@amd.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