From nobody Mon Feb 9 08:50:29 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=1583859162; cv=none; d=zohomail.com; s=zohoarc; b=bHTD9mM5fKJSqN1UW5zAF84QpFOgOrYgshFqFMGa/k25B8fgDM5VSlhPKHbQ0uT8KZt+PyKvGIr3K09oHUQwsuT7xncuL53HSpA31DN7LgRYQIMEXF2sCp7XE/jyZiz2hnPQSg8Y7ihYZZ3O3Ecq3gKUXoDunOg9Fy98U03FSN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859162; 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=mei2EqRHDoIbj238QEoyYX9NFE7ZUEKqjZS+ZpUU6U0=; b=UgDIOs7nEg6MNvemxUk3R1jLU7IEkHgSXT5OkfgOE5KUHa4cqyrDBXFHcybiMqV/MbtRiVXaqaxodKo2ELOQovg5Jg3k2JDc5tvmhFebEnPkrUWFqJfgR1umiuEbL5jPB9FwSGluaHk57gVWXlzW2g3JlmWVtEErg+6z8XMgPy8= 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 1583859162448793.881896973674; Tue, 10 Mar 2020 09:52:42 -0700 (PDT) Received: from localhost ([::1]:36894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi7S-0007f5-SO for importer@patchew.org; Tue, 10 Mar 2020 12:52:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49164) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6Q-0006Jt-Lv for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6O-0005C2-Jy for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:34 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6O-00050F-BU for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:32 -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 02AGcSox085222; Tue, 10 Mar 2020 16:51:29 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ym31ueteg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:29 +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 02AGbY5H030179; Tue, 10 Mar 2020 16:51:29 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2yp8rjyg5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:28 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpSND031524; Tue, 10 Mar 2020 16:51:28 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:27 -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=mei2EqRHDoIbj238QEoyYX9NFE7ZUEKqjZS+ZpUU6U0=; b=FqATn5+ONdulJapkNQDmuX+Gx3RjOLqodUtV9lBmGjpSzeVXrvr9DVh94Lpb7kwnAQhn pDKMZd1RBnfsY8Gn9flI0VJdJIdoYiWbAKChq+fLgNfQrD6ihf6YvIhg1QvufgrmcH+G H9UnLx9VeotI/BBbJIaSZPTCL/ahKK8dkLDF7LBIF+3W8Pq1rpPWsHVytPzLVzpvSj+E gbJptTrTQ4sRibA97YfBwxO1CvNuftkx1pllJsw6QJhlMQ/WC+/kg1qPxO6Cr5WBfeTY xjqJPj310Lz6I/jxV/fJhYH03n+AHn4S0i4kflziI8eI3L/W7JR2bglfwNlSldEnHqk9 sg== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 01/16] hw/i386/vmport: Add device properties Date: Tue, 10 Mar 2020 18:53:17 +0200 Message-Id: <20200310165332.140774-2-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" No functional change. This is done as a preparation for the following patches that will introduce several device properties. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 1f31e27c8aa4..8d7513e2a23c 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -25,6 +25,7 @@ #include "hw/isa/isa.h" #include "hw/i386/pc.h" #include "hw/input/i8042.h" +#include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "trace.h" @@ -154,6 +155,10 @@ static void vmport_realizefn(DeviceState *dev, Error *= *errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); } =20 +static Property vmport_properties[] =3D { + DEFINE_PROP_END_OF_LIST(), +}; + static void vmport_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -161,6 +166,7 @@ static void vmport_class_initfn(ObjectClass *klass, voi= d *data) dc->realize =3D vmport_realizefn; /* Reason: realize sets global port_state */ dc->user_creatable =3D false; + device_class_set_props(dc, vmport_properties); } =20 static const TypeInfo vmport_info =3D { --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859272; cv=none; d=zohomail.com; s=zohoarc; b=ILFEC52BZqo6RkH73GoWck3lG47fwIQELSdNl2t6uTKzoJnzxjyKIjDa8LunwZStr9M+5F0b37rP4rgOby+qobAhdqrilDQfEtElpHLgtflZjHyDmbhIY5UrJ/4MOLpjpBen/2V8y1Ype5sYOMuoWbLBXMhmxYJA60UO67E9lWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859272; 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=mpcf7favVlwULOZ6B5KpaVIfHziy38c68GzKP0xzj8s=; b=H4gJA2E6p0JFe4Qw23USJBBDuQh/+n6j8/wkc3cZIoL08gFKIZo+0RTyimEnbkqXVDLPacic0ftG+hyLijYRSSbq8maYd6BNwYeO5nhJ3+NUpsQ/aGs7WeY84ZAqAPZMK3fQ9S6jbYQRxvz2arBqlfNacBbzdr21GwzKdKJvkwM= 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 1583859272779425.47545058154344; Tue, 10 Mar 2020 09:54:32 -0700 (PDT) Received: from localhost ([::1]:36952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi9H-0002ix-RG for importer@patchew.org; Tue, 10 Mar 2020 12:54:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49227) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6T-0006M6-96 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6R-0005Qa-94 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6R-0005F0-00 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:35 -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 02AGcP8L010681; Tue, 10 Mar 2020 16:51:32 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2yp9v61vb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:32 +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 02AGbHDn102146; Tue, 10 Mar 2020 16:51:31 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2yp8qp6cn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:31 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpURI011357; Tue, 10 Mar 2020 16:51:30 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:29 -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=mpcf7favVlwULOZ6B5KpaVIfHziy38c68GzKP0xzj8s=; b=isddHPJJUihlysdwj0NY1FG+X7Ffbg6msGJSgrSB3EwB4/k/2um9fFgB93PK5IaNHtdi 22nxq4C3uvnnJwKXIPN8tMOSLKuFrOr9UioWlFDGcaTMUn0fR67RJ0tRi7GqcXvMgkZM SEkMAjQ7WWP4uYcSh54WhThr4L2i6jVwhBADjGMHaItM2ZEogqGxKSNFu1sc5puKQjnR XQww0aL0RGH24thMPBbzy/ys82SPawHjuQ8qu84RMRDG+9iSjRBoEZjVgHpZ1I4MZukw vlS884Lx4FnmyogdjNyIp0QK6IfV2ZlUGRsFWXkgdtsPtbxzVoUXhL9QCcgrpI/0AgWb 9A== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 02/16] hw/i386/vmport: Add compatability version field Date: Tue, 10 Mar 2020 18:53:18 +0200 Message-Id: <20200310165332.140774-3-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" No functional change. This is done as a preparation for the following patches which will change guest-visible behavior. Adding this version field will allow us to maintain migration compatability from new QEMU version to old QEMU version (Given machine-type is the compatabile). Signed-off-by: Liran Alon --- hw/i386/vmport.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 8d7513e2a23c..ca4d95fc017f 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -44,6 +44,8 @@ typedef struct VMPortState { MemoryRegion io; VMPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; + + uint8_t version; } VMPortState; =20 static VMPortState *port_state; @@ -156,6 +158,12 @@ static void vmport_realizefn(DeviceState *dev, Error *= *errp) } =20 static Property vmport_properties[] =3D { + /* + * Used to enforce compatibility for migration. + * On every guest-visible change, should make changes conditioned on + * version and define proper version for previous machine-types. + */ + DEFINE_PROP_UINT8("version", VMPortState, version, 1), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859178; cv=none; d=zohomail.com; s=zohoarc; b=EgbYSFRIAFcTcShySLyF0c0Ds7/TmTScyGOJreUrbvg/JrfdNQhFP8S+j13QRwPMN1CNL41GgsiOazL/DwMdcf+tLqiJQlozX/4JCNjFfH27gakSrjPrfiB2atKCKdvz0/yL7FcDCVtbsVYe+cndgCzs2FpbvZHYuaAPf+js2mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859178; 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=HZDCswLkofKqT1CocQZaTBU9Ra3S3FQjSz77kMT5qfA=; b=TCFuagielGoOJBEpG0tsMF52duDd/m5J1awHkFtVwOE3J92OwKPQQyxf9GPhmHxb+YbUnoMdn7/4fLccWeVXKN9+y6MJn0oG1lunaHZL9Cn48X6vqrsT7ozBtzP6iSTgOWUnYdNycup6nuy15x5R5VYyIF5fWP2TQMPSZrCJ1/A= 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 1583859178869804.1232402022815; Tue, 10 Mar 2020 09:52:58 -0700 (PDT) Received: from localhost ([::1]:36902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi7k-0008Dz-To for importer@patchew.org; Tue, 10 Mar 2020 12:52:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49230) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6T-0006M8-CA for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6S-0005WS-8i for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:37 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6S-0005Re-0Z for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:36 -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 02AGdJge103990; Tue, 10 Mar 2020 16:51:34 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2yp7hm35ps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:33 +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 02AGcJCW054662; Tue, 10 Mar 2020 16:51:33 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2yp8psg44c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:33 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpWSR030590; Tue, 10 Mar 2020 16:51:32 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:32 -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=HZDCswLkofKqT1CocQZaTBU9Ra3S3FQjSz77kMT5qfA=; b=CwpQ+pl79x/dDIeL4LAnAwscBkf3c4/qf2+hHL8DECC21B5bPm0yqqkpf97wX6Ge3IRK 5RX4Hn7SZ34jBamY8hpbRLKGIiEBAZlQVqbrhniaK3RtD+Ch1YxTq0mLDwV5ZJdDBk0g 8SlFs8o97OufwtoVcuRnFEgK/2D0LAaQuHlz6zaCwNPTVo2tmc8oGv+mLSAJSjLvWETj mo+CfGa2ch5APfuZhmI90kRt5JwnuaLNlNmXyY9rNnp1kKLtCo9/GlUgtkEHQgZQvjlk 6h3BsM8g5G91tPBW+7o89Bn4vP1jvJH6ERa/rQLjgGYHJXWLrl4YViada2uuu63VXAHR fg== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 03/16] hw/i386/vmport: Propagate IOPort read to vCPU EAX register Date: Tue, 10 Mar 2020 18:53:19 +0200 Message-Id: <20200310165332.140774-4-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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" vmport_ioport_read() returns the value that should propagate to vCPU EAX register when guest reads VMPort IOPort (i.e. By x86 IN instruction). However, because vmport_ioport_read() calls cpu_synchronize_state(), the returned value gets overridden by the value in QEMU vCPU EAX register. i.e. cpu->env.regs[R_EAX]. To fix this issue, change vmport_ioport_read() to explicitly override cpu->env.regs[R_EAX] with the value it wish to propagate to vCPU EAX register. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/core/machine.c | 1 + hw/i386/vmport.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9e8c06036faf..b9da40460d52 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ GlobalProperty hw_compat_4_2[] =3D { { "usb-redir", "suppress-remote-wake", "off" }, { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, + { "vmport", "version", "1" }, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index ca4d95fc017f..736d78263889 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -75,17 +75,33 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, =20 eax =3D env->regs[R_EAX]; if (eax !=3D VMPORT_MAGIC) { - return eax; + goto out; } =20 command =3D env->regs[R_ECX]; trace_vmport_command(command); if (command >=3D VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - return eax; + goto out; } =20 - return s->func[command](s->opaque[command], addr); + eax =3D s->func[command](s->opaque[command], addr); + +out: + /* + * The call above to cpu_synchronize_state() gets vCPU registers values + * to QEMU but also cause QEMU to write QEMU vCPU registers values to + * vCPU implementation (e.g. Accelerator such as KVM) just before + * resuming guest. + * + * Therefore, in order to make IOPort return value propagate to + * guest EAX, we need to explicitly update QEMU EAX register value. + */ + if (s->version > 1) { + cpu->env.regs[R_EAX] =3D eax; + } + + return eax; } =20 static void vmport_ioport_write(void *opaque, hwaddr addr, @@ -163,7 +179,7 @@ static Property vmport_properties[] =3D { * On every guest-visible change, should make changes conditioned on * version and define proper version for previous machine-types. */ - DEFINE_PROP_UINT8("version", VMPortState, version, 1), + DEFINE_PROP_UINT8("version", VMPortState, version, 2), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859383; cv=none; d=zohomail.com; s=zohoarc; b=L+pmdEarP7bkspSFhbPRnKeJ9JFEdXkZfffIW4XmxcRNct1kQ+pSW1bKUty9b6LgUfew1U7nN4NkNKg9lIBdATkt8nvIpZDCUklvgR83sQgeZQLvQ2iargY0c80ZXVXtSeWrC/zW0n5zTv6w3vDtBRJVBetBK5dHV7ivjuoJxj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859383; 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=U32aodggjpFbRI9pQdgcDhChVONF+RTDX2KHaPvvSBU=; b=F7iOS8btB3IfNke8A245gK9sMnuJeY7XalL8/l/m9xNh5wCnwhunhP2XHD4mrKxr6PxhppUtjqx6KxuVKFhTchrFyrXIztbj+GLU3OQlkUpNOKi+FWnJxFnWWXxeeiX8fSYnAUVkp3HgI7tmHCWJxhxZw6sTvTbbMRpHltKzNwQ= 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 1583859383560166.785467403589; Tue, 10 Mar 2020 09:56:23 -0700 (PDT) Received: from localhost ([::1]:36998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiB4-0005Kl-DL for importer@patchew.org; Tue, 10 Mar 2020 12:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6V-0006Py-Ar for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6U-0005gR-63 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:39 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6T-0005ce-Ty for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:38 -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 02AGdL8a104000; Tue, 10 Mar 2020 16:51:36 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yp7hm35pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:36 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02AGcOfS053104; Tue, 10 Mar 2020 16:51:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2yp8nu24su-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:35 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpYfm001913; Tue, 10 Mar 2020 16:51:34 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:34 -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=U32aodggjpFbRI9pQdgcDhChVONF+RTDX2KHaPvvSBU=; b=I/jfGyPos0ezCP3qj5dWTo8LcbVXuPc6zC8oD4fp/jOpvt2gvmf6LcpptYjsSih7VM36 BxqPjV9JsiQramPNaPRbhgTqE65amCeqxuPvVB9r1uSs2ZRnn+DpUlWyOpYnC/uzDZDb 0m4qQn+noqVbUYFbPrfVFYYM+QAcnVtTNgG4GncVW93R7I1b29EaRmxI4l3JGyKn3H9Z 57wdRvJQDg2tZrvjn81nT+cTMT4kI1U8l7f/6Cx9ULyTTnxuWEC6WPgG3PXze1QcIS0z Z94wouySSU+H6sNw/Ixp2e5Ilf1uAVJEiMc4zYFUzbcTpGxw7GNhm9yrX77WTnNolZE7 MQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 04/16] hw/i386/vmport: Set EAX to -1 on failed and unsupported commands Date: Tue, 10 Mar 2020 18:53:20 +0200 Message-Id: <20200310165332.140774-5-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=1 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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 is used as a signal for VMware Tools to know if a command it attempted to invoke, failed or is unsupported. As a result, VMware Tools will either report failure to user or fallback to another backdoor command in attempt to perform some operation. A few examples: * open-vm-tools TimeSyncReadHost() function fallbacks to CMD_GETTIMEFULL command when CMD_GETTIMEFULL_WITH_LAG fails/unsupported. * open-vm-tools Hostinfo_NestingSupported() function verifies EAX !=3D -1 to check for success. * open-vm-tools Hostinfo_VCPUInfoBackdoor() functions checks if reserved-bit is set to indicate command is unimplemented. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 736d78263889..8115852720c8 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -75,17 +75,23 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, =20 eax =3D env->regs[R_EAX]; if (eax !=3D VMPORT_MAGIC) { - goto out; + goto err; } =20 command =3D env->regs[R_ECX]; trace_vmport_command(command); if (command >=3D VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - goto out; + goto err; } =20 eax =3D s->func[command](s->opaque[command], addr); + goto out; + +err: + if (s->version > 1) { + eax =3D UINT32_MAX; + } =20 out: /* --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859276; cv=none; d=zohomail.com; s=zohoarc; b=aTMfASq+7RLS46BgVPoMVwGPnvt4VAV/+iE08TamWG13HiTmNcHnpnRJGLMAg13y90dfcabK+q4mzSh3jyz7a4TpnaxyZDvTN0s9x7Rf2lJTTiP+AJRTQgB+4iL7MtqZB0efTlGqeiDjdRmqWbNqOS4D3GBtJAGZBDv1U00wmtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859276; 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=VlJbFXph1o3QpRz6r1wPDq062qzt3UTQfdX2PanQWGY=; b=jSKw7ZhETWQZarB0IfOGpZWOA7c4eC2h7cULiOW/dg/FxoucH1xf2nWkqcxM1qujF8px19OdbFkyWouqSoFJE+L/4871kiuGS79nteFLB6mtmsj18n1IDo1uSNEke/gnlYhVj4pxiB6DJXe871HoDloHvllpw7TGH8RfYFZe3qc= 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 1583859276025844.4551449185858; Tue, 10 Mar 2020 09:54:36 -0700 (PDT) Received: from localhost ([::1]:36956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi9L-0002q5-2g for importer@patchew.org; Tue, 10 Mar 2020 12:54:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6Y-0006Vk-Kz for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6X-000617-Ht for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:42 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6X-0005wf-9k for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:41 -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 02AGcLqe010615; Tue, 10 Mar 2020 16:51:40 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2yp9v61vc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:39 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02AGcOu0053103; Tue, 10 Mar 2020 16:51:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2yp8nu255n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:39 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpbM3011502; Tue, 10 Mar 2020 16:51:38 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:37 -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=VlJbFXph1o3QpRz6r1wPDq062qzt3UTQfdX2PanQWGY=; b=DBsk2csZdrrwHc5JwovVme3G5Cjdia4aqJANEr8Pzix+B2eacHLEf/ToU4F7PbuCg+pa 8RlnXauhyFm4VCokDTOxMGJNGYOxrUWMCgKgGUh1mmctqYcPFEM6WAhG7Wyzcc2mcuEW 0VtOvlhPAnVSwGTIszY/igDufS0djtjWqo24YqBfiS0ZCbsMmzFeKugZD0CEpo1WgFVa f1J5mhDI5DkRUJnGBPNep1f0CO7/DmbXaJpTs/0/h6htf48T64ZMwTzc2htN0sZ63O+1 LWRDg5pF9lkqmv0shl21M+/Q6KwSQ6O0hH/PHg+sUVFg1QZmUJOSDi9uhchVtzu6NU4k RQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 05/16] hw/i386/vmport: Introduce vmx-version property Date: Tue, 10 Mar 2020 18:53:21 +0200 Message-Id: <20200310165332.140774-6-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=1 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" In VMware terminology, VMX is the name of VMware VMM. Short for Virtual Machine eXecutable. (Do not confuse with Intel VT-x which is also often named VMX). vmx-version is a number returned from CMD_GETVERSION which specifies to guest VMware Tools the the host VMX version. If the host reports a number that is different than what the guest VMware Tools expects, it may force guest to upgrade VMware Tools. (See comment above VERSION_MAGIC and VmCheck_IsVirtualWorld() function in open-vm-tools open-source code). For better readability and allow maintaining compatability for guests which may expect different vmx-version, make vmx-version a VMPort object property. This would allow user to control it's value via "-global vmport.vmx-version=3DX". Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 8115852720c8..0d3f19b0bb71 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -45,6 +45,8 @@ typedef struct VMPortState { VMPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; =20 + uint32_t vmx_version; + uint8_t version; } VMPortState; =20 @@ -123,7 +125,7 @@ static uint32_t vmport_cmd_get_version(void *opaque, ui= nt32_t addr) X86CPU *cpu =3D X86_CPU(current_cpu); =20 cpu->env.regs[R_EBX] =3D VMPORT_MAGIC; - return 6; + return port_state->vmx_version; } =20 static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) @@ -186,6 +188,10 @@ static Property vmport_properties[] =3D { * version and define proper version for previous machine-types. */ DEFINE_PROP_UINT8("version", VMPortState, version, 2), + + /* Default value taken from open-vm-tools code VERSION_MAGIC definitio= n */ + DEFINE_PROP_UINT32("vmx-version", VMPortState, vmx_version, 6), + DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859385; cv=none; d=zohomail.com; s=zohoarc; b=jmkGfypZaeM5T/poVakeWnvHjKhrRWvBkTXn5coVncwryPfIUuxdFM+WtFgS+mczzu0g+JjZ9ktop1rby9g00hRd3IRVPMEr/fn+oeJ/rPwVG+8P1oNdUfj4Xhj5XprVlof6G2WtejBSFpuq0wk4+QgM7YAeNaD5DXFfxTI2SSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859385; 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=UQjy1VwWA2VcbtHOtRUI+1J6Ijx9B1l+DyoKZk7XItI=; b=AefGU7a+TahyK7YeJ3gYeh5GuwPvfKCj0AqVr3dqv7EWhTtuQJbv2ML07A6tRH9gEfR0LIbyf7DjsObiVUCMc0XvPYGUgzNchNAAYSrsCbqU9Zt10WXJsfwoJds1st8mSqz3N6oBe38QosnLi9bjbgVqK2wPVa73+PTDlNB94wk= 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 1583859385472168.65845553981103; Tue, 10 Mar 2020 09:56:25 -0700 (PDT) Received: from localhost ([::1]:37002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiB6-0005O1-DG for importer@patchew.org; Tue, 10 Mar 2020 12:56:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49420) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6a-0006YD-J2 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6Z-0006GA-Io for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:44 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6Z-00066e-87 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:43 -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 02AGcLo8010592; Tue, 10 Mar 2020 16:51:41 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2yp9v61vcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:41 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02AGcOsm053102; Tue, 10 Mar 2020 16:51:40 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2yp8nu25af-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:40 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpenU030680; Tue, 10 Mar 2020 16:51:40 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:39 -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=UQjy1VwWA2VcbtHOtRUI+1J6Ijx9B1l+DyoKZk7XItI=; b=OmhoJ0RpWL/ZcDxZjFoedbPkGT9uIbQYIJ1Iu5flnQUqcv/I4lmhQYCrgSjG5Hi/prJM 2FwO4ysKTFJjdzzGC2e6gBrpFV4Wu6gvQyKEFo+/pQmoEVP8Q6m4PExkvNA/rPrHMNJZ LMLnq0zFP4CVrxzxvRoVxqg3DBmVGTcqOPi+99g7meq+JDqW0gMevE5T+ywTO6v6h2Yc czD5W/Ycd9tqurm8LGfMEyrfAO2osBMEF+SxDskWIXo+zEOmAknaBcw4pY06n985tZed dQI9JUBpkYmPPiPBvW4J47rxFw+okHvy6kLl4C3GLmALckewO0vem+PSkpZofCBmF9u6 aA== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 06/16] hw/i386/vmport: Report VMX type in CMD_GETVERSION Date: Tue, 10 Mar 2020 18:53:22 +0200 Message-Id: <20200310165332.140774-7-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=1 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" As can be seen from VmCheck_GetVersion() in open-vm-tools code, CMD_GETVERSION should return VMX type in ECX register. Default is to fake host as VMware ESX server. But user can control this value by "-global vmport.vmx-type=3DX". Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 0d3f19b0bb71..973f3f6448e9 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -36,6 +36,16 @@ #define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 =20 +/* Enum taken from open-vm-tools lib/include/vm_vmx_type.h */ +typedef enum { + VMX_TYPE_UNSET =3D 0, + VMX_TYPE_EXPRESS, /* Deprecated type used for VMware Express */ + VMX_TYPE_SCALABLE_SERVER, /* VMware ESX server */ + VMX_TYPE_WGS, /* Deprecated type used for VMware Server */ + VMX_TYPE_WORKSTATION, + VMX_TYPE_WORKSTATION_ENTERPRISE /* Deprecated type used for ACE 1.x */ +} VMXType; + #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 typedef struct VMPortState { @@ -46,6 +56,7 @@ typedef struct VMPortState { void *opaque[VMPORT_ENTRIES]; =20 uint32_t vmx_version; + uint8_t vmx_type; =20 uint8_t version; } VMPortState; @@ -125,6 +136,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, ui= nt32_t addr) X86CPU *cpu =3D X86_CPU(current_cpu); =20 cpu->env.regs[R_EBX] =3D VMPORT_MAGIC; + if (port_state->version > 1) { + cpu->env.regs[R_ECX] =3D port_state->vmx_type; + } return port_state->vmx_version; } =20 @@ -191,6 +205,8 @@ static Property vmport_properties[] =3D { =20 /* Default value taken from open-vm-tools code VERSION_MAGIC definitio= n */ DEFINE_PROP_UINT32("vmx-version", VMPortState, vmx_version, 6), + DEFINE_PROP_UINT8("vmx-type", VMPortState, vmx_type, + VMX_TYPE_SCALABLE_SERVER), =20 DEFINE_PROP_END_OF_LIST(), }; --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859484; cv=none; d=zohomail.com; s=zohoarc; b=n8klrhMhctvckpqLpEUKDZjwVTz5FmElXQo8xRpVUhbk6EpZ2zh83Dz6xggft/hbmYeQizlijOeuBOum+iKZo+X2HooIrqTjuZxMSuyiuLd41mnzSp2AItONsqmauDuD6sJTz5MVH7qaj9Ydh2KbXeUuMvuuQxvLapUGEY6r6DY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859484; 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=1BopZX2Bq3c5/duOSeJ+6j4/oECwiVetkO/A6IsO6gE=; b=NNoz9A38iNgA0gQzUxl+LlYe+2mI0+EKgkt8hnulQRDOHumo/2ImBsofwJbwZB0wPd0a8xv2qpaAQ0I8+aLjZ6rDRfe7AAZ0gfO43r70LDXSv/6x3Ul6ThptJ+1UqMzwv6pdwmfK9wgJa8Ne93NQO4mh8bM542ZtaYJETtst4Kc= 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 1583859484688674.0915270803666; Tue, 10 Mar 2020 09:58:04 -0700 (PDT) Received: from localhost ([::1]:37026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiCg-000750-Jo for importer@patchew.org; Tue, 10 Mar 2020 12:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49521) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6f-0006eP-AX for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6d-0006XP-Tl for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:49 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6d-0006JB-Lf for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:47 -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 02AGdGwG103809; Tue, 10 Mar 2020 16:51:44 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2yp7hm35qm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:43 +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 02AGbDMe101876; Tue, 10 Mar 2020 16:51:43 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2yp8qp6evk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:43 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpgSg011587; Tue, 10 Mar 2020 16:51:42 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:41 -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=1BopZX2Bq3c5/duOSeJ+6j4/oECwiVetkO/A6IsO6gE=; b=WgSywl+ta94/2kzVOIlc+9uqX05xEme/Rh1LcfYXVYvNyKzpWFZwv009MqDdtR3gCwva GQUtGoY9R7vp9biJnWjEsnYHs8mLj/Q+svO0YVvCBcnZPmOQ2z0ygfum71KSXu49NQIQ ziEmX/xykUwRClGbbmtGRjYT9B1RYJSNdg25pZRiYV81hwRkR4ckuc3WHw78FF8scUf4 +wR6X0vXc4WphDKzc219OLJrszP1vFSgnJjTqcilBapRuzfXcpHp0tALKJSUvDjm1HMg s8mdfPajrMFYEqZ+GykFP33A9CTYe/hpptzXxYux3gyi8+YO5jlCbsS56bb/ZaGZHMjJ Tw== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 07/16] hw/i386/vmport: Introduce vmport.h Date: Tue, 10 Mar 2020 18:53:23 +0200 Message-Id: <20200310165332.140774-8-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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" No functional change. This is mere refactoring. Suggested-by: Michael S. Tsirkin Signed-off-by: Liran Alon --- hw/i386/pc.c | 1 + hw/i386/vmmouse.c | 1 + hw/i386/vmport.c | 1 + include/hw/i386/pc.h | 13 ------------- include/hw/i386/vmport.h | 16 ++++++++++++++++ 5 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 include/hw/i386/vmport.h diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6ab4acb0c62e..6ac71e1af32b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -31,6 +31,7 @@ #include "hw/i386/apic.h" #include "hw/i386/topology.h" #include "hw/i386/fw_cfg.h" +#include "hw/i386/vmport.h" #include "sysemu/cpus.h" #include "hw/block/fdc.h" #include "hw/ide.h" diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index e8e62bd96b8c..49a546fd3bb6 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -26,6 +26,7 @@ #include "qapi/error.h" #include "ui/console.h" #include "hw/i386/pc.h" +#include "hw/i386/vmport.h" #include "hw/input/i8042.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 973f3f6448e9..7723d37a0657 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "hw/isa/isa.h" #include "hw/i386/pc.h" +#include "hw/i386/vmport.h" #include "hw/input/i8042.h" #include "hw/qdev-properties.h" #include "sysemu/hw_accel.h" diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index d5ac76d54e1f..60c988c4a5aa 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -134,19 +134,6 @@ typedef struct PCMachineClass { =20 GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled); =20 -/* vmport.c */ -#define TYPE_VMPORT "vmport" -typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); - -static inline void vmport_init(ISABus *bus) -{ - isa_create_simple(bus, TYPE_VMPORT); -} - -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); -void vmmouse_get_data(uint32_t *data); -void vmmouse_set_data(const uint32_t *data); - /* pc.c */ extern int fd_bootchk; =20 diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h new file mode 100644 index 000000000000..f0c1e985ca08 --- /dev/null +++ b/include/hw/i386/vmport.h @@ -0,0 +1,16 @@ +#ifndef HW_VMPORT_H +#define HW_VMPORT_H + +#define TYPE_VMPORT "vmport" +typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); + +static inline void vmport_init(ISABus *bus) +{ + isa_create_simple(bus, TYPE_VMPORT); +} + +void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); +void vmmouse_get_data(uint32_t *data); +void vmmouse_set_data(const uint32_t *data); + +#endif --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859891; cv=none; d=zohomail.com; s=zohoarc; b=Qh1IflkOfuVirUdD+FP7k2HUFOgdmN+hv3EGQXqsQOnFIo/Mqr6Ov+5AFxbgiyNIdl/2rQ1uWjgwM06Z4MPihGhO9KGZLX/zETDkWsB18VLtBwCe5jig7FJ27XHqoKZyEeX5i3W/iWTopMYKIHB3nbrpx+P7PhcZ224iG743izY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859891; 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=wROV/nYpL91JIG0MUHki0fUEQr6jGrkMkk/D+jAEc4k=; b=BOBySFAlBSNiHNyhDOt+BQhDuPh2euwgdU5deOUGHIJZHh8dASvatEvp34qtXIK0eMw3xxCoHjJGAya9QUsQnibWyaF5/sJFYB+XpFE4Y1Axgl/sThpLI8aKU34A2laGjuMjl4icb528iLdevqcvUP+zFELNmAUIR2CSCaymZE8= 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 1583859891965211.48210739638682; Tue, 10 Mar 2020 10:04:51 -0700 (PDT) Received: from localhost ([::1]:37172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiJH-0007wL-0g for importer@patchew.org; Tue, 10 Mar 2020 13:04:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52003) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi8c-0002Pr-Hp for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:53:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi8a-0004Vy-RW for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:53:50 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:50268) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi8Z-0004UC-DL for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:53:48 -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 02AGqUic144690; Tue, 10 Mar 2020 16:53:45 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yp9v61vq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:53:45 +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 02AGcTPm055083; Tue, 10 Mar 2020 16:51:45 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2yp8psg4uy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:45 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpil9030793; Tue, 10 Mar 2020 16:51:44 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:44 -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=wROV/nYpL91JIG0MUHki0fUEQr6jGrkMkk/D+jAEc4k=; b=LAQ+JQE5yGx1Cxi/YL8H+46xcnraxT1LD2m3lBoL6ml/7vrU/N7rJ7EHsha+NGU2rsQT TDdVUi/dqcZ9hnAVlUWOQ1uhhn9Bt5RLS1XqJtZmq++EoIa/iBWJWPXzC259iiE9gNeg /pQ8cB/fmXwgCduN7P/y6s4pSE7bBd5K8rZkeJrOP4h7EqXMxlud5VNLsHG+RoQJlOoQ m+SGRuMxhjj2pEDaHlQH7Jrd1v/cexmfCikq3LkIPOcVuW4ymspiyLKpfOo+rHwr0GB0 RAPpFsJBMYf20V4XZheo90yHKpZLtDyZoTOLo5XV/nuz3At7cozfoFg7axwMhQXEatIZ wA== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 08/16] hw/i386/vmport: Define enum for all commands Date: Tue, 10 Mar 2020 18:53:24 +0200 Message-Id: <20200310165332.140774-9-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" No functional change. Defining an enum for all VMPort commands have the following advantages: * It gets rid of the error-prone requirement to update VMPORT_ENTRIES when new VMPort commands are added to QEMU. * It makes it clear to know by looking at one place at the source, what are all the VMPort commands supported by QEMU. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmmouse.c | 18 ++++++------------ hw/i386/vmport.c | 11 ++--------- include/hw/i386/vmport.h | 11 ++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 49a546fd3bb6..afb8e9e09a30 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -34,12 +34,6 @@ /* debug only vmmouse */ //#define DEBUG_VMMOUSE =20 -/* VMMouse Commands */ -#define VMMOUSE_GETVERSION 10 -#define VMMOUSE_DATA 39 -#define VMMOUSE_STATUS 40 -#define VMMOUSE_COMMAND 41 - #define VMMOUSE_READ_ID 0x45414552 #define VMMOUSE_DISABLE 0x000000f5 #define VMMOUSE_REQUEST_RELATIVE 0x4c455252 @@ -197,10 +191,10 @@ static uint32_t vmmouse_ioport_read(void *opaque, uin= t32_t addr) command =3D data[2] & 0xFFFF; =20 switch (command) { - case VMMOUSE_STATUS: + case VMPORT_CMD_VMMOUSE_STATUS: data[0] =3D vmmouse_get_status(s); break; - case VMMOUSE_COMMAND: + case VMPORT_CMD_VMMOUSE_COMMAND: switch (data[1]) { case VMMOUSE_DISABLE: vmmouse_disable(s); @@ -219,7 +213,7 @@ static uint32_t vmmouse_ioport_read(void *opaque, uint3= 2_t addr) break; } break; - case VMMOUSE_DATA: + case VMPORT_CMD_VMMOUSE_DATA: vmmouse_data(s, data, data[1]); break; default: @@ -276,9 +270,9 @@ static void vmmouse_realizefn(DeviceState *dev, Error *= *errp) return; } =20 - vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s); - vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_STATUS, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_COMMAND, vmmouse_ioport_read, s); + vmport_register(VMPORT_CMD_VMMOUSE_DATA, vmmouse_ioport_read, s); } =20 static Property vmmouse_properties[] =3D { diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 7723d37a0657..0ea5e5f4dd14 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -31,10 +31,6 @@ #include "qemu/log.h" #include "trace.h" =20 -#define VMPORT_CMD_GETVERSION 0x0a -#define VMPORT_CMD_GETRAMSIZE 0x14 - -#define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 =20 /* Enum taken from open-vm-tools lib/include/vm_vmx_type.h */ @@ -64,12 +60,9 @@ typedef struct VMPortState { =20 static VMPortState *port_state; =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque) +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque) { - if (command >=3D VMPORT_ENTRIES) { - return; - } - + assert(command < VMPORT_ENTRIES); trace_vmport_register(command, func, opaque); port_state->func[command] =3D func; port_state->opaque[command] =3D opaque; diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index f0c1e985ca08..0501ccac6ddf 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -4,12 +4,21 @@ #define TYPE_VMPORT "vmport" typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t address); =20 +typedef enum { + VMPORT_CMD_GETVERSION =3D 10, + VMPORT_CMD_GETRAMSIZE =3D 20, + VMPORT_CMD_VMMOUSE_DATA =3D 39, + VMPORT_CMD_VMMOUSE_STATUS =3D 40, + VMPORT_CMD_VMMOUSE_COMMAND =3D 41, + VMPORT_ENTRIES +} VMPortCommand; + static inline void vmport_init(ISABus *bus) { isa_create_simple(bus, TYPE_VMPORT); } =20 -void vmport_register(unsigned char command, VMPortReadFunc *func, void *op= aque); +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque); void vmmouse_get_data(uint32_t *data); void vmmouse_set_data(const uint32_t *data); =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859483; cv=none; d=zohomail.com; s=zohoarc; b=bQPcYGqZinG1UCIp1OnXIiYUJtXO5fr/ujRgkkuBzUn6BQin8nHBWjalKO6jVV1dVkIYvZLpZQbva5pjwbRCzLFEN0Jlcc1JR8e60SlmqzdTJlaS7+q1YmyxmuPNL0mFKAxW+rng4L75I+XRn08gw8Rj/LbOyhpRzxM7WDqtqOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859483; 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=fbv9ovVqUbpKVUHDgKy1vLVDoNHDgmR6Pzcslc7ttFw=; b=C2yB0rf7vRaDyhlRlZH6a5EZWm160lrSYl2GW7NUOz+44qOEHlahL4FflK+W0Wkuvjs6+iaumzHnGIYJDyCLUhaoui+Lz9zOQJQHGTZgr/VcNsN4A4ZjePAToaTHnDiq+2dkvTuqRJyXlpiLyFmZ+8wGcSzFcmFdfrduu0XWxRo= 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 1583859483367983.2734855681268; Tue, 10 Mar 2020 09:58:03 -0700 (PDT) Received: from localhost ([::1]:37022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiCg-000748-4r for importer@patchew.org; Tue, 10 Mar 2020 12:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49590) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6h-0006kf-Ql for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6g-0006nz-LZ for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:51 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:48136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6g-0006iV-D1 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:50 -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 02AGcZLA010742; Tue, 10 Mar 2020 16:51:48 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yp9v61vdm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:48 +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 02AGbbhP030468; Tue, 10 Mar 2020 16:51:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2yp8rjyhb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:47 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpkeh030856; Tue, 10 Mar 2020 16:51:46 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51: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=fbv9ovVqUbpKVUHDgKy1vLVDoNHDgmR6Pzcslc7ttFw=; b=FwGKI6E7GhGrd8H3DOO0OL1Kneh7JcmLdqAnKB3/6FSmqhecNw6x6lXj4F7175ne9Vcc nJKgaCZGet851jDbvKwFvl6Su2GQc9EiRCbHAdC3t3Qsq3Lkm+XRBK3WutPdev6RdVJ9 //FFzAReXc7RjCAVXDre0yIeGPHeM8RBvCm7pWlj/T8rDBno7rCJBAabw8Mz01DNpvOM 41CE1eiOGXYlHp1jsmJYZczUPekgDT/kWKlt5CacI54cjCtuJWfGNhjPb9bpu8pksZQi AYLA8fDAOboFL6+f9QSxwglS1EM5GSgo9flNlFxiXaDU8VPhuzOlUCQ5RsmEc6gjhzem EQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 09/16] hw/i386/vmport: Add support for CMD_GETBIOSUUID Date: Tue, 10 Mar 2020 18:53:25 +0200 Message-Id: <20200310165332.140774-10-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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 is VMware documented functionallity that some guests rely on. Returns the BIOS UUID of the current virtual machine. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 17 +++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 0ea5e5f4dd14..ef94f4fe78c6 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -27,6 +27,7 @@ #include "hw/i386/vmport.h" #include "hw/input/i8042.h" #include "hw/qdev-properties.h" +#include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "qemu/log.h" #include "trace.h" @@ -136,6 +137,18 @@ static uint32_t vmport_cmd_get_version(void *opaque, u= int32_t addr) return port_state->vmx_version; } =20 +static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr) +{ + X86CPU *cpu =3D X86_CPU(current_cpu); + uint32_t *uuid_parts =3D (uint32_t *)(qemu_uuid.data); + + cpu->env.regs[R_EAX] =3D le32_to_cpu(uuid_parts[0]); + cpu->env.regs[R_EBX] =3D le32_to_cpu(uuid_parts[1]); + cpu->env.regs[R_ECX] =3D le32_to_cpu(uuid_parts[2]); + cpu->env.regs[R_EDX] =3D le32_to_cpu(uuid_parts[3]); + return cpu->env.regs[R_EAX]; +} + static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) { X86CPU *cpu =3D X86_CPU(current_cpu); @@ -184,9 +197,13 @@ static void vmport_realizefn(DeviceState *dev, Error *= *errp) isa_register_ioport(isadev, &s->io, 0x5658); =20 port_state =3D s; + /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); + if (s->version > 1) { + vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + } } =20 static Property vmport_properties[] =3D { diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 0501ccac6ddf..7f33512ca6f0 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -6,6 +6,7 @@ typedef uint32_t (VMPortReadFunc)(void *opaque, uint32_t ad= dress); =20 typedef enum { VMPORT_CMD_GETVERSION =3D 10, + VMPORT_CMD_GETBIOSUUID =3D 19, VMPORT_CMD_GETRAMSIZE =3D 20, VMPORT_CMD_VMMOUSE_DATA =3D 39, VMPORT_CMD_VMMOUSE_STATUS =3D 40, --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859564; cv=none; d=zohomail.com; s=zohoarc; b=hW7H/3y91RRzA58DTSywOAIHElsgrW8oMuxxNGDQLQqAoU1q8oOPAoPndBIMpNP1bBCUNvgfmB4zV/QI4UfetYlMLi/K1SmvFjG0uEjNWyl5cpLMaDvtXPH5DlnzuoPe/ljEDWmQj4rJJkXogn6xpnhFMBfgPG1wtC3xpkRut74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859564; 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=h4JqFba7YI0e69Veqsivgh105LSkDbD4DBRHy3EHmU0=; b=A1nB0zNIjr3ll12826a6nY3O+uBWDwadht/Hyqc0ijMUZrCyu5UCyAsnztBpT6jF3DrGiG2QNTNwsd//gmzOrI+CkKSUtrGW4MZtb9B8y4tL3wqQL4ztppRNU44P6W/BEU+d5uw9pe2xNGEVi8BoRSOwZA6DHG8mr4Za8xfF0cg= 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 1583859564644211.6399161104838; Tue, 10 Mar 2020 09:59:24 -0700 (PDT) Received: from localhost ([::1]:37066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiDx-0000UJ-OR for importer@patchew.org; Tue, 10 Mar 2020 12:59:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49663) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6k-0006rp-Qh for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6j-00073M-NI for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:54 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6j-0006zt-Ei for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:51:53 -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 02AGdJCP103995; Tue, 10 Mar 2020 16:51:51 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2yp7hm35re-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:51 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02AGcaaJ054063; Tue, 10 Mar 2020 16:51:50 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2yp8nu2670-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:50 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpmlV011632; Tue, 10 Mar 2020 16:51:49 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51: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=h4JqFba7YI0e69Veqsivgh105LSkDbD4DBRHy3EHmU0=; b=EeZ2bjqcGaUZAyUAuiMy/nEu5rnU9X34s4cLiwtGdaUs5gjoOAkGWShLP/0GWypi/x95 jlCjJ7LVfmFHzxwEmOnGHecS0FoTWkhyOmqZN7KICz4optIJbTx90SCvh+8rONuBD/mz lx7P0mIi3dlse3eI6rBfWQb3/03TPReWODTfur9l9zzbCZ59yIPmPfcVu3nXxqDQ0Sse LbMricj8SzB4JwZUR5cOdZw29nSk315msVxhBEywN71hroNKdaWR10YAWhRazHFICWT3 Zj8/qkFLf1QD48y+kWv2h0/vK90nevioJNo1ztXzYpAGmncGq2ZXcLJ5aZZd1kM5dAh5 +g== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 10/16] hw/i386/vmport: Add support for CMD_GETTIME Date: Tue, 10 Mar 2020 18:53:26 +0200 Message-Id: <20200310165332.140774-11-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 adultscore=0 suspectscore=1 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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 ef94f4fe78c6..15632c579199 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -55,6 +55,7 @@ typedef struct VMPortState { =20 uint32_t vmx_version; uint8_t vmx_type; + uint32_t max_time_lag_us; =20 uint8_t version; } VMPortState; @@ -157,6 +158,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) { @@ -203,6 +218,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); if (s->version > 1) { vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); + vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); } } =20 @@ -218,6 +234,11 @@ static Property vmport_properties[] =3D { DEFINE_PROP_UINT32("vmx-version", VMPortState, vmx_version, 6), DEFINE_PROP_UINT8("vmx-type", VMPortState, vmx_type, VMX_TYPE_SCALABLE_SERVER), + /* + * 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 From nobody Mon Feb 9 08:50:29 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=1583859560; cv=none; d=zohomail.com; s=zohoarc; b=b+5w90kljIsmiHecC+Gyl4XStfzMowHCsTsMgz6mxZPb/FuCbVuo+bv61Eva/VlMrR67ZYokJy2YIHhpMOR6HKNUToSuVzJUucffeM8GzDc3FIUswUlKpUj/kynlopd8jtHM99+Klz0Sgzt7yZtFLYaDQmmBBxeSH5F/Uj29nVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859560; 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=ne/YYCyGllSC9Z5aTXdOACyjwpUdbmtlKYRW3HOtyaY=; b=j8QCu+A+Hb6z46ErOBszagxV4+DqQM5dir8HhYxts0Gi5k7Ko74BvyiEBq6xtcJn6vweLdmH7kAbMY64+7LU9palvdvzKJFjO5jHxNK3YOQeTGt0p7h16FKBxXK2jS024gjHPYvOozDI6Jznwvv9Rgt+NsuDCQQaiAl31nD07do= 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 1583859560543331.81572536227577; Tue, 10 Mar 2020 09:59:20 -0700 (PDT) Received: from localhost ([::1]:37062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiDv-0000Rl-If for importer@patchew.org; Tue, 10 Mar 2020 12:59:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49803) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6r-00072D-8F for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6q-0007eP-7z for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:01 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48534) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6p-0007Yh-Vz for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:00 -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 02AGdG8K103869; Tue, 10 Mar 2020 16:51:58 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2yp7hm35s0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:58 +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 02AGbcos030537; Tue, 10 Mar 2020 16:51:57 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2yp8rjyj1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:51:57 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGpuwM031771; Tue, 10 Mar 2020 16:51:56 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:51 -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=ne/YYCyGllSC9Z5aTXdOACyjwpUdbmtlKYRW3HOtyaY=; b=b2rk7FatmpNS0YUbi7f4t1909m0+2L/3XCPZvcgYJ0PfAEa1P/QopU19cLn5nWYdslYa 8/s6iJyPsmvPkKHc5Br6MTka8BmEWxRepbdNhdimBokIMS7UQz3b8/L+MyWIoDQ6Chpj ecQMdKStp2t6adt7gSESYfRWZoyIbeJGkQ4QMMeX1vKfi+oAdfpAbtqV2fz3P9ujHzOR GIFyOyIyuR2yOw0W8wwXYyyq18ljaK2Z0ugp5KGXbEFfv7W03bcY/6dED5jpzgdgELOD zKCrYo5nE7tz+bC5lTrXk2wNlaTYi2BK5GP3/eq2cRVN+RG1bNKsIdYJxIBo75qE0pbU qg== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 11/16] hw/i386/vmport: Add support for CMD_GETTIMEFULL Date: Tue, 10 Mar 2020 18:53:27 +0200 Message-Id: <20200310165332.140774-12-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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" Similar to CMD_GETTIME but lacks the 136-year overflow issue, by returning full 64-bit of host uSeconds. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 17 +++++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 15632c579199..445104c71c2b 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -172,6 +172,22 @@ static uint32_t vmport_cmd_time(void *opaque, uint32_t= addr) return (uint32_t)tv.tv_sec; } =20 +static uint32_t vmport_cmd_time_full(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_ESI] =3D (uint32_t)((uint64_t)tv.tv_sec >> 32); + cpu->env.regs[R_EDX] =3D (uint32_t)tv.tv_sec; + cpu->env.regs[R_EBX] =3D (uint32_t)tv.tv_usec; + cpu->env.regs[R_ECX] =3D port_state->max_time_lag_us; + return VMPORT_MAGIC; +} + /* vmmouse helpers */ void vmmouse_get_data(uint32_t *data) { @@ -219,6 +235,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) if (s->version > 1) { vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); + vmport_register(VMPORT_CMD_GETTIMEFULL, vmport_cmd_time_full, NULL= ); } } =20 diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 50416c8c8f3e..5d19963ed417 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_GETTIMEFULL =3D 46, VMPORT_ENTRIES } VMPortCommand; =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859709; cv=none; d=zohomail.com; s=zohoarc; b=fJKGy2k2qkFltQDrc0aWyPOeVdcPrhS2TaugrbKdoP4tAY2IwzE8W7i7NKNNep8VwaX9ecm3Efnpdo8Is6O3miOUzKsWxNocxob6wcQxcgBa6/JoSJZd0uMxg20eqV0kRDMV//ARZXD2axz3Gg4xFQtdechyOhd3lD2gke5nvmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859709; 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=+fVJkCYwbJSI1WwvCYdwNV3zcSYtM/0dfrmJW7pdR9g=; b=CKlcfonASK/LWEqlwresP+KDRqSFQsMwONKxBE9HnuqWmcsBZI8f/zRLO1lkCpC6eO4HtjBzJNnFEkpyVMmRD92XFBmJa7OJW3dzH3R45WFM95OmDov3ZWxC4JXgJqLEEikx7yhrl9S6hy6LaeAQk9zEpPd8N8ZrnAVduOnVTb4= 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 1583859709450548.6221054356382; Tue, 10 Mar 2020 10:01:49 -0700 (PDT) Received: from localhost ([::1]:37122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiGF-0004CY-N5 for importer@patchew.org; Tue, 10 Mar 2020 13:01:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49879) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6u-00076o-BW for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6t-0007pe-9D for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:04 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48618) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6t-0007lS-15 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:03 -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 02AGdH6w103940; Tue, 10 Mar 2020 16:52:01 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2yp7hm35sn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:01 +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 02AGcHAj054490; Tue, 10 Mar 2020 16:52:00 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2yp8psg60t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:00 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGpwoY011670; Tue, 10 Mar 2020 16:51:58 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:51:58 -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=+fVJkCYwbJSI1WwvCYdwNV3zcSYtM/0dfrmJW7pdR9g=; b=VKC9UDD6vXN+jgTNCTD+HauaND0I2Pqiqap7MzXJjpKl1joWpEOk9ovRFTUZ/L16iQvy DcNIqB0rz9ji8IYDVOaYBUNiy7GS3Bca3edlW16QcRJSJvLgBL0CzHRReIEwuol8tbGz shplc4VMBG73KdSUPl3d5PdejWmeH14MTCoEAYUxIBb4qQtPiv60R7Z3I03/J83tLUaZ GYibnHYh3Sunc5dkLKRPCIxfeqImps3E3vQevltbz1aFSgHgnTnBrmHyzY25qbcvuR0t nltBPhwMnbjP3C0Pi4+1K6sx/6bjgKukOvq6WvKQZLQEgEhJbEpocgoBn6RNIUh/9SGN Lw== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 12/16] hw/i386/vmport: Add support for CMD_GET_VCPU_INFO Date: Tue, 10 Mar 2020 18:53:28 +0200 Message-Id: <20200310165332.140774-13-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 suspectscore=1 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 phishscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 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.leshchenko@oracle.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" Command currently returns that it is unimplemented by setting the reserved-bit in it's return value. Following patches will return various useful vCPU information to guest. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 14 ++++++++++++++ include/hw/i386/vmport.h | 1 + 2 files changed, 15 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 445104c71c2b..30641d3ffb20 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -44,6 +44,13 @@ typedef enum { VMX_TYPE_WORKSTATION_ENTERPRISE /* Deprecated type used for ACE 1.x */ } VMXType; =20 +/* vCPU features reported by CMD_GET_VCPU_INFO */ +#define VCPU_INFO_SLC64_BIT 0 +#define VCPU_INFO_SYNC_VTSCS_BIT 1 +#define VCPU_INFO_HV_REPLAY_OK_BIT 2 +#define VCPU_INFO_LEGACY_X2APIC_BIT 3 +#define VCPU_INFO_RESERVED_BIT 31 + #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) =20 typedef struct VMPortState { @@ -188,6 +195,11 @@ static uint32_t vmport_cmd_time_full(void *opaque, uin= t32_t addr) return VMPORT_MAGIC; } =20 +static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) +{ + return 1 << VCPU_INFO_RESERVED_BIT; +} + /* vmmouse helpers */ void vmmouse_get_data(uint32_t *data) { @@ -236,6 +248,8 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, = NULL); vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); vmport_register(VMPORT_CMD_GETTIMEFULL, vmport_cmd_time_full, NULL= ); + vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, + NULL); } } =20 diff --git a/include/hw/i386/vmport.h b/include/hw/i386/vmport.h index 5d19963ed417..34cc050b1ffa 100644 --- a/include/hw/i386/vmport.h +++ b/include/hw/i386/vmport.h @@ -13,6 +13,7 @@ typedef enum { VMPORT_CMD_VMMOUSE_STATUS =3D 40, VMPORT_CMD_VMMOUSE_COMMAND =3D 41, VMPORT_CMD_GETTIMEFULL =3D 46, + VMPORT_CMD_GET_VCPU_INFO =3D 68, VMPORT_ENTRIES } VMPortCommand; =20 --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859658; cv=none; d=zohomail.com; s=zohoarc; b=Zo60tQsDFa3UbDHu6tcnmua4QVVvpIZFCkG0Gx0qRGy0lO1TOT7aLRe1CIOH3Wa6c4gOtuNaZ2egm7GTT9JD0XBwbGpKODkz2xkcu2zQnhplBe5uQ+9lEX9jh6nWQuPF+fwZ3m2WUCuFxc4DBQ4Fl7EWm0HGTn1tPd5908YAuhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859658; 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=+kvXlSEdwyDTv0x+1fs7lkw2MU30gmREkPVpt94ognk=; b=SHiFNPOHwsQsvEXyPudfiEEN8mHpT8i3LerWJVkbQm8IZhu6gm0amIxLP3wBXn1g4uO494C2P8G1TttNaDbiEfr5MFPcynzxahvjbH35D96uTxUChg5bTYQeHcZGwEcbBjelg6N+vXUGtDRXfVFQj512524LbAeSBkDaUaGUvaY= 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 1583859658336135.08485545627275; Tue, 10 Mar 2020 10:00:58 -0700 (PDT) Received: from localhost ([::1]:37104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiFV-0003A0-5g for importer@patchew.org; Tue, 10 Mar 2020 13:00:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49926) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6w-00078Z-OU for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6u-0007vA-Nf for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:06 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:48354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6u-0007td-G9 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:04 -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 02AGcZLB010742; Tue, 10 Mar 2020 16:52:03 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yp9v61vef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52: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 02AGbj3l031071; Tue, 10 Mar 2020 16:52:02 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2yp8rjyje8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:01 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGq0vD031817; Tue, 10 Mar 2020 16:52:01 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:52:00 -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=+kvXlSEdwyDTv0x+1fs7lkw2MU30gmREkPVpt94ognk=; b=nvm2LW5Z0BCmLaFNbNJBKi8sttlYmXvXAawr8f8XDXJFjKjyLEtYhvksO/pnR091WaJX bGQxVUl441ai1DEWYK4oZ3ah3YVgcJkcLNUU/8IJvx8SHBuP7/T4RxSkAr/dfs+YrQES Hzf39A65llrV2VjYH2qEXV9rBrc6m3TM7Ady/AT6CbXJNGXdAX2ef5GQr67KmxkpbHB4 nhUyJa0DZagloRrMlH90jXodZyFc3VCxGca9KuxX+nzKoQQXxeHjDObdQrCpEb0UI0PS ojEm9colyaniuv8yXDAZcjtNr8NCntv1sRhm31J/6wMR85DpiTIMXaAZFn8i5DR8FNuJ 9g== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 13/16] hw/i386/vmport: Allow x2apic without IR Date: Tue, 10 Mar 2020 18:53:29 +0200 Message-Id: <20200310165332.140774-14-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=848 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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=911 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-2003100103 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.leshchenko@oracle.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" Signal to guest that hypervisor supports x2apic without VT-d/IOMMU Interrupt-Remapping support. This allows guest to use x2apic in case all APIC IDs fits in 8-bit (i.e. Max APIC ID < 255). See Linux kernel commit 4cca6ea04d31 ("x86/apic: Allow x2apic without IR on VMware platform") and Linux try_to_enable_x2apic() function. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 30641d3ffb20..6ca03273066e 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -197,7 +197,14 @@ static uint32_t vmport_cmd_time_full(void *opaque, uin= t32_t addr) =20 static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) { - return 1 << VCPU_INFO_RESERVED_BIT; + X86CPU *cpu =3D X86_CPU(current_cpu); + uint32_t ret =3D 0; + + if (cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC) { + ret |=3D 1 << VCPU_INFO_LEGACY_X2APIC_BIT; + } + + return ret; } =20 /* vmmouse helpers */ --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859782; cv=none; d=zohomail.com; s=zohoarc; b=O/kH0TlwRlV44wsXsSStd0a/0oXxORseMeuxdxzXaNl80JYUWOBsAlbN0HoQsWAazzi7bWbuNKQjL+n2tu3tXKO5vYCxgUl2AAaanPr9xUndFKjJdhvChpE/0L8HD2FvaZUWR9zicMfqK7gunY6kX2ULr66iaqgic4VsbubX6sU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859782; 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=Y+xng8xGIGilSa0d/6zOW6qU5eyKDrqFR+ferzQsKk8=; b=j34NyUjkQNuO0MijX/b6OhNIXoDNFuydIVnOh9SOQNn6uoJ8RjeKzxbSNhrW+0R1uJOES+4rLcS6tb+damAkSqJZgCoXJfkrNABGu9dKHMDbgopp7MTsUEY11Gj4NKGQppHZ8rzjwMPjE5Pk7vVxawWFbCNb05NNDgMAVBZO8Mg= 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 1583859782178288.7230376138202; Tue, 10 Mar 2020 10:03:02 -0700 (PDT) Received: from localhost ([::1]:37150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiHV-0005dB-6u for importer@patchew.org; Tue, 10 Mar 2020 13:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49964) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi6x-00079w-UQ for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6w-00080F-Rj for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6w-0007xs-JU for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:06 -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 02AGcToY085248; Tue, 10 Mar 2020 16:52:04 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ym31uetj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:04 +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 02AGbavG030383; Tue, 10 Mar 2020 16:52:04 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2yp8rjyjjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:04 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02AGq3Jh011704; Tue, 10 Mar 2020 16:52:03 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:52:02 -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=Y+xng8xGIGilSa0d/6zOW6qU5eyKDrqFR+ferzQsKk8=; b=bwXbOksO3UQhojgVu7Q0q1JwupoltXYP8IKYAjiXua1fcTST09+aPC+uE6ziJf8lxe6G 9SIHggY92DVFrcEdP4HPL07ZAGTOqCmIUui2CfGCPIFLFdATNB7lrv+KmlDETHtNR2Vv Nae8wbNXpGInjfo1Ybhz+ncVKqRZWds/dMocO4LpZ+iRIey7FXuEWRRWoulkSoj2rbQL w9seNg94Jcdpy5MKKYYMmEkK5v0CYe+DO+vLGwO77FDgSBSkOKDEhFbFN49sgQVAjFdj emaFcw0dh8E79CxVeOVcYZ39Gwjxb9+1WVjtETpqkj29RMYkVGhOhtjM9vEw5Do4ntGH lQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 14/16] i386/cpu: Store LAPIC bus frequency in CPU structure Date: Tue, 10 Mar 2020 18:53:30 +0200 Message-Id: <20200310165332.140774-15-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" No functional change. This information will be used by following patches. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- target/i386/cpu.h | 1 + target/i386/kvm.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 576f309bbfc8..9c7cd7cde107 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1580,6 +1580,7 @@ typedef struct CPUX86State { bool tsc_valid; int64_t tsc_khz; int64_t user_tsc_khz; /* for sanity check only */ + uint64_t apic_bus_freq; #if defined(CONFIG_KVM) || defined(CONFIG_HVF) void *xsave_buf; #endif diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 69eb43d796e6..8534ca9760d7 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -60,6 +60,10 @@ do { } while (0) #endif =20 +/* From arch/x86/kvm/lapic.h */ +#define KVM_APIC_BUS_CYCLE_NS 1 +#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) + #define MSR_KVM_WALL_CLOCK 0x11 #define MSR_KVM_SYSTEM_TIME 0x12 =20 @@ -1496,6 +1500,8 @@ int kvm_arch_init_vcpu(CPUState *cs) } } =20 + env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; + /* Paravirtualization CPUIDs */ r =3D hyperv_handle_properties(cs, cpuid_data.entries); if (r < 0) { @@ -1800,9 +1806,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c =3D &cpuid_data.entries[cpuid_i++]; c->function =3D KVM_CPUID_SIGNATURE | 0x10; c->eax =3D env->tsc_khz; - /* LAPIC resolution of 1ns (freq: 1GHz) is hardcoded in KVM's - * APIC_BUS_CYCLE_NS */ - c->ebx =3D 1000000; + c->ebx =3D env->apic_bus_freq / 1000; /* Hz to KHz */ c->ecx =3D c->edx =3D 0; =20 c =3D cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); --=20 2.20.1 From nobody Mon Feb 9 08:50:29 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=1583859193; cv=none; d=zohomail.com; s=zohoarc; b=K2yw2W2cOLHORRK4CK+DcrvQFzZBkzLC/eQq9sJk19GFU+ewG98itxQJhsr/OVGE6Ve2qI3RmUYO4un6NikInj/PRIyLt8RSatnGFo+kduj8Ye99OJmD8O8I6AUORfUMuzJJEekvgJxCruOaXgIhOe+I1RTK9X4cqTRpWTGWQWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859193; 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=g4SQtpo7MYbyBBQYcudURHtE+SSi+DfpnUAsPR5I+sQ=; b=Kh3SqKI60hCTPOPh5IAdt1iVyAJQco4oA8PuTl9xUx34pjqgTmT+6cfyGSR89Ba4WRIDZ1DZ4ODKWKzDd56Uh2m9SH68L9jXUNtRxdDCM//4BZzsaGJOdIbiIfQdiQuvSdhtoNczcJ+vZERNBlJl/DnFvgnbvGsK6X1IaBET5b8= 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 1583859193117158.495606717158; Tue, 10 Mar 2020 09:53:13 -0700 (PDT) Received: from localhost ([::1]:36907 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi80-0000TA-5q for importer@patchew.org; Tue, 10 Mar 2020 12:53:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50024) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi70-0007DZ-Bw for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi6z-00087i-6O for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:10 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:48444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi6y-00087B-VY for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:09 -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 02AGcYtv010737; Tue, 10 Mar 2020 16:52:07 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2yp9v61vey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:07 +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 02AGbbhS030468; Tue, 10 Mar 2020 16:52:06 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2yp8rjyjps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:06 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGq53x030957; Tue, 10 Mar 2020 16:52:05 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:52:05 -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=g4SQtpo7MYbyBBQYcudURHtE+SSi+DfpnUAsPR5I+sQ=; b=cYc/oiJkDjETmAQGJjDi4/UxDSgXcJCLUwj4rJK+6Vzy34i6CGpdou3x7aBSsp7ju9sG KAVFpfu1Itx4sHa1rO85izqpqfKlrjWtfQ1SIqCrSb/KV5P9oAKwNySv2mAJreBjT6fi 2oJQZmjI7aiUqwI330jZxBikhVFYqWoizrI+dDx7t76aKeFQ4oj9CotMchISj+NIW0hw GfpVIz7Dox/J1ND+u6A6goidqduP7ztbreR1PYZC7MDW9M6aIrcbgWVh+20yk2lb/Mog 1h6b7Mj8FbxGoE7daKv2+gj3IAbehUY3fHc4Gm8Z68bx8bAEj+B15miGkE0Qs50TgJIe UA== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 15/16] hw/i386/vmport: Add support for CMD_GETHZ Date: Tue, 10 Mar 2020 18:53:31 +0200 Message-Id: <20200310165332.140774-16-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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 6ca03273066e..76fd49c52058 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -165,6 +165,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); @@ -254,6 +272,7 @@ static void vmport_realizefn(DeviceState *dev, Error **= errp) if (s->version > 1) { 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 From nobody Mon Feb 9 08:50:29 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=1583859302; cv=none; d=zohomail.com; s=zohoarc; b=T4vkDVXsKI9spbY1yR8QS2aDGiHDqUi/ZTFRuqiwopP1HH/TDaXPn2tGWNShpCD/hiKSmehtJ+DhCKdp+8LMkWdnVJi7r4kPrkyo1lfEDwcZHqRUtn03Fb6/+w8+Uv3O63gPZHepYuj/rrChy0GyxNNcv5ZWq//z4jpBnrP3MgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583859302; 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=JVq0kbYvEA5Tt3sWhXqA9LBeHXTQ571xOUNlOccljG4=; b=AFVu61Xu0XLm6LXIHt9a5/4pJ6NXORov8Hg5TmhxVJngIqjTNJW39xzxb0eScKL+aNt+ULW9b7gqnpf/Qbnsz1PVTW+zrE18K3QWaM8b2WYbjqHvWPqcKNmZt0rQh2pMcq27VHulAf33IYBHIGUCEwNTXSIKa+iXvkHnX5hICD0= 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 1583859302792457.4320565078241; Tue, 10 Mar 2020 09:55:02 -0700 (PDT) Received: from localhost ([::1]:36960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi9l-0003f2-Jq for importer@patchew.org; Tue, 10 Mar 2020 12:55:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50069) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi72-0007HY-2E for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBi71-0008Fq-0M for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50780) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBi70-0008CU-P2 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 12:52:10 -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 02AGchjQ085365; Tue, 10 Mar 2020 16:52:09 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ym31uetjk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:08 +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 02AGbavJ030383; Tue, 10 Mar 2020 16:52:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2yp8rjyjug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 16:52:08 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02AGq7BI030974; Tue, 10 Mar 2020 16:52:07 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2020 09:52:07 -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=JVq0kbYvEA5Tt3sWhXqA9LBeHXTQ571xOUNlOccljG4=; b=ZziFfvhxND95JtTGdq8yX/hsdIV3V5qUgtGaoSiCREAEA5uRUkjmreOiVIPLvJBBv63O uNptJ7cX/eWLk1jJ+7PV1ZhQ+AsKF8YTHiVhQ78ruMiewM3BzmPq/3ttdSMOSUr+ajUE 3TkcYs3xiWqAcfVl3pmbgQMULCkcRN8+SOKOJFtU6gqHvIMTGM2BoiK9iNTo6kdIE0Zn gXC0INkMGYD85vzL2I8CyJgDdu+ZewdYgTLYleRiWf83uKcYCV2BupsfryCkNe7VR4Ff OH0nG8YJe8FLhROB30Qqcq5Gbe3s8hJ/KOA9psh919kX0eRDh7WD1r8JoAzvuCwvvBSh xA== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH v2 16/16] hw/i386/vmport: Assert vmport initialized before registering commands Date: Tue, 10 Mar 2020 18:53:32 +0200 Message-Id: <20200310165332.140774-17-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310165332.140774-1-liran.alon@oracle.com> References: <20200310165332.140774-1-liran.alon@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 mlxscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003100103 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9556 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-2003100103 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.leshchenko@oracle.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" vmport_register() is also called from other modules such as vmmouse. Therefore, these modules rely that vmport is realized before those call sites. If this is violated, vmport_register() will NULL-deref. To make such issues easier to debug, assert in vmport_register() that vmport is already realized. Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- hw/i386/vmport.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 76fd49c52058..8d3d268bfd7e 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -72,6 +72,8 @@ static VMPortState *port_state; void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *op= aque) { assert(command < VMPORT_ENTRIES); + assert(port_state); + trace_vmport_register(command, func, opaque); port_state->func[command] =3D func; port_state->opaque[command] =3D opaque; --=20 2.20.1