From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: devel@edk2.groups.io, lersek@redhat.com
Cc: "Joerg Roedel" <joro@8bytes.org>,
"Borislav Petkov" <bp@alien8.de>,
"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
"Jordan Justen" <jordan.l.justen@intel.com>,
"Brijesh Singh" <brijesh.singh@amd.com>,
"Erdem Aktas" <erdemaktas@google.com>,
"James Bottomley" <jejb@linux.ibm.com>,
"Jiewen Yao" <jiewen.yao@intel.com>,
"Min Xu" <min.m.xu@intel.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Stefan Berger" <stefanb@linux.ibm.com>
Subject: Re: [edk2-devel] [PATCH v2 4/4] OvmfPkg/Tcg2ConfigPei: Mark TPM MMIO range as unencrypted for SEV-ES
Date: Wed, 28 Apr 2021 20:33:21 -0500 [thread overview]
Message-ID: <19b4fa35-ad90-654e-a398-e955b778194a@amd.com> (raw)
In-Reply-To: <096090a1-6fd4-6364-fc88-733a0b3ef422@amd.com>
On 4/28/21 2:43 PM, Tom Lendacky wrote:
> On 4/28/21 12:51 PM, Laszlo Ersek via groups.io wrote:
>> I'm going to ask for v3 after all:
>>
>> On 04/27/21 18:21, Lendacky, Thomas wrote:
>>> From: Tom Lendacky <thomas.lendacky@amd.com>
>>>
>>> BZ: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3345&data=04%7C01%7Cthomas.lendacky%40amd.com%7C3c65ebfe044e4f3eb5b808d90a6e5455%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637552291252644310%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=G1GwQc6sZqRuNHWC5vbdb78gCOl4YkAq%2BHi0F0ceucg%3D&reserved=0
>>>
>>> During PEI, the MMIO range for the TPM is marked as encrypted when running
>>> as an SEV guest. While this isn't an issue for an SEV guest because of
>>> the way the nested page fault is handled, it does result in an SEV-ES
>>> guest terminating because of a mitigation check in the #VC handler to
>>> prevent MMIO to an encrypted address. For an SEV-ES guest, this range
>>> must be marked as unencrypted.
>>>
>>> Create a new x86 PEIM for TPM support that will map the TPM MMIO range as
>>> unencrypted when SEV-ES is active. The gOvmfTpmMmioAccessiblePpiGuid PPI
>>> will be unconditionally installed before exiting. The PEIM will exit with
>>> the EFI_ABORTED status so that the PEIM does not stay resident.
>>
...
>>> +
>>> + //
>>> + // If SEV or SEV-ES is active, MMIO succeeds against an encrypted physical
>>> + // address because the nested page fault (NPF) that occurs on access does not
>>> + // include the encryption bit in the guest physical address provided to the
>>> + // hypervisor.
>>> + //
>>> + // However, if SEV-ES is active, before performing the actual MMIO, an
>>> + // additional MMIO mitigation check is performed in the #VC handler to ensure
>>> + // that MMIO is being done to an unencrypted address. To prevent guest
>>> + // termination in this scenario, mark the range unencrypted ahead of access.
>>> + //
>>
>> Lovely comment, thanks!
I'm going to expand on this a bit more to really show the distinction
between SEV and SEV-ES when it comes to MMIO. Look for a bit more info in v3.
Thanks,
Tom
>>
>>> + if (MemEncryptSevEsIsEnabled ()) {
>>> + DEBUG ((DEBUG_INFO, "%a: mapping TPM MMIO address range unencrypted\n", __FUNCTION__));
>>> +
>>> + DecryptStatus = MemEncryptSevClearPageEncMask (
>>> + 0,
>>> + PcdGet64 (PcdTpmBaseAddress),
>>
>> (11) The INF file says [FixedPcd], so it would be cleanest to say
>> FixedPcdGet64() here.
>
> Will do.
>
>>
>>
>> (12) PcdLib is missing from both the [LibraryClasses] section and the
>> #include directives.
>
> Right, I'll update that.
>
>>
>>
>>> + EFI_SIZE_TO_PAGES ((UINTN) 0x5000),
>>> + FALSE
>>> + );
>>> +
>>> + if (RETURN_ERROR (DecryptStatus)) {
>>> + DEBUG ((DEBUG_INFO, "%a: failed to map TPM MMIO address range unencrypted\n", __FUNCTION__));
>>
>> (13) Overlong line.
>
> Ok, I'll change that. I though that was ok now since PatchCheck.py didn't
> complain.
>
>>
>>
>> (14) Please report errors with DEBUG_ERROR.
>
> Yup, will change.
>
> Thanks,
> Tom
>
>>
>>
>>> + ASSERT_RETURN_ERROR (DecryptStatus);
>>> + }
>>> + }
>>> +
>>> + //
>>> + // MMIO range available
>>> + //
>>> + Status = PeiServicesInstallPpi (&mTpmMmioRangeAccessible);
>>> + ASSERT_EFI_ERROR (Status);
>>> +
>>> + return EFI_ABORTED;
>>> +}
>>>
>>
>> Thanks!
>> Laszlo
>>
>>
>>
>>
>>
>>
next prev parent reply other threads:[~2021-04-29 1:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 16:21 [PATCH v2 0/4] SEV-ES TPM enablement fixes Lendacky, Thomas
2021-04-27 16:21 ` [PATCH v2 1/4] OvfmPkg/VmgExitLib: Properly decode MMIO MOVZX and MOVSX opcodes Lendacky, Thomas
2021-04-28 17:04 ` [edk2-devel] " Laszlo Ersek
2021-04-27 16:21 ` [PATCH v2 2/4] OvmfPkg/VmgExitLib: Add support for new MMIO MOV opcodes Lendacky, Thomas
2021-04-28 17:09 ` [edk2-devel] " Laszlo Ersek
2021-04-27 16:21 ` [PATCH v2 3/4] OvmfPkg: Define a new PPI GUID to signal TPM MMIO accessability Lendacky, Thomas
2021-04-28 17:12 ` [edk2-devel] " Laszlo Ersek
2021-04-28 17:15 ` Laszlo Ersek
2021-04-28 19:25 ` Lendacky, Thomas
2021-04-27 16:21 ` [PATCH v2 4/4] OvmfPkg/Tcg2ConfigPei: Mark TPM MMIO range as unencrypted for SEV-ES Lendacky, Thomas
2021-04-28 17:51 ` [edk2-devel] " Laszlo Ersek
2021-04-28 19:43 ` Lendacky, Thomas
2021-04-29 1:33 ` Lendacky, Thomas [this message]
2021-04-30 15:48 ` Laszlo Ersek
2021-04-30 17:57 ` Lendacky, Thomas
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=19b4fa35-ad90-654e-a398-e955b778194a@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