public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang
@ 2019-11-18  9:08 Tiger Liu(BJ-RD)
  2019-11-18 16:27 ` Michael D Kinney
  0 siblings, 1 reply; 5+ messages in thread
From: Tiger Liu(BJ-RD) @ 2019-11-18  9:08 UTC (permalink / raw)
  To: devel@edk2.groups.io

Dear All:
I met a question during debug multi-processor code.

I found if AP's procedure call GetPeiServicesTablePointer function , then it would hang.
GetPeiServicesTablePointer (
  VOID
  )
{
  CONST EFI_PEI_SERVICES  **PeiServices;
  IA32_DESCRIPTOR   Idtr;

  AsmReadIdtr (&Idtr);
  PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
  ASSERT (PeiServices != NULL);
  return PeiServices;
}

It seems BSP and AP use different IDT table? Why?

Thanks


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang
  2019-11-18  9:08 Tiger Liu(BJ-RD)
@ 2019-11-18 16:27 ` Michael D Kinney
  0 siblings, 0 replies; 5+ messages in thread
From: Michael D Kinney @ 2019-11-18 16:27 UTC (permalink / raw)
  To: devel@edk2.groups.io, tigerliu@zhaoxin.com, Kinney, Michael D

PEI Phase execution environment is focused on BSP execution.
The PEI Services and most of the PPI services are not designed
to be MP safe.  Since it is not safe for an AP to call PEI Services,
the IDT entry with the pointer to the PEI Service Table is
not available to an AP to prevent code from incorrectly calling
a PEI Service from an AP.

It is legal to run code on an AP in the PEI Phase, but the
code executed must be carefully designed to not use PEI Services
and is usually designed to execute using only stack/memory and 
system resources that have assigned for exclusive access by an AP.
This is usually communicated from BSP to an AP through a mailbox
in memory.  If an AP needs something like a PEI Service (e.g. 
memory allocation or logging), then the AP should make that 
request to the BSP to perform that operation for the AP.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On
> Behalf Of Tiger Liu(BJ-RD)
> Sent: Monday, November 18, 2019 1:08 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer function hang
> 
> Dear All:
> I met a question during debug multi-processor code.
> 
> I found if AP's procedure call
> GetPeiServicesTablePointer function , then it would
> hang.
> GetPeiServicesTablePointer (
>   VOID
>   )
> {
>   CONST EFI_PEI_SERVICES  **PeiServices;
>   IA32_DESCRIPTOR   Idtr;
> 
>   AsmReadIdtr (&Idtr);
>   PeiServices = (CONST EFI_PEI_SERVICES **)
> (*(UINTN*)(Idtr.Base - sizeof (UINTN)));
>   ASSERT (PeiServices != NULL);
>   return PeiServices;
> }
> 
> It seems BSP and AP use different IDT table? Why?
> 
> Thanks
> 
> 
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容
> 做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged
> information and is for the sole use of its intended
> recipient. Any unauthorized review, use, copying or
> forwarding of this email or the content of this email
> is strictly prohibited.
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang
@ 2019-11-19  1:20 Tiger Liu(BJ-RD)
  2019-11-19  1:51 ` Michael D Kinney
  0 siblings, 1 reply; 5+ messages in thread
From: Tiger Liu(BJ-RD) @ 2019-11-19  1:20 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io

Hi, Mike:
Got it!
Thank you very much!

I have another question:
Why does AP use an IDT table which is different with BSP?
Is there other concern?

Thanks
-----邮件原件-----
发件人: Kinney, Michael D <michael.d.kinney@intel.com>
发送时间: 2019年11月19日 0:27
收件人: devel@edk2.groups.io; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>; Kinney, Michael D <michael.d.kinney@intel.com>
主题: RE: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang

PEI Phase execution environment is focused on BSP execution.
The PEI Services and most of the PPI services are not designed to be MP safe.  Since it is not safe for an AP to call PEI Services, the IDT entry with the pointer to the PEI Service Table is not available to an AP to prevent code from incorrectly calling a PEI Service from an AP.

It is legal to run code on an AP in the PEI Phase, but the code executed must be carefully designed to not use PEI Services and is usually designed to execute using only stack/memory and system resources that have assigned for exclusive access by an AP.
This is usually communicated from BSP to an AP through a mailbox in memory.  If an AP needs something like a PEI Service (e.g.
memory allocation or logging), then the AP should make that request to the BSP to perform that operation for the AP.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Tiger
> Liu(BJ-RD)
> Sent: Monday, November 18, 2019 1:08 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer
> function hang
>
> Dear All:
> I met a question during debug multi-processor code.
>
> I found if AP's procedure call
> GetPeiServicesTablePointer function , then it would hang.
> GetPeiServicesTablePointer (
>   VOID
>   )
> {
>   CONST EFI_PEI_SERVICES  **PeiServices;
>   IA32_DESCRIPTOR   Idtr;
>
>   AsmReadIdtr (&Idtr);
>   PeiServices = (CONST EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.Base -
> sizeof (UINTN)));
>   ASSERT (PeiServices != NULL);
>   return PeiServices;
> }
>
> It seems BSP and AP use different IDT table? Why?
>
> Thanks
>
>
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容
> 做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged information and
> is for the sole use of its intended recipient. Any unauthorized
> review, use, copying or forwarding of this email or the content of
> this email is strictly prohibited.
>
> 



保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang
  2019-11-19  1:20 [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang Tiger Liu(BJ-RD)
@ 2019-11-19  1:51 ` Michael D Kinney
  0 siblings, 0 replies; 5+ messages in thread
