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.web10.6056.1610648984900491603 for ; Thu, 14 Jan 2021 10:29:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=byPFJ7pa; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610648984; 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=MJcRx6PigBiww6vw+zd7UpfL52kB1bZUcZt8OgNqDNI=; b=byPFJ7pa/GIuPmA9WOP2QDrbUTW45l7y9ULlPxNxYcbQxHNkkN/R1ZekkGAjXeQlUtdXO8 iso72vHgF7gYZawtdhOxQxI2hUKJC5XA9ifPum89JN1k6M8QGP4vo66bEITM09Ni+1dpkL yPl/ZmI9SR/Cg1qaoKHEcWvIKcgGNdo= 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-335-hcJ_lzyGMsKeY1VTj5N9Hg-1; Thu, 14 Jan 2021 13:29:40 -0500 X-MC-Unique: hcJ_lzyGMsKeY1VTj5N9Hg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98A23802B48; Thu, 14 Jan 2021 18:29:39 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-194.ams2.redhat.com [10.36.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74CD65F708; Thu, 14 Jan 2021 18:29:36 +0000 (UTC) Subject: Re: [PATCH] UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu To: Ray Ni , devel@edk2.groups.io Cc: Eric Dong , Rahul Kumar References: <20210114131200.1659-1-ray.ni@intel.com> From: "Laszlo Ersek" Message-ID: <9fa0ea25-52b6-6064-21f1-fd3ccb14daa2@redhat.com> Date: Thu, 14 Jan 2021 19:29:35 +0100 MIME-Version: 1.0 In-Reply-To: <20210114131200.1659-1-ray.ni@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 01/14/21 14:12, Ray Ni wrote: > When StackGuard is enabled, the CpuMp driver allocates > known good stacks for all CPUs for DF# and PF# exceptions. > It uses AllocatePool to do so. > > The size needed equals to 64KB > = StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16) > > However, AllocatePool max allocation size is less than 64K. > To fix the issue, AllocatePages() is used. > > Signed-off-by: Ray Ni > Cc: Eric Dong > Cc: Laszlo Ersek > Cc: Rahul Kumar > --- > UefiCpuPkg/CpuMpPei/CpuMpPei.c | 10 +++------- > UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 ++- > UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 3 ++- > 3 files changed, 7 insertions(+), 9 deletions(-) > > diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c > index d07540cf74..40729a09b9 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c > +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c > @@ -1,7 +1,7 @@ > /** @file > CPU PEI Module installs CPU Multiple Processor PPI. > > - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers ( > ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList); > NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber; > > - Status = PeiServicesAllocatePool ( > - NewStackSize * NumberOfProcessors, > - (VOID **)&StackTop > - ); > + StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors)); > ASSERT(StackTop != NULL); > - if (EFI_ERROR (Status)) { > - ASSERT_EFI_ERROR (Status); > + if (StackTop == NULL) { > return; > } > StackTop += NewStackSize * NumberOfProcessors; > diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h > index 6a481a84dc..c6870656ca 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h > +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h > @@ -1,7 +1,7 @@ > /** @file > Definitions to install Multiple Processor PPI. > > - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> + Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > extern EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc; > > diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf > index 7e511325d8..ba829d816e 100644 > --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf > +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf > @@ -1,7 +1,7 @@ > ## @file > # CPU driver installs CPU PI Multi-processor PPI. > # > -# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> +# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
> # SPDX-License-Identifier: BSD-2-Clause-Patent > # > ## > @@ -45,6 +45,7 @@ [LibraryClasses] > MpInitLib > BaseMemoryLib > CpuLib > + MemoryAllocationLib > > [Guids] > gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB > Please link into the commit message. Additionally, please add a link, pointing to this message in the list archive, to BZ#3167. Reviewed-by: Laszlo Ersek Thanks Laszlo