[edk2-devel] [PATCH 2/2] DxeMain: Fix the bug that StackGuard is not enabled

Ni, Ray posted 2 patches 3 years, 8 months ago
[edk2-devel] [PATCH 2/2] DxeMain: Fix the bug that StackGuard is not enabled
Posted by Ni, Ray 3 years, 8 months ago
Commit e7abb94d1 removed InitializeCpuExceptionHandlersEx
and updated DxeMain to call InitializeCpuExceptionHandlers
for exception setup. But the old behavior that calls *Ex() sets
up the stack guard as well. To match the old behavior,
the patch calls InitializeSeparateExceptionStacks.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index 83f49d7c00..0a1f3d79e2 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -256,6 +256,14 @@ DxeMain (
   Status = InitializeCpuExceptionHandlers (VectorInfoList);
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Setup Stack Guard
+  //
+  if (PcdGetBool (PcdCpuStackGuard)) {
+    Status = InitializeSeparateExceptionStacks (NULL);
+    ASSERT_EFI_ERROR (Status);
+  }
+
   //
   // Initialize Debug Agent to support source level debug in DXE phase
   //
-- 
2.35.1.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90468): https://edk2.groups.io/g/devel/message/90468
Mute This Topic: https://groups.io/mt/91719888/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 2/2] DxeMain: Fix the bug that StackGuard is not enabled
Posted by Sami Mujawar 3 years, 8 months ago
Hi Ray,

Thank you for this patch.

This change looks good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 13/06/2022 04:39 am, Ni, Ray via groups.io wrote:
> Commit e7abb94d1 removed InitializeCpuExceptionHandlersEx
> and updated DxeMain to call InitializeCpuExceptionHandlers
> for exception setup. But the old behavior that calls *Ex() sets
> up the stack guard as well. To match the old behavior,
> the patch calls InitializeSeparateExceptionStacks.
>
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> ---
>   MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
> index 83f49d7c00..0a1f3d79e2 100644
> --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
> +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
> @@ -256,6 +256,14 @@ DxeMain (
>     Status = InitializeCpuExceptionHandlers (VectorInfoList);
>
>     ASSERT_EFI_ERROR (Status);
>
>   
>
> +  //
>
> +  // Setup Stack Guard
>
> +  //
>
> +  if (PcdGetBool (PcdCpuStackGuard)) {
>
> +    Status = InitializeSeparateExceptionStacks (NULL);
>
> +    ASSERT_EFI_ERROR (Status);
>
> +  }
>
> +
>
>     //
>
>     // Initialize Debug Agent to support source level debug in DXE phase
>
>     //
>


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