From: Michael D Kinney @ 2019-11-19  1:51 UTC (permalink / raw)
  To: Tiger Liu(BJ-RD), devel@edk2.groups.io, Kinney, Michael D

That is the only reason the IDTs are different.

Earlier in this project, the same IDT was used by BSP and
APs.  This meant APs could call PEI Services and we did not
know until there was a side effect.  By using different IDTs,
we catch APs calling PEI Services immediately.

Mike

> -----Original Message-----
> From: Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>
> Sent: Monday, November 18, 2019 5:21 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>;
> devel@edk2.groups.io
> Subject: Re: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer function hang
> 
> Hi, Mike:
> Got it!
> Thank you very much!
> 
> I have another question:
> Why does AP use an IDT table which is different with
> BSP?
> Is there other concern?
> 
> Thanks
> -----邮件原件-----
> 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> 发送时间: 2019年11月19日 0:27
> 收件人: devel@edk2.groups.io; Tiger Liu(BJ-RD)
> <TigerLiu@zhaoxin.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> 主题: RE: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer function hang
> 
> PEI Phase execution environment is focused on BSP
> execution.
> The PEI Services and most of the PPI services are not
> designed to be MP safe.  Since it is not safe for an AP
> to call PEI Services, the IDT entry with the pointer to
> the PEI Service Table is not available to an AP to
> prevent code from incorrectly calling a PEI Service
> from an AP.
> 
> It is legal to run code on an AP in the PEI Phase, but
> the code executed must be carefully designed to not use
> PEI Services and is usually designed to execute using
> only stack/memory and system resources that have
> assigned for exclusive access by an AP.
> This is usually communicated from BSP to an AP through
> a mailbox in memory.  If an AP needs something like a
> PEI Service (e.g.
> memory allocation or logging), then the AP should make
> that request to the BSP to perform that operation for
> the AP.
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On
> Behalf Of Tiger
> > Liu(BJ-RD)
> > Sent: Monday, November 18, 2019 1:08 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer
> > function hang
> >
> > Dear All:
> > I met a question during debug multi-processor code.
> >
> > I found if AP's procedure call
> > GetPeiServicesTablePointer function , then it would
> hang.
> > GetPeiServicesTablePointer (
> >   VOID
> >   )
> > {
> >   CONST EFI_PEI_SERVICES  **PeiServices;
> >   IA32_DESCRIPTOR   Idtr;
> >
> >   AsmReadIdtr (&Idtr);
> >   PeiServices = (CONST EFI_PEI_SERVICES **)
> (*(UINTN*)(Idtr.Base -
> > sizeof (UINTN)));
> >   ASSERT (PeiServices != NULL);
> >   return PeiServices;
> > }
> >
> > It seems BSP and AP use different IDT table? Why?
> >
> > Thanks
> >
> >
> > 保密声明:
> > 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内
> 容
> > 做任何未经授权的查阅、使用、复制或转发。
> > CONFIDENTIAL NOTE:
> > This email contains confidential or legally
> privileged information and
> > is for the sole use of its intended recipient. Any
> unauthorized
> > review, use, copying or forwarding of this email or
> the content of
> > this email is strictly prohibited.
> >
> > 
> 
> 
> 
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容
> 做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged
> information and is for the sole use of its intended
> recipient. Any unauthorized review, use, copying or
> forwarding of this email or the content of this email
> is strictly prohibited.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang
@ 2019-11-19  2:37 Tiger Liu(BJ-RD)
  0 siblings, 0 replies; 5+ messages in thread
