]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Wed, 24 Feb 2010 22:07:05 +0000 (14:07 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 24 Feb 2010 22:07:05 +0000 (14:07 -0800)
. Patch backdoorGcc64.c to trick Apple's GCC into not thinking we clobber
  the PIC register. This allows us to build lib/backdoor on mac64.

. Do not use new NAPI poll in Linux kernel < 2.6.24.

. Avoid tx hangs while running NDIStest.

. Changes in shared code that don't affect open-vm-tools functionality.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/backdoor/backdoorGcc64.c
open-vm-tools/lib/file/filePosix.c
open-vm-tools/lib/include/file.h
open-vm-tools/lib/include/win32util.h
open-vm-tools/modules/linux/pvscsi/scsi_defs.h
open-vm-tools/modules/linux/shared/compat_netdevice.h
open-vm-tools/modules/shared/vmxnet/shared/npa_defs.h [moved from open-vm-tools/modules/shared/vmxnet/npa_defs.h with 93% similarity]
open-vm-tools/modules/solaris/vmxnet3/vmxnet3_tx.c

index 28acfb062c2029461ad559d9c67bb6520b216ded..48cd5b7c72f7db72709587217c2881f27e6bd91b 100644 (file)
@@ -76,6 +76,14 @@ Backdoor_InOut(Backdoor_proto *myBp) // IN/OUT
    uint64 dummy;
 
    __asm__ __volatile__(
+#ifdef __APPLE__
+        /*
+         * Save %rbx on the stack because the Mac OS GCC doesn't want us to
+         * clobber it - it erroneously thinks %rbx is the PIC register.
+         * (Radar bug 7304232)
+         */
+        "pushq %%rbx"           "\n\t"
+#endif
         "pushq %%rax"           "\n\t"
         "movq 40(%%rax), %%rdi" "\n\t"
         "movq 32(%%rax), %%rsi" "\n\t"
@@ -90,14 +98,22 @@ Backdoor_InOut(Backdoor_proto *myBp) // IN/OUT
         "movq %%rdx, 24(%%rax)" "\n\t"
         "movq %%rcx, 16(%%rax)" "\n\t"
         "movq %%rbx,  8(%%rax)" "\n\t"
-        "popq          (%%rax)"
+        "popq          (%%rax)" "\n\t"
+#ifdef __APPLE__
+        "popq %%rbx"            "\n\t"
+#endif
       : "=a" (dummy)
       : "0" (myBp)
       /*
        * vmware can modify the whole VM state without the compiler knowing
        * it. So far it does not modify EFLAGS. --hpreg
        */
-      : "rbx", "rcx", "rdx", "rsi", "rdi", "memory"
+      :
+#ifndef __APPLE__
+      /* %rbx is unchanged at the end of the function on Mac OS. */
+      "rbx",
+#endif
+      "rcx", "rdx", "rsi", "rdi", "memory"
    );
 }
 
@@ -127,7 +143,14 @@ BackdoorHbIn(Backdoor_proto_hb *myBp) // IN/OUT
 
    __asm__ __volatile__(
         "pushq %%rbp"           "\n\t"
-
+#ifdef __APPLE__
+        /*
+         * Save %rbx on the stack because the Mac OS GCC doesn't want us to
+         * clobber it - it erroneously thinks %rbx is the PIC register.
+         * (Radar bug 7304232)
+         */
+        "pushq %%rbx"           "\n\t"
+#endif
         "pushq %%rax"           "\n\t"
         "movq 48(%%rax), %%rbp" "\n\t"
         "movq 40(%%rax), %%rdi" "\n\t"
@@ -146,7 +169,9 @@ BackdoorHbIn(Backdoor_proto_hb *myBp) // IN/OUT
         "movq %%rcx, 16(%%rax)" "\n\t"
         "movq %%rbx,  8(%%rax)" "\n\t"
         "popq          (%%rax)" "\n\t"
-
+#ifdef __APPLE__
+        "popq %%rbx"            "\n\t"
+#endif
         "popq %%rbp"
       : "=a" (dummy)
       : "0" (myBp)
@@ -154,7 +179,12 @@ BackdoorHbIn(Backdoor_proto_hb *myBp) // IN/OUT
        * vmware can modify the whole VM state without the compiler knowing
        * it. --hpreg
        */
-      : "rbx", "rcx", "rdx", "rsi", "rdi", "memory", "cc"
+      :
+#ifndef __APPLE__
+      /* %rbx is unchanged at the end of the function on Mac OS. */
+      "rbx",
+#endif
+      "rcx", "rdx", "rsi", "rdi", "memory", "cc"
    );
 }
 
@@ -166,7 +196,14 @@ BackdoorHbOut(Backdoor_proto_hb *myBp) // IN/OUT
 
    __asm__ __volatile__(
         "pushq %%rbp"           "\n\t"
-
+#ifdef __APPLE__
+        /*
+         * Save %rbx on the stack because the Mac OS GCC doesn't want us to
+         * clobber it - it erroneously thinks %rbx is the PIC register.
+         * (Radar bug 7304232)
+         */
+        "pushq %%rbx"           "\n\t"
+#endif
         "pushq %%rax"           "\n\t"
         "movq 48(%%rax), %%rbp" "\n\t"
         "movq 40(%%rax), %%rdi" "\n\t"
@@ -185,11 +222,18 @@ BackdoorHbOut(Backdoor_proto_hb *myBp) // IN/OUT
         "movq %%rcx, 16(%%rax)" "\n\t"
         "movq %%rbx,  8(%%rax)" "\n\t"
         "popq          (%%rax)" "\n\t"
-
+#ifdef __APPLE__
+        "popq %%rbx"            "\n\t"
+#endif
         "popq %%rbp"
       : "=a" (dummy)
       : "0" (myBp)
-      : "rbx", "rcx", "rdx", "rsi", "rdi", "memory", "cc"
+      :
+#ifndef __APPLE__
+      /* %rbx is unchanged at the end of the function on Mac OS. */
+      "rbx",
+#endif
+      "rcx", "rdx", "rsi", "rdi", "memory", "cc"
    );
 }
 
index 17aab88816021900c1ede7a2fcbafa59f25f8398..019565213647a999eebeab115643d66a7cc2d9c3 100644 (file)
@@ -1293,7 +1293,67 @@ done:
    }
    return ret;
 }
-#endif
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * File_GetVMFSMountInfo --
+ *
+ *      Acquire the FS mount point info such as fsType, major version,
+ *      local mount point (/vmfs/volumes/xyz), and for NFS,
+ *      remote IP and remote mount point for a given file.     
+ *
+ * Results:
+ *      Integer return value and allocated data
+ *
+ * Side effects:
+ *      Only implemented on ESX. Will fail on other platforms. 
+ *      remoteIP and remoteMountPoint are only populated for files on NFS.   
+ *
+ *----------------------------------------------------------------------
+ */
+
+int 
+File_GetVMFSMountInfo(ConstUnicode pathName,
+                     char **fsType,
+                     uint32 *version,
+                     char **remoteIP,
+                     char **remoteMountPoint,
+                     char **localMountPoint)
+{
+   int ret;
+   int len;
+   FS_PartitionListResult *fsAttrs;
+
+   *localMountPoint = File_GetUniqueFileSystemID(pathName);
+
+   if (*localMountPoint == NULL) {
+      return -1;
+   }
+
+   // Get file IP and mount point
+   ret = File_GetVMFSAttributes(pathName, &fsAttrs);  
+   if (ret >= 0 && fsAttrs) { 
+      *version = fsAttrs->versionNumber;
+      *fsType = Util_SafeStrdup(fsAttrs->fsType);
+      if (strncmp(fsAttrs->fsType, "NFS", sizeof("NFS")) == 0) {
+         len = strlen(fsAttrs->logicalDevice);
+         *remoteIP = Util_SafeMalloc(len);
+         *remoteMountPoint = Util_SafeMalloc(len);
+         sscanf(fsAttrs->logicalDevice, "%s %s", *remoteIP, *remoteMountPoint);
+      } else {
+         *remoteIP = NULL;
+         *remoteMountPoint = NULL;   
+      }  
+   }
+
+   free(fsAttrs);
+   return ret;
+}
+
+#endif 
 
 
 /*
index 34b80b4f3426a44e35c11d5aeafd490625b76650..7b1ae3ca99a7a80a73451091ca8dc990ba054f0f 100644 (file)
@@ -88,6 +88,12 @@ EXTERN char *FileMacos_SliceUUIDToSliceDev(char const *uuid);
 #elif defined VMX86_SERVER
 EXTERN int File_GetVMFSBlockSize(ConstUnicode pathName, uint32 *blockSize);
 EXTERN int File_GetVMFSfsType(ConstUnicode pathName, char **fsType);
+EXTERN int File_GetVMFSMountInfo(ConstUnicode pathName,
+                                 char **fsType,
+                                 uint32 *version,
+                                 char **remoteIP,
+                                 char **remoteMountPoint,
+                                 char **localMountPoint);
 #endif
 
 EXTERN Bool File_Exists(ConstUnicode pathName);
index 2d6dea002be1d5da422dad66f64bbd11e0f1df7c..43fcc4ef0b701855d37f9ff7b9dc796ebccf9b06 100644 (file)
@@ -214,5 +214,7 @@ HMODULE W32Util_GetModuleByAddress(const void *addr);
 
 Bool W32Util_VerifyXPModeHostLicense(void);
 
+Unicode W32Util_GetPipeNameFromFilePath(ConstUnicode fileName);
+
 #endif // _WIN32
 #endif // WIN32UTIL_H_
index eebb6b08b738f63cbe33d3877c001ac3d8253e69..6b886ede4b8590658fb573a75166f3116facc32b 100644 (file)
@@ -1423,6 +1423,24 @@ struct {
 #include "vmware_pack_end.h"
 SCSIVerify10Cmd;
 
+typedef
+#include "vmware_pack_begin.h"
+struct {
+   uint8    opcode;
+   uint8    relAdr  :1,         // relative address
+            bytChk  :1,         // byte
+            blkvfy  :1,         // blank blocks verification, scsi-2 rev 8.
+                    :1,  
+            dpo     :1,         // cache control bit
+            resvd   :3;         // reserved
+   uint64   lbn;                // logical block address
+   uint32   length;             // verification length
+   uint8    reserved;
+   uint8    control;            // control byte
+}
+#include "vmware_pack_end.h"
+SCSIVerify16Cmd;
+
 typedef
 #include "vmware_pack_begin.h"
 struct {
index 5af03ced4c16b9224bce606637c05c41ac59425b..f77f3cb4d7aaf181a6296d46ee4cccf6f973ce30 100644 (file)
@@ -299,11 +299,6 @@ static inline int compat_unregister_netdevice_notifier(struct notifier_block *nb
 
 #else
 
-#   define compat_netif_napi_add(dev, napi, pollcb, quota) \
-   do {                        \
-      (dev)->poll = (pollcb);    \
-      (dev)->weight = (quota);\
-   } while (0)
 #   define compat_napi_schedule(dev, napi) netif_rx_schedule(dev)
 #   define compat_napi_enable(dev, napi)   netif_poll_enable(dev)
 #   define compat_napi_disable(dev, napi)  netif_poll_disable(dev)
@@ -311,11 +306,24 @@ static inline int compat_unregister_netdevice_notifier(struct notifier_block *nb
 /* RedHat ported GRO to 2.6.18 bringing new napi_struct with it */
 #   if defined NETIF_F_GRO
 #      define compat_napi_complete(dev, napi) napi_complete(napi)
