From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.191473.1673941423940464461 for ; Mon, 16 Jan 2023 23:43:43 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=iTS+kKT5; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673941423; x=1705477423; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=e8XxYpZZVARuUUvsF3fckcMwLOb64NqseRe+NCkEflc=; b=iTS+kKT5abbday1jYcJC7W8gbXlh77nM7RX8VcqTm8xNmpsDm2IUvpPv +Gd0vCVhoybNKQK1kiTsOCt5drEYzm7FftBEdLaL/DGwVcin5AXahlB79 UeJz6hlmgWD/W+2sL+8yw6dxriGmLag8DNUiKqjSdXwY0PYoO916beSIo TBpNG22M0kZjyK+g7T8JFIg/H8FOKH0W2xpVXD8S9SoEAIPkgmjEmJRgz uaUaC8Y4arlmtkQloBFn0yeGjwq6EWU1AgqYsZMXMx86YKV2ivun+Ce51 0H6wQFlb15pgIBGGtefJTYCur7rUOmoqZ8KkojM8LcvT05J5keVlJceed Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="304320662" X-IronPort-AV: E=Sophos;i="5.97,222,1669104000"; d="scan'208";a="304320662" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 23:43:43 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="636772705" X-IronPort-AV: E=Sophos;i="5.97,222,1669104000"; d="scan'208";a="636772705" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.254.211.139]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 23:43:39 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky , Ryan Afranji Subject: [PATCH V3 0/2] [PATCH V1 0/2] Refactor TDX MmioExit Date: Tue, 17 Jan 2023 15:43:28 +0800 Message-Id: <20230117074330.1058-1-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4169 The previous TDX MmioExit doesn't handle the Mmio instructions correctly in some scenarios. This patch-set refactors the implementation to fix the issues. Before the refactoring, common X86 instruction codes in CcExitVcHandler.c are moved to separate files (CcInstruction.h / CcInstruction.c) so that these codes can be re-used in TDX. Code: https://github.com/mxu9/edk2/tree/TdxMmioExit.v3 v3 changes: - Handle the error if an error is returned from TdxMmioReadWrite. - Add more check in ParseMmioExitInstructions. v2 changes: - Add CpuDeadLoop () after each TDVMCALL(HALT) in VE handler. Because TDVMCALL(HALT) is not trusted. - Other minor changes such as deleting ASSERT in VE handler. Because any error in VE handler will trigger CpuDeadLoop (). So ASSERT is not needed any more. Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Cc: Ryan Afranji Reported-by: Ryan Afranji Signed-off-by: Min Xu Min M Xu (2): OvmfPkg/CcExitLib: Move common X86 instruction code to separate file OvmfPkg/CcExitLib: Refactor TDX MmioExit OvmfPkg/Library/CcExitLib/CcExitLib.inf | 1 + OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 697 +++----------------- OvmfPkg/Library/CcExitLib/CcExitVeHandler.c | 546 ++++++++++----- OvmfPkg/Library/CcExitLib/CcInstruction.c | 454 +++++++++++++ OvmfPkg/Library/CcExitLib/CcInstruction.h | 197 ++++++ OvmfPkg/Library/CcExitLib/SecCcExitLib.inf | 1 + 6 files changed, 1117 insertions(+), 779 deletions(-) create mode 100644 OvmfPkg/Library/CcExitLib/CcInstruction.c create mode 100644 OvmfPkg/Library/CcExitLib/CcInstruction.h -- 2.29.2.windows.2