From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4857C210EB4DD for ; Fri, 10 Aug 2018 09:22:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CFBA4023444; Fri, 10 Aug 2018 16:22:56 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-207.rdu2.redhat.com [10.10.120.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF1987C54; Fri, 10 Aug 2018 16:22:53 +0000 (UTC) To: Eric Dong , edk2-devel@lists.01.org Cc: Ruiyu Ni References: <20180810041909.12776-1-eric.dong@intel.com> <20180810041909.12776-5-eric.dong@intel.com> From: Laszlo Ersek Message-ID: Date: Fri, 10 Aug 2018 18:22:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180810041909.12776-5-eric.dong@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 10 Aug 2018 16:22:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 10 Aug 2018 16:22:56 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [Patch v3 4/5] UefiCpuPkg/CpuS3DataDxe: Remove below 4G limitation. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2018 16:22:57 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/10/18 06:19, Eric Dong wrote: > Because PrepareApStartupVector() stores StackAddress to > "mExchangeInfo->StackStart" (which has type (VOID*)), and because > "UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm" reads the latter with: > > add edi, StackStartAddressLocation > add rax, qword [edi] > mov rsp, rax > mov qword [edi], rax > > in long-mode code. So code can remove below 4G limitation. > > Cc: Laszlo Ersek > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > index 5b99a6e759..d18f33a5b8 100644 > --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c > @@ -46,9 +46,7 @@ typedef struct { > } ACPI_CPU_DATA_EX; > > /** > - Allocate EfiACPIMemoryNVS below 4G memory address. > - > - This function allocates EfiACPIMemoryNVS below 4G memory address. > + Allocate EfiACPIMemoryNVS memory. > > @param[in] Size Size of memory to allocate. > > @@ -56,7 +54,7 @@ typedef struct { > > **/ > VOID * > -AllocateAcpiNvsMemoryBelow4G ( > +AllocateAcpiNvsMemory ( > IN UINTN Size > ) > { > @@ -64,9 +62,8 @@ AllocateAcpiNvsMemoryBelow4G ( > EFI_STATUS Status; > VOID *Buffer; > > - Address = BASE_4GB - 1; > Status = gBS->AllocatePages ( > - AllocateMaxAddress, > + AllocateAnyPages, > EfiACPIMemoryNVS, > EFI_SIZE_TO_PAGES (Size), > &Address > @@ -239,9 +236,13 @@ CpuS3DataInitialize ( > AcpiCpuData->MtrrTable = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable; > > // > - // Allocate stack space for all CPUs > + // Allocate stack space for all CPUs. > + // Use ACPI NVS memory type because this data will be directly used by APs > + // in S3 resume phase in long mode. Also during S3 resume, the stack buffer > + // will only be used as scratch space. i.e. we won't read anything from it > + // before we write to it, in PiSmmCpuDxeSemm. Please fix the typo: "PiSmmCpuDxeSemm" --> "PiSmmCpuDxeSmm". With that: Reviewed-by: Laszlo Ersek Thanks Laszlo > // > - Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize); > + Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize); > ASSERT (Stack != NULL); > AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack; > >