From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web08.6798.1604421529077509946 for ; Tue, 03 Nov 2020 08:38:49 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TcJqTzCE; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604421528; 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=b1pW7azdTFQx2M2537szgnbfeXkwY3IIx3LbwFkvNUs=; b=TcJqTzCECyxxuc4AzmqWup+3OgzoKlxXnfTrC+1G4DJh5RxHIE3ZghOn4J024R3cjsVNDd z4UJpSBBJoQo/R4XXQVSoIlel3v9NcPnvPKUWQ8ZGU0Lh+boPh/ziI2JrLLkmBPtg7TMf5 IF/N0epHJqSzhgGA83k8h0VOzl6Ksag= 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-95-rdSm9PwuPOqDqWaxau_UvQ-1; Tue, 03 Nov 2020 11:38:44 -0500 X-MC-Unique: rdSm9PwuPOqDqWaxau_UvQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A54DC10A0B8D; Tue, 3 Nov 2020 16:38:42 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-129.ams2.redhat.com [10.36.112.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F54717511; Tue, 3 Nov 2020 16:38:40 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v3 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits To: Eric Dong , Ray Ni Cc: devel@edk2.groups.io, thomas.lendacky@amd.com, Brijesh Singh , Rahul Kumar References: <360a3882884716ebb60276220c18e33e127a83f9.1603981082.git.thomas.lendacky@amd.com> From: "Laszlo Ersek" Message-ID: <02e347ac-81ed-25fc-f021-8363992c9c91@redhat.com> Date: Tue, 3 Nov 2020 17:38:39 +0100 MIME-Version: 1.0 In-Reply-To: <360a3882884716ebb60276220c18e33e127a83f9.1603981082.git.thomas.lendacky@amd.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Ray, Eric, can one of you please ACK this patch? I've reviewed it already, but your ACK would be appreciated, process-wise. I intend to merge the series on Thursday at the latest (Nov 5th). Thank you. Laszlo On 10/29/20 15:17, 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 > Reviewed-by: Laszlo Ersek > 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..07e8af6450b9 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_REGISTER 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 valid in the GHCB > + @retval FALSE Offset is not marked valid in the GHCB > + > +**/ > +BOOLEAN > +EFIAPI > +VmgIsOffsetValid ( > + IN GHCB *Ghcb, > + IN GHCB_REGISTER Offset > + ); > + > /** > Handle a #VC exception. > > diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c > index bb265e1700d2..b47e282aff82 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_REGISTER 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 valid in the GHCB > + @retval FALSE Offset is not marked valid in the GHCB > + > +**/ > +BOOLEAN > +EFIAPI > +VmgIsOffsetValid ( > + IN GHCB *Ghcb, > + IN GHCB_REGISTER Offset > + ) > +{ > + return FALSE; > +} > + > /** > Handle a #VC exception. > >