Re: [edk2] SMM Drivers in EDKII

Subject: Re: [edk2] SMM Drivers in EDKII

From: Lethom Legrand <cendrais@gmail.com>

To: edk2-devel@lists.sourceforge.net

Date: 2014-03-27 21:06:14

Thanks for your suggestion. I will take a look.

I've one last question: I've seen that the Nt32Pkg permits to have EDKII as a Windows application. Does Nt32Pkg supports SMM? If that so, it might be possible to debug SMM that way?

Best regards,
Thomas


2014-03-26 17:29 GMT+01:00 Andrew Fish <afish@apple.com>:

On Mar 26, 2014, at 1:03 AM, Lethom Legrand <cendrais@gmail.com> wrote:

Thank you for your answer!

I was afraid it would be some thing like this.

Easy to anticipate my next question, but I will ask anyway: how can I debug SMM code? I heard about DuetPkg, that is a full emulation of UEFI, so maybe it is a solution?
Otherwise, I think my last hope is hardware debuging through USB port 0?


The USB port is not a hardware debugger. It is just the serial transport for a software debugger. 

If you have an edk2 based ROM you can use the SourceLevelDebugPkg https://svn.code.sf.net/p/edk2/code/trunk/edk2/SourceLevelDebugPkg/ to get a software debugger in SMM. You need to rebuild the ROM and make sure the DebugAgentLIb for the SMM points to here: https://svn.code.sf.net/p/edk2/code/trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf

Your kind of asking questions like you don’t have a firmware build for your platform. The firmware will lock down SMM, and you can only access SMM memory from SMM mode. So there is not really a way to get code into SMM from a 3rd party. The usually policy is to only load modules that are in the sighed ROM into SMM, and to lock SMM prior to running any third party code (PCI option ROMs etc.). 

Thanks,

Andrew Fish

Thomas


2014-03-25 17:53 GMT+01:00 Jordan Justen <jljusten@gmail.com>:
On Tue, Mar 25, 2014 at 3:03 AM, Lethom Legrand <cendrais@gmail.com> wrote:
> Hello everyone,
>
> I am trying to see how the things work in UEFI with the System Management
> Mode (SMM) of x86(-64) CPU.
>
> My understanding is the following:
> 1. When entering in SMM, the CPU sets itself in a real-like mode
> 2. A first SMM Dispatcher handles "legacy" SMM code: it executes them, one
> after the other
> 3. This first SMM Dispatcher sets the CPU in flat protected mode
> 4. A second SMM Dispatcher runs and executes SMM Drivers (SMM Drivers are
> Runtime Drivers that loaded themselves in SMRAM)
> 5. When every SMM Driver is executed, the RSM instruction is executed.
>
> I think I'm close to the truth. Unfortunately, when I'm searching in EDKII,
> I cannot find anything before the 4. statement. That is, it seems that EDKII
> misses the real-like mode part of SMM flow.
>
> So my question, actually, is simple: is it true that EDKII is not
> "complete". By that, I mean there are missing part that have to be implement
> by, for instance, hardware vendors that want to use it? I understand SMM
> Drivers code is the most hardware specific part of UEFI, so it makes sense.
>
> (another "bonus" question: have you any idea of how I can debug SMM code?
> For instance, in KVM?)

Initializing SMM and handling SMM entry is usually chipset specific
code. I don't think there is an example in EDK II.

I think QEMU (without KVM) supports SMM. Unfortunately, OVMF doesn't
support SMM so I don't think you'll be able debug SMM code with OVMF.

-Jordan

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel