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 3DAEE74003B for ; Fri, 5 Jan 2024 18:38:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=YXU4wMxPjax9jFhSI6s/M5aRV+l9MjuTLvOPDKfjwIM=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: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=1704479888; v=1; b=etKyuvk/qjH6r+IVPl685HYfKy6+AaaPsE6MRTbl7SmvoiBXstmETugVtNkfIU6pvVK5aust +ss0bs12BVp40CnUch53yZ1HiSnnrY7MBwC/wZlgKyzxUn14QSVHTwAG/G1caJtfhXgftx3mcO9 Dg6+Ndv3nsoPQVjyNmp4kDUo= X-Received: by 127.0.0.2 with SMTP id gJLMYY7687511x5uLAijYHxP; Fri, 05 Jan 2024 10:38:08 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.31159.1704479888231431611 for ; Fri, 05 Jan 2024 10:38:08 -0800 X-Received: from [10.137.194.171] (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 98E3F20B3CC1; Fri, 5 Jan 2024 10:38:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 98E3F20B3CC1 Message-ID: <51aea8c8-25bd-4630-b305-e4337284661e@linux.microsoft.com> Date: Fri, 5 Jan 2024 10:38:07 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint To: devel@edk2.groups.io, yeoreum.yun@arm.com, Ard Biesheuvel , Laszlo Ersek Cc: sami.mujawar@arm.com, ray.ni@intel.com, pierre.gondois@arm.com, nd@arm.com References: <20240105114931.844886-1-yeoreum.yun@arm.com> <5a07db2b-ea25-495d-91f8-7b51ddd9ec75@arm.com> From: "Oliver Smith-Denny" In-Reply-To: <5a07db2b-ea25-495d-91f8-7b51ddd9ec75@arm.com> 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: RHXr8MMi0knsRZDjnVswDRv8x7686176AA= 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="etKyuvk/"; 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 1/5/2024 9:22 AM, levi.yun wrote: >=20 > Hi Ard :) >=20 >> So now we will always initialize the serial port in the entrypoint >> only because DebugLib might use it later with doing the >> initialization. >> >> That doesn't sound quite correct to me. >> >> Could you explain why we cannot rely on DebugLib to call the >> initializer / constructor at the right time? > Because, DebugLib constructor which use serial port is called in > StandAloneMmMain function. > But, this constrcutor is in _ModuleEntryPoint in StandAloneMmCoreEntry. >=20 > That means all DEBUG used in _ModuleEntryPoint can use uninitialized > serial port. > one of typical example is GetSpmVersion function. >=20 > =C2=A0=C2=A0=C2=A0 _ModuleEntryPoint (in StandAloneMmCoreEntry) >=20 > =C2=A0=C2=A0=C2=A0=C2=A0 // Hazard Area start > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 GetSpmVersion > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 DEBUG= (DEBUG_INFO, xxx)=C2=A0 // It could be use uninitalized > Serial port. >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... > =C2=A0=C2=A0=C2=A0 //=C2=A0 Hazard Area end > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ProcessModuleEntryPointList (= StandAloneMmMain) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Proce= ssLibraryConstructorList // Here. call DebugLib > constructor with SerialPortIntialize >=20 > When you see above, I would be clear. between Hazard Area Start to > Hazard Area End. > DEBUG macro would use uninitailized Serial port if that's not > initialized by TF-A. >=20 > So, It should be call SerialPortInitialized at the _ModuleEntryPoint. + Laszlo This sounds very similar to our DxeCore early serial logging discussion a couple months ago :). Laszlo wrote up a good summary here:=20 https://edk2.groups.io/g/devel/topic/101203427#109235. If I am understanding correctly, this would be the "lower left" in Laszlo's diagram. Standalone MM is likely smaller missing window than in DxeCore, but some important information could be lost there (like the SPM version called out, which could be very important for debugging early crashes). So this goes back to should be we have a more generic solution for the cores to use early logging, by fixing the SerialPortLibs? I'll parse this more and reread the old thread further, still paging the info back in. 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 (#113314): https://edk2.groups.io/g/devel/message/113314 Mute This Topic: https://groups.io/mt/103540969/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-