From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io, ray.ni@intel.com
Cc: Eric Dong <eric.dong@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>
Subject: Re: [edk2-devel] [PATCH 3/3] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF
Date: Mon, 29 Jul 2019 13:49:01 +0200 [thread overview]
Message-ID: <cf467762-c7fd-e3d9-670f-34e0ff56171b@redhat.com> (raw)
In-Reply-To: <20190727032850.337840-4-ray.ni@intel.com>
On 07/27/19 05:28, Ni, Ray wrote:
> Commit c60d36b4d1ee1f69b7cca897d3621dfa951895c2
> * UefiCpuPkg/SmmCpu: Block access-out only when static paging is used
>
> updated page fault handler to treat SMM access-out as allowed
> address when static paging is not used.
>
> But that commit is not complete because the page table is still
> updated in SetUefiMemMapAttributes() for non-SMRAM memory. When SMM
> code accesses non-SMRAM memory, page fault is still generated.
>
> This patch skips to update page table for non-SMRAM memory and
> page table itself.
>
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> index 69a04dfb23..d7d94c8b6d 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
> @@ -1121,6 +1121,9 @@ FindSmramInfo (
> *SmrrBase = (UINT32)CurrentSmramRange->CpuStart;
> *SmrrSize = (UINT32)CurrentSmramRange->PhysicalSize;
>
> + //
> + // Extend *SmrrBase/*SmrrSize to include adjacent SMRAM ranges
> + //
> do {
> Found = FALSE;
> for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {
> @@ -1432,14 +1435,20 @@ PerformRemainingTasks (
> SetMemMapAttributes ();
>
> //
> - // For outside SMRAM, we only map SMM communication buffer or MMIO.
> + // Protect memory outside SMRAM when SMM Static Page Table is enabled.
> //
> - SetUefiMemMapAttributes ();
> + if (IsStaticPageTableEnabled ()) {
>
> - //
> - // Set page table itself to be read-only
> - //
> - SetPageTableAttributes ();
> + //
> + // For outside SMRAM, we only map SMM communication buffer or MMIO.
> + //
> + SetUefiMemMapAttributes ();
> +
> + //
> + // Set page table itself to be read-only
> + //
> + SetPageTableAttributes ();
> + }
>
> //
> // Configure SMM Code Access Check feature if available.
>
With the IA32 bug in patch#1 fixed, this patch will also do the right
thing (as part of OVMF anyway):
- on IA32, there will be no change in behavior
(IsStaticPageTableEnabled() will evaluate to constant TRUE)
- on X64, OVMF keeps the DEC-default TRUE value for the underlying PCD
(PcdCpuSmmStaticPageTable), hence IsStaticPageTableEnabled() will return
TRUE, and the behavior won't change.
Because I cannot validate the PcdCpuSmmStaticPageTable==FALSE case, I
won't give R-b. But I can certainly give:
Acked-by: Laszlo Ersek <lersek@redhat.com>
Thanks!
Laszlo
prev parent reply other threads:[~2019-07-29 11:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-27 3:28 [PATCH 0/3] Allow SMM access-out when static paging is OFF Ni, Ray
2019-07-27 3:28 ` [PATCH 1/3] UefiCpuPkg/PiSmmCpu: Add Internal function IsStaticPageTableEnabled Ni, Ray
2019-07-29 11:33 ` [edk2-devel] " Dong, Eric
2019-07-29 11:33 ` Laszlo Ersek
2019-07-30 15:20 ` Ni, Ray
2019-07-31 9:57 ` Laszlo Ersek
2019-07-31 16:40 ` Ni, Ray
2019-07-27 3:28 ` [PATCH 2/3] UefiCpuPkg/PiSmmCpu: Refine CR2 save/restore logic Ni, Ray
2019-07-29 11:33 ` Dong, Eric
2019-07-29 11:42 ` [edk2-devel] " Laszlo Ersek
2019-07-27 3:28 ` [PATCH 3/3] UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF Ni, Ray
2019-07-29 11:33 ` Dong, Eric
2019-07-29 11:49 ` Laszlo Ersek [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=cf467762-c7fd-e3d9-670f-34e0ff56171b@redhat.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