From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web10.5493.1603140428775180515 for ; Mon, 19 Oct 2020 13:47:08 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WIbJ7SOT; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603140428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5mNrOnhptKXBHazqtZI5CF4wybAyJuabrDi1Rr37UVQ=; b=WIbJ7SOTuCHPniwWBs8h15ZPksiCQzpiVWh+KOpSCCxf4FFQC3mRcFN30O7oozFgMxCaS0 urP3vJAl8yOQ0VYJI4vjRg9aZ8uxK9d3U8jpTfyg+e2P77QFaFhLn/3eZb3BVuHdhowb6w Cqnum7B5XDRWEbLfBKpvrKRnVXrzu4I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-3fDZGnunMpOpOjrK2TcR8Q-1; Mon, 19 Oct 2020 16:47:00 -0400 X-MC-Unique: 3fDZGnunMpOpOjrK2TcR8Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71ACD57055; Mon, 19 Oct 2020 20:46:59 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-137.ams2.redhat.com [10.36.113.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id A878A10016DA; Mon, 19 Oct 2020 20:46:57 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits To: devel@edk2.groups.io, thomas.lendacky@amd.com Cc: Brijesh Singh , Eric Dong , Ray Ni , Rahul Kumar References: From: "Laszlo Ersek" Message-ID: <0fba81e3-69df-2dca-7b1a-9ab1d0a1c9fc@redhat.com> Date: Mon, 19 Oct 2020 22:46:56 +0200 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/16/20 18:09, Lendacky, Thomas wrote: > From: Tom Lendacky > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3008 > > In upcoming patches, the setting of the bits in the GHCB ValidBitmap will > be performed in multiple places. In order to reduce code duplication, add > an interface, VmgSetOffsetValid(), to VmgExitLib library to perform this > function. Also, to keep management of the ValidBitmap within the library, > add an inteface, VmgIsOffsetValid(), to return whether the bit in the > ValidBitmap is set for a specified offset. > > The new VmgSetOffsetValid() function is a VOID function and will be an > empty function in the VmgExitLibNull implementation of the VmgExitLib > library. > > The new VmgIsOffsetValid() function returns a BOOLEAN to indicate if the > offset is valid. This will always return FALSE in the VmgExitLibNull > implementation of the VmgExitLib library. > > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Signed-off-by: Tom Lendacky > --- > UefiCpuPkg/Include/Library/VmgExitLib.h | 37 +++++++++++++++++ > UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c | 42 ++++++++++++++++++++ > 2 files changed, 79 insertions(+) > > diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h b/UefiCpuPkg/Include/Library/VmgExitLib.h > index 45fc27d35e29..ba5ea024839e 100644 > --- a/UefiCpuPkg/Include/Library/VmgExitLib.h > +++ b/UefiCpuPkg/Include/Library/VmgExitLib.h > @@ -74,6 +74,43 @@ VmgDone ( > IN OUT GHCB *Ghcb > ); > > +/** > + Marks a specified offset as valid in the GHCB. > + > + The ValidBitmap area represents the areas of the GHCB that have been marked > + valid. Set the bit in ValidBitmap for the input offset. > + > + @param[in, out] Ghcb A pointer to the GHCB > + @param[in] Offset Qword offset in the GHCB to mark valid > + > +**/ > +VOID > +EFIAPI > +VmgSetOffsetValid ( > + IN OUT GHCB *Ghcb, > + IN GHCB_QWORD_OFFSET Offset > + ); > + > +/** > + Checks if a specified offset is valid in the GHCB. > + > + The ValidBitmap area represents the areas of the GHCB that have been marked > + valid. Return whether the bit in the ValidBitmap is set for the input offset. > + > + @param[in] Ghcb A pointer to the GHCB > + @param[in] Offset Qword offset in the GHCB to mark valid > + > + @retval TRUE Offset is marked vald in the GHCB > + @retval FALSE Offset is not marked valid in the GHCB > + > +**/ > +BOOLEAN > +EFIAPI > +VmgIsOffsetValid ( > + IN GHCB *Ghcb, > + IN GHCB_QWORD_OFFSET Offset > + ); > + > /** > Handle a #VC exception. > > diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c > index bb265e1700d2..b000232c472e 100644 > --- a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c > +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c > @@ -89,6 +89,48 @@ VmgDone ( > { > } > > +/** > + Marks a field at the specified offset as valid in the GHCB. > + > + The ValidBitmap area represents the areas of the GHCB that have been marked > + valid. Set the bit in ValidBitmap for the input offset. > + > + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Block > + @param[in] Offset Qword offset in the GHCB to mark valid > + > +**/ > +VOID > +EFIAPI > +VmgSetOffsetValid ( > + IN OUT GHCB *Ghcb, > + IN GHCB_QWORD_OFFSET Offset > + ) > +{ > +} > + > +/** > + Checks if a specified offset is valid in the GHCB. > + > + The ValidBitmap area represents the areas of the GHCB that have been marked > + valid. Return whether the bit in the ValidBitmap is set for the input offset. > + > + @param[in] Ghcb A pointer to the GHCB > + @param[in] Offset Qword offset in the GHCB to mark valid > + > + @retval TRUE Offset is marked vald in the GHCB > + @retval FALSE Offset is not marked valid in the GHCB > + > +**/ > +BOOLEAN > +EFIAPI > +VmgIsOffsetValid ( > + IN GHCB *Ghcb, > + IN GHCB_QWORD_OFFSET Offset > + ) > +{ > + return FALSE; > +} > + > /** > Handle a #VC exception. > > s/vald/valid/, twice With that fixed: Reviewed-by: Laszlo Ersek Thanks Laszlo