From nobody Mon Feb 9 10:44:14 2026 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=1584033242; cv=none; d=zohomail.com; s=zohoarc; b=mxCzS3AY1ni36FiTk8xItS1AtuGXMr6Cl3AoeInlGO8un/7BUI6UIpgfBIWQQqC6rNiXKK0RnMR40QwZqdQJzHkYMDspi7EdzW226pWWIiSPfwA0NxI9osKwcnNcuh8HwkFuuLW/n7bEWD7R6XaPmccAzTabsJoRqHd05WfXTTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584033242; 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=fbLv/CerSDaSAWfb6IF36JDddIIq1GrRFsqGjoitlpI=; b=itHRLx4WW4J/lNmY2ilPVlnSbZy03tALZUVOxKbTnA4RojaxsLYBZLa1W0fx4u0+nvbtlje3TBLWb+M+rkqcWy/GRiIB3iQJXJ5WkdP+rYgJSadP837Lzl3kDdh1LJjn/EWr/YWfXoolYN4UFffY9RolfXBZ55IAOrvcQPJZxFs= 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 1584033242058116.70641849925767; Thu, 12 Mar 2020 10:14:02 -0700 (PDT) Received: from localhost ([::1]:46312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCRPE-00021f-Ut for importer@patchew.org; Thu, 12 Mar 2020 13:14:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37157) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCR52-0003Zw-7N for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCR51-0000s0-18 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:53:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60610) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCR50-0000qM-PJ for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:53:06 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGnRIe189541; Thu, 12 Mar 2020 16:53:03 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yqkg8a04p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:53:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02CGoOaB123129; Thu, 12 Mar 2020 16:53:03 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2yp8r0sp8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Mar 2020 16:53:02 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02CGr1cl032463; Thu, 12 Mar 2020 16:53:02 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Mar 2020 09:53:01 -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=fbLv/CerSDaSAWfb6IF36JDddIIq1GrRFsqGjoitlpI=; b=alKijP9CSv8C+KTJ+hy3O0ciywO2UBUO1tm8oWDoSnyfE2Tnrym4+ZFcpRfIZxcIyO9X dZy+Aa6VXNJ1n1NPr8EmUCwkGWVI19MY6R9n3Cs/d8cwrChzxS9lQDJ3VyASdvBza6g7 WYGDSLa8J1BddQqoXyS9/IKEMEO7ektwAUnN8uSUaO0LzKsVimFGTj189T+rinHIF7c2 VGrKWJMS9CQfB1snK/ZxDwWeB0bEKVW4sOVQkp0+Pr4VdLIOnn7l9Ahk3TSVY8eiLkFo nV0PEnh3reib1oLp9P5riDmw/UIsIFKUNU3sJ3MmaxM+KNDHxA/39tI7zY2WgS4U/hHS ZA== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v3 15/16] hw/i386/vmport: Add support for CMD_GETHZ Date: Thu, 12 Mar 2020 18:54:30 +0200 Message-Id: <20200312165431.82118-16-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 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=1 bulkscore=0 spamscore=0 mlxlogscore=999 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 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 suspectscore=1 bulkscore=0 mlxscore=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: 156.151.31.85 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 returns to guest information on LAPIC bus frequency and TSC frequency. One can see how this interface is used by Linux vmware_platform_setup() introduced in Linux commit 88b094fb8d4f ("x86: Hypervisor detection and get tsc_freq from hypervisor"). Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 19 +++++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 1664a6b97332..9d3921cf418d 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -176,6 +176,24 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint= 32_t addr) return ram_size; } =20 +static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + + if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) { + uint64_t tsc_freq =3D (uint64_t)cpu->env.tsc_khz * 1000; + + cpu->env.regs[R_ECX] =3D cpu->env.apic_bus_freq; + cpu->env.regs[R_EBX] =3D (uint32_t)(tsc_freq >> 32); + cpu->env.regs[R_EAX] =3D (uint32_t)tsc_freq; + } else { + /* Signal cmd as not supported */ + cpu->env.regs[R_EBX] =3D UINT32_MAX; + } + + return cpu->env.regs[R_EAX]; +} + static uint32_t vmport_cmd_time(void *opaque, uint32_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); @@ -265,6 +283,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) 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); + vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL); vmport_register(VMPORT_CMD_GETTIMEFULL, vmport_cmd_time_full, NULL= ); vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, NULL); diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 34cc050b1ffa..aee809521aa0 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -12,6 +12,7 @@ typedef enum { VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_CMD_GETHZ =3D 45, VMPORT_CMD_GETTIMEFULL =3D 46, VMPORT_CMD_GET_VCPU_INFO =3D 68, VMPORT_ENTRIES --=20 2.20.1