public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: Nikita Leshenko <nikita.leshchenko@oracle.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: Liran Alon <liran.alon@oracle.com>
Subject: Re: PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress
Date: Fri, 7 Sep 2018 00:25:24 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BDF99C7@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <B8F0AD9D-A640-496A-9ED3-1D9D7D68A756@oracle.com>

Mike,
Do you think that maybe just raising to TPL_NOTIFY is enough for PCI BAR probing?
Though the timer interrupt still triggers, all callbacks are suspended in TPL_NOTIFY.

Thanks,
Ray

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Nikita
> Leshenko
> Sent: Friday, September 7, 2018 3:09 AM
> To: edk2-devel@lists.01.org
> Cc: Liran Alon <liran.alon@oracle.com>
> Subject: [edk2] PciBusDxe: PCI-Express bug with dynamic
> PcdPciExpressBaseAddress
> 
> 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
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2018-09-07  0:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 19:08 PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress Nikita Leshenko
2018-09-07  0:25 ` Ni, Ruiyu [this message]
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

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=734D49CCEBEEF84792F5B80ED585239D5BDF99C7@SHSMSX104.ccr.corp.intel.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