From: Tiger Liu(BJ-RD) @ 2019-11-19  2:37 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io

Hi, Mike:
Got it!

Thanks

Best wishes,
-----邮件原件-----
发件人: Kinney, Michael D <michael.d.kinney@intel.com>
发送时间: 2019年11月19日 9:51
收件人: Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>; devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>
主题: RE: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang

That is the only reason the IDTs are different.

Earlier in this project, the same IDT was used by BSP and APs.  This meant APs could call PEI Services and we did not know until there was a side effect.  By using different IDTs, we catch APs calling PEI Services immediately.

Mike

> -----Original Message-----
> From: Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>
> Sent: Monday, November 18, 2019 5:21 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>;
> devel@edk2.groups.io
> Subject: Re: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer function hang
>
> Hi, Mike:
> Got it!
> Thank you very much!
>
> I have another question:
> Why does AP use an IDT table which is different with BSP?
> Is there other concern?
>
> Thanks
> -----邮件原件-----
> 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> 发送时间: 2019年11月19日 0:27
> 收件人: devel@edk2.groups.io; Tiger Liu(BJ-RD) <TigerLiu@zhaoxin.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>
> 主题: RE: [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer
> function hang
>
> PEI Phase execution environment is focused on BSP execution.
> The PEI Services and most of the PPI services are not designed to be
> MP safe.  Since it is not safe for an AP to call PEI Services, the IDT
> entry with the pointer to the PEI Service Table is not available to an
> AP to prevent code from incorrectly calling a PEI Service from an AP.
>
> It is legal to run code on an AP in the PEI Phase, but the code
> executed must be carefully designed to not use PEI Services and is
> usually designed to execute using only stack/memory and system
> resources that have assigned for exclusive access by an AP.
> This is usually communicated from BSP to an AP through a mailbox in
> memory.  If an AP needs something like a PEI Service (e.g.
> memory allocation or logging), then the AP should make that request to
> the BSP to perform that operation for the AP.
>
> Mike
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On
> Behalf Of Tiger
> > Liu(BJ-RD)
> > Sent: Monday, November 18, 2019 1:08 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [edk2] AP core : call
> GetPeiServicesTablePointer
> > function hang
> >
> > Dear All:
> > I met a question during debug multi-processor code.
> >
> > I found if AP's procedure call
> > GetPeiServicesTablePointer function , then it would
> hang.
> > GetPeiServicesTablePointer (
> >   VOID
> >   )
> > {
> >   CONST EFI_PEI_SERVICES  **PeiServices;
> >   IA32_DESCRIPTOR   Idtr;
> >
> >   AsmReadIdtr (&Idtr);
> >   PeiServices = (CONST EFI_PEI_SERVICES **)
> (*(UINTN*)(Idtr.Base -
> > sizeof (UINTN)));
> >   ASSERT (PeiServices != NULL);
> >   return PeiServices;
> > }
> >
> > It seems BSP and AP use different IDT table? Why?
> >
> > Thanks
> >
> >
> > 保密声明:
> > 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内
> 容
> > 做任何未经授权的查阅、使用、复制或转发。
> > CONFIDENTIAL NOTE:
> > This email contains confidential or legally
> privileged information and
> > is for the sole use of its intended recipient. Any
> unauthorized
> > review, use, copying or forwarding of this email or
> the content of
> > this email is strictly prohibited.
> >
> > 
>
>
>
> 保密声明:
> 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容
> 做任何未经授权的查阅、使用、复制或转发。
> CONFIDENTIAL NOTE:
> This email contains confidential or legally privileged information and
> is for the sole use of its intended recipient. Any unauthorized
> review, use, copying or forwarding of this email or the content of
> this email is strictly prohibited.


保密声明:
本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。
CONFIDENTIAL NOTE:
This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-19  2:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-19  1:20 [edk2-devel] [edk2] AP core : call GetPeiServicesTablePointer function hang Tiger Liu(BJ-RD)
2019-11-19  1:51 ` Michael D Kinney
  -- strict thread matches above, loose matches on Subject: below --
2019-11-19  2:37 Tiger Liu(BJ-RD)
2019-11-18  9:08 Tiger Liu(BJ-RD)
2019-11-18 16:27 ` Michael D Kinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox