From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by mx.groups.io with SMTP id smtpd.web10.718.1639690986867355247 for ; Thu, 16 Dec 2021 13:43:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MA2SebN/; spf=pass (domain: gmail.com, ip: 209.85.166.54, mailfrom: shivanshu3@gmail.com) Received: by mail-io1-f54.google.com with SMTP id p65so328129iof.3 for ; Thu, 16 Dec 2021 13:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x0CYNgtpgCn+cnoqKOR8BwHkaVovRrZnVwcwI5TevkQ=; b=MA2SebN/60Yx5Tx3KMtDGWmkqzZ6d1nRi1jfez84BdJVBSfF9Pz4PMC4DOKcgQQHPC PSGEXe4xzsnRxhvp+PyHePpgyTugZqMuvU+c8H/Mh4Ndu+UN5i5YjQk3R6uZ/qhfv3Z8 dSCZjzryE+41w1SY5vYeyH648PozbH6sbr+LmDtqutrAfvlowugDdSrmAhd3gnmhk5F+ OYhvIMBXQoaDLMK7yzth8vvay+gMvSTyHmw01re4nDW6AH34mDFl3dC+MM/GU/as4gxH s8/KdvLPWCwRYNWuuV+MpcZ9ZrFokqlr0AB8tH0APIHtHve/ieGHanF1syFNmngbN2u1 uDMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x0CYNgtpgCn+cnoqKOR8BwHkaVovRrZnVwcwI5TevkQ=; b=QlOpzs0liMs4Lm8RGT8ofHBFvPmNhbljh7yjLT7oQNDIIt+dA7xfyOR7V4RzO2pfuJ y1lTL1+B9wjEGS7tGY9FexzpsE34LaTO+GQYIQJNiyTHXci363ace1YcD3EmucNjU1M1 fMGM8N939+mHixqdNA7nPoe7/YdOACojwovh7mBTeSLIjxdM0ont3C5a3SBkjUmlBBOz oFJfFfag/1vw6jbNA6Vz1l1GBN5zD5okl0jR8KeW8nNtjRCWpCkZtJGHepJp0ObsAZzF EyAmHoVjeqZg7wlZhgKKSecRuViHs5Owmc3ABOyQi06SV206TZCAhvphvbR0HrCCahSD XUXQ== X-Gm-Message-State: AOAM533mavqq4C726p+9PfN3VXa/tVntLp8hLBQ+jwkGjxnqqdHaAfc1 M45JFWt4WDlZoqpYnP1KBIQKvaPxlC3RTE+0p04= X-Google-Smtp-Source: ABdhPJyqGGn24vCkLa709JJbZBt1dGR6B8TtPa/r0AiisSaB76dEs28z1MP5wdfM7GnBhamcpKeHyc7ZP5CKLOoOsCo= X-Received: by 2002:a02:c053:: with SMTP id u19mr10854208jam.5.1639690986251; Thu, 16 Dec 2021 13:43:06 -0800 (PST) MIME-Version: 1.0 References: <20211215154408.248444-1-stefanb@linux.ibm.com> In-Reply-To: <20211215154408.248444-1-stefanb@linux.ibm.com> From: Shivanshu Goyal Date: Thu, 16 Dec 2021 13:42:55 -0800 Message-ID: Subject: Re: [PATCH] OvmfPkg: Call PlatformInitializeConsole for GPU passthrough case To: Stefan Berger Cc: devel@edk2.groups.io, marcandre.lureau@redhat.com, Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann Content-Type: multipart/alternative; boundary="000000000000c6ed5705d34a4ec6" --000000000000c6ed5705d34a4ec6 Content-Type: text/plain; charset="UTF-8" Thank you for making this change Stefan. I tested your patch locally on my GPU passthrough Windows 10 VM and it successfully fixes it. I added a "Tested-by:" note inline in your patch. Thank you, Shivanshu Goyal On Wed, Dec 15, 2021 at 7:44 AM Stefan Berger wrote: > For GPU passthrough support we have to initialize the console after > EfiBootManagerDispatchDeferredImages() has loaded ROMs. This was the > calling order before the TCG physical presence support moved it to > before End-of-DXE since End-of-DXE disables the TPM 2 platform > hierarchy and some physical presence commands would not work otherwise. > To enable user interaction, the console initialization was also moved > to before End-of-DXE. With this fix, the console is now initialized twice > where the second initialization fixes the GPU passthrough support but it > doesn't allow user interaction for TCG physical presence when GPU > passthrough is used. > > Fixes: b8675deaa819631db2667df63f89799fe65fc906 > Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3771 > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Cc: Gerd Hoffmann > Signed-off-by: Stefan Berger > Tested-by: Shivanshu Goyal > --- > OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | 7 +++++++ > OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c | 6 ++++++ > OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c | 6 ++++++ > 3 files changed, 19 insertions(+) > > diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c > b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c > index 186401296a..faf5d2b9ae 100644 > --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c > +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c > @@ -414,6 +414,13 @@ PlatformBootManagerBeforeConsole ( > // > EfiBootManagerDispatchDeferredImages (); > > + // > + // GPU passthrough only allows console enablement after ROM image load > + // > + PlatformInitializeConsole ( > + XenDetected() ? gXenPlatformConsole : gPlatformConsole); > + > + > FrontPageTimeout = GetFrontPageTimeoutFromQemu (); > PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout); > ASSERT_RETURN_ERROR (PcdStatus); > diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c > b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c > index e767c3b172..0dab0ecbb7 100644 > --- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c > +++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c > @@ -400,6 +400,12 @@ PlatformBootManagerBeforeConsole ( > // > EfiBootManagerDispatchDeferredImages (); > > + // > + // GPU passthrough only allows console enablement after ROM image load > + // > + PlatformInitializeConsole ( > + XenDetected() ? gXenPlatformConsole : gPlatformConsole); > + > PlatformRegisterOptionsAndKeys (); > > // > diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c > b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c > index fd80577355..b82931d726 100644 > --- a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c > +++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c > @@ -363,6 +363,12 @@ PlatformBootManagerBeforeConsole ( > // > EfiBootManagerDispatchDeferredImages (); > > + // > + // GPU passthrough only allows console enablement after ROM image load > + // > + PlatformInitializeConsole ( > + XenDetected() ? gXenPlatformConsole : gPlatformConsole); > + > Status = gRT->SetVariable ( > EFI_TIME_OUT_VARIABLE_NAME, > &gEfiGlobalVariableGuid, > -- > 2.31.1 > > -- Shivanshu Goyal shivanshu.ca --000000000000c6ed5705d34a4ec6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for making this change Stefan. I tested you= r patch locally on my GPU passthrough Windows 10 VM and it successfully fix= es it.
I added a "Tested-by:" note inline in your patch= .

