From: "Brian J. Johnson" <brian.johnson@hpe.com>
To: <devel@edk2.groups.io>, <yeoreum.yun@arm.com>,
Laszlo Ersek <lersek@redhat.com>,
Oliver Smith-Denny <osde@linux.microsoft.com>,
"Ard Biesheuvel" <ardb@kernel.org>
Cc: <sami.mujawar@arm.com>, <ray.ni@intel.com>,
<pierre.gondois@arm.com>, <nd@arm.com>
Subject: Re: [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint
Date: Wed, 10 Jan 2024 15:06:26 -0600 [thread overview]
Message-ID: <10e4dfd5-a086-4889-b531-f697fee022e2@hpe.com> (raw)
In-Reply-To: <9e1c0701-c6f1-45a1-843f-5f4821eb6259@arm.com>
On 1/10/24 11:16, levi.yun wrote:
> Hi, Laszlo.
>> This will keep initing the serial port upon every API call until the
>> global variable becomes writeable, and then the next API call will init
>> the serial port for one last time, and also prevent further page table
>> checks.
>>
>> The CheckWritable() function is an implementation detail. In the DXE
>> phase, it could be implemented (I think?) with the
>> GetMemorySpaceDescriptor() DXE service, or perhaps even the
>> EFI_MEMORY_ATTRIBUTE_PROTOCOL.GetMemoryAttributes() UEFI protocol member
>> function. In the standalone MM core, CheckWritable() could walk the page
>> tables explicitly. The idea is, either way, to *predict* whether writing
>> to "mInitialized" would trap. >> I think it wouldn't proper, to DxeCore and StMM too.
> IIUC, before CoreInitializeMemoryServices is called, we couldn't use
> that method in case DxeCore.
> And the problem now I face is also StMM before populating memory
> information (done in LibConstructor).
>
>
>> Now I think that speculative / out of order execution could actually
>> trigger the trap *before* GlobalsWriteable is calculated; however, I
>> think such a trap should be architecturally hidden (i.e., invisible). I
>> think at worst we could need a compiler barrier (maybe throw in some
>> "volatile" for GlobalsWriteable and mInitialized), so that the
>> *compiler* not try to reorder the accesses. But even that sounds like a
>> stretch.
> Agree if we develop CheckPerm??
>
> Currently, (In my narrow thinking) there is no more generic solution
> than create new interface SerialPortInitilizeEarly.
>
> Am I missing?
>
> Many Thanks.
>
> --------
> Sincerely,
> Levi.
Levi,
FWIW I prefer your original approach: explicitly call
SerialPortInitialize() early enough that you don't need to worry about
output occurring before that point. Then you can also use a
SerialPortLib instance which assumes that this has already been done and
doesn't try to re-initialize the port, which saves some overhead.
Constructors in DebugLib, SerialPortLib, and other very low-level
libraries are problematic due to the issue you ran in to, so it seems
best to just avoid them altogether.
Ard didn't want a SerialPortInitialize() call directly in the
all-platform StandaloneMmCore _ModuleEntryPoint() function, which is
understandable. So perhaps you could either:
1. Propose a platform-specific callout at that point and a library class
to implement it, with an empty instance for general use and your own
platform-specific instance which calls SerialPortInitialize().
or
2. Write your own platform-specific version of StandaloneMmCoreEntryPoint.
--
Brian J. Johnson
Enterprise X86 Lab
Hewlett Packard Enterprise
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113540): https://edk2.groups.io/g/devel/message/113540
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]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-01-10 21:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 11:49 [edk2-devel] [PATCH v1 1/1] StandaloneMmPkg: Initialise serial port early in StandaloneMmEntryPoint levi.yun
2024-01-05 11:52 ` levi.yun
2024-01-05 16:46 ` Ard Biesheuvel
2024-01-05 17:22 ` levi.yun
2024-01-05 18:38 ` Oliver Smith-Denny
2024-01-08 12:16 ` Laszlo Ersek
2024-01-10 16:13 ` levi.yun
2024-01-10 16:41 ` Laszlo Ersek
2024-01-10 17:16 ` levi.yun
2024-01-10 21:06 ` Brian J. Johnson [this message]
2024-01-11 9:05 ` levi.yun
[not found] ` <17A93FAECCFD3533.4530@groups.io>
2024-01-18 10:19 ` levi.yun
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=10e4dfd5-a086-4889-b531-f697fee022e2@hpe.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