From: "James Bottomley" <James.Bottomley@HansenPartnership.com>
To: Min Xu <min.m.xu@intel.com>, Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>, devel@edk2.groups.io
Subject: Regression: 100x I/O performance slowdown in SEC phase caused by TDX
Date: Tue, 12 Apr 2022 17:22:01 -0400 [thread overview]
Message-ID: <e69f65c5800014337d4a06bee96211e4b55bed43.camel@HansenPartnership.com> (raw)
I'm using a SEC phase which has a TPM driver to experiment with sorting
out measured boot, which is how I noticed (usually SEC doesn't do MMIO)
. What I'm seeing is after commit b6b2de884864 ("MdePkg: Support mmio
for Tdx guest in BaseIoLibIntrinsic") we get a massive slowdown of
about 100x in TPM performance. The reason seems to be this addition to
the mmioreadX/mmiowriteX code:
MemoryFence ();
- *(volatile UINT16 *)Address = Value;
+
+ if (IsTdxGuest ()) {
+ TdMmioWrite16 (Address, Value);
+ } else {
+ *(volatile UINT16 *)Address = Value;
+ }
+
MemoryFence ();
The problem is that IsTdxGuest () has this structure:
BOOLEAN
EFIAPI
IsTdxGuest (
VOID
)
{
if (mTdxProbed) {
return mTdxEnabled;
}
mTdxEnabled = TdIsEnabled ();
mTdxProbed = TRUE;
return mTdxEnabled;
}
Which is trying to cache the result of the probe in the efi data
segment. However, that doesn't work in SEC, because the data segment
is read only (so the write seems to succeed but a read will always
return the original value), leading to us calling TdIsEnabled() check
for every mmio we do, which is causing the slowdown because it's very
expensive.
James
next reply other threads:[~2022-04-12 21:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 21:22 James Bottomley [this message]
2022-04-13 3:33 ` [edk2-devel] Regression: 100x I/O performance slowdown in SEC phase caused by TDX Min Xu
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=e69f65c5800014337d4a06bee96211e4b55bed43.camel@HansenPartnership.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