From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Wed, 02 Oct 2019 07:38:39 -0700 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 mx1.redhat.com (Postfix) with ESMTPS id 6BA5B30820C9; Wed, 2 Oct 2019 14:38:38 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-71.rdu2.redhat.com [10.10.120.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA40C608A5; Wed, 2 Oct 2019 14:38:37 +0000 (UTC) Subject: Re: [edk2-devel] [RFC PATCH v2 39/44] OvmfPkg: Move the GHCB allocations into reserved memory To: devel@edk2.groups.io, thomas.lendacky@amd.com References: <7a169f2dd9e6ae7f266b8ef2b690865dc04b4764.1568922729.git.thomas.lendacky@amd.com> From: "Laszlo Ersek" Message-ID: <25b37eb8-992d-fccf-ee76-d1b06f7f8cbf@redhat.com> Date: Wed, 2 Oct 2019 16:38:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7a169f2dd9e6ae7f266b8ef2b690865dc04b4764.1568922729.git.thomas.lendacky@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 02 Oct 2019 14:38:38 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/20/19 15:16, Lendacky, Thomas wrote: > From: Tom Lendacky > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 > > After having transitioned from UEFI to the OS, the OS will need to boot > the APs. For an SEV-ES guest, the APs will have been parked by UEFI using > GHCB pages allocated by UEFI. The hypervisor will write to the GHCB > SW_EXITINFO2 field of the GHCB when the AP is booted. As a result, the > GHCB pages must be marked reserved so that the OS does not attempt to use > them and experience memory corruption because of the hypervisor write. > > Change the GHCB allocation from the default boot services memory to > reserved memory. > > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Signed-off-by: Tom Lendacky > --- > OvmfPkg/PlatformPei/AmdSev.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c > index d6733447bdf2..53eeb59702ae 100644 > --- a/OvmfPkg/PlatformPei/AmdSev.c > +++ b/OvmfPkg/PlatformPei/AmdSev.c > @@ -49,9 +49,11 @@ AmdSevEsInitialize ( > > // > // Allocate GHCB pages. > + // Since the pages must survive across the UEFI to OS transition > + // make them reserved. > // > GhcbPageCount = mMaxCpuCount * 2; > - GhcbBase = AllocatePages (GhcbPageCount); > + GhcbBase = AllocateReservedPages (GhcbPageCount); > ASSERT (GhcbBase); > > GhcbBasePa = (PHYSICAL_ADDRESS)(UINTN) GhcbBase; > Reviewed-by: Laszlo Ersek