]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add backdoor support for host time of day in Arm
authorJohn Wolfe <jwolfe@vmware.com>
Thu, 20 May 2021 18:38:38 +0000 (11:38 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Thu, 20 May 2021 18:38:38 +0000 (11:38 -0700)
The timeSync plugin makes backdoor calls to get host time of day.
Update the time of day backdoor calls to function with the Arm
backdoor implementation.  Also fix a bug where an error returned
by the GETTIME backdoor handler is incorrectly treated as a time value.

open-vm-tools/services/plugins/timeSync/timeSync.c
open-vm-tools/toolbox/toolboxcmd-stat.c

index 514078075c62be4c254577df47ca63d7613f8cbe..f2f2c1ed910281519f1c7ff1634022c29db646e8 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2021 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
@@ -275,7 +275,15 @@ TimeSyncReadHost(int64 *host, int64 *apparentError, Bool *apparentErrorValid,
                  "attempting BDOOR_CMD_GETTIME\n");
          bp.in.cx.halfs.low = BDOOR_CMD_GETTIME;
          Backdoor(&bp);
-         hostSecs = bp.out.ax.word;
+         /*
+          * This backdoor returns uint32 time value in bp.out.ax.word or
+          * MAX_UINT32 in case of error.
+          */
+         if (bp.out.ax.word == MAX_UINT32) {
+            hostSecs = -1;
+         } else {
+            hostSecs = bp.out.ax.word;
+         }
       }
    }
    hostUsecs = bp.out.bx.word;
index cdd3a70536dd94858fc67be7d940de84c15f1a49..5e8201a5d3f02326b971e7d12410a8f1e61b6439 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2008-2016,2019 VMware, Inc. All rights reserved.
+ * Copyright (C) 2008-2021 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
@@ -144,7 +144,15 @@ StatHostTime(void)
       /* Falling back to older command. */
       bp.in.cx.halfs.low = BDOOR_CMD_GETTIME;
       Backdoor(&bp);
-      hostSecs = bp.out.ax.word;
+      /*
+       * This backdoor returns uint32 time value in bp.out.ax.word or
+       * MAX_UINT32 in case of error.
+       */
+      if (bp.out.ax.word == MAX_UINT32) {
+         hostSecs = -1;
+      } else {
+         hostSecs = bp.out.ax.word;
+      }
    }
    hostUsecs = bp.out.bx.word;