public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>,
	"Vanguput, Narendra K" <narendra.k.vanguput@intel.com>
Subject: Re: [PATCH 2/3] UefiCpuPkg/PiSmmCpu: Refine CR2 save/restore logic
Date: Mon, 29 Jul 2019 11:33:40 +0000	[thread overview]
Message-ID: <ED077930C258884BBCB450DB737E662259EB623E@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20190727032850.337840-3-ray.ni@intel.com>

Reviewed-by: Eric Dong <eric.dong@intel.com>

> -----Original Message-----
> From: Ni, Ray
> Sent: Saturday, July 27, 2019 11:29 AM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Laszlo Ersek <lersek@redhat.com>;
> Vanguput, Narendra K <narendra.k.vanguput@intel.com>
> Subject: [PATCH 2/3] UefiCpuPkg/PiSmmCpu: Refine CR2 save/restore logic
> 
> Because IsStaticPageTableEnabled() is added for both IA32 and x64 build, the
> CR2 save/restore logic can be refined:
> 1. Remove arch specific SaveCr2() /  RestoreCr2() implementation; 2.
> Conditionally save and restore CR2 in SmiRendezvous().
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Vanguput Narendra K <narendra.k.vanguput@intel.com>
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   | 25 -------------------
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c      |  8 ++++--
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 22 ----------------
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c    | 29 ----------------------
>  4 files changed, 6 insertions(+), 78 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> index 2a9af4b77d..cae23d6d1d 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c
> @@ -327,28 +327,3 @@ SetPageTableAttributes (
>    return ;
>  }
> 
> -/**
> -  This function returns with no action for 32 bit.
> -
> -  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
> -**/
> -VOID
> -SaveCr2 (
> -  OUT UINTN  *Cr2
> -  )
> -{
> -  return ;
> -}
> -
> -/**
> -  This function returns with no action for 32 bit.
> -
> -  @param[in]  Cr2  Value to write into CR2 register.
> -**/
> -VOID
> -RestoreCr2 (
> -  IN UINTN  Cr2
> -  )
> -{
> -  return ;
> -}
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index ef16997547..5d0124b368 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1575,7 +1575,9 @@ SmiRendezvous (
>    // when using on-demand paging for above 4G memory.
>    //
>    Cr2 = 0;
> -  SaveCr2 (&Cr2);
> +  if (!IsStaticPageTableEnabled ()) {
> +    Cr2 = AsmReadCr2 ();
> +  }
> 
>    //
>    // Call the user register Startup function first.
> @@ -1725,7 +1727,9 @@ Exit:
>    //
>    // Restore Cr2
>    //
> -  RestoreCr2 (Cr2);
> +  if (!IsStaticPageTableEnabled ()) {
> +    AsmWriteCr2 (Cr2);
> +  }
>  }
> 
>  /**
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index 14b7676c16..5a97733def 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -1282,28 +1282,6 @@ IsStaticPageTableEnabled (
>    )
>  ;
> 
> -/**
> -  This function reads CR2 register when on-demand paging is enabled
> -  for 64 bit and no action for 32 bit.
> -
> -  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
> -**/
> -VOID
> -SaveCr2 (
> -  OUT UINTN  *Cr2
> -  );
> -
> -/**
> -  This function writes into CR2 register when on-demand paging is enabled
> -  for 64 bit and no action for 32 bit.
> -
> -  @param[in]  Cr2  Value to write into CR2 register.
> -**/
> -VOID
> -RestoreCr2 (
> -  IN UINTN  Cr2
> -  );
> -
>  /**
>    Schedule a procedure to run on the specified CPU.
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> index 18e3f9e08d..8259b01a95 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> @@ -1209,32 +1209,3 @@ SetPageTableAttributes (
>    return ;
>  }
> 
> -/**
> -  This function reads CR2 register when on-demand paging is enabled.
> -
> -  @param[out]  *Cr2  Pointer to variable to hold CR2 register value.
> -**/
> -VOID
> -SaveCr2 (
> -  OUT UINTN  *Cr2
> -  )
> -{
> -  if (!mCpuSmmStaticPageTable) {
> -    *Cr2 = AsmReadCr2 ();
> -  }
> -}
> -
> -/**
> -  This function restores CR2 register when on-demand paging is enabled.
> -
> -  @param[in]  Cr2  Value to write into CR2 register.
> -**/
> -VOID
> -RestoreCr2 (
> -  IN UINTN  Cr2
> -  )
> -{
> -  if (!mCpuSmmStaticPageTable) {
> -    AsmWriteCr2 (Cr2);
> -  }
> -}
> --
> 2.21.0.windows.1


  reply	other threads:[~2019-07-29 13:15 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 [this message]
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   ` [edk2-devel] " Laszlo Ersek

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=ED077930C258884BBCB450DB737E662259EB623E@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