From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 82DB7AC12B9 for ; Thu, 7 Sep 2023 15:24:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xfAXLounDgLnvHA1l3qAyKzdAUU52dQFyj0JZ2UbjMk=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1694100279; v=1; b=J5nMECymZrWszRK/TFpqhXQEoPi5ynUFffOhJhXtUMxo1V2mTJMLU+gEKLrcYHoFvk+1ctOO k1mAnrAMhK899vvV89Ff7O4u075Tk/nHtTt/Z+m7ar8Suk1jQ9huMP97D/Qtx2FAAse3E1liGLo jqgYRBL2Z+XDKxj7wxfRRVGY= X-Received: by 127.0.0.2 with SMTP id qoGNYY7687511xWE8RhDQra8; Thu, 07 Sep 2023 08:24:39 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.15921.1694100278581799543 for ; Thu, 07 Sep 2023 08:24:38 -0700 X-Received: from [10.137.194.171] (unknown [131.107.1.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 13465212B5AC; Thu, 7 Sep 2023 08:24:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 13465212B5AC Message-ID: <1e6f37af-f407-43f2-aa14-9c5de85eb404@linux.microsoft.com> Date: Thu, 7 Sep 2023 08:24:37 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 1/1] ArmVirtPkg: Enable Early Serial For DxeCore To: devel@edk2.groups.io, lersek@redhat.com, Ard Biesheuvel References: <27912.1694092220075253890@groups.io> From: "Oliver Smith-Denny" In-Reply-To: <27912.1694092220075253890@groups.io> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: mR7vzVz3ahjQIOpws2zZFDqvx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=J5nMECym; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 9/7/2023 6:10 AM, Laszlo Ersek wrote: > (replying on the webui... sorry!) >=20 > The problem is actually embedded in MdePkg and MdeModulePkg. >=20 > - In DxeMain() (and in functions called by DxeMain()), we call DebugLib= =20 > APIs *before* reaching ProcessLibraryConstructorList(). >=20 > - In ArmVirtQemu, we resolve the DXE Core's DebugLib dependency to=20 > BaseDebugLibSerialPort (from MdePkg). >=20 > - BaseDebugLibSerialPort has a constructor function=20 > (BaseDebugLibSerialPortConstructor()). >=20 > These already suffice for broken DebugLib behavior. APIs of a library=20 > class should not be called because the library instance has a chance to= =20 > initialize. >=20 > The rest is circumstantial. Like, BaseDebugLibSerialPortConstructor=20 > calls SerialPortInitialize, but our SerialPortInitialize (in=20 > FdtPL011SerialPortLib) does nothing. Well, the latter doesn't need to do= =20 > anything, because FdtPL011SerialPortLib has its own constructor=20 > (FdtPL011SerialPortLibInitialize), thus, if constructors were called=20 > properly, then BaseDebugLibSerialPort + FdtPL011SerialPortLib would work= =20 > properly together, regardless of SerialPortInitialize being empty in the= =20 > latter. >=20 > Basically the DXE Core has a hidden requirement -- it can only use such= =20 > DebugLib instances that need no explicit initialization. >=20 > The proposed patch works around the problem by satisfying that hidden=20 > requirement one level lower down: in the SerialPortLib instance. The=20 > initialization of BaseDebugLibSerialPort is still busted (its=20 > constructor is not called, so it cannot call SerialPortInitialize=20 > either), but now it is masked, because EarlyFdtPL011SerialPortLib works= =20 > withouth *both* SerialPortInitialize and construction. >=20 > The real fix would be to make the DXE Core requirement explicit, by=20 > introducing separate (dedicated) DebugLib and SerialPortLib *classes*=20 > (whose APIs are guaranteed to work without initialization). >=20 > Laszlo Thanks for the comprehensive breakdown! :). I completely agree that fixing this at the upper level (and ideally documenting this requirement) is the better move. I can drop this patch and take a crack at that. I'm in the last few weeks leading up to an extended parental leave, so we'll see if I can squeeze it in prior to then :). Oliver -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108402): https://edk2.groups.io/g/devel/message/108402 Mute This Topic: https://groups.io/mt/101203427/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-