public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Page Table initialization and update in SMM mode
@ 2017-03-22 14:14 William Tambe
  2017-03-24 15:58 ` Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: William Tambe @ 2017-03-22 14:14 UTC (permalink / raw)
  To: edk2-devel

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 ?

- Where does it get updated when a new page needs to be allocated or freed ?

- 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 ?

Sincerely,
William Tambe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Page Table initialization and update in SMM mode
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Ersek @ 2017-03-24 15:58 UTC (permalink / raw)
  To: William Tambe, Jiewen Yao; +Cc: edk2-devel

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 ?
> 
> - Where does it get updated when a new page needs to be allocated or freed ?
> 
> - 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 ?

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Page Table initialization and update in SMM mode
  2017-03-24 15:58 ` Laszlo Ersek
@ 2017-03-24 23:48   ` Yao, Jiewen
  0 siblings, 0 replies; 3+ messages in thread
From: Yao, Jiewen @ 2017-03-24 23:48 UTC (permalink / raw)
  To: Laszlo Ersek, William Tambe; +Cc: edk2-devel@lists.01.org

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-24 23:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox