From: Oliver Kurth Date: Wed, 3 Jul 2019 21:26:54 +0000 (-0700) Subject: Changes to common source files not directly applicable to open-vm-tools. X-Git-Tag: stable-11.0.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e266c0bb1879792f24b29d38af9f9f833475f228;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not directly applicable to open-vm-tools. Reduce malloc/free overheads in the VMX for HGFS over VMCI --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c b/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c index 166083104..230a6f933 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -788,14 +788,10 @@ HSPUMapBuf(HgfsChannelMapVirtAddrFunc mapVa, // IN: map virtual address funct iovIndex < iovCount && remainingSize > 0; iovIndex++, mappedIovCount++) { - iov[iovIndex].context = NULL; - /* Check: Iov in VMCI should never cross page boundary */ ASSERT(iov[iovIndex].len <= (PAGE_SIZE - PAGE_OFFSET(iov[iovIndex].pa))); - iov[iovIndex].va = mapVa(iov[iovIndex].pa, - iov[iovIndex].len, - &iov[iovIndex].context); + iov[iovIndex].va = mapVa(&iov[iovIndex]); if (NULL == iov[iovIndex].va) { /* Failed to map the physical address. */ break; @@ -842,9 +838,7 @@ HSPUUnmapBuf(HgfsChannelUnmapVirtAddrFunc unmapVa, // IN/OUT: Hgfs Packet for (iovIndex = startIndex, endIndex = startIndex + *mappedCount; iovIndex < endIndex; iovIndex++) { - ASSERT(iov[iovIndex].context); unmapVa(&iov[iovIndex].context); - iov[iovIndex].context = NULL; iov[iovIndex].va = NULL; } *mappedCount = 0; diff --git a/open-vm-tools/lib/include/hgfsServer.h b/open-vm-tools/lib/include/hgfsServer.h index d8509c12d..37bd54d55 100644 --- a/open-vm-tools/lib/include/hgfsServer.h +++ b/open-vm-tools/lib/include/hgfsServer.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -19,18 +19,23 @@ #ifndef _HGFS_SERVER_H_ #define _HGFS_SERVER_H_ -#include "hgfs.h" /* for HGFS_PACKET_MAX */ #include "dbllnklst.h" +#include "hgfs.h" /* for HGFS_PACKET_MAX */ +#include "vm_basic_defs.h" /* for vmx86_debug */ #if defined(__cplusplus) extern "C" { #endif +#define HGFS_VMX_IOV_CONTEXT_SIZE (vmx86_debug ? 112 : 96) typedef struct HgfsVmxIov { void *va; /* Virtual addr */ uint64 pa; /* Physical address passed by the guest */ uint32 len; /* length of data; should be <= PAGE_SIZE for VMCI; arbitrary for backdoor */ - void *context; /* Mapping context */ + union { + void *ptr; + char clientStorage[HGFS_VMX_IOV_CONTEXT_SIZE]; + } context; /* Mapping context */ } HgfsVmxIov; typedef enum { @@ -175,8 +180,8 @@ typedef void (*HgfsInvalidateObjectsFunc)(DblLnkLst_Links *shares); typedef Bool (*HgfsChannelSendFunc)(void *opaqueSession, HgfsPacket *packet, HgfsSendFlags flags); -typedef void * (*HgfsChannelMapVirtAddrFunc)(uint64 pa, uint32 size, void **context); -typedef void (*HgfsChannelUnmapVirtAddrFunc)(void **context); +typedef void * (*HgfsChannelMapVirtAddrFunc)(HgfsVmxIov *iov); +typedef void (*HgfsChannelUnmapVirtAddrFunc)(void *context); typedef void (*HgfsChannelRegisterThreadFunc)(void); typedef void (*HgfsChannelUnregisterThreadFunc)(void);