From nobody Fri Nov 14 00:55:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1584033035; cv=none; d=zohomail.com; s=zohoarc; b=F6OQtWBbHyhqn/HJ01YxvbqjvC7SN6LE3ZSmCLEf2fvXZBcirjCC2uLkM5kplU15DKz7SCCeqB4UQXUHLQzj5gqTTJ4oz0bLYqMdHRiC7oM9h9MoFFkzNS0iEX2R2c/bKm1x7YOHbpK8VfHLVdb9kxslVbd9h2gWi+TnfVruuk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584033035; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FKCUnH7M6yII73DL3cJNRCcCrSaiey8Karm452GgPFQ=; b=HBAIlwQPoUI3kxLnLprIYlePM8+/oNyI5uqL6wyzXC0XyQs2n/5W7Xu5auJeyktM9mgA4YWbr3Uf/J1DOZ+ZL5bgdptLYXlbGGXDyL/il9GTdC93gEofQ9l8OY5dnblzQKtmF/y7Dl2t868R9fPMPWLtMHJ2zsaEtySecl6GnuU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15840330350531001.3219910194188; Thu, 12 Mar 2020 10:10:35 -0700 (PDT) Received: from localhost ([::1]:46202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCRLt-0000gZ-VE for importer@patchew.org; Thu, 12 Mar 2020 13:10:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37052) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCR4n-0002xQ-87 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCR4l-0000Wi-Qt for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:53 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCR4l-0000UE-Iu for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:52:51 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGmcS9177888; Thu, 12 Mar 2020 16:52:49 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yp9v6dw5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:52:49 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGoOpd065919; Thu, 12 Mar 2020 16:52:49 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2yqkvn0g09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:52:48 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02CGqmaV030549; Thu, 12 Mar 2020 16:52:48 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Mar 2020 09:52:48 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=FKCUnH7M6yII73DL3cJNRCcCrSaiey8Karm452GgPFQ=; b=b8FYI4FfGn/0xCb0BrMT8cYLXgwxkTYi93pTwWk3Bw/Sq6UdgyUAITps+GRtK4REMaYI iY4Z1S2mZia1uTkRBC7Heu5CQt74q2ezD5XyU9CAVCI21SdTVeBGGNK54O4MMRJ7Xtfi /CKsS+XCBbEiNfal9cPrcC6aGbFgxIdyV5nFwt1vqAGHdYD1EpjlgsGuumQKl+424vTL S22qdhv9nVB3/RGLSo6pTIoSlg2gWU3fY3xX2NcJpJ7J7wTxg2qUZOTGBytCHVeDLipm X44SRHphPsRC5rIon/L46Pvnra6oz0VsnJXZduZ37ebwCxL3r6RNKZDJpXqpZFgz/AGf LQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v3 10/16] hw/i386/vmport: Add support for CMD_GETTIME Date: Thu, 12 Mar 2020 18:54:25 +0200 Message-Id: <20200312165431.82118-11-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312165431.82118-1-liran.alon@oracle.com> References: <20200312165431.82118-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9558 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 mlxlogscore=999 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9558 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003120085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This command is used by guest to gettimeofday() from host. See usage example in open-vm-tools TimeSyncReadHost() function. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 21 +++++++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 22 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 3fb8a8bd458a..c5b659c59343 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -66,6 +66,7 @@ typedef struct VMPortState { =20 uint32_t vmware_vmx_version; uint8_t vmware_vmx_type; + uint32_t max_time_lag_us; =20 uint32_t compat_flags; } VMPortState; @@ -168,6 +169,20 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint= 32_t addr) return ram_size; } =20 +static uint32_t vmport_cmd_time(void *opaque, uint32_t addr) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + qemu_timeval tv; + + if (qemu_gettimeofday(&tv) < 0) { + return UINT32_MAX; + } + + cpu->env.regs[R_EBX] =3D (uint32_t)tv.tv_usec; + cpu->env.regs[R_ECX] =3D port_state->max_time_lag_us; + return (uint32_t)tv.tv_sec; +} + /* vmmouse helpers */ void vmmouse_get_data(uint32_t *data) { @@ -214,6 +229,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); if (s->compat_flags & VMPORT_COMPAT_CMDS_V2) { vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); } } =20 @@ -249,6 +265,11 @@ static Property vmport_properties[] =3D { * 5 - ACE 1.x (Deprecated) */ DEFINE_PROP_UINT8("vmware-vmx-type", VMPortState, vmware_vmx_type, 2), + /* + * Max amount of time lag that can go uncorrected. + * Value taken from VMware Workstation 5.5. + **/ + DEFINE_PROP_UINT32("max-time-lag", VMPortState, max_time_lag_us, 10000= 00), =20 DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 7f33512ca6f0..50416c8c8f3e 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -8,6 +8,7 @@ typedef enum { VMPORT_CMD_GETVERSION =3D 10, VMPORT_CMD_GETBIOSUUID =3D 19, VMPORT_CMD_GETRAMSIZE =3D 20, + VMPORT_CMD_GETTIME =3D 23, VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, VMPORT_CMD_VMMOUSE_COMMAND =3D 41, --=20 2.20.1