From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Mon, 16 Sep 2019 07:38:12 -0700 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 mx1.redhat.com (Postfix) with ESMTPS id 198D8883825; Mon, 16 Sep 2019 14:38:12 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-124-96.rdu2.redhat.com [10.10.124.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0A511001B09; Mon, 16 Sep 2019 14:38:10 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 02/11] OvmfPkg/XenBusDxe: Have XenStoreFindWatch take a pointer To: devel@edk2.groups.io, anthony.perard@citrix.com Cc: Ard Biesheuvel , Julien Grall , Jordan Justen , xen-devel@lists.xenproject.org References: <20190913145100.303433-1-anthony.perard@citrix.com> <20190913145100.303433-3-anthony.perard@citrix.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 16 Sep 2019 16:38:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190913145100.303433-3-anthony.perard@citrix.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 16 Sep 2019 14:38:12 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/13/19 16:50, Anthony PERARD wrote: > Rework XenStoreFindWatch() to be able to search for a registered watch > with a pointer instead of a string. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2190 > Signed-off-by: Anthony PERARD > --- > OvmfPkg/XenBusDxe/XenStore.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c > index 7253d8ae37..727641a0fe 100644 > --- a/OvmfPkg/XenBusDxe/XenStore.c > +++ b/OvmfPkg/XenBusDxe/XenStore.c > @@ -253,14 +253,12 @@ Split ( > STATIC > XENSTORE_WATCH * > XenStoreFindWatch ( > - IN CONST CHAR8 *Token > + IN VOID *Token > ) > { > - XENSTORE_WATCH *Watch, *WantedWatch; > + XENSTORE_WATCH *Watch; > LIST_ENTRY *Entry; > > - WantedWatch = (VOID *) AsciiStrHexToUintn (Token); > - > if (IsListEmpty (&xs.RegisteredWatches)) { > return NULL; > } > @@ -268,7 +266,7 @@ XenStoreFindWatch ( > !IsNull (&xs.RegisteredWatches, Entry); > Entry = GetNextNode (&xs.RegisteredWatches, Entry)) { > Watch = XENSTORE_WATCH_FROM_LINK (Entry); > - if (Watch == WantedWatch) > + if ((VOID *) Watch == Token) > return Watch; > } > > @@ -632,12 +630,16 @@ XenStoreProcessMessage ( > Body[Message->Header.len] = '\0'; > > if (Message->Header.type == XS_WATCH_EVENT) { > + VOID *ConvertedToken; > + > Message->u.Watch.Vector = Split(Body, Message->Header.len, > &Message->u.Watch.VectorSize); > > + ConvertedToken = > + (VOID *) AsciiStrHexToUintn (Message->u.Watch.Vector[XS_WATCH_TOKEN]); > + > EfiAcquireLock (&xs.RegisteredWatchesLock); > - Message->u.Watch.Handle = > - XenStoreFindWatch (Message->u.Watch.Vector[XS_WATCH_TOKEN]); > + Message->u.Watch.Handle = XenStoreFindWatch (ConvertedToken); > DEBUG ((EFI_D_INFO, "XenStore: Watch event %a\n", > Message->u.Watch.Vector[XS_WATCH_TOKEN])); > if (Message->u.Watch.Handle != NULL) { > @@ -1384,8 +1386,7 @@ XenStoreUnregisterWatch ( > > ASSERT (Watch->Signature == XENSTORE_WATCH_SIGNATURE); > > - AsciiSPrint (Token, sizeof (Token), "%p", (VOID *) Watch); > - if (XenStoreFindWatch (Token) == NULL) { > + if (XenStoreFindWatch (Watch) == NULL) { > return; > } > > @@ -1393,6 +1394,7 @@ XenStoreUnregisterWatch ( > RemoveEntryList (&Watch->Link); > EfiReleaseLock (&xs.RegisteredWatchesLock); > > + AsciiSPrint (Token, sizeof (Token), "%p", (VOID *) Watch); > XenStoreUnwatch (Watch->Node, Token); > > /* Cancel pending watch events. */ > Reviewed-by: Laszlo Ersek