[edk2-devel] [PATCH] UefiCpuPkg: Solve that stack top address is not mapped in pagetable

Yuanhao Xie posted 1 patch 1 year, 1 month ago
Failed in applying to current master (apply log)
UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 1 +
1 file changed, 1 insertion(+)
[edk2-devel] [PATCH] UefiCpuPkg: Solve that stack top address is not mapped in pagetable
Posted by Yuanhao Xie 1 year, 1 month ago
For the case CPU logic index is 0, RSP points to the very top of all AP
stacks. That address is not mapped in page table.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
index 9ebe31795b..5bcdf7726b 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
@@ -315,6 +315,7 @@ MwaitCheckGeneric:
 MwaitLoopGeneric:
     cli
     mov        rax, rsp           ; Set Monitor Address
+    sub        eax, 8             ; To ensure the monitor address is in the page table
     xor        ecx, ecx           ; ecx = 0
     xor        edx, edx           ; edx = 0
     monitor
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101480): https://edk2.groups.io/g/devel/message/101480
Mute This Topic: https://groups.io/mt/97750173/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] UefiCpuPkg: Solve that stack top address is not mapped in pagetable
Posted by Ni, Ray 1 year ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

> -----Original Message-----
> From: Xie, Yuanhao <yuanhao.xie@intel.com>
> Sent: Tuesday, March 21, 2023 3:30 PM
> To: devel@edk2.groups.io
> Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Rhodes,
> Sean <sean@starlabs.systems>; Lu, James <james.lu@intel.com>; Guo, Gua
> <gua.guo@intel.com>; Kuo, Ted <ted.kuo@intel.com>
> Subject: [PATCH] UefiCpuPkg: Solve that stack top address is not mapped in
> pagetable
> 
> For the case CPU logic index is 0, RSP points to the very top of all AP
> stacks. That address is not mapped in page table.
> 
> Cc: Guo Dong <guo.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Sean Rhodes <sean@starlabs.systems>
> Cc: James Lu <james.lu@intel.com>
> Cc: Gua Guo <gua.guo@intel.com>
> Signed-off-by: Ted Kuo <ted.kuo@intel.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
> b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
> index 9ebe31795b..5bcdf7726b 100644
> --- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
> +++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
> @@ -315,6 +315,7 @@ MwaitCheckGeneric:
>  MwaitLoopGeneric:
>      cli
>      mov        rax, rsp           ; Set Monitor Address
> +    sub        eax, 8             ; To ensure the monitor address is in the page table
>      xor        ecx, ecx           ; ecx = 0
>      xor        edx, edx           ; edx = 0
>      monitor
> --
> 2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101620): https://edk2.groups.io/g/devel/message/101620
Mute This Topic: https://groups.io/mt/97750173/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-