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 ACE31D81113 for ; Mon, 8 Jan 2024 12:16:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ARWitlJ9u/vL+uydpCAYyQe/RHjpbTFJjvOkNuyTYNo=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version: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=1704716217; v=1; b=Xuu4QVnnbMBsJFWgp3IvHoj49WVX4zQuGfoNFFtq0h3f/PubtE1r2Vu/ZKHIesziDOyj+6/g IbS1auozKgwuHlS+fG7VsYAED3s29lz0zjQolHpg7j8bWR5tQ9/qxM2ToK6xXigon2KSjny8YUl G0UPgYWahIqh51WRQWx6x9A8= X-Received: by 127.0.0.2 with SMTP id yAdpYY7687511xv3BDBJO023; Mon, 08 Jan 2024 04:16:57 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.5310.1704716216536452901 for ; Mon, 08 Jan 2024 04:16:56 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-91-qVDnK9SJOiGu4aGlj1w7TQ-1; Mon, 08 Jan 2024 07:16:52 -0500 X-MC-Unique: qVDnK9SJOiGu4aGlj1w7TQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9D92837186; Mon, 8 Jan 2024 12:16:50 +0000 (UTC) X-Received: from [10.39.192.221] (unknown [10.39.192.221]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DB351C060AF; Mon, 8 Jan 2024 12:16:49 +0000 (UTC) Message-ID: <90dd9b46-b0a6-99f3-db30-4225c337e0a9@redhat.com> Date: Mon, 8 Jan 2024 13:16:47 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint To: Oliver Smith-Denny , devel@edk2.groups.io, yeoreum.yun@arm.com, Ard Biesheuvel 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> <51aea8c8-25bd-4630-b305-e4337284661e@linux.microsoft.com> From: "Laszlo Ersek" In-Reply-To: <51aea8c8-25bd-4630-b305-e4337284661e@linux.microsoft.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 1JnwKokxUFbd8CoBSpMcbJZ4x7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 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=Xuu4QVnn; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) On 1/5/24 19:38, Oliver Smith-Denny wrote: > On 1/5/2024 9:22 AM, levi.yun wrote: >> >> Hi Ard :) >> >>> 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. >> >> That means all DEBUG used in _ModuleEntryPoint can use uninitialized >> serial port. >> one of typical example is GetSpmVersion function. >> >> _ModuleEntryPoint (in StandAloneMmCoreEntry) >> >> // Hazard Area start >> GetSpmVersion >> DEBUG (DEBUG_INFO, xxx) // It could be use uninitalized >> Serial port. >> >> ... >> // Hazard Area end >> ProcessModuleEntryPointList (StandAloneMmMain) >> ProcessLibraryConstructorList // Here. call DebugLib >> constructor with SerialPortIntialize >> >> 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. >> >> 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: > 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. My personal conclusion in that thread was [1], and correspondingly, commit 5087a0773645 ("ArmVirtPkg/FdtPL011SerialPortLib: initialize implicitly", 2023-10-07). In the end, the only tractable solution was to initialize the serial port (hardware, and library instance) exactly once, in (a) the constructor, or (b) the explicit SerialPortInitialize() call, or (c) any SerialPortLib API, whichever occurred first. (And (a) and (b) can be coalesced, because SerialPortInitialize() can be marked as the constructor for the lib instance.) [1] http://mid.mail-archive.com/542db9e1-cd28-27a2-3a98-5b0c85cd7c79@redhat= .com https://edk2.groups.io/g/devel/message/109235 Laszlo -=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 (#113386): https://edk2.groups.io/g/devel/message/113386 Mute This Topic: https://groups.io/mt/103540969/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-