From nobody Mon Feb 9 03:14:34 2026 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+88216+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+88216+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648597640; cv=none; d=zohomail.com; s=zohoarc; b=Mh42oBz2ypy/WPKxojbjC0td543fDCPaSRHfMjBuTRKRAVkw6fqdtMSy6weVaCAob0BuhxfdIyLtg5V2dfMwQ9j01w98dsrMt+qdjb6BuTrv8op6A5zuwaRbr4SF3GLjkBySM85mEBPX9XRY+inmX9Cdb4lWolWNqpH1xohMv3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648597640; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=GwMSz2Xx5SM3dR2p0oT1fEc2Hqmxf1xXEZVpCICOMiE=; b=OOXsF2mYT73+03CjOqG9ulj7mRPlKV3kmkfsoqC024Pj40MhQ/6DgpmCmlupt9OY2l4/HI5IF2vdT3Ol0cN/I143anxgGE8G7w8HQSeXQnWoO/MaFVSKfw+2zIkPLEmwOlcSqUJeBne3+R5wkhh6YQPpb3fr8Ko3N0GK4wpe8sY= 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+88216+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 1648597640317933.6237584890741; Tue, 29 Mar 2022 16:47:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wCIBYY1788612xL1DELaJcOx; Tue, 29 Mar 2022 16:47:20 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.1139.1648597631562797263 for ; Tue, 29 Mar 2022 16:47:19 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10301"; a="259375016" X-IronPort-AV: E=Sophos;i="5.90,220,1643702400"; d="scan'208";a="259375016" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2022 16:47:19 -0700 X-IronPort-AV: E=Sophos;i="5.90,220,1643702400"; d="scan'208";a="521658465" X-Received: from zhangpen-mobl.ccr.corp.intel.com (HELO mxu9-mobl1.ccr.corp.intel.com) ([10.255.29.230]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2022 16:47:16 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [PATCH V12 07/47] UefiCpuPkg/CpuExceptionHandler: Add base support for the #VE exception Date: Wed, 30 Mar 2022 07:46:00 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,min.m.xu@intel.com X-Gm-Message-State: wkufVfiKxNvIGbRzwYFLVE9Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648597640; bh=NSP7ysylo6XfjWMLEhfEiuKjkfj6tKYvQfs6f7AkO6Y=; h=Cc:Date:From:Reply-To:Subject:To; b=NBwGysgGaJPlYwKv6sDKbyZGwzH2MyhuqCSZ/UdovgerRfFQEYFg3gc0DnVVShK+Zqb j1Hir4TFDslr3m7KYLPhd6+SDP0PN+idFeFSE4zloQj/M/gs1E+CUUXbQHZRozNb7sFDR sk4i8EosZlEXBW9jtXwTFasMQD4HdomSZ50= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648597642323100007 Content-Type: text/plain; charset="utf-8" RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3429 Add base support to handle #VE exceptions. Update the common exception handlers to invoke the VmTdExitHandleVe () function of the VmgExitLib library when a #VE is encountered. A non-zero return code will propagate to the targeted exception handler. Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Acked-by: Gerd Hoffmann Reviewed-by: Ray Ni Signed-off-by: Min Xu --- .../PeiDxeSmmCpuException.c | 53 ++++++++++++----- .../SecPeiCpuException.c | 57 +++++++++++++------ 2 files changed, 79 insertions(+), 31 deletions(-) diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuExceptio= n.c b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c index 762ea2460f91..f47a80dcab8f 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c @@ -24,25 +24,48 @@ CommonExceptionHandlerWorker ( IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData ) { + EFI_STATUS Status; EXCEPTION_HANDLER_CONTEXT *ExceptionHandlerContext; RESERVED_VECTORS_DATA *ReservedVectors; EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler; =20 - if (ExceptionType =3D=3D VC_EXCEPTION) { - EFI_STATUS Status; - // - // #VC needs to be handled immediately upon enabling exception handling - // and therefore can't use the RegisterCpuInterruptHandler() interface. - // - // Handle the #VC: - // On EFI_SUCCESS - Exception has been handled, return - // On other - ExceptionType contains (possibly new) exception - // value - // - Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); - if (!EFI_ERROR (Status)) { - return; - } + switch (ExceptionType) { + case VC_EXCEPTION: + // + // #VC needs to be handled immediately upon enabling exception handl= ing + // and therefore can't use the RegisterCpuInterruptHandler() interfa= ce. + // + // Handle the #VC: + // On EFI_SUCCESS - Exception has been handled, return + // On other - ExceptionType contains (possibly new) exception + // value + // + Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); + if (!EFI_ERROR (Status)) { + return; + } + + break; + + case VE_EXCEPTION: + // + // #VE needs to be handled immediately upon enabling exception handl= ing + // and therefore can't use the RegisterCpuInterruptHandler() interfa= ce. + // + // Handle the #VE: + // On EFI_SUCCESS - Exception has been handled, return + // On other - ExceptionType contains (possibly new) exception + // value + // + Status =3D VmTdExitHandleVe (&ExceptionType, SystemContext); + if (!EFI_ERROR (Status)) { + return; + } + + break; + + default: + break; } =20 ExceptionHandlerContext =3D (EXCEPTION_HANDLER_CONTEXT *)(UINTN)(System= Context.SystemContextIa32); diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c= b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c index c614d5b0b6f1..6e5216380da8 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c @@ -25,22 +25,47 @@ CommonExceptionHandler ( IN EFI_SYSTEM_CONTEXT SystemContext ) { - if (ExceptionType =3D=3D VC_EXCEPTION) { - EFI_STATUS Status; - // - // #VC needs to be handled immediately upon enabling exception handling - // and therefore can't use the RegisterCpuInterruptHandler() interface - // (which isn't supported under Sec and Pei anyway). - // - // Handle the #VC: - // On EFI_SUCCESS - Exception has been handled, return - // On other - ExceptionType contains (possibly new) exception - // value - // - Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); - if (!EFI_ERROR (Status)) { - return; - } + EFI_STATUS Status; + + switch (ExceptionType) { + case VC_EXCEPTION: + // + // #VC needs to be handled immediately upon enabling exception handl= ing + // and therefore can't use the RegisterCpuInterruptHandler() interfa= ce + // (which isn't supported under Sec and Pei anyway). + // + // Handle the #VC: + // On EFI_SUCCESS - Exception has been handled, return + // On other - ExceptionType contains (possibly new) exception + // value + // + Status =3D VmgExitHandleVc (&ExceptionType, SystemContext); + if (!EFI_ERROR (Status)) { + return; + } + + break; + + case VE_EXCEPTION: + // + // #VE needs to be handled immediately upon enabling exception handl= ing + // and therefore can't use the RegisterCpuInterruptHandler() interfa= ce + // (which isn't supported under Sec and Pei anyway). + // + // Handle the #VE: + // On EFI_SUCCESS - Exception has been handled, return + // On other - ExceptionType contains (possibly new) exception + // value + // + Status =3D VmTdExitHandleVe (&ExceptionType, SystemContext); + if (!EFI_ERROR (Status)) { + return; + } + + break; + + default: + break; } =20 // --=20 2.29.2.windows.2 -=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 (#88216): https://edk2.groups.io/g/devel/message/88216 Mute This Topic: https://groups.io/mt/90121192/1787277 Mute #ve:https://edk2.groups.io/g/devel/mutehashtag/ve 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-