public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "Xu, Min M" <min.m.xu@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Aktas, Erdem" <erdemaktas@google.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	James Bottomley <jejb@linux.ibm.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [PATCH V2 1/1] OvmfPkg/VmgExitLig: HALT on #VE when access to private memory
Date: Fri, 28 Oct 2022 08:30:00 +0000	[thread overview]
Message-ID: <MW4PR11MB5872173943096DE54AF2F4858C329@MW4PR11MB5872.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20221028082401.1227-1-min.m.xu@intel.com>

Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: Xu, Min M <min.m.xu@intel.com>
> Sent: Friday, October 28, 2022 4:24 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M <min.m.xu@intel.com>; Aktas, Erdem
> <erdemaktas@google.com>; Gerd Hoffmann <kraxel@redhat.com>; James
> Bottomley <jejb@linux.ibm.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Tom Lendacky <thomas.lendacky@amd.com>
> Subject: [PATCH V2 1/1] OvmfPkg/VmgExitLig: HALT on #VE when access to
> private memory
> 
> From: Min M Xu <min.m.xu@intel.com>
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4125
> 
> EPT-violation #VE should be always on shared memory, which means the
> shared bit of the GuestPA should be set. But in current #VE Handler
> it is not checked. When it occurs, stop TD immediately and log out
> the error.
> 
> Cc: Erdem Aktas <erdemaktas@google.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: James Bottomley <jejb@linux.ibm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Min Xu <min.m.xu@intel.com>
> ---
>  .../Library/VmgExitLib/VmTdExitVeHandler.c    | 40 ++++++++++++++-----
>  1 file changed, 29 insertions(+), 11 deletions(-)
> 
> diff --git a/OvmfPkg/Library/VmgExitLib/VmTdExitVeHandler.c
> b/OvmfPkg/Library/VmgExitLib/VmTdExitVeHandler.c
> index b73e877c093b..c89268c5d8e8 100644
> --- a/OvmfPkg/Library/VmgExitLib/VmTdExitVeHandler.c
> +++ b/OvmfPkg/Library/VmgExitLib/VmTdExitVeHandler.c
> @@ -300,23 +300,41 @@ MmioExit (
>    IN TDCALL_VEINFO_RETURN_DATA   *Veinfo
>    )
>  {
> -  UINT64   Status;
> -  UINT32   MmioSize;
> -  UINT32   RegSize;
> -  UINT8    OpCode;
> -  BOOLEAN  SeenRex;
> -  UINT64   *Reg;
> -  UINT8    *Rip;
> -  UINT64   Val;
> -  UINT32   OpSize;
> -  MODRM    ModRm;
> -  REX      Rex;
> +  UINT64          Status;
> +  UINT32          MmioSize;
> +  UINT32          RegSize;
> +  UINT8           OpCode;
> +  BOOLEAN         SeenRex;
> +  UINT64          *Reg;
> +  UINT8           *Rip;
> +  UINT64          Val;
> +  UINT32          OpSize;
> +  MODRM           ModRm;
> +  REX             Rex;
> +  TD_RETURN_DATA  TdReturnData;
> +  UINT8           Gpaw;
> +  UINT64          TdSharedPageMask;
> 
>    Rip     = (UINT8 *)Regs->Rip;
>    Val     = 0;
>    Rex.Val = 0;
>    SeenRex = FALSE;
> 
> +  Status = TdCall (TDCALL_TDINFO, 0, 0, 0, &TdReturnData);
> +  if (Status == TDX_EXIT_REASON_SUCCESS) {
> +    Gpaw             = (UINT8)(TdReturnData.TdInfo.Gpaw & 0x3f);
> +    TdSharedPageMask = 1ULL << (Gpaw - 1);
> +  } else {
> +    DEBUG ((DEBUG_ERROR, "TDCALL failed with status=%llx\n", Status));
> +    return Status;
> +  }
> +
> +  if ((Veinfo->GuestPA & TdSharedPageMask) == 0) {
> +    DEBUG ((DEBUG_ERROR, "EPT-violation #VE on private memory is not
> allowed!"));
> +    TdVmCall (TDVMCALL_HALT, 0, 0, 0, 0, 0);
> +    CpuDeadLoop ();
> +  }
> +
>    //
>    // Default to 32bit transfer
>    //
> --
> 2.29.2.windows.2


      reply	other threads:[~2022-10-28  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28  8:24 [PATCH V2 1/1] OvmfPkg/VmgExitLig: HALT on #VE when access to private memory Min Xu
2022-10-28  8:30 ` Yao, Jiewen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MW4PR11MB5872173943096DE54AF2F4858C329@MW4PR11MB5872.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox