From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 0962CAC0269 for ; Thu, 25 Jan 2024 01:43:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=glrDKheX96ukbSoauwzaMkxsxroBwi2CpmkM+1dn9Gg=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1706147023; v=1; b=ghvCm04fCSwQ2PDy0HrV4o3DNHsEVsW4nWOi2AGHaxWqG/IdXwUQvzdBoH9xsY5haQu4wGE3 +arMEBGMcBlZbW9SESQuwZUkC97QzNWAZVjQUr47v5U80XjFycP9U02SgupWlRQ9isrjKZI0xqd PXyKMiXKKEYYvWcMNlQBDTPE= X-Received: by 127.0.0.2 with SMTP id 8KktYY7687511x8Yg1lmq0wq; Wed, 24 Jan 2024 17:43:43 -0800 X-Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by mx.groups.io with SMTP id smtpd.web11.6419.1706147022899355935 for ; Wed, 24 Jan 2024 17:43:43 -0800 X-Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6869233d472so16415456d6.2 for ; Wed, 24 Jan 2024 17:43:42 -0800 (PST) X-Gm-Message-State: SRz5yuFFlJfyXzIvw5yOEtAVx7686176AA= X-Google-Smtp-Source: AGHT+IG9bHJVpDo4IcYosF0HnbjeKMndHXBlURPF9TY0AyQZsdhi3E+QR/HOy37kuM1ftnH930iCeOLnU+GrgOCHag4= X-Received: by 2002:a05:6214:240e:b0:686:8ffe:1278 with SMTP id fv14-20020a056214240e00b006868ffe1278mr214175qvb.4.1706147021775; Wed, 24 Jan 2024 17:43:41 -0800 (PST) MIME-Version: 1.0 References: <20240124153107.2112760-1-kraxel@redhat.com> <67da33f7-5038-6732-455a-2576f641f1c0@redhat.com> <4d8b55a7-0898-4ab3-90d0-394b3bd533de@amd.com> In-Reply-To: From: "Erdem Aktas via groups.io" Date: Wed, 24 Jan 2024 17:43:29 -0800 Message-ID: Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/ResetVector: send post codes to qemu debug console To: Tom Lendacky Cc: Laszlo Ersek , devel@edk2.groups.io, kraxel@redhat.com, Jiewen Yao , Ard Biesheuvel , Michael Roth , Min Xu , Oliver Steffen Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,erdemaktas@google.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="0000000000002b4ef5060fbb4f2c" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=ghvCm04f; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --0000000000002b4ef5060fbb4f2c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Same for TDX, I did not run it but it should cause failure as debugShowPostCode is called OvmfPkg/ResetVector/Ia32/IntelTdx.asm before actually the #VE handlers are installed. -Erdem On Wed, Jan 24, 2024 at 11:55=E2=80=AFAM Tom Lendacky wrote: > 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 > >>> --- > >>> 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.
> >>> +; 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 sing= le > >> character written to the debug console is very slow. If it only produc= es > >> 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 revi= ew > >> 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 i= n > > place. > > > > I'm pretty sure this will cause issues for those types of guests, but i= t > > 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 > >> > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114361): https://edk2.groups.io/g/devel/message/114361 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --0000000000002b4ef5060fbb4f2c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Same for TDX, I did not run it but it should=C2=A0cause fa= ilure as=C2=A0debugShowPostCode is called OvmfPkg/ResetVector/Ia32/IntelTdx= .asm before actually the #VE handlers are installed.

-Er= dem

On Wed, Jan 24, 2024 at 11:55=E2=80=AFAM Tom Lendacky <thomas.lendacky@amd.com> wrote:<= br>
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>
>>> ---
>>> =C2=A0 OvmfPkg/ResetVector/DebugCon.asm=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 | 43 +++++++++++++++++++++++++++
>>> =C2=A0 OvmfPkg/ResetVector/ResetVector.nasmb |=C2=A0 2 +-
>>> =C2=A0 2 files changed, 44 insertions(+), 1 deletion(-)
>>> =C2=A0 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 mac= ros)
>>> +;
>>> +; Copyright (c) 2008 - 2018, Intel Corporation. All rights re= served.<BR>
>>> +; SPDX-License-Identifier: BSD-2-Clause-Patent
>>> +;
>>> +;------------------------------------------------------------= ------------------
>>> +
>>> +%macro=C2=A0 outToDebugPort 1
>>> +=C2=A0=C2=A0=C2=A0 mov=C2=A0=C2=A0=C2=A0=C2=A0 dx, 0x402
>>> +=C2=A0=C2=A0=C2=A0 mov=C2=A0=C2=A0=C2=A0=C2=A0 al, %1
>>> +=C2=A0=C2=A0=C2=A0 out=C2=A0=C2=A0=C2=A0=C2=A0 dx, al
>>> +%endmacro
>>> +
>>> +%macro=C2=A0 debugShowCharacter 1
>>> +=C2=A0=C2=A0=C2=A0 outToDebugPort %1
>>> +%endmacro
>>> +
>>> +%macro=C2=A0 debugShowHexDigit 1
>>> +=C2=A0 %if (%1 < 0xa)
>>> +=C2=A0=C2=A0=C2=A0 debugShowCharacter BYTE ('0' + (%1= ))
>>> +=C2=A0 %else
>>> +=C2=A0=C2=A0=C2=A0 debugShowCharacter BYTE ('a' + ((%= 1) - 0xa))
>>> +=C2=A0 %endif
>>> +%endmacro
>>> +
>>> +%macro=C2=A0 debugNewline 0
>>> +=C2=A0=C2=A0=C2=A0 debugShowCharacter `\r`
>>> +=C2=A0=C2=A0=C2=A0 debugShowCharacter `\n`
>>> +%endmacro
>>> +
>>> +%macro=C2=A0 debugShowPostCode 1
>>> +=C2=A0=C2=A0=C2=A0 debugShowHexDigit (((%1) >> 4) &= 0xf)
>>> +=C2=A0=C2=A0=C2=A0 debugShowHexDigit ((%1) & 0xf)
>>> +=C2=A0=C2=A0=C2=A0 debugNewline
>>> +%endmacro
>>> +
>>> +BITS=C2=A0=C2=A0=C2=A0 16
>>> +
>>> +%macro=C2=A0 debugInitialize 0
>>> +=C2=A0=C2=A0=C2=A0 ; 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 @@
>>> =C2=A0 %elifdef DEBUG_SERIAL
>>> =C2=A0=C2=A0=C2=A0 %include "SerialDebug.asm"
>>> =C2=A0 %else
>>> -=C2=A0 %include "DebugDisabled.asm"
>>> +=C2=A0 %include "DebugCon.asm"
>>> =C2=A0 %endif
>>> =C2=A0 %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 pr= oduces
>> 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 sing= le byte
>> somewhere, detect the console in debugInitialize, save the result = in
>> that byte, then check the byte in debugShowPostCode. Eliminates ev= en
>> 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? T= he
>> 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 muc= h
>> 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:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#114361) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--0000000000002b4ef5060fbb4f2c--