From nobody Tue May 14 08:43:36 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+111235+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+111235+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021543; cv=none; d=zohomail.com; s=zohoarc; b=fORlkXbg8h0UmgEfTwUzb5ps1RNWo89GSn0ftXs8Nz7I3DJ6EK0D+UDcwnZ0H3qD6/krxdGETfdlIVRHItIn9NB92kteval3AstNO0Tw1O/L/v7DO/e+cQ4B8Sp6Cxv3GtjLEFgYPDTX6/p4B1EVWkXIJPp75a3Ney/8JscCfDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021543; 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=OMxfp+qzPPipaI0oKFZMoAsHwo9S0VhPmv4jwRnGK50=; b=ONu7qIVVnAThm91mMSuk+qOekLxZNLDw4mAlf4Dx+0pxkBU8zZg15EnAaQoJe3xnISaR0PBkkdqmsP8P5iQQkouTYjgVLR47Pq4g/AdE1+2kEY4ZSie+rTv4eWMmxeH8pz/p7ar36ygs/2OsZo0aMjLmOb1drzdHww4nIUQoUWE= 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+111235+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 1700021543492453.1385297404112; Tue, 14 Nov 2023 20:12:23 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=B3aaj5vwRe4ViDD+gA5TBzEpKQENLlchOsXddqqIK7Y=; 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=1700021543; v=1; b=CuaiBRTMR7eAoh2+PuRzx4Ul0sgXTNBCdGZQ+LgXP4BCge5BptvUXb6fpCN2NWELf2c0pNOC sQ4sI9It/S6KwbtSwWt2JJemxEb4nJW0HW5f3V+SZTrX6GP79sU0P3L7rthyjfKT/iCYw+ZNBOp wsk5zAkUqhlcdAN1SoRpBqd8= X-Received: by 127.0.0.2 with SMTP id xcVhYY1788612xVRRK9XGmRC; Tue, 14 Nov 2023 20:12:23 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:22 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666237" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666237" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266109" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266109" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:20 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 1/6] MdePkg: Add macro definitions for CET feature for NASM files. Date: Wed, 15 Nov 2023 12:12:11 +0800 Message-Id: <20231115041216.2016-2-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: nQQm8lKXH8udJdd5poo9EpO2x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021544907100003 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 --- MdePkg/Include/Cet.inc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 MdePkg/Include/Cet.inc diff --git a/MdePkg/Include/Cet.inc b/MdePkg/Include/Cet.inc new file mode 100644 index 0000000000..a4038a0682 --- /dev/null +++ b/MdePkg/Include/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 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_BIT 23 +%define CR4_CET 0x800000 --=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 (#111235): https://edk2.groups.io/g/devel/message/111235 Mute This Topic: https://groups.io/mt/102599349/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 Tue May 14 08:43:36 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+111236+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+111236+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021544; cv=none; d=zohomail.com; s=zohoarc; b=cPO71f8pM6KmKTV77ADVwXjAUxl6sL9xStSLxgImMF++h6j6kD7BDH3F57Yb5IRZ5l5RqIoI+lBnYXZtPPhJ+pOKHu+5MD1IWPR00k6JPufCvaV7yHff4cAHnsAiXUGv+vZAkhRGi9HaE8fbc4LDAk/Zwg6aNiE64i/ZeIk2QyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021544; 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=Nx9Fle98IHFj8OlIkbSD74oLV5ksVC6nEOboAVRhAsY=; b=igbz48m0iuPOIji7froV2VvlN73pZuIAjJ1xZH/nF66bZIvafDX9WBwMrdoqtaIItoY4VCTsFvHrmn+OPTbvPJSTS2gMm/QgByXPpXsHNqH0rYcA6etqoVk3LkagYMbPkwVc2QFRLOhBXulA59wy1OYtulQ4pq2EQosUO0vR1/M= 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+111236+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 1700021544835269.83431805426085; Tue, 14 Nov 2023 20:12:24 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=gyoYaTT1oGxuznssIjvVKI1S6o4Ts3+paGLvGr/DEDM=; 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=1700021544; v=1; b=vJwUi8MBBcCzi5rfo7QjU1/8xigll78axphYq/EONLWnN04wu+XN1npMq6IQ04nFVsggjK6e 9RfsPtubkDxJhre83rj03icdlILlrpuwKTzDCMsqToLzWpdoxSzJoddgpQmN7VLxmS9xhl/ar58 WnVZqq7lpGK67fvg+UzG0VsE= X-Received: by 127.0.0.2 with SMTP id tY0sYY1788612xzf8cLRIXf6; Tue, 14 Nov 2023 20:12:24 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:24 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666241" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666241" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266115" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266115" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:22 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 2/6] UefiCpuPkg: Use macro CR4_CET_BIT to replace hard code value in Cet.nasm. Date: Wed, 15 Nov 2023 12:12:12 +0800 Message-Id: <20231115041216.2016-3-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: RNcm4Yz2i7RR4k4FmUoz8jJ5x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021546853100009 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 --- 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 (#111236): https://edk2.groups.io/g/devel/message/111236 Mute This Topic: https://groups.io/mt/102599350/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 Tue May 14 08:43:36 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+111237+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+111237+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021546; cv=none; d=zohomail.com; s=zohoarc; b=XhLznySYyckKuaUi/6lnri0+r3WT3ONRTGOqManpgiT/SL8nZecEILnUE+Byv7CP6Tl83+Slxu/ZgQol1AinePi2ZYaJ79di2ukmhDVTwbdAHB39mlWJ3EKjDeFKrBlyAvasNMyzWqf91uOxVwe6EX7PBpwh6au/oik9Kdnacxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021546; 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=OQ4YWhs+D2LExEop2zb2xICyjTxW2bLhhnjrtvq+nb0=; b=Xuk82aUGkQj5ZQHdEFL3EzQQd1lrexVSR5zxvZbW8s3prYsRcyC2R+DOmweISG3ClZzBlCj8CzgwrWjNYP0nKceW9Ls/KcDeCcjaTppoVp+eyt0bT2i+XwbIaTIeLSZJjnnOmx9PqzS3BdCdwwe6VA4bIw5sWtc/YWDhu33bxdU= 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+111237+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 1700021546866142.3845577264833; Tue, 14 Nov 2023 20:12:26 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=gV8E0cOEO2uY7GO0sjjiezTKR7EUrdkm6guy82ZQBew=; 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=1700021546; v=1; b=DmdfVxcbMzrc37KZB0y1s2ehjEADXD9vXQzlc2wSBcdZhLgUCaOaYlw653CNpn+Qg/T753wZ z+HmSqii70aHOEisExKvdjvpP3iihPhHbrKcr5gdZMP4tH5hcA6L5CXsAXFgXqVFQw8s4c408EE sdyZ3I/WMwLGOLfevqX4uhb4= X-Received: by 127.0.0.2 with SMTP id VYAYYY1788612xL88V2kFKo1; Tue, 14 Nov 2023 20:12:26 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:25 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666244" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666244" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266123" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266123" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:23 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 3/6] UefiCpuPkg: Use CET macro definitions in Cet.inc for SmiEntry.nasm files. Date: Wed, 15 Nov 2023 12:12:13 +0800 Message-Id: <20231115041216.2016-4-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: aHE1EclQauKaK6tup8Y0Xy3Sx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021548849100015 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 --- 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 (#111237): https://edk2.groups.io/g/devel/message/111237 Mute This Topic: https://groups.io/mt/102599352/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 Tue May 14 08:43:36 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+111238+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+111238+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021548; cv=none; d=zohomail.com; s=zohoarc; b=Iiw36yrAPyQNy36F/QwyJlDCiLdgWo0I4rjATF30zljCZRyTsn0zzQP7T7EctiSY068Zm4bbOIv1+N1kEiXx3vH7Rv9rcgFqhdsqiA6+ZlpfJC3WyQ4Y8sxZteOE60yDqSGxe9mFnpVDY1RdxiQ8OkemTfB4TaNehv40uq9dy/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021548; 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=y8OKT6Tttnf8iaHw368w7mXwPTnp1NVydxJqtrn+Cxk=; b=Jm5CuSkFqmSBdYNWj982l6BguJhhBqIdR9S09ZQXmUDgUBb1Y/H9gMyMDBZ42rpK86STvBnvF3l4m1EmEARJKv8dKrbuHHj9y68/hPFoiiec9O3Wy8ISaeJ/mFW3u62/MjLfzdDb1iYXTrJZ3csSuPqHnxriovAoRoTvREFAZcg= 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+111238+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 17000215484431017.615624537778; Tue, 14 Nov 2023 20:12:28 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=sIgbYL9m7gyeyMW7ZmpuY3MCB6tUsdMDp3ssAhhFTlA=; 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=1700021548; v=1; b=fUp69hG4mA6UdA6F+0bVHzXU0kn6qYFGiA4Bi0YWxHwA+MPkyZ+NPiNNIHI9a2f7AKiJtne8 iOe0C1nW9+nAQY4dGt3bsKf09COgOKifKZVINi9ngTckYN4p2+zjametxmURQndlXb6psFS4s5r 78m/rHAIeQN6BtNl4a33GurE= X-Received: by 127.0.0.2 with SMTP id kd3OYY1788612xxXnylaz08a; Tue, 14 Nov 2023 20:12:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:27 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666247" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666247" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266132" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266132" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:25 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 4/6] UefiCpuPkg: Only change CR4.CET bit for enable and disable CET. Date: Wed, 15 Nov 2023 12:12:14 +0800 Message-Id: <20231115041216.2016-5-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: qYP0m74qiB2TnqJ91CtRD9aQx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021548876100016 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 --- 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 (#111238): https://edk2.groups.io/g/devel/message/111238 Mute This Topic: https://groups.io/mt/102599354/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 Tue May 14 08:43:36 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+111239+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+111239+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021550; cv=none; d=zohomail.com; s=zohoarc; b=R0CJFWpnej3anetwrEroecHaO+DEEL0cHTbRx8m+ONdQP1//nHtmMmz6M1sPbnPaBNzF9V9rU1LKALkWqIrUD+Y2dcnxAlDoNFmaDgwBV6t/Dm0XpRQ46pWNQCqzZv/2MKCEpdKWcB50RbRpL5Zf1ZBMp4KHdHFBXTRkkV+S1b0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021550; 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=9FevYrnfBquj0bRDc2x7VVU0hJoB5AyIrEgPpnivoqM=; b=ckeVWrceHtYeF5m8uOHV932cYIeUgwxiDXi5rSw0wKiD+8qqMTzY7ASDD62o4CoMomrzWECh8OHZc7oWI4/EqZTDxQ22kD0/nysaPz2wGFvam/j/dGZnUTj5IiJqVR1ZF2OvVoGNAUfn72iXpIFVNPAiGcDLKQ0TRBCor99SZTU= 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+111239+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 1700021550432182.39441627870985; Tue, 14 Nov 2023 20:12:30 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=wvUVk9gQo/4nHy1aSd2eE12BOmtdREYDg/k28a9g4EE=; 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=1700021550; v=1; b=rKQ0FOACEShc/e3Etv8il1v22k5OItEB19Oq68G1AnmyVACN08AOePjFAj7vl7QrduoWCGI0 x64vZ3IIthTmGbC0HZDwR4XPWFxRPsQr2oES37UWU2nMy47mOxUJ3dFF7EffwLqm4JiLiUtr0YS Wt7TlyM/45quEe95ZACfevhk= X-Received: by 127.0.0.2 with SMTP id dWUUYY1788612x4B3dgaFYy3; Tue, 14 Nov 2023 20:12:30 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:29 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666250" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666250" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266138" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266138" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:27 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 5/6] UefiCpuPkg: Backup and Restore MSR IA32_U_CET in SMI handler. Date: Wed, 15 Nov 2023 12:12:15 +0800 Message-Id: <20231115041216.2016-6-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: 0rddFaAEbH6xaS04vFldWxiFx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021550902100021 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 --- 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 (#111239): https://edk2.groups.io/g/devel/message/111239 Mute This Topic: https://groups.io/mt/102599355/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 Tue May 14 08:43:36 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+111240+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+111240+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1700021552; cv=none; d=zohomail.com; s=zohoarc; b=dEUEgLWF1xLhTFEVfwFkrJme12Ng7CvuUIvMH2ivsnUVczNO4VcfATXPTwq4wLvu+S3JH9Hqu7O7wfJZRSz0wAsygryy5Bzoz8yihpsiEVkhofNjrUD4oyK3i8wpUdTb0W7epzEzFFwyZ/sNa6KK3qi/okzE6/gPAuOxvU0RSJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700021552; 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=22lngb/y+FxrnZc5NR85h42R9ehKD31X6ecUXVznWT4=; b=gTgDd1r3u+9h75vQcWy8JcpclvPnCHd70Zxq/eWl6rUVMYhUxIcpTQdps6DuvSU+bvvnOqDerrDO86fQaSDh+J6a/yj1S1yoPlvTxIk7rVFHU1LZLPgHOH4A+WX3pIIHrtE49aVMbla1652dt+IDYlQS7hE8HNgwJ7Hj4WlIwAc= 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+111240+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 1700021552080703.0054552721456; Tue, 14 Nov 2023 20:12:32 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=3qiyPYe5RVQSqF/otO5nldPUKhON1oUffs9KdUupSlQ=; 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=1700021551; v=1; b=ZKMqvo8SHlfFLGYYdb56Xs6x0XluM5I2CxzlsCpMLyW6d5LlXlE2J/KY1mGCIDc66DDEozny d7WZL+ojcHvcE87trHqCUH8uj/4U+uvrhvYikdZIjGJWcj5hYO4wGYWk6CTsZeOAZLLf4KiwnS4 OhamuE6g9848yBrJg02lLpTI= X-Received: by 127.0.0.2 with SMTP id 02bLYY1788612xH34YGiLmOp; Tue, 14 Nov 2023 20:12:31 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.5844.1700021541097014257 for ; Tue, 14 Nov 2023 20:12:31 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="393666252" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="393666252" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 20:12:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="882266146" X-IronPort-AV: E=Sophos;i="6.03,303,1694761200"; d="scan'208";a="882266146" X-Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.28]) by fmsmga002.fm.intel.com with ESMTP; 14 Nov 2023 20:12:29 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Laszlo Ersek , Wu Jiaxin , Tan Dun Subject: [edk2-devel] [PATCH v5 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard code value. Date: Wed, 15 Nov 2023 12:12:16 +0800 Message-Id: <20231115041216.2016-7-w.sheng@intel.com> In-Reply-To: <20231115041216.2016-1-w.sheng@intel.com> References: <20231115041216.2016-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: To1csIo8cpWDMroLBR7KwQglx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1700021552878100025 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 --- 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 (#111240): https://edk2.groups.io/g/devel/message/111240 Mute This Topic: https://groups.io/mt/102599356/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-