From nobody Mon May 13 20:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111515+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111515+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700550172; cv=none; d=zohomail.com; s=zohoarc; b=DcVTlicXNjU2u/hwoZdJ+FRV2AA3g1Cc4OWKRz21+IprQCN//4q6iVWVWtx8g0mvMlIg11hsUOgJbZyTh4lFDThruk00UPiqEDYjHcx4/FrGNDF6KbUlLbIKYfETlTI5b3Cpjc9BVeA3rX5fdvIl6J/lA5BxHCBYmlV4gVVcEcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700550172; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=IsiCD8cPIP6SXKCIwISEyiL2O6bqkfr6MY6GmpTtpXA=; b=MWXgAQ+G2j/NA9Yy3uRcl3kQt7hd60fECGgjAvjnQ0GLmvX2ojAWE9yH+kt0EZkXt+A7SQnW3FlvM4iDknrpkQyupMsFbQjSuTgUxtOwOm7FeOeERmDXVtnd4Ng58tdlf911FDpA7IWUjGnAfNrvSLc/Ncj7690wQKWPNMhnUUs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111515+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550172529330.3684326476349; Mon, 20 Nov 2023 23:02:52 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=A114QaexmjWU1Njx85bKY99JPLLH7zv7Jm/zsgYbkKY=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550172; v=1; b=Uxee4/vwO7HsZjpu2ESA5rTrXH1UPvwHBc8z4L5APNfE69QrDKpV02q1vmZfusDcgkqcAd4a DyREWB/JUfTx/7ByFIf/vBpf+Hc0cOQ37QMNain/CkojMGqYh626+oM9fuKNDvxmXnG3UHhjK5u hsqFIjgLd9jFykHcbhSu3ssA= X-Received: by 127.0.0.2 with SMTP id AFEKYY1788612xJIoMQ1nvKx; Mon, 20 Nov 2023 23:02:52 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:02:51 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633391" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633391" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:02:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795704917" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795704917" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:02:49 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 1/6] MdePkg: Add macro definitions for CET feature for NASM files. Date: Tue, 21 Nov 2023 15:02:41 +0800 Message-Id: <20231121070246.505-2-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: nklFR23tk3PlQbsZgeEAUmrNx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550173090100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- MdePkg/Include/Ia32/Cet.inc | 26 ++++++++++++++++++++++++++ MdePkg/Include/X64/Cet.inc | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 MdePkg/Include/Ia32/Cet.inc create mode 100644 MdePkg/Include/X64/Cet.inc diff --git a/MdePkg/Include/Ia32/Cet.inc b/MdePkg/Include/Ia32/Cet.inc new file mode 100644 index 0000000000..41c99988c9 --- /dev/null +++ b/MdePkg/Include/Ia32/Cet.inc @@ -0,0 +1,26 @@ +;-------------------------------------------------------------------------= ----- +; +; Copyright (c) 2023, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Abstract: +; +; This file provides macro definitions for CET feature for NASM files. +; +;-------------------------------------------------------------------------= ----- + +%define MSR_IA32_U_CET 0x6A0 +%define MSR_IA32_S_CET 0x6A2 +%define MSR_IA32_CET_SH_STK_EN (1<<0) +%define MSR_IA32_CET_WR_SHSTK_EN (1<<1) +%define MSR_IA32_CET_ENDBR_EN (1<<2) +%define MSR_IA32_CET_LEG_IW_EN (1<<3) +%define MSR_IA32_CET_NO_TRACK_EN (1<<4) +%define MSR_IA32_CET_SUPPRESS_DIS (1<<5) +%define MSR_IA32_CET_SUPPRESS (1<<10) +%define MSR_IA32_CET_TRACKER (1<<11) +%define MSR_IA32_PL0_SSP 0x6A4 +%define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR 0x6A8 + +%define CR4_CET_BIT 23 +%define CR4_CET (1< +; SPDX-License-Identifier: BSD-2-Clause-Patent +; +; Abstract: +; +; This file provides macro definitions for CET feature for NASM files. +; +;-------------------------------------------------------------------------= ----- + +%define MSR_IA32_U_CET 0x6A0 +%define MSR_IA32_S_CET 0x6A2 +%define MSR_IA32_CET_SH_STK_EN (1<<0) +%define MSR_IA32_CET_WR_SHSTK_EN (1<<1) +%define MSR_IA32_CET_ENDBR_EN (1<<2) +%define MSR_IA32_CET_LEG_IW_EN (1<<3) +%define MSR_IA32_CET_NO_TRACK_EN (1<<4) +%define MSR_IA32_CET_SUPPRESS_DIS (1<<5) +%define MSR_IA32_CET_SUPPRESS (1<<10) +%define MSR_IA32_CET_TRACKER (1<<11) +%define MSR_IA32_PL0_SSP 0x6A4 +%define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR 0x6A8 + +%define CR4_CET_BIT 23 +%define CR4_CET (1< (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550174267473.4877737140365; Mon, 20 Nov 2023 23:02:54 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=q4JwwGRUBrKy9tJ7Hpdqzz6wlpl+BE098HssKSqjckc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550173; v=1; b=WJohEUiDeNE4HzL0oSKzILafZ9R8gfFLVG+zdDa2CVGKgH3tvdWUdFaZX6WF8mboR7y4SJbO 3rZWIui0SnqMJXH6NIlYliJBp7AJYhcU4zwbaij7R6I5M4hDIoJzx0jGHTuEz8mrMtylmyojK5N hSsWmK2HhBSFNmgnSOFElvGk= X-Received: by 127.0.0.2 with SMTP id vr3qYY1788612xKqec9KU3Dv; Mon, 20 Nov 2023 23:02:53 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:02:53 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633397" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633397" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:02:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795704948" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795704948" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:02:51 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 2/6] UefiCpuPkg: Use macro CR4_CET_BIT to replace hard code value in Cet.nasm. Date: Tue, 21 Nov 2023 15:02:42 +0800 Message-Id: <20231121070246.505-3-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: sgo7vA7HjGCO7zyU5jUxO74Cx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550174955100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm | 5 +++-- UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm b/UefiCpuPkg/PiSmmCpuD= xeSmm/Ia32/Cet.nasm index 9d66b9c5da..3d07da1cd4 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm @@ -5,6 +5,7 @@ ;-------------------------------------------------------------------------= ------ =20 %include "Nasm.inc" +%include "Cet.inc" =20 SECTION .text =20 @@ -16,7 +17,7 @@ ASM_PFX(DisableCet): incsspd eax =20 mov eax, cr4 - btr eax, 23 ; clear CET + btr eax, CR4_CET_BIT ; clear CET mov cr4, eax ret =20 @@ -24,7 +25,7 @@ global ASM_PFX(EnableCet) ASM_PFX(EnableCet): =20 mov eax, cr4 - bts eax, 23 ; set CET + bts eax, CR4_CET_BIT ; set CET mov cr4, eax =20 ; use jmp to skip the check for ret diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm b/UefiCpuPkg/PiSmmCpuDx= eSmm/X64/Cet.nasm index 8bbdbb31cc..700aef4703 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm @@ -5,6 +5,7 @@ ;-------------------------------------------------------------------------= ------ =20 %include "Nasm.inc" +%include "Cet.inc" =20 DEFAULT REL SECTION .text @@ -17,7 +18,7 @@ ASM_PFX(DisableCet): incsspq rax =20 mov rax, cr4 - btr eax, 23 ; clear CET + btr eax, CR4_CET_BIT ; clear CET mov cr4, rax ret =20 @@ -25,7 +26,7 @@ global ASM_PFX(EnableCet) ASM_PFX(EnableCet): =20 mov rax, cr4 - bts eax, 23 ; set CET + bts eax, CR4_CET_BIT ; set CET mov cr4, rax =20 ; use jmp to skip the check for ret --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111516): https://edk2.groups.io/g/devel/message/111516 Mute This Topic: https://groups.io/mt/102724273/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 13 20:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111517+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111517+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700550176; cv=none; d=zohomail.com; s=zohoarc; b=gtL4h8DH66eJLGK+9wPH+KWoW/u+oknpYL5GjwmFA7hq4tjtd5eXTCmqwUptgya/jjGjkCeuhLHXUezRLCHmjel5SqZB+RdQEZ6OL2+G1sZqTiakjvNBZwcdjyCUC1btnwITobkS5e0IW+A2FP9t2FxSWclxVM+SfHGldLA5sqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700550176; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=5qH+z1Kdd2ulqnbBX2Tk2vouwnEZslL2ba5lrZwqMag=; b=Hp14g6FgfO+BLoI8AOp3coTUBU2JvhoeBmnfJerXxEtidvKX1lkDuGjGOLZMvTFpIXkKzyMhRgk4Cmfq/3xEXqzmGKiPnM2npRh+TRo5+m+WVQAY2v1Wjkmpm7jnVx434c29BhbkZBu2MDIXrVbsEXen333eFIBEotRwWNA29Ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111517+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550176417561.0703992130137; Mon, 20 Nov 2023 23:02:56 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=7g+GWnkzfFn4kRmNqlv9joZ8pBFuH/mxU0+RM3ef6uA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550176; v=1; b=GJ5R5lewxz0KAbC1EUKKPRfQ3UDd2fZSxJh96GMw3/7ogbHOk729sCvxqYEcIGZl1zjDaami SbZNZve2PJVnA8FmYoPlL19RZoqd6Nkm0932CLZrD3+6FRTk0BYBctf5Cc5PAx54FH4ucYnJqK/ vC8d3xwBLwXZoZpQxhYQbj/M= X-Received: by 127.0.0.2 with SMTP id WzOBYY1788612xQdZcPGLwI1; Mon, 20 Nov 2023 23:02:56 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:02:55 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633401" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633401" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:02:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795704955" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795704955" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:02:53 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 3/6] UefiCpuPkg: Use CET macro definitions in Cet.inc for SmiEntry.nasm files. Date: Tue, 21 Nov 2023 15:02:43 +0800 Message-Id: <20231121070246.505-4-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: iIOJA20kZCtGyrvUf2xbTAwDx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550176923100013 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 14 +------------- UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 15 +-------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSm= mCpuDxeSmm/Ia32/SmiEntry.nasm index 19de5f614e..6368982433 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm @@ -15,19 +15,7 @@ =20 %include "StuffRsbNasm.inc" %include "Nasm.inc" - -%define MSR_IA32_S_CET 0x6A2 -%define MSR_IA32_CET_SH_STK_EN 0x1 -%define MSR_IA32_CET_WR_SHSTK_EN 0x2 -%define MSR_IA32_CET_ENDBR_EN 0x4 -%define MSR_IA32_CET_LEG_IW_EN 0x8 -%define MSR_IA32_CET_NO_TRACK_EN 0x10 -%define MSR_IA32_CET_SUPPRESS_DIS 0x20 -%define MSR_IA32_CET_SUPPRESS 0x400 -%define MSR_IA32_CET_TRACKER 0x800 -%define MSR_IA32_PL0_SSP 0x6A4 - -%define CR4_CET 0x800000 +%include "Cet.inc" =20 %define MSR_IA32_MISC_ENABLE 0x1A0 %define MSR_EFER 0xc0000080 diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmm= CpuDxeSmm/X64/SmiEntry.nasm index d302ca8d01..9a225bc3be 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm @@ -15,25 +15,12 @@ =20 %include "StuffRsbNasm.inc" %include "Nasm.inc" +%include "Cet.inc" =20 ; ; Variables referenced by C code ; =20 -%define MSR_IA32_S_CET 0x6A2 -%define MSR_IA32_CET_SH_STK_EN 0x1 -%define MSR_IA32_CET_WR_SHSTK_EN 0x2 -%define MSR_IA32_CET_ENDBR_EN 0x4 -%define MSR_IA32_CET_LEG_IW_EN 0x8 -%define MSR_IA32_CET_NO_TRACK_EN 0x10 -%define MSR_IA32_CET_SUPPRESS_DIS 0x20 -%define MSR_IA32_CET_SUPPRESS 0x400 -%define MSR_IA32_CET_TRACKER 0x800 -%define MSR_IA32_PL0_SSP 0x6A4 -%define MSR_IA32_INTERRUPT_SSP_TABLE_ADDR 0x6A8 - -%define CR4_CET 0x800000 - %define MSR_IA32_MISC_ENABLE 0x1A0 %define MSR_EFER 0xc0000080 %define MSR_EFER_XD 0x800 --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111517): https://edk2.groups.io/g/devel/message/111517 Mute This Topic: https://groups.io/mt/102724274/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 13 20:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111518+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111518+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700550179; cv=none; d=zohomail.com; s=zohoarc; b=EtSrKTF5KgXuNDJHrlYqSfVDM1L+ZVHR0Te09u/4iVjsMr64CTVk0SkaIzN+XzAOtHk/eaR4z+36Y4w3L6IQ/CC4ysvF+Y/3sLYy+FVAkkr3ii5QnmzBYE7SduifaN35Xgm1c/+7sUBIG4AVdazXcxMx3kmXfGmQFiLV+EXfEEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700550179; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=oag35DtHktMsBhwKS2lZLQBtP5sGR2xqY7CSbdpcz5U=; b=hYEdpi4C7SSjofLxhrdnAN02RoBxgefJhIt6WJYGT+hTGFvao24r+p3frOsvVd28XoXiUf3l8WgcLVGF2jsY/e2u0mhf3kOUxELDA4jbqeB4gpFzynpKqU02lgVIuFQWej+ehTdmi2v+233W4G6P6KwaE+zHTSUi3w4ytI2GFsw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111518+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550179036143.94785025144552; Mon, 20 Nov 2023 23:02:59 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=L++TN2ZzgUoUZOqTHT8YqXTt4kADbbEEdCwPZ6TbYsA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550178; v=1; b=qXqTIt8IFLdOzxOqgT6Lx6vXF9wFbOzwomMhUlGzeTS/03treU7KOvp6qHQhiSpXP6uS8AVb abegzHweyFmMA+2S/YGsUB1ZZ8VKoXM1t8Yt8ujZD8SuD/BKBZtHZQ9nzYjyikfxVMw8+oJM49I I96erX8niWCRG21ier1U25cw= X-Received: by 127.0.0.2 with SMTP id MwyLYY1788612xxxenqSlCIb; Mon, 20 Nov 2023 23:02:58 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:02:58 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633406" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633406" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:02:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795704960" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795704960" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:02:55 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 4/6] UefiCpuPkg: Only change CR4.CET bit for enable and disable CET. Date: Tue, 21 Nov 2023 15:02:44 +0800 Message-Id: <20231121070246.505-5-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: lUz5YlCVpMxmzp6wljNzszlBx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550180935100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 10 +++++++--- UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSm= mCpuDxeSmm/Ia32/SmiEntry.nasm index 6368982433..1da9afab97 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm @@ -237,7 +237,9 @@ CetInterruptDone: bts ecx, 16 ; set WP mov cr0, ecx =20 - mov eax, 0x668 | CR4_CET + ; set CR4.CET bit for enable CET + mov eax, cr4 + bts eax, CR4_CET_BIT mov cr4, eax =20 setssbsy @@ -264,8 +266,10 @@ CetDone: cmp al, 0 jz CetDone2 =20 - mov eax, 0x668 - mov cr4, eax ; disable CET + ; clear CR4.CET bit for disable CET + mov eax, cr4 + btr eax, CR4_CET_BIT + mov cr4, eax =20 mov ecx, MSR_IA32_PL0_SSP pop eax diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmm= CpuDxeSmm/X64/SmiEntry.nasm index 9a225bc3be..abf9f1a90a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm @@ -263,7 +263,9 @@ CetInterruptDone: bts ecx, 16 ; set WP mov cr0, rcx =20 - mov eax, 0x668 | CR4_CET + ; set CR4.CET bit for enable CET + mov rax, cr4 + bts rax, CR4_CET_BIT mov cr4, rax =20 setssbsy @@ -308,8 +310,10 @@ mCetSupportedAbsAddr: cmp al, 0 jz CetDone2 =20 - mov eax, 0x668 - mov cr4, rax ; disable CET + ; clear CR4.CET bit for disable CET + mov rax, cr4 + btr rax, CR4_CET_BIT + mov cr4, rax =20 mov ecx, MSR_IA32_INTERRUPT_SSP_TABLE_ADDR pop rax --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111518): https://edk2.groups.io/g/devel/message/111518 Mute This Topic: https://groups.io/mt/102724275/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 13 20:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111519+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111519+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700550182; cv=none; d=zohomail.com; s=zohoarc; b=afLtFLkGDiG/VdOjUC7UZy6LdkZM8lK0F9nEJevM1oiTA3DUJwCIVsLDP+BQP2EELDn9sBAK3SlvKgZ14w7sM+M1ZRlelB7JmDA6txV05Na6Vt+s0zqIQqXLY4Q9zYLzRZE27JgB/CwwBF2XxF7DgiXUvU33wEG0B4KRLg4xEw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700550182; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=OGAohxBRXErP78LINxaHp0JKKHvzHfhRx94QmuhIVn8=; b=C/135vcXHVlv1DEZAQv3XNNfJE1ZvZylwpdKLOHdLDh1rd6PVdXeYACQi7QtjMMoLiIW9dV4/XsciOHMO6n5Za2gMWAAhDayVMxVSsNS4iP+nzUa2mj8EmbW19U8A+L9Qpvs8RuZadU9pOHIBW7I5thucT24sUym4KIziD2vpYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111519+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550182095405.2981216520318; Mon, 20 Nov 2023 23:03:02 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=ADLlj5TIR7nuQP9U2gmXEzgSbUT1V7Dr01jnT9eoBcw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550181; v=1; b=JMFQbODQSTMiiRd365VLhjTQogyVZpduCDVW9Z7RFENxBt/7qvKwDnIoTrnd7+9jyc6ASo4Z 691rR8LzoAliCmjkVoTYNNDlGM92b25ZiuTF9tx1YalbsW4YIFY/YzMTNBO7uR0sUgmLHJu0DIg ZTVSL4WUJqBGU7AIkwjh7s4M= X-Received: by 127.0.0.2 with SMTP id DGdqYY1788612x2hMQDdg8k6; Mon, 20 Nov 2023 23:03:01 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:03:01 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633424" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633424" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:03:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795704989" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795704989" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:02:58 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 5/6] UefiCpuPkg: Backup and Restore MSR IA32_U_CET in SMI handler. Date: Tue, 21 Nov 2023 15:02:45 +0800 Message-Id: <20231121070246.505-6-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pk6xUgefFGCRp0ISXfHgmu9Gx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550182926100007 Content-Type: text/plain; charset="utf-8" OS may enable CET-IBT feature by set MSR IA32_U_CET.bit2. If IA32_U_CET.bit2 is set, CPU is in WAIT_FOR_ENDBRANCH state and the next assemble code is not ENDBR, it will trigger #CP exception when set CR4.CET bit. SMI handler needs to backup MSR IA32_U_CET and clear MSR IA32_U_CET before set CR4.CET bit, And SMI handler needs to restore MSR IA32_U_CET when exit SMI handler. Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm | 15 +++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm b/UefiCpuPkg/PiSm= mCpuDxeSmm/Ia32/SmiEntry.nasm index 1da9afab97..9e1155dee6 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiEntry.nasm @@ -202,11 +202,21 @@ ASM_PFX(mPatchCetSupported): push edx push eax =20 + mov ecx, MSR_IA32_U_CET + rdmsr + push edx + push eax + mov ecx, MSR_IA32_PL0_SSP rdmsr push edx push eax =20 + mov ecx, MSR_IA32_U_CET + xor eax, eax + xor edx, edx + wrmsr + mov ecx, MSR_IA32_S_CET mov eax, MSR_IA32_CET_SH_STK_EN xor edx, edx @@ -276,6 +286,11 @@ CetDone: pop edx wrmsr =20 + mov ecx, MSR_IA32_U_CET + pop eax + pop edx + wrmsr + mov ecx, MSR_IA32_S_CET pop eax pop edx diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm b/UefiCpuPkg/PiSmm= CpuDxeSmm/X64/SmiEntry.nasm index abf9f1a90a..881d3177f7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm @@ -217,6 +217,11 @@ ASM_PFX(mPatchCetSupported): push rdx push rax =20 + mov ecx, MSR_IA32_U_CET + rdmsr + push rdx + push rax + mov ecx, MSR_IA32_PL0_SSP rdmsr push rdx @@ -227,6 +232,11 @@ ASM_PFX(mPatchCetSupported): push rdx push rax =20 + mov ecx, MSR_IA32_U_CET + xor eax, eax + xor edx, edx + wrmsr + mov ecx, MSR_IA32_S_CET mov eax, MSR_IA32_CET_SH_STK_EN xor edx, edx @@ -325,6 +335,11 @@ mCetSupportedAbsAddr: pop rdx wrmsr =20 + mov ecx, MSR_IA32_U_CET + pop rax + pop rdx + wrmsr + mov ecx, MSR_IA32_S_CET pop rax pop rdx --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111519): https://edk2.groups.io/g/devel/message/111519 Mute This Topic: https://groups.io/mt/102724276/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 13 20:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111520+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111520+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700550184; cv=none; d=zohomail.com; s=zohoarc; b=K7qMMSEzNV4023xBTM1jUhaaRf7TqDg9B2onWkCLi22CxOkX3Ar2aDYHZMJZNoZVgZ/tlOCUf+FM5+hEpjDNWNp1OaGtLE+UX39oldgYVqjK+47S5kPZFFtfoEehqCS732t4AIhWI81mmfSXoilpzrcmlAXZNTxb21RD5d1q3rs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700550184; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=xyS4BYZG3DoNLQc/DgiIBJOjsGx5Hv1hS99dGdNhLJ8=; b=Ej+GLPsKf5ZRJJMiz44b1PThr9F6yRY1gFcY8fsH35aNEOL8zB89XV1LmC5adY9f0v76jef7LuSgNku79y4sljXAa6pHD0ce0D849KPIOGJRRjKj2RGobKToSx924VdIODr0FQKHuWbZ3htsbjtrreum3tSoZjT3V9RlLkdHOmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111520+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1700550184522471.6519415285808; Mon, 20 Nov 2023 23:03:04 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=jaWJbwPhVPZwhNFlsxd/blBW/riP+Z+4zCqwv0OU2O8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700550183; v=1; b=kXf0clarXi1dPwcb6NGLZi2YWJzYUT2mLTEB52exP4NTFY32iGls/vGy1SSm35q8Gg4WPn0Q MAy9O1km0bBTr1OWnNUUe5H8CuhTqHbvgEbT0dHoVqtiFujDWKJYqsNWbui+bz6YxKM7Ld5yfuu iZHMaRn5gXqilOR6CggbXIC0= X-Received: by 127.0.0.2 with SMTP id SjUmYY1788612x8pO83a01VU; Mon, 20 Nov 2023 23:03:03 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.30512.1700550170171771930 for ; Mon, 20 Nov 2023 23:03:02 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390633425" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="390633425" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:03:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="795705010" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="795705010" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by orsmga008.jf.intel.com with ESMTP; 20 Nov 2023 23:03:00 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v6 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard code value. Date: Tue, 21 Nov 2023 15:02:46 +0800 Message-Id: <20231121070246.505-7-w.sheng@intel.com> In-Reply-To: <20231121070246.505-1-w.sheng@intel.com> References: <20231121070246.505-1-w.sheng@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: EELZmPaqegHXv7slTfAxaP5Nx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700550186922100001 Content-Type: text/plain; charset="utf-8" The macro is used in file LongJump.nasm and SetJump.nasm. Signed-off-by: Sheng Wei Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Wu Jiaxin Cc: Tan Dun Reviewed-by: Laszlo Ersek Reviewed-by: Ray Ni --- MdePkg/Library/BaseLib/Ia32/LongJump.nasm | 3 ++- MdePkg/Library/BaseLib/Ia32/SetJump.nasm | 3 ++- MdePkg/Library/BaseLib/X64/LongJump.nasm | 3 ++- MdePkg/Library/BaseLib/X64/SetJump.nasm | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm b/MdePkg/Library/Bas= eLib/Ia32/LongJump.nasm index 6c13dfe307..df1bf9749e 100644 --- a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm +++ b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm @@ -14,6 +14,7 @@ ;-------------------------------------------------------------------------= ----- =20 %include "Nasm.inc" +%include "Cet.inc" =20 SECTION .text =20 @@ -34,7 +35,7 @@ ASM_PFX(InternalLongJump): test eax, eax jz CetDone mov eax, cr4 - bt eax, 23 ; check if CET is enabled + bt eax, CR4_CET_BIT ; check if CET is enabled jnc CetDone =20 mov edx, [esp + 4] ; edx =3D JumpBuffer diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm b/MdePkg/Library/Base= Lib/Ia32/SetJump.nasm index 2577373241..0c484f6852 100644 --- a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm +++ b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm @@ -14,6 +14,7 @@ ;-------------------------------------------------------------------------= ----- =20 %include "Nasm.inc" +%include "Cet.inc" =20 SECTION .text =20 @@ -42,7 +43,7 @@ ASM_PFX(SetJump): test eax, eax jz CetDone mov eax, cr4 - bt eax, 23 ; check if CET is enabled + bt eax, CR4_CET_BIT ; check if CET is enabled jnc CetDone =20 mov eax, 1 diff --git a/MdePkg/Library/BaseLib/X64/LongJump.nasm b/MdePkg/Library/Base= Lib/X64/LongJump.nasm index 2002f65cba..021b49e855 100644 --- a/MdePkg/Library/BaseLib/X64/LongJump.nasm +++ b/MdePkg/Library/BaseLib/X64/LongJump.nasm @@ -14,6 +14,7 @@ ;-------------------------------------------------------------------------= ----- =20 %include "Nasm.inc" +%include "Cet.inc" =20 DEFAULT REL SECTION .text @@ -35,7 +36,7 @@ ASM_PFX(InternalLongJump): test eax, eax jz CetDone mov rax, cr4 - bt eax, 23 ; check if CET is enabled + bt eax, CR4_CET_BIT ; check if CET is enabled jnc CetDone =20 push rdx ; save rdx diff --git a/MdePkg/Library/BaseLib/X64/SetJump.nasm b/MdePkg/Library/BaseL= ib/X64/SetJump.nasm index 5943a5ebe5..d2c0991e66 100644 --- a/MdePkg/Library/BaseLib/X64/SetJump.nasm +++ b/MdePkg/Library/BaseLib/X64/SetJump.nasm @@ -14,6 +14,7 @@ ;-------------------------------------------------------------------------= ----- =20 %include "Nasm.inc" +%include "Cet.inc" =20 DEFAULT REL SECTION .text @@ -44,7 +45,7 @@ ASM_PFX(SetJump): test eax, eax jz CetDone mov rax, cr4 - bt eax, 23 ; check if CET is enabled + bt eax, CR4_CET_BIT ; check if CET is enabled jnc CetDone =20 mov rax, 1 --=20 2.26.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111520): https://edk2.groups.io/g/devel/message/111520 Mute This Topic: https://groups.io/mt/102724277/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-