From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.90720.1673308590013112462 for ; Mon, 09 Jan 2023 15:56:30 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=LBrWf6hT; spf=pass (domain: intel.com, ip: 192.55.52.120, 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=1673308589; x=1704844589; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6aGl7Z9ao6AGRJhAxmL5IaS4jONf5QzEJv0NvHqRKyU=; b=LBrWf6hTIJZiSIwk2N+hDb1+YTkBSNN0Hn0ze7CggSi0WsaCvV63t9bt biTi5huYATCCKSp66JEVXkxCwGEE3kliJ/HTZcxkw7peToOpWNKG23DY0 2FZzbUFteaH9rPtaAj8c8amSWWXpYgIJ3QQNPKj8g8BFP2l3HqBrBqItK qRRwvZXg1iiG57UxO8IETuSFw6xQ2mzicHiPYhCeh98VCTjSKmB/UYoL4 1Td0Pki5MxOowWyNWAzAgIBqgd/ATSEaFuCKQ3VvR68LF1kmqoHFF/9Dq XNY/TIjvLMh3Kn21mlwb/SX+91mkhVW6XjyqFdwa+9aFCHxpoDxtZ9sJa A==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="321715265" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="321715265" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 15:56:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="689221914" X-IronPort-AV: E=Sophos;i="5.96,313,1665471600"; d="scan'208";a="689221914" Received: from caij-mobl.ccr.corp.intel.com (HELO mxu9-mobl1.ccr.corp.intel.com) ([10.255.29.89]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 15:56:25 -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 V2 0/2] [PATCH V1 0/2] Refactor TDX MmioExit Date: Tue, 10 Jan 2023 07:56:10 +0800 Message-Id: <20230109235612.439-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.v2 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 | 525 ++++++++++----- OvmfPkg/Library/CcExitLib/CcInstruction.c | 454 +++++++++++++ OvmfPkg/Library/CcExitLib/CcInstruction.h | 197 ++++++ OvmfPkg/Library/CcExitLib/SecCcExitLib.inf | 1 + 6 files changed, 1098 insertions(+), 777 deletions(-) create mode 100644 OvmfPkg/Library/CcExitLib/CcInstruction.c create mode 100644 OvmfPkg/Library/CcExitLib/CcInstruction.h -- 2.29.2.windows.2