[edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc

Sheng Wei posted 1 patch 3 years, 2 months ago
Failed in applying to current master (apply log)
MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
[edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Sheng Wei 3 years, 2 months ago
This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in Nasm,
because these instructions are not supported yet.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
 MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
 MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Ia32/Nasm.inc b/MdePkg/Include/Ia32/Nasm.inc
index 31ce861f1e..9c1b7796ea 100644
--- a/MdePkg/Include/Ia32/Nasm.inc
+++ b/MdePkg/Include/Ia32/Nasm.inc
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------
 ;
-; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Abstract:
@@ -20,3 +20,15 @@
 %macro INCSSP_EAX      0
     DB 0xF3, 0x0F, 0xAE, 0xE8
 %endmacro
+
+%macro SAVEPREVSSP     0
+    DB 0xF3, 0x0F, 0x01, 0xEA
+%endmacro
+
+%macro CLRSSBSY_EAX    0
+    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
+%endmacro
+
+%macro RSTORSSP_EAX    0
+    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
+%endmacro
diff --git a/MdePkg/Include/X64/Nasm.inc b/MdePkg/Include/X64/Nasm.inc
index 42412735ea..c5189982bb 100644
--- a/MdePkg/Include/X64/Nasm.inc
+++ b/MdePkg/Include/X64/Nasm.inc
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------
 ;
-; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Abstract:
@@ -20,3 +20,15 @@
 %macro INCSSP_RAX      0
     DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
 %endmacro
+
+%macro SAVEPREVSSP     0
+    DB 0xF3, 0x0F, 0x01, 0xEA
+%endmacro
+
+%macro CLRSSBSY_RAX    0
+    DB 0xF3, 0x0F, 0xAE, 0x30
+%endmacro
+
+%macro RSTORSSP_RAX    0
+    DB 0xF3, 0x0F, 0x01, 0x28
+%endmacro
-- 
2.16.2.windows.1



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Michael D Kinney 3 years, 2 months ago
Sheng,

The following version of the NASM documentation shows support for these instructions.

	https://nasm.us/doc/nasmdocb.html

Do we need to increase the min NASM version requirements for EDK II to avoid adding macros with DB?

Thanks,

Mike

> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Thursday, January 28, 2021 6:35 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in Nasm,
> because these instructions are not supported yet.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> 
> Signed-off-by: Sheng Wei <w.sheng@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> ---
>  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
>  MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
>  2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/MdePkg/Include/Ia32/Nasm.inc b/MdePkg/Include/Ia32/Nasm.inc
> index 31ce861f1e..9c1b7796ea 100644
> --- a/MdePkg/Include/Ia32/Nasm.inc
> +++ b/MdePkg/Include/Ia32/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_EAX      0
>      DB 0xF3, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> diff --git a/MdePkg/Include/X64/Nasm.inc b/MdePkg/Include/X64/Nasm.inc
> index 42412735ea..c5189982bb 100644
> --- a/MdePkg/Include/X64/Nasm.inc
> +++ b/MdePkg/Include/X64/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_RAX      0
>      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_RAX    0
> +    DB 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_RAX    0
> +    DB 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> --
> 2.16.2.windows.1



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Bret Barkelew via groups.io 3 years, 2 months ago
Agreed. Do we also want to go ahead and move the CI binary forward to get some hours on it?

- Bret

From: Michael D Kinney via groups.io<mailto:michael.d.kinney=intel.com@groups.io>
Sent: Friday, January 29, 2021 9:22 AM
To: Sheng, W<mailto:w.sheng@intel.com>; devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Kinney, Michael D<mailto:michael.d.kinney@intel.com>
Cc: Liming Gao<mailto:gaoliming@byosoft.com.cn>; Liu, Zhiguang<mailto:zhiguang.liu@intel.com>; Yao, Jiewen<mailto:jiewen.yao@intel.com>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc

Sheng,

The following version of the NASM documentation shows support for these instructions.

        https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fnasm.us%2Fdoc%2Fnasmdocb.html&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C64baec72ed934d46095808d8c47a7cfd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637475377656169680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=c5NkC4v46Pgx3Bu0KqiaM0RdQ%2FIjauW3hzzDQlfeyZg%3D&amp;reserved=0

Do we need to increase the min NASM version requirements for EDK II to avoid adding macros with DB?

Thanks,

Mike

> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Thursday, January 28, 2021 6:35 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
>
> This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in Nasm,
> because these instructions are not supported yet.
>
> REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3192&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C64baec72ed934d46095808d8c47a7cfd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637475377656169680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=j3x2gnCcnx2E%2B8nuUrQJ7YPdWQbr4yI9yWlkFIiRrj4%3D&amp;reserved=0
>
> Signed-off-by: Sheng Wei <w.sheng@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> ---
>  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
>  MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
>  2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/MdePkg/Include/Ia32/Nasm.inc b/MdePkg/Include/Ia32/Nasm.inc
> index 31ce861f1e..9c1b7796ea 100644
> --- a/MdePkg/Include/Ia32/Nasm.inc
> +++ b/MdePkg/Include/Ia32/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_EAX      0
>      DB 0xF3, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> diff --git a/MdePkg/Include/X64/Nasm.inc b/MdePkg/Include/X64/Nasm.inc
> index 42412735ea..c5189982bb 100644
> --- a/MdePkg/Include/X64/Nasm.inc
> +++ b/MdePkg/Include/X64/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_RAX      0
>      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_RAX    0
> +    DB 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_RAX    0
> +    DB 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> --
> 2.16.2.windows.1








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


[edk2-devel] 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by gaoliming 3 years, 2 months ago
Mike and Sheng:
  Linux or Mac OS includes the pre-built nasm. Their nasm version may be old. Can you evaluate the impact to update nasm version?

Thanks
Liming
> -----邮件原件-----
> 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> 发送时间: 2021年1月30日 1:23
> 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io; Kinney,
> Michael D <michael.d.kinney@intel.com>
> 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Sheng,
> 
> The following version of the NASM documentation shows support for these
> instructions.
> 
> 	https://nasm.us/doc/nasmdocb.html
> 
> Do we need to increase the min NASM version requirements for EDK II to
> avoid adding macros with DB?
> 
> Thanks,
> 
> Mike
> 
> > -----Original Message-----
> > From: Sheng, W <w.sheng@intel.com>
> > Sent: Thursday, January 28, 2021 6:35 PM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> Nasm,
> > because these instructions are not supported yet.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> >
> > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > ---
> >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> >  MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> >  2 files changed, 26 insertions(+), 2 deletions(-)
> >
> > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> b/MdePkg/Include/Ia32/Nasm.inc
> > index 31ce861f1e..9c1b7796ea 100644
> > --- a/MdePkg/Include/Ia32/Nasm.inc
> > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > @@ -1,6 +1,6 @@
> >  ;------------------------------------------------------------------------------
> >  ;
> > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
> >  ; SPDX-License-Identifier: BSD-2-Clause-Patent
> >  ;
> >  ; Abstract:
> > @@ -20,3 +20,15 @@
> >  %macro INCSSP_EAX      0
> >      DB 0xF3, 0x0F, 0xAE, 0xE8
> >  %endmacro
> > +
> > +%macro SAVEPREVSSP     0
> > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > +%endmacro
> > +
> > +%macro CLRSSBSY_EAX    0
> > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> > +%endmacro
> > +
> > +%macro RSTORSSP_EAX    0
> > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> > +%endmacro
> > diff --git a/MdePkg/Include/X64/Nasm.inc
> b/MdePkg/Include/X64/Nasm.inc
> > index 42412735ea..c5189982bb 100644
> > --- a/MdePkg/Include/X64/Nasm.inc
> > +++ b/MdePkg/Include/X64/Nasm.inc
> > @@ -1,6 +1,6 @@
> >  ;------------------------------------------------------------------------------
> >  ;
> > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
> >  ; SPDX-License-Identifier: BSD-2-Clause-Patent
> >  ;
> >  ; Abstract:
> > @@ -20,3 +20,15 @@
> >  %macro INCSSP_RAX      0
> >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
> >  %endmacro
> > +
> > +%macro SAVEPREVSSP     0
> > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > +%endmacro
> > +
> > +%macro CLRSSBSY_RAX    0
> > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > +%endmacro
> > +
> > +%macro RSTORSSP_RAX    0
> > +    DB 0xF3, 0x0F, 0x01, 0x28
> > +%endmacro
> > --
> > 2.16.2.windows.1





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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Sheng Wei 3 years, 2 months ago
Hi Mike, Liming,
The latest NASM version is version 2.15.05.
The CET instructions is supported since NASM version 2.15.01, it is released at 2020-06-27.
Do you think we need to request everyone to update the NASM tool now?
Or could I still use macros with DB for CET instructions in my patch ?
BR
Sheng Wei

> -----Original Message-----
> From: gaoliming <gaoliming@byosoft.com.cn>
> Sent: 2021年2月2日 10:44
> To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> <w.sheng@intel.com>; devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> <lersek@redhat.com>
> Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Mike and Sheng:
>   Linux or Mac OS includes the pre-built nasm. Their nasm version may be old.
> Can you evaluate the impact to update nasm version?
> 
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > 发送时间: 2021年1月30日 1:23
> > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io; Kinney,
> > Michael D <michael.d.kinney@intel.com>
> > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Sheng,
> >
> > The following version of the NASM documentation shows support for
> > these instructions.
> >
> > 	https://nasm.us/doc/nasmdocb.html
> >
> > Do we need to increase the min NASM version requirements for EDK II to
> > avoid adding macros with DB?
> >
> > Thanks,
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: Sheng, W <w.sheng@intel.com>
> > > Sent: Thursday, January 28, 2021 6:35 PM
> > > To: devel@edk2.groups.io
> > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> > Nasm,
> > > because these instructions are not supported yet.
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > >
> > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > ---
> > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > b/MdePkg/Include/Ia32/Nasm.inc
> > > index 31ce861f1e..9c1b7796ea 100644
> > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > @@ -1,6 +1,6 @@
> > >
> > > ;-------------------------------------------------------------------
> > > -----------
> > >  ;
> > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > +reserved.<BR>
> > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > @@ -20,3 +20,15 @@
> > >  %macro INCSSP_EAX      0
> > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > >  %endmacro
> > > +
> > > +%macro SAVEPREVSSP     0
> > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > +%endmacro
> > > +
> > > +%macro CLRSSBSY_EAX    0
> > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > +
> > > +%macro RSTORSSP_EAX    0
> > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > b/MdePkg/Include/X64/Nasm.inc
> > > index 42412735ea..c5189982bb 100644
> > > --- a/MdePkg/Include/X64/Nasm.inc
> > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > @@ -1,6 +1,6 @@
> > >
> > > ;-------------------------------------------------------------------
> > > -----------
> > >  ;
> > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > +reserved.<BR>
> > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > @@ -20,3 +20,15 @@
> > >  %macro INCSSP_RAX      0
> > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > +
> > > +%macro SAVEPREVSSP     0
> > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > +%endmacro
> > > +
> > > +%macro CLRSSBSY_RAX    0
> > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > +%endmacro
> > > +
> > > +%macro RSTORSSP_RAX    0
> > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > +%endmacro
> > > --
> > > 2.16.2.windows.1
> 
> 



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Michael D Kinney 3 years, 2 months ago
Hi Sheng,

I recommend we update required NASM version.

From your investigation, the new min version would be 2.15.01.

Mike

> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Monday, February 1, 2021 7:39 PM
> To: gaoliming <gaoliming@byosoft.com.cn>; Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> Ersek' <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Mike, Liming,
> The latest NASM version is version 2.15.05.
> The CET instructions is supported since NASM version 2.15.01, it is released at 2020-06-27.
> Do you think we need to request everyone to update the NASM tool now?
> Or could I still use macros with DB for CET instructions in my patch ?
> BR
> Sheng Wei
> 
> > -----Original Message-----
> > From: gaoliming <gaoliming@byosoft.com.cn>
> > Sent: 2021年2月2日 10:44
> > To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> > <w.sheng@intel.com>; devel@edk2.groups.io
> > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> > <lersek@redhat.com>
> > Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Mike and Sheng:
> >   Linux or Mac OS includes the pre-built nasm. Their nasm version may be old.
> > Can you evaluate the impact to update nasm version?
> >
> > Thanks
> > Liming
> > > -----邮件原件-----
> > > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > > 发送时间: 2021年1月30日 1:23
> > > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io; Kinney,
> > > Michael D <michael.d.kinney@intel.com>
> > > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > Sheng,
> > >
> > > The following version of the NASM documentation shows support for
> > > these instructions.
> > >
> > > 	https://nasm.us/doc/nasmdocb.html
> > >
> > > Do we need to increase the min NASM version requirements for EDK II to
> > > avoid adding macros with DB?
> > >
> > > Thanks,
> > >
> > > Mike
> > >
> > > > -----Original Message-----
> > > > From: Sheng, W <w.sheng@intel.com>
> > > > Sent: Thursday, January 28, 2021 6:35 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > >
> > > > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> > > Nasm,
> > > > because these instructions are not supported yet.
> > > >
> > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > > >
> > > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > ---
> > > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > b/MdePkg/Include/Ia32/Nasm.inc
> > > > index 31ce861f1e..9c1b7796ea 100644
> > > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > > @@ -1,6 +1,6 @@
> > > >
> > > > ;-------------------------------------------------------------------
> > > > -----------
> > > >  ;
> > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > +reserved.<BR>
> > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > @@ -20,3 +20,15 @@
> > > >  %macro INCSSP_EAX      0
> > > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > > >  %endmacro
> > > > +
> > > > +%macro SAVEPREVSSP     0
> > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > +%endmacro
> > > > +
> > > > +%macro CLRSSBSY_EAX    0
> > > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > > +
> > > > +%macro RSTORSSP_EAX    0
> > > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > > b/MdePkg/Include/X64/Nasm.inc
> > > > index 42412735ea..c5189982bb 100644
> > > > --- a/MdePkg/Include/X64/Nasm.inc
> > > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > > @@ -1,6 +1,6 @@
> > > >
> > > > ;-------------------------------------------------------------------
> > > > -----------
> > > >  ;
> > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > +reserved.<BR>
> > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > @@ -20,3 +20,15 @@
> > > >  %macro INCSSP_RAX      0
> > > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > > +
> > > > +%macro SAVEPREVSSP     0
> > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > +%endmacro
> > > > +
> > > > +%macro CLRSSBSY_RAX    0
> > > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > > +%endmacro
> > > > +
> > > > +%macro RSTORSSP_RAX    0
> > > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > > +%endmacro
> > > > --
> > > > 2.16.2.windows.1
> >
> >



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Sheng Wei 3 years, 2 months ago
Hi Mike,
If we plan to update the NSAM version, it will affect everyone why is building the BIOS image, do you know the process ?
How to request all the people update their NSAM tool ?
How long will be the whole process ?
Thanks
BR
Sheng Wei

> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: 2021年2月2日 23:22
> To: Sheng, W <w.sheng@intel.com>; gaoliming
> <gaoliming@byosoft.com.cn>; devel@edk2.groups.io; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Sheng,
> 
> I recommend we update required NASM version.
> 
> From your investigation, the new min version would be 2.15.01.
> 
> Mike
> 
> > -----Original Message-----
> > From: Sheng, W <w.sheng@intel.com>
> > Sent: Monday, February 1, 2021 7:39 PM
> > To: gaoliming <gaoliming@byosoft.com.cn>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; devel@edk2.groups.io
> > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> > Ersek' <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> > Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Hi Mike, Liming,
> > The latest NASM version is version 2.15.05.
> > The CET instructions is supported since NASM version 2.15.01, it is released
> at 2020-06-27.
> > Do you think we need to request everyone to update the NASM tool now?
> > Or could I still use macros with DB for CET instructions in my patch ?
> > BR
> > Sheng Wei
> >
> > > -----Original Message-----
> > > From: gaoliming <gaoliming@byosoft.com.cn>
> > > Sent: 2021年2月2日 10:44
> > > To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> > > <w.sheng@intel.com>; devel@edk2.groups.io
> > > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> Ersek'
> > > <lersek@redhat.com>
> > > Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to
> > > Nasm.inc
> > >
> > > Mike and Sheng:
> > >   Linux or Mac OS includes the pre-built nasm. Their nasm version may be
> old.
> > > Can you evaluate the impact to update nasm version?
> > >
> > > Thanks
> > > Liming
> > > > -----邮件原件-----
> > > > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > > > 发送时间: 2021年1月30日 1:23
> > > > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io;
> Kinney,
> > > > Michael D <michael.d.kinney@intel.com>
> > > > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > >
> > > > Sheng,
> > > >
> > > > The following version of the NASM documentation shows support for
> > > > these instructions.
> > > >
> > > > 	https://nasm.us/doc/nasmdocb.html
> > > >
> > > > Do we need to increase the min NASM version requirements for EDK
> > > > II to avoid adding macros with DB?
> > > >
> > > > Thanks,
> > > >
> > > > Mike
> > > >
> > > > > -----Original Message-----
> > > > > From: Sheng, W <w.sheng@intel.com>
> > > > > Sent: Thursday, January 28, 2021 6:35 PM
> > > > > To: devel@edk2.groups.io
> > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > > Subject: [PATCH] MdePkg/Include: Add CET instructions to
> > > > > Nasm.inc
> > > > >
> > > > > This is to add instruction SAVEPREVSSP, CLRSSBSY and
> > > > > RSTORSSP_RAX in
> > > > Nasm,
> > > > > because these instructions are not supported yet.
> > > > >
> > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > > > >
> > > > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > > ---
> > > > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > > > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > > b/MdePkg/Include/Ia32/Nasm.inc
> > > > > index 31ce861f1e..9c1b7796ea 100644
> > > > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > > > @@ -1,6 +1,6 @@
> > > > >
> > > > > ;---------------------------------------------------------------
> > > > > ----
> > > > > -----------
> > > > >  ;
> > > > > -; Copyright (c) 2019, Intel Corporation. All rights
> > > > > reserved.<BR>
> > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > +reserved.<BR>
> > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > @@ -20,3 +20,15 @@
> > > > >  %macro INCSSP_EAX      0
> > > > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > > > >  %endmacro
> > > > > +
> > > > > +%macro SAVEPREVSSP     0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > +%endmacro
> > > > > +
> > > > > +%macro CLRSSBSY_EAX    0
> > > > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > > > +
> > > > > +%macro RSTORSSP_EAX    0
> > > > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > > > b/MdePkg/Include/X64/Nasm.inc
> > > > > index 42412735ea..c5189982bb 100644
> > > > > --- a/MdePkg/Include/X64/Nasm.inc
> > > > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > > > @@ -1,6 +1,6 @@
> > > > >
> > > > > ;---------------------------------------------------------------
> > > > > ----
> > > > > -----------
> > > > >  ;
> > > > > -; Copyright (c) 2019, Intel Corporation. All rights
> > > > > reserved.<BR>
> > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > +reserved.<BR>
> > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > @@ -20,3 +20,15 @@
> > > > >  %macro INCSSP_RAX      0
> > > > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > > > +
> > > > > +%macro SAVEPREVSSP     0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > +%endmacro
> > > > > +
> > > > > +%macro CLRSSBSY_RAX    0
> > > > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > > > +%endmacro
> > > > > +
> > > > > +%macro RSTORSSP_RAX    0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > > > +%endmacro
> > > > > --
> > > > > 2.16.2.windows.1
> > >
> > >



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


[edk2-devel] 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by gaoliming 3 years, 2 months ago
Wei:
  The normal process is to send RFC in edk2 mail list and collect the feedback. This RFC introduces the proposed change, the impact and the suggestion. Then, wait for one or two weeks to collect the feedback. If there are more feedback, more time will be required.

  Now, we are in the late phase of edk2-stable202102 tag development. If the change brings the big impact, I suggest to add it in the early phase of one stable tag. For this change, I suggest to collect its impact and send RFC to start the discussion first. 

Proposed Schedule
Date (00:00:00 UTC-8)	Description
2020-11-27	Beginning of development
2021-02-15	Feature Planning Freeze
2021-02-22	Soft Feature Freeze
2021-03-01	Hard Feature Freeze
2021-03-05	Release

Thanks
Liming
> -----邮件原件-----
> 发件人: Sheng, W <w.sheng@intel.com>
> 发送时间: 2021年2月3日 8:07
> 收件人: Kinney, Michael D <michael.d.kinney@intel.com>; gaoliming
> <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
> 抄送: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Mike,
> If we plan to update the NSAM version, it will affect everyone why is building
> the BIOS image, do you know the process ?
> How to request all the people update their NSAM tool ?
> How long will be the whole process ?
> Thanks
> BR
> Sheng Wei
> 
> > -----Original Message-----
> > From: Kinney, Michael D <michael.d.kinney@intel.com>
> > Sent: 2021年2月2日 23:22
> > To: Sheng, W <w.sheng@intel.com>; gaoliming
> > <gaoliming@byosoft.com.cn>; devel@edk2.groups.io; Kinney, Michael D
> > <michael.d.kinney@intel.com>
> > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> > <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> > Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Hi Sheng,
> >
> > I recommend we update required NASM version.
> >
> > From your investigation, the new min version would be 2.15.01.
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: Sheng, W <w.sheng@intel.com>
> > > Sent: Monday, February 1, 2021 7:39 PM
> > > To: gaoliming <gaoliming@byosoft.com.cn>; Kinney, Michael D
> > > <michael.d.kinney@intel.com>; devel@edk2.groups.io
> > > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> > > Ersek' <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> > > Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > Hi Mike, Liming,
> > > The latest NASM version is version 2.15.05.
> > > The CET instructions is supported since NASM version 2.15.01, it is
> released
> > at 2020-06-27.
> > > Do you think we need to request everyone to update the NASM tool now?
> > > Or could I still use macros with DB for CET instructions in my patch ?
> > > BR
> > > Sheng Wei
> > >
> > > > -----Original Message-----
> > > > From: gaoliming <gaoliming@byosoft.com.cn>
> > > > Sent: 2021年2月2日 10:44
> > > > To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> > > > <w.sheng@intel.com>; devel@edk2.groups.io
> > > > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > > > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> > Ersek'
> > > > <lersek@redhat.com>
> > > > Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to
> > > > Nasm.inc
> > > >
> > > > Mike and Sheng:
> > > >   Linux or Mac OS includes the pre-built nasm. Their nasm version may
> be
> > old.
> > > > Can you evaluate the impact to update nasm version?
> > > >
> > > > Thanks
> > > > Liming
> > > > > -----邮件原件-----
> > > > > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > > > > 发送时间: 2021年1月30日 1:23
> > > > > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io;
> > Kinney,
> > > > > Michael D <michael.d.kinney@intel.com>
> > > > > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > > >
> > > > > Sheng,
> > > > >
> > > > > The following version of the NASM documentation shows support for
> > > > > these instructions.
> > > > >
> > > > > 	https://nasm.us/doc/nasmdocb.html
> > > > >
> > > > > Do we need to increase the min NASM version requirements for EDK
> > > > > II to avoid adding macros with DB?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Mike
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Sheng, W <w.sheng@intel.com>
> > > > > > Sent: Thursday, January 28, 2021 6:35 PM
> > > > > > To: devel@edk2.groups.io
> > > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > > > Subject: [PATCH] MdePkg/Include: Add CET instructions to
> > > > > > Nasm.inc
> > > > > >
> > > > > > This is to add instruction SAVEPREVSSP, CLRSSBSY and
> > > > > > RSTORSSP_RAX in
> > > > > Nasm,
> > > > > > because these instructions are not supported yet.
> > > > > >
> > > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > > > > >
> > > > > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > > > ---
> > > > > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > > > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > > > > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > > > > >
> > > > > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > > > b/MdePkg/Include/Ia32/Nasm.inc
> > > > > > index 31ce861f1e..9c1b7796ea 100644
> > > > > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > > > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > > > > @@ -1,6 +1,6 @@
> > > > > >
> > > > > > ;---------------------------------------------------------------
> > > > > > ----
> > > > > > -----------
> > > > > >  ;
> > > > > > -; Copyright (c) 2019, Intel Corporation. All rights
> > > > > > reserved.<BR>
> > > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > > +reserved.<BR>
> > > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > > @@ -20,3 +20,15 @@
> > > > > >  %macro INCSSP_EAX      0
> > > > > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > > > > >  %endmacro
> > > > > > +
> > > > > > +%macro SAVEPREVSSP     0
> > > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > > +%endmacro
> > > > > > +
> > > > > > +%macro CLRSSBSY_EAX    0
> > > > > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > > > > +
> > > > > > +%macro RSTORSSP_EAX    0
> > > > > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > > > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > > > > b/MdePkg/Include/X64/Nasm.inc
> > > > > > index 42412735ea..c5189982bb 100644
> > > > > > --- a/MdePkg/Include/X64/Nasm.inc
> > > > > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > > > > @@ -1,6 +1,6 @@
> > > > > >
> > > > > > ;---------------------------------------------------------------
> > > > > > ----
> > > > > > -----------
> > > > > >  ;
> > > > > > -; Copyright (c) 2019, Intel Corporation. All rights
> > > > > > reserved.<BR>
> > > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > > +reserved.<BR>
> > > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > > @@ -20,3 +20,15 @@
> > > > > >  %macro INCSSP_RAX      0
> > > > > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > > > > +
> > > > > > +%macro SAVEPREVSSP     0
> > > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > > +%endmacro
> > > > > > +
> > > > > > +%macro CLRSSBSY_RAX    0
> > > > > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > > > > +%endmacro
> > > > > > +
> > > > > > +%macro RSTORSSP_RAX    0
> > > > > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > > > > +%endmacro
> > > > > > --
> > > > > > 2.16.2.windows.1
> > > >
> > > >





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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Laszlo Ersek 3 years, 2 months ago
On 02/02/21 16:21, Kinney, Michael D wrote:
> Hi Sheng,
> 
> I recommend we update required NASM version.
> 
> From your investigation, the new min version would be 2.15.01.

I'd be happy with that -- the Linux distros I primarily care about seem
to support a nasm version that's not earlier than this.

On my personal laptop, I'd have to build nasm from source, but that's OK.

Given the above, I'd like to avoid more DB-encoded instructions in edk2.

Thanks,
Laszlo



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


[edk2-devel] 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by gaoliming 3 years, 2 months ago
Sheng:
  Can you check nasm version in ubuntu-18.04 and latest ubuntu OS? Those Oss are used in open CI. 

Thanks
Liming
> -----邮件原件-----
> 发件人: Sheng, W <w.sheng@intel.com>
> 发送时间: 2021年2月2日 11:39
> 收件人: gaoliming <gaoliming@byosoft.com.cn>; Kinney, Michael D
> <michael.d.kinney@intel.com>; devel@edk2.groups.io
> 抄送: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Mike, Liming,
> The latest NASM version is version 2.15.05.
> The CET instructions is supported since NASM version 2.15.01, it is released at
> 2020-06-27.
> Do you think we need to request everyone to update the NASM tool now?
> Or could I still use macros with DB for CET instructions in my patch ?
> BR
> Sheng Wei
> 
> > -----Original Message-----
> > From: gaoliming <gaoliming@byosoft.com.cn>
> > Sent: 2021年2月2日 10:44
> > To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> > <w.sheng@intel.com>; devel@edk2.groups.io
> > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> > <lersek@redhat.com>
> > Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Mike and Sheng:
> >   Linux or Mac OS includes the pre-built nasm. Their nasm version may be
> old.
> > Can you evaluate the impact to update nasm version?
> >
> > Thanks
> > Liming
> > > -----邮件原件-----
> > > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > > 发送时间: 2021年1月30日 1:23
> > > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io; Kinney,
> > > Michael D <michael.d.kinney@intel.com>
> > > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > Sheng,
> > >
> > > The following version of the NASM documentation shows support for
> > > these instructions.
> > >
> > > 	https://nasm.us/doc/nasmdocb.html
> > >
> > > Do we need to increase the min NASM version requirements for EDK II to
> > > avoid adding macros with DB?
> > >
> > > Thanks,
> > >
> > > Mike
> > >
> > > > -----Original Message-----
> > > > From: Sheng, W <w.sheng@intel.com>
> > > > Sent: Thursday, January 28, 2021 6:35 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > >
> > > > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> > > Nasm,
> > > > because these instructions are not supported yet.
> > > >
> > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > > >
> > > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > ---
> > > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > b/MdePkg/Include/Ia32/Nasm.inc
> > > > index 31ce861f1e..9c1b7796ea 100644
> > > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > > @@ -1,6 +1,6 @@
> > > >
> > > > ;-------------------------------------------------------------------
> > > > -----------
> > > >  ;
> > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > +reserved.<BR>
> > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > @@ -20,3 +20,15 @@
> > > >  %macro INCSSP_EAX      0
> > > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > > >  %endmacro
> > > > +
> > > > +%macro SAVEPREVSSP     0
> > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > +%endmacro
> > > > +
> > > > +%macro CLRSSBSY_EAX    0
> > > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > > +
> > > > +%macro RSTORSSP_EAX    0
> > > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > > b/MdePkg/Include/X64/Nasm.inc
> > > > index 42412735ea..c5189982bb 100644
> > > > --- a/MdePkg/Include/X64/Nasm.inc
> > > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > > @@ -1,6 +1,6 @@
> > > >
> > > > ;-------------------------------------------------------------------
> > > > -----------
> > > >  ;
> > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > +reserved.<BR>
> > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > @@ -20,3 +20,15 @@
> > > >  %macro INCSSP_RAX      0
> > > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > > +
> > > > +%macro SAVEPREVSSP     0
> > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > +%endmacro
> > > > +
> > > > +%macro CLRSSBSY_RAX    0
> > > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > > +%endmacro
> > > > +
> > > > +%macro RSTORSSP_RAX    0
> > > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > > +%endmacro
> > > > --
> > > > 2.16.2.windows.1
> >
> >





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


Re: [edk2-devel] 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Michael D Kinney 3 years, 2 months ago
Liming,

We can always install a newer version in CI agents,

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
> Sent: Monday, February 1, 2021 7:51 PM
> To: Sheng, W <w.sheng@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo
> Ersek' <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> Subject: [edk2-devel] 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Sheng:
>   Can you check nasm version in ubuntu-18.04 and latest ubuntu OS? Those Oss are used in open CI.
> 
> Thanks
> Liming
> > -----邮件原件-----
> > 发件人: Sheng, W <w.sheng@intel.com>
> > 发送时间: 2021年2月2日 11:39
> > 收件人: gaoliming <gaoliming@byosoft.com.cn>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; devel@edk2.groups.io
> > 抄送: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> > <lersek@redhat.com>; Feng, Roger <roger.feng@intel.com>
> > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Hi Mike, Liming,
> > The latest NASM version is version 2.15.05.
> > The CET instructions is supported since NASM version 2.15.01, it is released at
> > 2020-06-27.
> > Do you think we need to request everyone to update the NASM tool now?
> > Or could I still use macros with DB for CET instructions in my patch ?
> > BR
> > Sheng Wei
> >
> > > -----Original Message-----
> > > From: gaoliming <gaoliming@byosoft.com.cn>
> > > Sent: 2021年2月2日 10:44
> > > To: Kinney, Michael D <michael.d.kinney@intel.com>; Sheng, W
> > > <w.sheng@intel.com>; devel@edk2.groups.io
> > > Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen
> > > <jiewen.yao@intel.com>; 'Andrew Fish' <afish@apple.com>; 'Laszlo Ersek'
> > > <lersek@redhat.com>
> > > Subject: 回复: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > Mike and Sheng:
> > >   Linux or Mac OS includes the pre-built nasm. Their nasm version may be
> > old.
> > > Can you evaluate the impact to update nasm version?
> > >
> > > Thanks
> > > Liming
> > > > -----邮件原件-----
> > > > 发件人: Kinney, Michael D <michael.d.kinney@intel.com>
> > > > 发送时间: 2021年1月30日 1:23
> > > > 收件人: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io; Kinney,
> > > > Michael D <michael.d.kinney@intel.com>
> > > > 抄送: Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > 主题: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > >
> > > > Sheng,
> > > >
> > > > The following version of the NASM documentation shows support for
> > > > these instructions.
> > > >
> > > > 	https://nasm.us/doc/nasmdocb.html
> > > >
> > > > Do we need to increase the min NASM version requirements for EDK II to
> > > > avoid adding macros with DB?
> > > >
> > > > Thanks,
> > > >
> > > > Mike
> > > >
> > > > > -----Original Message-----
> > > > > From: Sheng, W <w.sheng@intel.com>
> > > > > Sent: Thursday, January 28, 2021 6:35 PM
> > > > > To: devel@edk2.groups.io
> > > > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > > > > <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > > > > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > > > >
> > > > > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> > > > Nasm,
> > > > > because these instructions are not supported yet.
> > > > >
> > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > > > >
> > > > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > > > ---
> > > > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > > > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > > b/MdePkg/Include/Ia32/Nasm.inc
> > > > > index 31ce861f1e..9c1b7796ea 100644
> > > > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > > > @@ -1,6 +1,6 @@
> > > > >
> > > > > ;-------------------------------------------------------------------
> > > > > -----------
> > > > >  ;
> > > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > +reserved.<BR>
> > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > @@ -20,3 +20,15 @@
> > > > >  %macro INCSSP_EAX      0
> > > > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > > > >  %endmacro
> > > > > +
> > > > > +%macro SAVEPREVSSP     0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > +%endmacro
> > > > > +
> > > > > +%macro CLRSSBSY_EAX    0
> > > > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30 %endmacro
> > > > > +
> > > > > +%macro RSTORSSP_EAX    0
> > > > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28 %endmacro
> > > > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > > > b/MdePkg/Include/X64/Nasm.inc
> > > > > index 42412735ea..c5189982bb 100644
> > > > > --- a/MdePkg/Include/X64/Nasm.inc
> > > > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > > > @@ -1,6 +1,6 @@
> > > > >
> > > > > ;-------------------------------------------------------------------
> > > > > -----------
> > > > >  ;
> > > > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > > > +reserved.<BR>
> > > > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > > > @@ -20,3 +20,15 @@
> > > > >  %macro INCSSP_RAX      0
> > > > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8  %endmacro
> > > > > +
> > > > > +%macro SAVEPREVSSP     0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > > > +%endmacro
> > > > > +
> > > > > +%macro CLRSSBSY_RAX    0
> > > > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > > > +%endmacro
> > > > > +
> > > > > +%macro RSTORSSP_RAX    0
> > > > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > > > +%endmacro
> > > > > --
> > > > > 2.16.2.windows.1
> > >
> > >
> 
> 
> 
> 
> 
> 
> 



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Yao, Jiewen 3 years, 2 months ago
Hi Wei
Would you please send out the second patch to consume these instruction?

As such people can have a full picture on what the issue is and what the solution is.

Thank you
Yao Jiewen

> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Friday, January 29, 2021 10:35 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; Yao,
> Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> Nasm,
> because these instructions are not supported yet.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> 
> Signed-off-by: Sheng Wei <w.sheng@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> ---
>  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
>  MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
>  2 files changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/MdePkg/Include/Ia32/Nasm.inc
> b/MdePkg/Include/Ia32/Nasm.inc
> index 31ce861f1e..9c1b7796ea 100644
> --- a/MdePkg/Include/Ia32/Nasm.inc
> +++ b/MdePkg/Include/Ia32/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_EAX      0
>      DB 0xF3, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_EAX    0
> +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> diff --git a/MdePkg/Include/X64/Nasm.inc
> b/MdePkg/Include/X64/Nasm.inc
> index 42412735ea..c5189982bb 100644
> --- a/MdePkg/Include/X64/Nasm.inc
> +++ b/MdePkg/Include/X64/Nasm.inc
> @@ -1,6 +1,6 @@
>  ;------------------------------------------------------------------------------
>  ;
> -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> +; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
>  ; SPDX-License-Identifier: BSD-2-Clause-Patent
>  ;
>  ; Abstract:
> @@ -20,3 +20,15 @@
>  %macro INCSSP_RAX      0
>      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
>  %endmacro
> +
> +%macro SAVEPREVSSP     0
> +    DB 0xF3, 0x0F, 0x01, 0xEA
> +%endmacro
> +
> +%macro CLRSSBSY_RAX    0
> +    DB 0xF3, 0x0F, 0xAE, 0x30
> +%endmacro
> +
> +%macro RSTORSSP_RAX    0
> +    DB 0xF3, 0x0F, 0x01, 0x28
> +%endmacro
> --
> 2.16.2.windows.1



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


Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Sheng Wei 3 years, 2 months ago
Hi Jiewen, all,
The 2 patches are for fix #DF exception when enable CET shadow stack feature.
The file 0002-UefiCpuPkg-CpuExceptionHandlerLib-Clear-CET-shadow-s.patch is used to fix the #DF exception issue.
The file 0001-MdePkg-Include-Add-CET-instructions-to-Nasm.inc.patch is used to add the CET instruction which is used in patch 0002.

Some description about the issue and the fix:
If CET shadows stack feature enabled in SMM and stack switch is enabled.
When code execute from SMM handler to SMM exception, CPU will check SMM
exception shadow stack token busy bit if it is cleared or not. 
If it is set, it will trigger #DF exception.
If it is not set, CPU will set the busy bit when enter SMM exception.
The busy bit should be cleared when return back form SMM exception to SMM
handler. Otherwise, keeping busy bit in set state will cause to trigger
#DF exception when enter SMM exception next time.
So, we use instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP to clear the
shadow stack token busy bit before RETF instruction in SMM exception.

Could you help to review and merge the patch?
Thank you
BR
Sheng Wei

> -----Original Message-----
> From: Yao, Jiewen <jiewen.yao@intel.com>
> Sent: 2021年1月29日 14:36
> To: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Wei
> Would you please send out the second patch to consume these instruction?
> 
> As such people can have a full picture on what the issue is and what the
> solution is.
> 
> Thank you
> Yao Jiewen
> 
> > -----Original Message-----
> > From: Sheng, W <w.sheng@intel.com>
> > Sent: Friday, January 29, 2021 10:35 AM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> > Yao, Jiewen <jiewen.yao@intel.com>
> > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in
> > Nasm, because these instructions are not supported yet.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> >
> > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > ---
> >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> >  2 files changed, 26 insertions(+), 2 deletions(-)
> >
> > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > b/MdePkg/Include/Ia32/Nasm.inc index 31ce861f1e..9c1b7796ea 100644
> > --- a/MdePkg/Include/Ia32/Nasm.inc
> > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > @@ -1,6 +1,6 @@
> >
> > ;---------------------------------------------------------------------
> > ---------
> >  ;
> > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > @@ -20,3 +20,15 @@
> >  %macro INCSSP_EAX      0
> >      DB 0xF3, 0x0F, 0xAE, 0xE8
> >  %endmacro
> > +
> > +%macro SAVEPREVSSP     0
> > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > +%endmacro
> > +
> > +%macro CLRSSBSY_EAX    0
> > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> > +%endmacro
> > +
> > +%macro RSTORSSP_EAX    0
> > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> > +%endmacro
> > diff --git a/MdePkg/Include/X64/Nasm.inc
> b/MdePkg/Include/X64/Nasm.inc
> > index 42412735ea..c5189982bb 100644
> > --- a/MdePkg/Include/X64/Nasm.inc
> > +++ b/MdePkg/Include/X64/Nasm.inc
> > @@ -1,6 +1,6 @@
> >
> > ;---------------------------------------------------------------------
> > ---------
> >  ;
> > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > +reserved.<BR>
> >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > @@ -20,3 +20,15 @@
> >  %macro INCSSP_RAX      0
> >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
> >  %endmacro
> > +
> > +%macro SAVEPREVSSP     0
> > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > +%endmacro
> > +
> > +%macro CLRSSBSY_RAX    0
> > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > +%endmacro
> > +
> > +%macro RSTORSSP_RAX    0
> > +    DB 0xF3, 0x0F, 0x01, 0x28
> > +%endmacro
> > --
> > 2.16.2.windows.1



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


From d1099ae09e6bfeac086ee974edbee7a5c4a34905 Mon Sep 17 00:00:00 2001
From: Sheng Wei <w.sheng@intel.com>
Date: Fri, 29 Jan 2021 15:25:11 +0800
Subject: [PATCH 0/2] Fix #DF issue when enable CET shadow stack feature.

If CET shadows stack feature enabled in SMM and stack switch is enabled.
When code execute from SMM handler to SMM exception, CPU will check SMM
exception shadow stack token busy bit if it is cleared or not. 
If it is set, it will trigger #DF exception.
If it is not set, CPU will set the busy bit when enter SMM exception.
The busy bit should be cleared when return back form SMM exception to SMM
handler. Otherwise, keeping busy bit in set state will cause to trigger
#DF exception when enter SMM exception next time.
So, we use instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP to clear the
shadow stack token busy bit before RETF instruction in SMM exception.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>

Sheng Wei (2):
  MdePkg/Include: Add CET instructions to Nasm.inc
  UefiCpuPkg/CpuExceptionHandlerLib: Clear CET shadow stack token busy
    bit

 MdePkg/Include/Ia32/Nasm.inc                       | 14 ++++++++++-
 MdePkg/Include/X64/Nasm.inc                        | 14 ++++++++++-
 .../DxeCpuExceptionHandlerLib.inf                  |  3 +++
 .../PeiCpuExceptionHandlerLib.inf                  |  3 +++
 .../SecPeiCpuExceptionHandlerLib.inf               |  4 ++++
 .../SmmCpuExceptionHandlerLib.inf                  |  3 +++
 .../X64/Xcode5ExceptionHandlerAsm.nasm             | 28 +++++++++++++++++++++-
 .../Xcode5SecPeiCpuExceptionHandlerLib.inf         |  4 ++++
 8 files changed, 70 insertions(+), 3 deletions(-)

-- 
2.16.2.windows.1

From d27044daf924c1ceb98d61edde57f5e3a11a1164 Mon Sep 17 00:00:00 2001
From: Sheng Wei <w.sheng@intel.com>
Date: Tue, 26 Jan 2021 16:54:15 +0800
Subject: [PATCH 1/2] MdePkg/Include: Add CET instructions to Nasm.inc

This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX in Nasm,
because these instructions are not supported yet.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
 MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
 MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Ia32/Nasm.inc b/MdePkg/Include/Ia32/Nasm.inc
index 31ce861f1e..9c1b7796ea 100644
--- a/MdePkg/Include/Ia32/Nasm.inc
+++ b/MdePkg/Include/Ia32/Nasm.inc
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------
 ;
-; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Abstract:
@@ -20,3 +20,15 @@
 %macro INCSSP_EAX      0
     DB 0xF3, 0x0F, 0xAE, 0xE8
 %endmacro
+
+%macro SAVEPREVSSP     0
+    DB 0xF3, 0x0F, 0x01, 0xEA
+%endmacro
+
+%macro CLRSSBSY_EAX    0
+    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
+%endmacro
+
+%macro RSTORSSP_EAX    0
+    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
+%endmacro
diff --git a/MdePkg/Include/X64/Nasm.inc b/MdePkg/Include/X64/Nasm.inc
index 42412735ea..c5189982bb 100644
--- a/MdePkg/Include/X64/Nasm.inc
+++ b/MdePkg/Include/X64/Nasm.inc
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------
 ;
-; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Abstract:
@@ -20,3 +20,15 @@
 %macro INCSSP_RAX      0
     DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
 %endmacro
+
+%macro SAVEPREVSSP     0
+    DB 0xF3, 0x0F, 0x01, 0xEA
+%endmacro
+
+%macro CLRSSBSY_RAX    0
+    DB 0xF3, 0x0F, 0xAE, 0x30
+%endmacro
+
+%macro RSTORSSP_RAX    0
+    DB 0xF3, 0x0F, 0x01, 0x28
+%endmacro
-- 
2.16.2.windows.1

From d1099ae09e6bfeac086ee974edbee7a5c4a34905 Mon Sep 17 00:00:00 2001
From: Sheng Wei <w.sheng@intel.com>
Date: Tue, 26 Jan 2021 17:00:58 +0800
Subject: [PATCH 2/2] UefiCpuPkg/CpuExceptionHandlerLib: Clear CET shadow stack
 token busy bit

If CET shadows stack feature enabled in SMM and stack switch is enabled.
When code execute from SMM handler to SMM exception, CPU will check SMM
exception shadow stack token busy bit if it is cleared or not. 
If it is set, it will trigger #DF exception.
If it is not set, CPU will set the busy bit when enter SMM exception.
The busy bit should be cleared when return back form SMM exception to SMM
handler. Otherwise, keeping busy bit in set state will cause to trigger
#DF exception when enter SMM exception next time.
So, we use instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP to clear the
shadow stack token busy bit before RETF instruction in SMM exception.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
---
 .../DxeCpuExceptionHandlerLib.inf                  |  3 +++
 .../PeiCpuExceptionHandlerLib.inf                  |  3 +++
 .../SecPeiCpuExceptionHandlerLib.inf               |  4 ++++
 .../SmmCpuExceptionHandlerLib.inf                  |  3 +++
 .../X64/Xcode5ExceptionHandlerAsm.nasm             | 28 +++++++++++++++++++++-
 .../Xcode5SecPeiCpuExceptionHandlerLib.inf         |  4 ++++
 6 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
index 07b34c92a8..e7a81bebdb 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
@@ -43,6 +43,9 @@
   gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList
   gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize
 
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard                    ## CONSUMES
+
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
index feae7b3e06..cf5bfe4083 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
@@ -57,3 +57,6 @@
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard    # CONSUMES
 
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard                    ## CONSUMES
+
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
index 967cb61ba6..8ae4feae62 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
@@ -49,3 +49,7 @@
   LocalApicLib
   PeCoffGetEntryPointLib
   VmgExitLib
+
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard                    ## CONSUMES
+
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
index 4cdb11c04e..5c3d1f7cfd 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
@@ -53,3 +53,6 @@
   DebugLib
   VmgExitLib
 
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard                    ## CONSUMES
+
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
index 26cae56cc5..13fd147f11 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
@@ -1,5 +1,5 @@
 ;------------------------------------------------------------------------------ ;
-; Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.<BR>
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;
 ; Module Name:
@@ -13,6 +13,7 @@
 ; Notes:
 ;
 ;------------------------------------------------------------------------------
+%include "Nasm.inc"
 
 ;
 ; CommonExceptionHandler()
@@ -23,6 +24,7 @@
 extern ASM_PFX(mErrorCodeFlag)    ; Error code flags for exceptions
 extern ASM_PFX(mDoFarReturnFlag)  ; Do far return flag
 extern ASM_PFX(CommonExceptionHandler)
+extern ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))
 
 SECTION .data
 
