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 08:43:43 -0700 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C6FA86E86F; Mon, 16 Sep 2019 15:43:42 +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 2F85160BE1; Mon, 16 Sep 2019 15:43:41 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 05/11] OvmfPkg/XenBusDxe: Construct paths without allocation From: "Laszlo Ersek" 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-6-anthony.perard@citrix.com> <59a12b9c-17ce-2e4c-96a9-f741858b2ba6@redhat.com> Message-ID: <8f1860bf-c9e9-8281-402c-c65d7dcd0e76@redhat.com> Date: Mon, 16 Sep 2019 17:43:40 +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: <59a12b9c-17ce-2e4c-96a9-f741858b2ba6@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 16 Sep 2019 15:43:42 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/16/19 17:39, Laszlo Ersek wrote: > On 09/13/19 16:50, Anthony PERARD wrote: >> When doing an action with a path and subpath in the xenstore, >> XenStoreJoin is called to generate "$path/$subpath". But this function >> do an allocation of memory which isn't necessary. Instead we will >> construct the path with WRITE_REQUEST and data used to generate the >> path will be copied directly to the xenstore shared ring. >> >> Also change WRITE_REQUEST.Len type, it only contain sizes and doesn't >> need to be exactly 32bits. >> >> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2190 >> Signed-off-by: Anthony PERARD >> --- >> OvmfPkg/XenBusDxe/XenStore.c | 78 +++++++++++++++++++++--------------- >> 1 file changed, 46 insertions(+), 32 deletions(-) >> >> diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c >> index 7b71dc156d..ca7be12d68 100644 >> --- a/OvmfPkg/XenBusDxe/XenStore.c >> +++ b/OvmfPkg/XenBusDxe/XenStore.c >> @@ -53,7 +53,7 @@ >> >> typedef struct { >> CONST VOID *Data; >> - UINT32 Len; >> + UINTN Len; >> } WRITE_REQUEST; >> >> /* Register callback to watch subtree (node) in the XenStore. */ >> @@ -260,6 +260,35 @@ XenStoreFindWatch ( >> return NULL; >> } >> >> +/** >> + Fill the first three slots of a WRITE_REQUEST array. >> + >> + When those three slots are concatenated to generate a string, the resulting >> + string will be "$Path\0" or "$Path/$SubPath\0" if SubPath is provided. >> +**/ >> +STATIC >> +VOID >> +XenStorePrepareWriteRequest ( >> + IN OUT WRITE_REQUEST *WriteRequest, (6) I think this could be just OUT -- we start by zeroing it out. >> + IN CONST CHAR8 *Path, >> + IN CONST CHAR8 *SubPath OPTIONAL >> + ) >> +{ >> + SetMem(WriteRequest, 3 * sizeof (WRITE_REQUEST), 0); Thanks Laszlo