public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: "Marvin Häuser" <mhaeuser@posteo.de>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up.
Date: Wed, 8 Feb 2023 10:36:43 +0000	[thread overview]
Message-ID: <CO1PR11MB50267B397BED709ECCBB6E52F0D89@CO1PR11MB5026.namprd11.prod.outlook.com> (raw)
In-Reply-To: <32073.1675788041796635561@groups.io>

[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]

Hi Marvin,

Thanks for the feedbacks.
The corrected implementation is in patch 5.
The stacks are located high and the function is located low. With padding, it ensures page alignment.
I'll resend the patch to make sure the changes are included in patch 2.

Best Regards,
Yuanhao


From: Marvin Häuser <mhaeuser@posteo.de>
Sent: Wednesday, February 8, 2023 12:41 AM
To: Xie, Yuanhao <yuanhao.xie@intel.com>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up.

Hi Yuanhao,

1) The code comments and copy code suggest that the stacks are located low and the function is located high (good). However, the SetMemorySpaceAttributes() call un-XP's Address, which is the low address. So, do I misunderstand the changes, or are you un-XP'ing the first stack (and keep the function XP'd)?

2) The same SetMemorySpaceAttributes() call, you now pass ApLoopFuncSize over ApSafeBufferSize. The latter was explicitly page-aligned, while the former is not. How is it guaranteed it is indeed aligned? If it is not, I don't think this is supported, at least universally.

3) Similar to 2), the stack size is much smaller than the page size, no? How do you guarantee the function is on a page boundary for memory protection?

4) A proper W^X flow should be to wait with un-XP till the CopyMem() for the function code has returned. Right before that, the copied code should be marked read-only.

Best regards,
Marvin

[-- Attachment #2: Type: text/html, Size: 3778 bytes --]

  parent reply	other threads:[~2023-02-08 10:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 13:49 [PATCH 0/5] Put APs in 64 bit mode before handoff to OS Yuanhao Xie
2023-02-07 13:49 ` [PATCH 1/5] UefiCpuPkg: Duplicate RelocateApLoop for Amd x64 processors Yuanhao Xie
2023-02-07 13:49 ` [PATCH 2/5] UefiCpuPkg: Contiguous memory allocation and code clean-up Yuanhao Xie
2023-02-07 16:40   ` [edk2-devel] " Marvin Häuser
2023-02-07 16:43     ` Marvin Häuser
2023-02-08 10:36     ` Yuanhao Xie [this message]
2023-02-08 11:09   ` Gerd Hoffmann
2023-02-10  9:12     ` Yuanhao Xie
2023-02-10 11:09       ` Gerd Hoffmann
2023-02-10 12:52         ` Ni, Ray
2023-02-07 13:49 ` [PATCH 3/5] OvmfPkg: Add CpuPageTableLib required by MpInitLib Yuanhao Xie
2023-02-08 10:53   ` Gerd Hoffmann
2023-02-09 16:30     ` [edk2-devel] " Ard Biesheuvel
2023-02-07 13:49 ` [PATCH 4/5] UefiPayloadPkg: " Yuanhao Xie
2023-02-08  5:38   ` Guo, Gua
2023-02-08 17:02   ` Guo Dong
2023-02-07 13:49 ` [PATCH 5/5] UefiCpuPkg: Put APs in 64 bit mode before handoff to OS Yuanhao Xie

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=CO1PR11MB50267B397BED709ECCBB6E52F0D89@CO1PR11MB5026.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