From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=141.146.126.78; helo=aserp2120.oracle.com; envelope-from=nikita.leshchenko@oracle.com; receiver=edk2-devel@lists.01.org Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BE8E12111B773 for ; Thu, 6 Sep 2018 12:09:03 -0700 (PDT) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w86J92Y5007477 for ; Thu, 6 Sep 2018 19:09:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : content-type : content-transfer-encoding : mime-version : subject : message-id : date : cc : to; s=corp-2018-07-02; bh=8lw1pSeH0coH8d+0/mVOwEOg2yykEYuxwAaFg7/xu4E=; b=1EAS5SFmAPQrcLyOQYLEIIhYT41WpNodPrZ/97fBcjsHbnYC0RtpgFlJQdPX++yTO+cL 9LH9nHjYnAhD/ZrAQT+KMKP9e+VfN4M2wHK+waRIB9FXVdaqtVYi+caunTSThPRo4oq/ vGu8LSE1wFERLz4n+hZ3fnJ6WLHKx6mbXJ0Z7+7iUyRUaBxkABBmucNrQXWiR/ePKSp5 iawiLOv5oNoAl0Y3fp3nVEHOBLyj0rgcVwXLLLYw+qwoYs+UlJHm1INMtuiKhSh1xTk1 vlPrFn9YqK0HrSJmcRuZuqOJC8nyvN1mUAEsggNy2zxzqw2tFwU1y/jOc5piHp2jVtXk pw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2m7jqpx0sb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 06 Sep 2018 19:09:02 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w86J92xe005393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 6 Sep 2018 19:09:02 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w86J910J018283 for ; Thu, 6 Sep 2018 19:09:01 GMT Received: from ravellos-mbp.lan (/87.214.231.131) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 06 Sep 2018 19:09:01 +0000 From: Nikita Leshenko Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Message-Id: Date: Thu, 6 Sep 2018 21:08:36 +0200 Cc: Liran Alon To: edk2-devel@lists.01.org X-Mailer: Apple Mail (2.3445.9.1) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9008 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=1 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=1 mlxscore=1 mlxlogscore=222 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809060185 Subject: PciBusDxe: PCI-Express bug with dynamic PcdPciExpressBaseAddress X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 19:09:04 -0000 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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=