[edk2-devel] [PATCH 05/11] OvmfPkg/XenBusDxe: Construct paths without allocation
Laszlo Ersek
lersek at redhat.com
Mon Sep 16 15:43:40 UTC 2019
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 <anthony.perard at citrix.com>
>> ---
>> 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#47286): https://edk2.groups.io/g/devel/message/47286
Mute This Topic: https://groups.io/mt/34128016/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list