From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web08.7268.1619170140998674900 for ; Fri, 23 Apr 2021 02:29:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gt7xAYRx; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619170140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lKQaySe5PIIfSL3UwEqJs+aSZ6lYMah/Uljkm78dis8=; b=Gt7xAYRx/QfRcWpZD3UpESYbOXRtmVNER8m+srIslOXrvQuQ5uIELdB95Br5chRVDzRJhb iSxbHMEsdRymPtkMG0kMAMzaEDamkKsgpN0ZGCezZGQ5Y2RdeEUsuuBAVErRmA/npBjC6t ofEmFjmnrQdiuGpfYDb9cwzFAQ28Y6E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-Jlerg9-zN5eqXNjcFOxv_Q-1; Fri, 23 Apr 2021 05:28:56 -0400 X-MC-Unique: Jlerg9-zN5eqXNjcFOxv_Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C641E81A281; Fri, 23 Apr 2021 09:28:54 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-2.ams2.redhat.com [10.36.115.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7654819703; Fri, 23 Apr 2021 09:28:52 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 3/3] OvmfPkg/PlatformPei: Mark TPM MMIO range as unencrypted for SEV To: Tom Lendacky , devel@edk2.groups.io Cc: Joerg Roedel , Borislav Petkov , Ard Biesheuvel , Jordan Justen , Brijesh Singh , James Bottomley , Jiewen Yao , Min Xu References: <1677B2EC90F30786.1355@groups.io> <007e59ea-3933-7b93-afff-4023f3111558@amd.com> <08f723a5-9883-7785-91c0-9e5627836288@redhat.com> From: "Laszlo Ersek" Message-ID: <0d9c9497-da65-7a45-9e72-f679cbac62fd@redhat.com> Date: Fri, 23 Apr 2021 11:28:51 +0200 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 04/22/21 21:10, Tom Lendacky wrote: > On 4/22/21 3:39 AM, Laszlo Ersek wrote: >> On 04/22/21 09:34, Laszlo Ersek wrote: >> >>> The new InternalTpmDecryptAddressRange() function should be called >>> from Tcg2ConfigPeimEntryPoint(), before the latter calls >>> InternalTpm12Detect(). Regarding error checking... if >>> InternalTpmDecryptAddressRange() fails, I think we can log an error >>> message, and hang with CpuDeadLoop(). >> > > Unfortunately, this method doesn't work. The OVMF Tcg2ConfigPei.inf file > uses the SecurityPkg Tpm2DeviceLib library. The SecurityPkg Tpm2DeviceLib > library's constructor is called before the OVMF Tcg2ConfigPei constructor. > The Tpm2DeviceLib constructor performs MMIO to the TPM base address and > fails because the pages haven't been marked unencrypted yet by OVMF > Tcg2ConfigPei. Some debug output: > > Loading PEIM at 0x0007F793000 EntryPoint=0x0007F794E4F Tcg2ConfigPei.efi > *** DEBUG: InternalTpm2DeviceLibDTpmCommonConstructor:55 > *** DEBUG: Tpm2GetPtpInterface:425 > *** DEBUG: Tpm2IsPtpPresence:51 > MMIO using encrypted memory: FED40000 > !!!! X64 Exception Type - 0D(#GP - General Protection) CPU Apic ID - 00000000 !!!! Thank you for checking this approach. Let me re-review this patch from scratch. Thanks Laszlo