public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Liu, Zhiguang" <zhiguang.liu@intel.com>
Cc: "Dong, Eric" <eric.dong@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>
Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Enhance logic in InitializeMpExceptionStackSwitchHandlers
Date: Thu, 25 Aug 2022 09:32:39 +0000	[thread overview]
Message-ID: <MWHPR11MB1631238689E525AAA22740668C729@MWHPR11MB1631.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220825025506.2323-1-zhiguang.liu@intel.com>

> +  MpInitLibWhoAmI (&Index);
>    SwitchStackData = (EXCEPTION_STACK_SWITCH_CONTEXT *)Buffer;
> -  InitializeSeparateExceptionStacks (SwitchStackData->Buffer,
> SwitchStackData->BufferSize);
> +  if ((SwitchStackData[Index].Status == EFI_NOT_STARTED) ||
> (SwitchStackData[Index].Status == EFI_BUFFER_TOO_SMALL)) {
> +    SwitchStackData[Index].Status = InitializeSeparateExceptionStacks
> (SwitchStackData[Index].Buffer, &SwitchStackData[Index].BufferSize);
> +  }
>  }

1. Can you add comment to explain why BufferTooSmall is checked?
I guess you want to handle the case when calls in some APs succeed
while some calls in other APs get BufferTooSmall.
So this check makes sure that the 2nd call happens only on those failed APs.

> +  SwitchStackData = AllocateRuntimeZeroPool (mNumberOfProcessors *
> sizeof (EXCEPTION_STACK_SWITCH_CONTEXT));
2. Why runtime type memory?

> +      if (SwitchStackData[Index].Status == EFI_BUFFER_TOO_SMALL) {
3. Can you add assertion to make sure " SwitchStackData[Index].BufferSize != 0"?


> +        SwitchStackData[Index].Buffer = (VOID *)(BufferSize + (UINTN)Buffer);
4. Use "&Buffer[BufferSize]";



> 
> -  SwitchStackData.BufferSize = &BufferSize;
>    MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL);
> -  MpInitLibWhoAmI (&Bsp);
> +  SwitchStackData = AllocateRuntimeZeroPool (NumberOfProcessors *
> sizeof (EXCEPTION_STACK_SWITCH_CONTEXT));

5. No need for runtime memory.

> +  for (Index = 0; Index < NumberOfProcessors; ++Index) {
> +    if (SwitchStackData[Index].Status == EFI_BUFFER_TOO_SMALL) {
> +      BufferSize += SwitchStackData[Index].BufferSize;

6. add assertion to make sure ".BufferSize == 0" when ".Status == EFI_SUCCESS".
I think assertion here is better than my last comment which requests assertion in
the other place.

7. Please use AllocatePages in PEI because in a many-core platform the pool 64KB
limitation may cause the code fail to allocate.

Thanks,
Ray

      parent reply	other threads:[~2022-08-25  9:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  2:55 [PATCH] UefiCpuPkg: Enhance logic in InitializeMpExceptionStackSwitchHandlers Zhiguang Liu
2022-08-25  2:55 ` [PATCH] UefiCpuPkg/MpInitLib: Fix potential issue when IDT table is at above 4G Zhiguang Liu
2022-08-25  9:32   ` Ni, Ray
2022-08-25  2:55 ` [PATCH] UefiCpuPkg/MpInitLib: Simplify logic in SwitchBsp Zhiguang Liu
2022-08-25  9:18   ` Ni, Ray
2022-08-25  2:55 ` [PATCH] UefiCpuPkg: Simplify the implementation when separate exception stacks Zhiguang Liu
2022-08-25  9:32 ` Ni, Ray [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR11MB1631238689E525AAA22740668C729@MWHPR11MB1631.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox