From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web12.6667.1611907194868853779 for ; Thu, 28 Jan 2021 23:59:55 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: w.sheng@intel.com) IronPort-SDR: Ww9Obmb2xBghVwVBgulp5ZgAOMlshnkgi5PB2Wf9u+wpJcEEq0faYhl5Vps8qPEeniGoSfZDhl 9RsACqYOlvdg== X-IronPort-AV: E=McAfee;i="6000,8403,9878"; a="160155457" X-IronPort-AV: E=Sophos;i="5.79,384,1602572400"; d="scan'208";a="160155457" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2021 23:59:53 -0800 IronPort-SDR: XHpjqWG/4JXD4N86N36hVCmI/xZEhEQLqAh2xxA5rycSj2N7t6r7U7VuFC0JaVEOQhhTRq4eJH BPE2vQP8yPUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,384,1602572400"; d="scan'208";a="364211088" Received: from shwdesssddpdwei.ccr.corp.intel.com ([10.239.157.35]) by fmsmga008.fm.intel.com with ESMTP; 28 Jan 2021 23:59:50 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH 0/2] Fix #DF issue when enable CET shadow stack feature. Date: Fri, 29 Jan 2021 15:59:44 +0800 Message-Id: <20210129075946.31684-1-w.sheng@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 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 Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Jiewen Yao Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar 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