public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress
@ 2018-09-06 19:08 Nikita Leshenko
  2018-09-07  0:25 ` Ni, Ruiyu
  2018-09-07  8:44 ` Laszlo Ersek
  0 siblings, 2 replies; 8+ messages in thread
From: Nikita Leshenko @ 2018-09-06 19:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Liran Alon

Hi,

We ran into a bug in EDK2 relating to PCI-Express in PciBusDxe. Here's the flow
of the bug:

1. PciBusDxe/PciEnumeratorSupport.c: Function BarExisted probes a BAR. It raises
   TPL to TPL_HIGH_LEVEL to avoid timer interrupts while probing the BAR and
   calls PciIo->Pci.Write.
2. BasePciExpressLib/PciExpressLib.c: The write reaches PciExpressWrite32, which
   calls GetPciExpressBaseAddress.
3. GetPciExpressBaseAddress retrieves the address from PcdPciExpressBaseAddress.
4. Reading the PCD calls DxePcdGet64 -> GetWorker ->
   EfiAcquireLock(&mPcdDatabaseLock), which is at TPL_NOTIFY level. This crashes
   the firmware because step 1 raised the TPL to TPL_HIGH_LEVEL.

This doesn't happen when PcdPciExpressBaseAddress is fixed at build (because
then the read is optimized to a static global variable), but when the PCD is
dynamic PCI-Express is broken.

Does anybody have a suggestion for fixing it?

Options we thought about:
- Change mPcdDatabaseLock.Tpl to TPL_HIGH_LEVEL
- Don't use a PCD for the base address, put it in a static global variable and
  create functions to set and retrieve it.

Thanks,
Nikita

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

end of thread, other threads:[~2018-09-16 12:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 19:08 PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress Nikita Leshenko
2018-09-07  0:25 ` Ni, Ruiyu
2018-09-07  8:44 ` Laszlo Ersek
2018-09-07 17:01   ` Liran Alon
2018-09-11 13:34     ` Laszlo Ersek
2018-09-13 12:27       ` Nikita Leshenko
2018-09-13 13:15         ` Laszlo Ersek
2018-09-16 12:28           ` Nikita Leshenko

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