public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: Laszlo Ersek <lersek@redhat.com>, William Tambe <tambewilliam@gmail.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: Page Table initialization and update in SMM mode
Date: Fri, 24 Mar 2017 23:48:56 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503A913D02@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <4d40b816-c024-020d-0471-c6023c6b5d0b@redhat.com>

Hi Laszlo
Thanks for the reminder.

Hi William
I try to your answer below. Feel free to let me know if you have more question.

For more detail information on how we protect SMRAM, please refer to https://www.gitbook.com/book/edk2-docs/a-tour-beyond-bios-memory-protection-in-uefi-bios/details


Thank you
Yao Jiewen


From: Laszlo Ersek [mailto:lersek@redhat.com]
Sent: Friday, March 24, 2017 11:58 PM
To: William Tambe <tambewilliam@gmail.com>; Yao, Jiewen <jiewen.yao@intel.com>
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] Page Table initialization and update in SMM mode

Jiewen,

On 03/22/17 15:14, William Tambe wrote:
> Dear all,
>
> When building OVMF with SMM_REQUIRE:
>
> - Would you know where in the code base the Page Table set in the Cr3
> register is initialized during boot ?
[Jiewen] UefiCpuPkg\PiSmmCpuDxeSmm\MpService.c: InitializeMpServiceData()

  //
  // Create page tables
  //
  Cr3 = SmmInitPageTable ();


>
> - Where does it get updated when a new page needs to be allocated or freed ?
[Jiewen] We do not update page table on allocation/free.

Instead PiSmmCpu driver updates page table once, after ready to lock.
UefiCpuPkg\PiSmmCpuDxeSmm\PiSmmCpuDxeSmm.c: PerformRemainingTasks()


    //
    // Create a mix of 2MB and 4KB page table. Update some memory ranges absent and execute-disable.
    //
    InitPaging ();

    //
    // Mark critical region to be read-only in page table
    //
    SetMemMapAttributes ();

    //
    // For outside SMRAM, we only map SMM communication buffer or MMIO.
    //
    SetUefiMemMapAttributes ();

    //
    // Set page table itself to be read-only
    //
    SetPageTableAttributes ();


>
> - Or is there a hook I can register myself to in order to get a chance to
> review an entry to be added or removed from the Page Tables ?
[Jiewen] You can register a ready to boot event in your SMM driver and dump page table, which is the final page table in SMM.
(That is what our internal test case does. :))



can you please help answer these questions? I seem to remember that we
discussed code around this when we were looking into the SMM stack
overflow experienced with OVMF:

509f8425b75d UefiCpuPkg: change PcdCpuSmmStackGuard default to TRUE
0d0c245dfb14 OvmfPkg: set SMM stack size to 16KB

William: I suggest to check out the following files:

UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c

and/or to grep the code for "PcdCpuSmmStackGuard", to get a feel for
what to investigate.

Thanks
Laszlo


      reply	other threads:[~2017-03-24 23:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 14:14 Page Table initialization and update in SMM mode William Tambe
2017-03-24 15:58 ` Laszlo Ersek
2017-03-24 23:48   ` Yao, Jiewen [this message]

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=74D8A39837DF1E4DA445A8C0B3885C503A913D02@shsmsx102.ccr.corp.intel.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