public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Abhishek Singh <abh@cs.unc.edu>
To: "Marvin Häuser" <Marvin.Haeuser@outlook.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Laszlo Ersek <lersek@redhat.com>,
	 "afish@apple.com" <afish@apple.com>,
	"ruiyu.ni@intel.com" <ruiyu.ni@intel.com>,
	"eric.dong@intel.com" <eric.dong@intel.com>,
	"star.zeng@intel.com" <star.zeng@intel.com>
Subject: Re: smm lock query
Date: Mon, 28 May 2018 14:02:07 -0400	[thread overview]
Message-ID: <CAGB8-zqRFNr3A5ji-yYu9VXqK1bh3rHkMv9JgVjswYxnthhfgw@mail.gmail.com> (raw)
In-Reply-To: <VI1PR0801MB1790B82640064C967D78AF64806E0@VI1PR0801MB1790.eurprd08.prod.outlook.com>

Thank you everyone for your inputs and clarifications. They are helping me
to better understand the uefi code, to which I am very new. I do not mean
to hijack the thread: so please continue your discussions about whether the
implementation matches the spec.

However, I want to state why I am interested in the IPL code. For my
research, I wish to dump the contents of SMRAM when it has reached steady
state, i.e., all the drivers have made changes to smram and it has been
locked. The current implementation (smm ipl) locks smram when it receives
the SmmReadyToLock event and then propagates the event to the smm drivers
that make further changes to smram. Unfortunately, I cannot take a snapshot
of smram after it has been locked! Thus, I have solved this issue by
propagating the event to the smm drivers first (using
SmmIplGuidedEventNotify), then opening access to and dumping the contents
of SMRAM, and finally closing access to and locking smram. Would it be fair
to say that this would give me the fully initialized contents of smram?



My second observation is that despite opening access to smram, I am unable
to access its contents, which is a violation of the
EFI_MM_ACCESS_PROTOCOL.Open() description in the spec, which says: "This
function “opens” MMRAM so that it is visible while not inside of MM." Note
that I am working with minnowboard firmware release 0.97. So some of the
binaries like SmmAccess.efi are provided by Intel, while others have been
built from the edk source tree: thus, this may not be an EDK issue. Please
suggest further steps and/or workarounds. Should I contact edk2-platforms
maintainers, or start a new thread here for this issue?

-Abhishek


On Mon, May 28, 2018 at 10:03 AM, Marvin Häuser <Marvin.Haeuser@outlook.com>
wrote:

> Hello Andrew and Laszlo,
>
> Thanks for your comments!
> Of course I'm with you that it is the platform that signals the
> SmmReadyToLock event and therefor is aware.
> However, they might rely on the protocol's description that the resources
> are about(!) to be locked and code accordingly, not considering the event
> characteristic of the handler in PiSmmIpl.
> The code might be written by different people, not especially reviewed
> against edk2's actions, or additional code might be supplied by third
> parties that do not have tree code access (which, by integration, would be
> "platform binaries" by the definition applying here).
>
> Therefor I would still ask everyone to consider figuring out a solution to
> this discrepancy from the specification, such as the internal "dummy event"
> I proposed.
>
> Thanks,
> Marvin.
>
> > -----Original Message-----
> > From: Laszlo Ersek <lersek@redhat.com>
> > Sent: Monday, May 28, 2018 12:58 PM
> > To: Andrew Fish <afish@apple.com>; Marvin H?user
> > <Marvin.Haeuser@outlook.com>
> > Cc: edk2-devel@lists.01.org; Abhishek Singh <abh@cs.unc.edu>;
> > ruiyu.ni@intel.com; eric.dong@intel.com; star.zeng@intel.com
> > Subject: Re: [edk2] smm lock query
> >
> > On 05/27/18 22:44, Andrew Fish wrote:
> > >
> > >
> > >> On May 27, 2018, at 9:47 AM, Marvin H?user
> > <Marvin.Haeuser@outlook.com> wrote:
> > >>
> > >> Good day Abhishek,
> > >>
> > >> I CC'd the MdeModulePkg maintainers, Ruiyu for the Platform BDS aspect
> > (exposes the ReadyToLock protocol) and Laszlo for his high-quality
> answers.
> > >>
> > >> Strictly speaking you are, right, because of the description for the
> MM
> > protocol:
> > >> "Indicates that MM resources and services that should not be used by
> the
> > third party code are about[Marvin: (!)] to be locked."
> > >> Practically however, I don't see any issue with the current
> > implementation. Code inside MMRAM is not affected directly by the lock,
> it is
> > just notified.
> > >> However, either the code or the specification should be slightly
> updated
> > to be in sync. A code update might require review of the caller
> assumptions,
> > just to be sure.
> > >>
> > >> I have a different concern though and hope I'm actually overlooking
> > something.
> > >> If I understand the code correctly, it is the Platform BDS that
> exposes the
> > (S)MmReadyToLock protocol. PiSmmIpl seems to consume that event and
> > lock SMM resources based on the event.
> > >> Because of latter being an event however, I don't think it is, or can
> be,
> > guaranteed to be the last event group member executing.
> > >> When it is not the last, the "about to be locked" part is not true
> for any
> > subsequent callbacks, that could actually be a risky break of the
> specification
> > - if it is.
> > >> If it is a break of the specification, I can only think of letting
> Platform BDS
> > expose an "internal" event group, which is only caught by PiSmmIpl, which
> > then drives the actual SmmReadyToLock flow.
> > >> This would require updates to all platform trees and hence I would
> > propose a temporary backwards-compatibility.
> > >>
> > >> Any comments? Did I overlook something (I hope)?
> > >>
> > >
> > > Mavvin,
> > >
> > > You are correct there is no guarantee of order in events. Thanks for
> cc'ing
> > the right folks, as I don't remember all the low level details...
> > >
> > > In general the idea behind the MM code is it only comes from the
> platform,
> > then by definition that code should be aware when the platform was going
> > to lock MM. In a practical sense any MM module that had a depex evaluate
> > to true would have dispatched in DXE prior to BDS being launched. In
> general
> > BDS is the code that enumerates PCI and connects devices, thus there is
> no
> > chance for 3rd party software to run before that point in the boot. So
> in an
> > abstract sense that lock represents the end of DXE dispatch.
> >
> > This is my understanding as well. gEfiDxeSmmReadyToLockProtocolGuid is
> > installed by Plaform BDS before any non-platform binaries get a chance to
> > run. In terms of the current PlatformBootManagerLib interfaces, that
> means
> > the protocol should be installed from
> > PlatformBootManagerBeforeConsole() (as noted on the API declaration
> > itself).
> >
> > Thanks
> > Laszlo
>


  reply	other threads:[~2018-05-28 18:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 15:04 smm lock query Abhishek Singh
2018-05-27 16:47 ` Marvin H?user
2018-05-27 20:44   ` Andrew Fish
2018-05-27 20:45     ` Andrew Fish
2018-05-28 10:57     ` Laszlo Ersek
2018-05-28 14:03       ` Marvin Häuser
2018-05-28 18:02         ` Abhishek Singh [this message]
2018-05-29  1:15           ` Zeng, Star
2018-05-29  2:21             ` Yao, Jiewen
2018-05-29  5:17               ` Abhishek Singh
2018-05-29 14:54                 ` Andrew Fish
2018-05-29 14:56                 ` Yao, Jiewen

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=CAGB8-zqRFNr3A5ji-yYu9VXqK1bh3rHkMv9JgVjswYxnthhfgw@mail.gmail.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