Thank you,
Shivanshu Goyal

On Wed, Dec = 15, 2021 at 7:44 AM Stefan Berger <stefanb@linux.ibm.com> wrote:
For GPU passthrough support we have to initialize = the console after
EfiBootManagerDispatchDeferredImages() has loaded ROMs. This was the
calling order before the TCG physical presence support moved it to
before End-of-DXE since End-of-DXE disables the TPM 2 platform
hierarchy and some physical presence commands would not work otherwise.
To enable user interaction, the console initialization was also moved
to before End-of-DXE. With this fix, the console is now initialized twice where the second initialization fixes the GPU passthrough support but it doesn't allow user interaction for TCG physical presence when GPU
passthrough is used.

Fixes: b8675deaa819631db2667df63f89799fe65fc906
Fixes: https://bugzilla.tianocore.org/show_bug.= cgi?id=3D3771
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Tested-= by: Shivanshu Goyal <shivanshu3@= gmail.com>=C2=A0
---
=C2=A0OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c=C2=A0 =C2=A0 =C2= =A0 | 7 +++++++
=C2=A0OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c | 6 ++++++<= br> =C2=A0OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c=C2=A0 | 6 ++= ++++
=C2=A03 files changed, 19 insertions(+)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg= /Library/PlatformBootManagerLib/BdsPlatform.c
index 186401296a..faf5d2b9ae 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -414,6 +414,13 @@ PlatformBootManagerBeforeConsole (
=C2=A0 =C2=A0//
=C2=A0 =C2=A0EfiBootManagerDispatchDeferredImages ();

+=C2=A0 //
+=C2=A0 // GPU passthrough only allows console enablement after ROM image l= oad
+=C2=A0 //
+=C2=A0 PlatformInitializeConsole (
+=C2=A0 =C2=A0 XenDetected() ? gXenPlatformConsole : gPlatformConsole);
+
+
=C2=A0 =C2=A0FrontPageTimeout =3D GetFrontPageTimeoutFromQemu ();
=C2=A0 =C2=A0PcdStatus =3D PcdSet16S (PcdPlatformBootTimeOut, FrontPageTime= out);
=C2=A0 =C2=A0ASSERT_RETURN_ERROR (PcdStatus);
diff --git a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c b/Ov= mfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
index e767c3b172..0dab0ecbb7 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c
@@ -400,6 +400,12 @@ PlatformBootManagerBeforeConsole (
=C2=A0 =C2=A0//
=C2=A0 =C2=A0EfiBootManagerDispatchDeferredImages ();

+=C2=A0 //
+=C2=A0 // GPU passthrough only allows console enablement after ROM image l= oad
+=C2=A0 //
+=C2=A0 PlatformInitializeConsole (
+=C2=A0 =C2=A0 XenDetected() ? gXenPlatformConsole : gPlatformConsole);
+
=C2=A0 =C2=A0PlatformRegisterOptionsAndKeys ();

=C2=A0 =C2=A0//
diff --git a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c b/Ovm= fPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
index fd80577355..b82931d726 100644
--- a/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c
@@ -363,6 +363,12 @@ PlatformBootManagerBeforeConsole (
=C2=A0 =C2=A0//
=C2=A0 =C2=A0EfiBootManagerDispatchDeferredImages ();

+=C2=A0 //
+=C2=A0 // GPU passthrough only allows console enablement after ROM image l= oad
+=C2=A0 //
+=C2=A0 PlatformInitializeConsole (
+=C2=A0 =C2=A0 XenDetected() ? gXenPlatformConsole : gPlatformConsole);
+
=C2=A0 =C2=A0Status =3D gRT->SetVariable (
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0EFI_TI= ME_OUT_VARIABLE_NAME,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&g= EfiGlobalVariableGuid,
--
2.31.1



--
Shivanshu Goyal
--000000000000c6ed5705d34a4ec6--