public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "Liu, Zhiguang" <zhiguang.liu@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Guo" <guo.dong@intel.com>,
	Maurice Ma <maurice.ma@intel.com>,
	"You, Benjamin" <benjamin.you@intel.com>,
	"Rhodes, Sean" <sean@starlabs.systems>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH v2] UefiPayloadPkg: Always split page table entry to 4K if it covers stack.
Date: Mon, 20 Jun 2022 01:53:02 +0000	[thread overview]
Message-ID: <MWHPR11MB1631F4AEEF7A7D67C0238D788CB09@MWHPR11MB1631.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220617082803.4428-1-zhiguang.liu@intel.com>

Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Friday, June 17, 2022 4:28 PM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Dong, Guo
> <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Maurice Ma
> <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>;
> Rhodes, Sean <sean@starlabs.systems>; Gerd Hoffmann
> <kraxel@redhat.com>
> Subject: [PATCH v2] UefiPayloadPkg: Always split page table entry to 4K if it
> covers stack.
> 
> We observed page fault in the following situation:
> 1.PayloadEntry uses 2M entry in page table to cover DXE stack range.
> 2.In DXE phase, image protection code needs to mark some sub-range in
> this 2M entry as readonly. So the the 2M page table entry is split to
> 512 4K entries, and some of the entries are marked as readonly.
> (the entries covering stack still remain R/W)
> 3.Page fault exception happens when trying to access stack.
> 
> Always split the page table entry to 4K if it covers stack to avoid this
> issue.
> More discussion about this issue can be seen at below link
> https://edk2.groups.io/g/devel/topic/91446026
> 
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Maurice Ma <maurice.ma@intel.com>
> Cc: Benjamin You <benjamin.you@intel.com>
> Cc: Sean Rhodes <sean@starlabs.systems>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
>  UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> index ac0d58e685..74b667a62a 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> @@ -218,16 +218,8 @@ ToSplitPageTable (
>      return TRUE;
>    }
> 
> -  if (PcdGetBool (PcdCpuStackGuard)) {
> -    if ((StackBase >= Address) && (StackBase < (Address + Size))) {
> -      return TRUE;
> -    }
> -  }
> -
> -  if (PcdGetBool (PcdSetNxForStack)) {
> -    if ((Address < StackBase + StackSize) && ((Address + Size) > StackBase)) {
> -      return TRUE;
> -    }
> +  if ((Address < StackBase + StackSize) && ((Address + Size) > StackBase)) {
> +    return TRUE;
>    }
> 
>    if (GhcbBase != 0) {
> --
> 2.16.2.windows.1


  reply	other threads:[~2022-06-20  1:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17  8:28 [PATCH v2] UefiPayloadPkg: Always split page table entry to 4K if it covers stack Zhiguang Liu
2022-06-20  1:53 ` Ni, Ray [this message]
2022-06-20 10:43 ` [edk2-devel] " Gerd Hoffmann

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=MWHPR11MB1631F4AEEF7A7D67C0238D788CB09@MWHPR11MB1631.namprd11.prod.outlook.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