@@ -371,6 +373,30 @@ DoReturn:
     push    qword [rax + 0x18]       ; save EFLAGS in new location
     mov     rax, [rax]        ; restore rax
     popfq                     ; restore EFLAGS
+
+    push    rax
+    cmp     byte [dword ASM_PFX(FeaturePcdGet (PcdCpuSmmStackGuard))], 0
+    jz      CetDone
+    mov     rax, cr4
+    and     rax, 0x800000     ; check if CET is enabled
+    jz      CetDone
+    push    rbx
+    mov     rax, 0x04
+    INCSSP_RAX
+    SAVEPREVSSP
+    READSSP_RAX
+    mov     rbx, rax
+    sub     rax, 0x10
+    CLRSSBSY_RAX
+    mov     rax, rbx
+    sub     rax, 0x30
+    RSTORSSP_RAX
+    mov     rax, 0x01
+    INCSSP_RAX
+    pop     rbx
+CetDone:
+    pop     rax
+
     DB      0x48               ; prefix to composite "retq" with next "retf"
     retf                      ; far return
 DoIret:
diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
index 743c2aa766..a15f125d5b 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
@@ -54,3 +54,7 @@
   LocalApicLib
   PeCoffGetEntryPointLib
   VmgExitLib
+
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackGuard                    ## CONSUMES
+
-- 
2.16.2.windows.1

