From: "Stefan Berger" <stefanb@linux.ibm.com>
To: "Yao, Jiewen" <jiewen.yao@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>,
"stefanb@linux.vnet.ibm.com" <stefanb@linux.vnet.ibm.com>
Cc: "mhaeuser@posteo.de" <mhaeuser@posteo.de>,
"spbrogan@outlook.com" <spbrogan@outlook.com>,
"marcandre.lureau@redhat.com" <marcandre.lureau@redhat.com>,
"kraxel@redhat.com" <kraxel@redhat.com>
Subject: Re: [edk2-devel] [PATCH v7 0/9] Ovmf: Disable the TPM2 platform hierarchy
Date: Fri, 10 Sep 2021 16:47:46 -0400 [thread overview]
Message-ID: <cb12bd72-185b-5d2d-5995-701918e3c319@linux.ibm.com> (raw)
In-Reply-To: <16A38214549AD34A.16479@groups.io>
On 9/10/21 12:15 PM, Stefan Berger wrote:
>
> On 9/10/21 11:32 AM, Yao, Jiewen wrote:
>> According to the security policy, PP request must be processed before
>> EndOfDxe.
>>
>> May I know when you trigger PP request?
>
> OVMF has 3 implementations invoking it in
> PlatformBootManagerAfterConsole():
>
> https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c#L1517
>
>
> https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformBootManagerLibBhyve/BdsPlatform.c#L1451
>
>
> https://github.com/tianocore/edk2/blob/master/OvmfPkg/Library/PlatformBootManagerLibGrub/BdsPlatform.c#L1316
>
Before I post yet another series...:
The problem is that PPI may require interaction with the console, so it
seems we have to handle it in PlatformBootManagerAfterConsole(). The
disablement of the TPM 2 platform hierarchy may only occur after that,
so we have to move this part here after TPM-PPI-Handling from
BeforeConsole() into AfterConsole() because this is what triggers that
new code from edk2-platforms to disable that TPM 2 platform hierarchy:
Status = gBS->InstallProtocolInterface (&Handle,
&gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
NULL);
And then we have this part here also in BeforeConsole() that has to be
moved as well into AfterConsole().
//
// Dispatch deferred images after EndOfDxe event and ReadyToLock
// installation.
//
EfiBootManagerDispatchDeferredImages ();
This then leads to something like this with the sequence
(TPM-PPI-handling, gEfiDxeSmmReadyToLockProtocol,
EfiBootManagerDispatchDeferredImages) needing to stay in that order.
However, I am not sure know whether one can just move these parts around
like this.
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 71f63b2448..266d58dfbe 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -354,7 +354,6 @@ PlatformBootManagerBeforeConsole (
VOID
)
{
- EFI_HANDLE Handle;
EFI_STATUS Status;
UINT16 FrontPageTimeout;
RETURN_STATUS PcdStatus;
@@ -387,8 +386,10 @@ PlatformBootManagerBeforeConsole (
SaveS3BootScript ();
}
+#if 0
//
// Prevent further changes to LockBoxes or SMRAM.
+ // Any TPM 2 Physical Presence Interface opcode must be handled BEFORE
//
Handle = NULL;
Status = gBS->InstallProtocolInterface (&Handle,
@@ -401,6 +402,7 @@ PlatformBootManagerBeforeConsole (
// installation.
//
EfiBootManagerDispatchDeferredImages ();
+#endif
PlatformInitializeConsole (
XenDetected() ? gXenPlatformConsole : gPlatformConsole);
@@ -437,6 +439,7 @@ PlatformBootManagerBeforeConsole (
//
VisitAllInstancesOfProtocol (&gEfiPciIoProtocolGuid,
ConnectVirtioPciRng,
NULL);
+
}
@@ -1474,6 +1477,8 @@ PlatformBootManagerAfterConsole (
VOID
)
{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
EFI_BOOT_MODE BootMode;
DEBUG ((DEBUG_INFO, "PlatformBootManagerAfterConsole\n"));
@@ -1511,11 +1516,29 @@ PlatformBootManagerAfterConsole (
//
PciAcpiInitialization ();
+#if 1
//
- // Process TPM PPI request
+ // Process TPM PPI request; this may require interaction via console
//
Tcg2PhysicalPresenceLibProcessRequest (NULL);
+ //
+ // Prevent further changes to LockBoxes or SMRAM.
+ // Any TPM 2 Physical Presence Interface opcode must be handled BEFORE
+ //
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (&Handle,
+ &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
+ NULL);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Dispatch deferred images after EndOfDxe event and ReadyToLock
+ // installation.
+ //
+ EfiBootManagerDispatchDeferredImages ();
+#endif
+
//
// Process QEMU's -kernel command line option
//
Stefan
next prev parent reply other threads:[~2021-09-10 20:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 17:35 [PATCH v7 0/9] Ovmf: Disable the TPM2 platform hierarchy Stefan Berger
2021-09-09 17:35 ` [PATCH v7 1/9] SecurityPkg/TPM: Import PeiDxeTpmPlatformHierarchyLib.c from edk2-platforms Stefan Berger
2021-09-09 17:35 ` [PATCH v7 2/9] SecurityPkg/TPM: Fix bugs in imported PeiDxeTpmPlatformHierarchyLib Stefan Berger
2021-09-09 17:35 ` [PATCH v7 3/9] SecrutiyPkg/Tcg: Import Tcg2PlatformDxe from edk2-platforms Stefan Berger
2021-09-09 17:35 ` [PATCH v7 4/9] SecurityPkg/Tcg: Make Tcg2PlatformDxe buildable Stefan Berger
2021-09-09 17:35 ` [PATCH v7 5/9] SecurityPkg: Introduce new PCD PcdRandomizePlatformHierarchy Stefan Berger
2021-09-09 17:35 ` [PATCH v7 6/9] OvmfPkg: Reference new Tcg2PlatformDxe in the build system for compilation Stefan Berger
2021-09-09 17:35 ` [PATCH v7 7/9] SecurityPkg/Tcg: Import Tcg2PlatformPei from edk2-platforms Stefan Berger
2021-09-09 17:35 ` [PATCH v7 8/9] SecurityPkg/Tcg: Make Tcg2PlatformPei buildable Stefan Berger
2021-09-09 17:35 ` [PATCH v7 9/9] OvmfPkg: Reference new Tcg2PlatformPei in the build system Stefan Berger
2021-09-10 14:24 ` [edk2-devel] [PATCH v7 0/9] Ovmf: Disable the TPM2 platform hierarchy Stefan Berger
2021-09-10 15:32 ` Yao, Jiewen
2021-09-10 16:15 ` Stefan Berger
2021-09-11 2:38 ` Yao, Jiewen
2021-09-11 2:46 ` Yao, Jiewen
2021-09-12 0:42 ` Stefan Berger
2021-09-12 0:45 ` Yao, Jiewen
2021-09-12 1:52 ` Stefan Berger
2021-09-13 14:51 ` Stefan Berger
[not found] ` <16A38214549AD34A.16479@groups.io>
2021-09-10 20:47 ` Stefan Berger [this message]
2021-09-13 7:08 ` Yao, Jiewen
[not found] ` <16A44FFF7B7DEB00.6211@groups.io>
2021-09-13 9:31 ` [edk2-devel] " Yao, Jiewen
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=cb12bd72-185b-5d2d-5995-701918e3c319@linux.ibm.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