+#      define compat_netif_napi_add(netdev, napi, pollcb, quota) \
+      do {                        \
+         (netdev)->poll = (pollcb);    \
+         (netdev)->weight = (quota);\
+         (napi)->dev = (netdev); \
+      } while (0)
+
 #   else
 #      define compat_napi_complete(dev, napi) netif_rx_complete(dev)
        struct napi_struct {
           int dummy;
        };
+#      define compat_netif_napi_add(dev, napi, pollcb, quota) \
+       do {                        \
+          (dev)->poll = (pollcb);    \
+          (dev)->weight = (quota);\
+       } while (0)
+
 #   endif
 
 #endif
similarity index 93%
rename from open-vm-tools/modules/shared/vmxnet/npa_defs.h
rename to open-vm-tools/modules/shared/vmxnet/shared/npa_defs.h
index aa531c608d0c4d3dbf16a59bb0896c0775eabc19..22881110a80e2b6a9e315ef4589a237c712e63f9 100644 (file)
@@ -35,6 +35,7 @@
 
 #define NPA_PLUGIN_NUMPAGES      64
 #define NPA_MEMIO_NUMPAGES       32
+#define NPA_SHARED_NUMPAGES      6
 #define VMXNET3_NPA_CMD_SUCCESS   0
 #define VMXNET3_NPA_CMD_FAILURE   1
 #define VMXNET3_PLUGIN_INFO_LEN  32
@@ -65,11 +66,21 @@ struct NPA_MemioPages {
 #include "vmware_pack_end.h"
 NPA_MemioPages;
 
+typedef
+#include "vmware_pack_begin.h"
+struct NPA_SharedPages {
+   PPN64  startPPN;
+   uint32 numPages;
+}
+#include "vmware_pack_end.h"
+NPA_SharedPages;
+
 typedef
 #include "vmware_pack_begin.h"
 struct NPA_PluginConf {
    NPA_PluginPages   pluginPages;
    NPA_MemioPages    memioPages;
+   NPA_SharedPages   sharedPages;
    uint64            entryVA;    // address of entry function in the plugin 
    uint32            deviceInfo[VMXNET3_PLUGIN_INFO_LEN]; // opaque data returned by PF driver
 }
index a0e4c5bb81497444aabafaed2dcaeb0f4facc3fb..f77f13b0b92a98b79281aecb029152806075a9ff 100644 (file)
@@ -441,8 +441,8 @@ vmxnet3_tx(void *data, mblk_t *mps)
    /* Notify the device */
    mutex_enter(&dp->txLock);
    if (txqCtrl->txNumDeferred >= txqCtrl->txThreshold) {
-      VMXNET3_BAR0_PUT32(dp, VMXNET3_REG_TXPROD, cmdRing->next2fill);
       txqCtrl->txNumDeferred = 0;
+      VMXNET3_BAR0_PUT32(dp, VMXNET3_REG_TXPROD, cmdRing->next2fill);
    }
    mutex_exit(&dp->txLock);