Re: [edk2-devel] [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
Posted by Yao, Jiewen 3 years, 2 months ago
Thanks.

A question: Do we also need change the https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiException.nasm#L174

Thank you
Yao Jiewen


> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Friday, January 29, 2021 4:33 PM
> To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io; Dong, Eric
> <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo Ersek
> <lersek@redhat.com>; Kumar, Rahul1 <rahul1.kumar@intel.com>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> 
> Hi Jiewen, all,
> The 2 patches are for fix #DF exception when enable CET shadow stack
> feature.
> The file 0002-UefiCpuPkg-CpuExceptionHandlerLib-Clear-CET-shadow-
> s.patch is used to fix the #DF exception issue.
> The file 0001-MdePkg-Include-Add-CET-instructions-to-Nasm.inc.patch is
> used to add the CET instruction which is used in patch 0002.
> 
> Some description about the issue and the fix:
> If CET shadows stack feature enabled in SMM and stack switch is enabled.
> When code execute from SMM handler to SMM exception, CPU will check
> SMM
> exception shadow stack token busy bit if it is cleared or not.
> If it is set, it will trigger #DF exception.
> If it is not set, CPU will set the busy bit when enter SMM exception.
> The busy bit should be cleared when return back form SMM exception to
> SMM
> handler. Otherwise, keeping busy bit in set state will cause to trigger
> #DF exception when enter SMM exception next time.
> So, we use instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP to clear the
> shadow stack token busy bit before RETF instruction in SMM exception.
> 
> Could you help to review and merge the patch?
> Thank you
> BR
> Sheng Wei
> 
> > -----Original Message-----
> > From: Yao, Jiewen <jiewen.yao@intel.com>
> > Sent: 2021年1月29日 14:36
> > To: Sheng, W <w.sheng@intel.com>; devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
> > Subject: RE: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> >
> > Hi Wei
> > Would you please send out the second patch to consume these
> instruction?
> >
> > As such people can have a full picture on what the issue is and what the
> > solution is.
> >
> > Thank you
> > Yao Jiewen
> >
> > > -----Original Message-----
> > > From: Sheng, W <w.sheng@intel.com>
> > > Sent: Friday, January 29, 2021 10:35 AM
> > > To: devel@edk2.groups.io
> > > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao
> > > <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> > > Yao, Jiewen <jiewen.yao@intel.com>
> > > Subject: [PATCH] MdePkg/Include: Add CET instructions to Nasm.inc
> > >
> > > This is to add instruction SAVEPREVSSP, CLRSSBSY and RSTORSSP_RAX
> in
> > > Nasm, because these instructions are not supported yet.
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> > >
> > > Signed-off-by: Sheng Wei <w.sheng@intel.com>
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > > ---
> > >  MdePkg/Include/Ia32/Nasm.inc | 14 +++++++++++++-
> > > MdePkg/Include/X64/Nasm.inc  | 14 +++++++++++++-
> > >  2 files changed, 26 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/MdePkg/Include/Ia32/Nasm.inc
> > > b/MdePkg/Include/Ia32/Nasm.inc index 31ce861f1e..9c1b7796ea
> 100644
> > > --- a/MdePkg/Include/Ia32/Nasm.inc
> > > +++ b/MdePkg/Include/Ia32/Nasm.inc
> > > @@ -1,6 +1,6 @@
> > >
> > > ;---------------------------------------------------------------------
> > > ---------
> > >  ;
> > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > +reserved.<BR>
> > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > @@ -20,3 +20,15 @@
> > >  %macro INCSSP_EAX      0
> > >      DB 0xF3, 0x0F, 0xAE, 0xE8
> > >  %endmacro
> > > +
> > > +%macro SAVEPREVSSP     0
> > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > +%endmacro
> > > +
> > > +%macro CLRSSBSY_EAX    0
> > > +    DB 0x67, 0xF3, 0x0F, 0xAE, 0x30
> > > +%endmacro
> > > +
> > > +%macro RSTORSSP_EAX    0
> > > +    DB 0x67, 0xF3, 0x0F, 0x01, 0x28
> > > +%endmacro
> > > diff --git a/MdePkg/Include/X64/Nasm.inc
> > b/MdePkg/Include/X64/Nasm.inc
> > > index 42412735ea..c5189982bb 100644
> > > --- a/MdePkg/Include/X64/Nasm.inc
> > > +++ b/MdePkg/Include/X64/Nasm.inc
> > > @@ -1,6 +1,6 @@
> > >
> > > ;---------------------------------------------------------------------
> > > ---------
> > >  ;
> > > -; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> > > +; Copyright (c) 2019 - 2021, Intel Corporation. All rights
> > > +reserved.<BR>
> > >  ; SPDX-License-Identifier: BSD-2-Clause-Patent  ;  ; Abstract:
> > > @@ -20,3 +20,15 @@
> > >  %macro INCSSP_RAX      0
> > >      DB 0xF3, 0x48, 0x0F, 0xAE, 0xE8
> > >  %endmacro
> > > +
> > > +%macro SAVEPREVSSP     0
> > > +    DB 0xF3, 0x0F, 0x01, 0xEA
> > > +%endmacro
> > > +
> > > +%macro CLRSSBSY_RAX    0
> > > +    DB 0xF3, 0x0F, 0xAE, 0x30
> > > +%endmacro
> > > +
> > > +%macro RSTORSSP_RAX    0
> > > +    DB 0xF3, 0x0F, 0x01, 0x28
> > > +%endmacro
> > > --
> > > 2.16.2.windows.1



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