From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web09.6217.1634197813281268194 for ; Thu, 14 Oct 2021 00:50:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J230FHNR; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634197812; 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: in-reply-to:in-reply-to:references:references; bh=NtRdZo8fJzKbPNHdv4g+i5d54/hvi3GOP36iDTF1rRw=; b=J230FHNRtvWdHHvrJ56cdxqQvZ0NQDbqa/Yhn+M0DJslyS36iIKLO6u+scU4q1z2NysPcs Xlefi/cyBoHI0UZZyCaTClCYtzhGzWSi0ULvvuSGnXs0WDhtpvBEiKJglmyiR1wFkWMvuC 4tNQFVloofjjRDoTww70dRweNkG8MEY= 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-275-sJOhaRYSPM-b5TbTsQ0FGw-1; Thu, 14 Oct 2021 03:50:07 -0400 X-MC-Unique: sJOhaRYSPM-b5TbTsQ0FGw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A76D391271; Thu, 14 Oct 2021 07:50:05 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F2965BAE6; Thu, 14 Oct 2021 07:50:05 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3023318007AC; Thu, 14 Oct 2021 09:50:03 +0200 (CEST) Date: Thu, 14 Oct 2021 09:50:03 +0200 From: "Gerd Hoffmann" To: Brijesh Singh Cc: devel@edk2.groups.io, James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Erdem Aktas , Michael Roth , Laszlo Ersek Subject: Re: [PATCH v9 13/32] OvmfPkg/AmdSevDxe: do not use extended PCI config space Message-ID: <20211014075003.w77mydav2yyic4jd@sirius.home.kraxel.org> References: <20211013165713.727815-1-brijesh.singh@amd.com> <20211013165713.727815-14-brijesh.singh@amd.com> MIME-Version: 1.0 In-Reply-To: <20211013165713.727815-14-brijesh.singh@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 13, 2021 at 11:56:54AM -0500, Brijesh Singh wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3275 > > Commit 85b8eac59b8c5bd9c7eb9afdb64357ce1aa2e803 added support to ensure > that MMIO is only performed against the un-encrypted memory. If MMIO > is performed against encrypted memory, a #GP is raised. > > The AmdSevDxe uses the functions provided by the MemEncryptSevLib to > clear the memory encryption mask from the page table. If the > MemEncryptSevLib is extended to include VmgExitLib then depedency > chain will look like this: > > OvmfPkg/AmdSevDxe/AmdSevDxe.inf > -----> MemEncryptSevLib class > -----> "OvmfPkg/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf" instance > -----> VmgExitLib class > -----> "OvmfPkg/VmgExitLib" instance > -----> LocalApicLib class > -----> "UefiCpuPkg/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf" instance > -----> TimerLib class > -----> "OvmfPkg/AcpiTimerLib/DxeAcpiTimerLib.inf" instance > -----> PciLib class > -----> "OvmfPkg/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf" instance > -----> PciExpressLib class > -----> "MdePkg/BasePciExpressLib/BasePciExpressLib.inf" instance > > The LocalApicLib provides a constructor that gets called before the > AmdSevDxe can clear the memory encryption mask from the MMIO regions. > > When running under the Q35 machine type, the call chain looks like this: > > AcpiTimerLibConstructor () [AcpiTimerLib] > PciRead32 () [DxePciLibI440FxQ35] > PciExpressRead32 () [PciExpressLib] > > The PciExpressRead32 () reads the MMIO region. The MMIO regions are not > yet mapped un-encrypted, so the check introduced in the commit > 85b8eac59b8c5bd9c7eb9afdb64357ce1aa2e803 raises a #GP. > > The AmdSevDxe driver does not require the access to the extended PCI > config space. Accessing a normal PCI config space, via IO port should be > sufficent. Use the module-scope override to make the AmdSevDxe use the > BasePciLib instead of BasePciExpressLib so that PciRead32 () uses the > IO ports instead of the extended config space. Acked-by: Gerd Hoffmann