From nobody Tue Feb 10 03:16:03 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=1583798456; cv=none; d=zohomail.com; s=zohoarc; b=Hae3d2zBv8Q8yZ2mVm0P1q0ewva5h4yad+TGQlxN5YaJaMwylsyL+kySpS7R6Wa1XcneF0P198hzg6qmgN5F3XbpcBQa3eH2JlXKZ5M5PWLw75v10fU0SP5RZGkfcP2WL+GpLhzlrC9uzbNkitZuifVsluTcuT//FEy8xVLS6ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583798456; 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=xeXTfkCIs233YAHIBuNOs5RVrM+SnIVuZZRDkCcUbG8=; b=LI2fpGhMR5CM2FmMq7lV2K5RxAkohyTqMEMsGdwg+cNxwefhgJDhRRdwDHeGM3czqyIoyuCrNLF34jlRNGF8CF7tLoTAaAtNy1ZGqw3XoNup+18/BD0UY/oiHlq0sHzqRHrWQomQNKFxfj0d8T8TZan+64w9drYpC0pWhBbF1KQ= 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 1583798456006293.0605273175538; Mon, 9 Mar 2020 17:00:56 -0700 (PDT) Received: from localhost ([::1]:51748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSKL-00082N-HB for importer@patchew.org; Mon, 09 Mar 2020 20:00:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCn-00063Y-Ui for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCm-00072B-OX for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:05 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCm-00070l-Go for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:04 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029NqUus147112; Mon, 9 Mar 2020 23:53:02 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ym31ua669-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:53:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029NqxYu095547; Mon, 9 Mar 2020 23:53:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2ymnb1kas9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:53:02 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqkGp027472; Mon, 9 Mar 2020 23:52:46 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:46 -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=xeXTfkCIs233YAHIBuNOs5RVrM+SnIVuZZRDkCcUbG8=; b=rrrl1qWpMGGG89rzRbjnZnfdaojjnaRIBAD9jOBuCh6K38uptGNjoM1knYgmTej1Thos 9QBRfWqT6oT97O7MUi0WX7fe1N/OGgr5XRlX4Y1xuBniMnfPpsvNkp1tG81jcqjiuNV1 avH9eFIATpMPQruPTtHAMzh8O2NNqZM6tTFKMVN8mvhuS4WQCLaKgdHdqXGBHfqkSoqC KmmbaU3XP9XyxxG0DChrHGPlAvrdhBqA2ahKMDFEbS8y79e84o3a44PIA3opyxh0/X9e yAg9f8TDTgxISo6jP/RJ+qeKLNz987YKOut8C8zQ7QCwPsb/S7T8REqSU6noiLupuJe3 Ew== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 13/14] hw/i386/vmport: Add support for CMD_GETHZ Date: Tue, 10 Mar 2020 01:54:10 +0200 Message-Id: <20200309235411.76587-14-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=1 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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/pc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 2b0a623f19c1..95d4a23ce9ba 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -150,6 +150,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); @@ -237,6 +255,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL= ); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, 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, NU= LL); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index e880ca39ee3b..679bf429c6a5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -146,6 +146,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