From patchwork Tue Mar 10 16:53:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429905 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37D0414B7 for ; Tue, 10 Mar 2020 16:52:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E19D20873 for ; Tue, 10 Mar 2020 16:52:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FqATn5+O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E19D20873 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi7D-0007f5-AR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:52:23 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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); } +static Property vmport_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + static void vmport_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -161,6 +166,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data) dc->realize = vmport_realizefn; /* Reason: realize sets global port_state */ dc->user_creatable = false; + device_class_set_props(dc, vmport_properties); } static const TypeInfo vmport_info = { From patchwork Tue Mar 10 16:53:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86F4714B7 for ; Tue, 10 Mar 2020 16:54:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D11120873 for ; Tue, 10 Mar 2020 16:54:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="isddHPJJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D11120873 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi93-0002ix-Iw for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:54:17 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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; static VMPortState *port_state; @@ -156,6 +158,12 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) } static Property vmport_properties[] = { + /* + * 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(), }; From patchwork Tue Mar 10 16:53:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB568139A for ; Tue, 10 Mar 2020 16:52:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8273B21D56 for ; Tue, 10 Mar 2020 16:52:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="CwpQ+pl7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8273B21D56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi7R-0008Dz-Lz for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:52:37 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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[] = { { "usb-redir", "suppress-remote-wake", "off" }, { "qxl", "revision", "4" }, { "qxl-vga", "revision", "4" }, + { "vmport", "version", "1" }, }; const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2); 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, eax = env->regs[R_EAX]; if (eax != VMPORT_MAGIC) { - return eax; + goto out; } command = env->regs[R_ECX]; trace_vmport_command(command); if (command >= VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - return eax; + goto out; } - return s->func[command](s->opaque[command], addr); + eax = 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] = eax; + } + + return eax; } static void vmport_ioport_write(void *opaque, hwaddr addr, @@ -163,7 +179,7 @@ static Property vmport_properties[] = { * 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(), }; From patchwork Tue Mar 10 16:53:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429921 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A3A614B7 for ; Tue, 10 Mar 2020 16:55:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FF51222C3 for ; Tue, 10 Mar 2020 16:55:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="I/jfGyPo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FF51222C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiAf-0005Kl-8O for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:55:57 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 != -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, eax = env->regs[R_EAX]; if (eax != VMPORT_MAGIC) { - goto out; + goto err; } command = env->regs[R_ECX]; trace_vmport_command(command); if (command >= VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); - goto out; + goto err; } eax = s->func[command](s->opaque[command], addr); + goto out; + +err: + if (s->version > 1) { + eax = UINT32_MAX; + } out: /* From patchwork Tue Mar 10 16:53:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429915 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A4C1139A for ; Tue, 10 Mar 2020 16:54:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1095A20873 for ; Tue, 10 Mar 2020 16:54:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DBsk2csZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1095A20873 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi96-0002q5-6r for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:54:20 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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=X". 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]; + uint32_t vmx_version; + uint8_t version; } VMPortState; @@ -123,7 +125,7 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) X86CPU *cpu = X86_CPU(current_cpu); cpu->env.regs[R_EBX] = VMPORT_MAGIC; - return 6; + return port_state->vmx_version; } static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) @@ -186,6 +188,10 @@ static Property vmport_properties[] = { * 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 definition */ + DEFINE_PROP_UINT32("vmx-version", VMPortState, vmx_version, 6), + DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue Mar 10 16:53:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429923 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3674F14B7 for ; Tue, 10 Mar 2020 16:56:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CB6F21D7E for ; Tue, 10 Mar 2020 16:56:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="OmhoJ0Rp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0CB6F21D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiAi-0005O1-9y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:56:00 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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=X". 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 +/* Enum taken from open-vm-tools lib/include/vm_vmx_type.h */ +typedef enum { + VMX_TYPE_UNSET = 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) typedef struct VMPortState { @@ -46,6 +56,7 @@ typedef struct VMPortState { void *opaque[VMPORT_ENTRIES]; uint32_t vmx_version; + uint8_t vmx_type; uint8_t version; } VMPortState; @@ -125,6 +136,9 @@ static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) X86CPU *cpu = X86_CPU(current_cpu); cpu->env.regs[R_EBX] = VMPORT_MAGIC; + if (port_state->version > 1) { + cpu->env.regs[R_ECX] = port_state->vmx_type; + } return port_state->vmx_version; } @@ -191,6 +205,8 @@ static Property vmport_properties[] = { /* Default value taken from open-vm-tools code VERSION_MAGIC definition */ DEFINE_PROP_UINT32("vmx-version", VMPortState, vmx_version, 6), + DEFINE_PROP_UINT8("vmx-type", VMPortState, vmx_type, + VMX_TYPE_SCALABLE_SERVER), DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue Mar 10 16:53:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429927 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4E9E18E8 for ; Tue, 10 Mar 2020 16:57:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B01521D7E for ; Tue, 10 Mar 2020 16:57:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="WgSywl+t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B01521D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiCN-000750-TG for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:57:43 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 { GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled); -/* 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 *opaque); -void vmmouse_get_data(uint32_t *data); -void vmmouse_set_data(const uint32_t *data); - /* pc.c */ extern int fd_bootchk; 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 *opaque); +void vmmouse_get_data(uint32_t *data); +void vmmouse_set_data(const uint32_t *data); + +#endif From patchwork Tue Mar 10 16:53:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 221AB92A for ; Tue, 10 Mar 2020 17:04:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBFEF21D7E for ; Tue, 10 Mar 2020 17:04:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="LAQ+JQE5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBFEF21D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiIy-0007wL-4L for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 13:04:32 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 -/* 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, uint32_t addr) command = data[2] & 0xFFFF; switch (command) { - case VMMOUSE_STATUS: + case VMPORT_CMD_VMMOUSE_STATUS: data[0] = 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, uint32_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; } - 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); } static Property vmmouse_properties[] = { 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" -#define VMPORT_CMD_GETVERSION 0x0a -#define VMPORT_CMD_GETRAMSIZE 0x14 - -#define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 /* Enum taken from open-vm-tools lib/include/vm_vmx_type.h */ @@ -64,12 +60,9 @@ typedef struct VMPortState { static VMPortState *port_state; -void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque) +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *opaque) { - if (command >= VMPORT_ENTRIES) { - return; - } - + assert(command < VMPORT_ENTRIES); trace_vmport_register(command, func, opaque); port_state->func[command] = func; port_state->opaque[command] = 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); +typedef enum { + VMPORT_CMD_GETVERSION = 10, + VMPORT_CMD_GETRAMSIZE = 20, + VMPORT_CMD_VMMOUSE_DATA = 39, + VMPORT_CMD_VMMOUSE_STATUS = 40, + VMPORT_CMD_VMMOUSE_COMMAND = 41, + VMPORT_ENTRIES +} VMPortCommand; + static inline void vmport_init(ISABus *bus) { isa_create_simple(bus, TYPE_VMPORT); } -void vmport_register(unsigned char command, VMPortReadFunc *func, void *opaque); +void vmport_register(VMPortCommand command, VMPortReadFunc *func, void *opaque); void vmmouse_get_data(uint32_t *data); void vmmouse_set_data(const uint32_t *data); From patchwork Tue Mar 10 16:53:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429925 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35AF61874 for ; Tue, 10 Mar 2020 16:57:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AD6521D7E for ; Tue, 10 Mar 2020 16:57:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FwGKI6E7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AD6521D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiCN-000748-AF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:57:43 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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, uint32_t addr) return port_state->vmx_version; } +static uint32_t vmport_cmd_get_bios_uuid(void *opaque, uint32_t addr) +{ + X86CPU *cpu = X86_CPU(current_cpu); + uint32_t *uuid_parts = (uint32_t *)(qemu_uuid.data); + + cpu->env.regs[R_EAX] = le32_to_cpu(uuid_parts[0]); + cpu->env.regs[R_EBX] = le32_to_cpu(uuid_parts[1]); + cpu->env.regs[R_ECX] = le32_to_cpu(uuid_parts[2]); + cpu->env.regs[R_EDX] = 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 = X86_CPU(current_cpu); @@ -184,9 +197,13 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) isa_register_ioport(isadev, &s->io, 0x5658); port_state = 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); + } } static Property vmport_properties[] = { 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 address); typedef enum { VMPORT_CMD_GETVERSION = 10, + VMPORT_CMD_GETBIOSUUID = 19, VMPORT_CMD_GETRAMSIZE = 20, VMPORT_CMD_VMMOUSE_DATA = 39, VMPORT_CMD_VMMOUSE_STATUS = 40, From patchwork Tue Mar 10 16:53:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429931 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 168D214B7 for ; Tue, 10 Mar 2020 16:59:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD2D122522 for ; Tue, 10 Mar 2020 16:59:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="EeZ2bjqc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD2D122522 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiDi-0000UJ-UI for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:59:06 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 { uint32_t vmx_version; uint8_t vmx_type; + uint32_t max_time_lag_us; uint8_t version; } VMPortState; @@ -157,6 +158,20 @@ static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) return ram_size; } +static uint32_t vmport_cmd_time(void *opaque, uint32_t addr) +{ + X86CPU *cpu = X86_CPU(current_cpu); + qemu_timeval tv; + + if (qemu_gettimeofday(&tv) < 0) { + return UINT32_MAX; + } + + cpu->env.regs[R_EBX] = (uint32_t)tv.tv_usec; + cpu->env.regs[R_ECX] = 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); } } @@ -218,6 +234,11 @@ static Property vmport_properties[] = { 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, 1000000), 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 = 10, VMPORT_CMD_GETBIOSUUID = 19, VMPORT_CMD_GETRAMSIZE = 20, + VMPORT_CMD_GETTIME = 23, VMPORT_CMD_VMMOUSE_DATA = 39, VMPORT_CMD_VMMOUSE_STATUS = 40, VMPORT_CMD_VMMOUSE_COMMAND = 41, From patchwork Tue Mar 10 16:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429929 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1390514BC for ; Tue, 10 Mar 2020 16:59:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCBD7222D9 for ; Tue, 10 Mar 2020 16:59:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="b2rk7Fat" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCBD7222D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiDi-0000Rl-Bh for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:59:06 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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; } +static uint32_t vmport_cmd_time_full(void *opaque, uint32_t addr) +{ + X86CPU *cpu = X86_CPU(current_cpu); + qemu_timeval tv; + + if (qemu_gettimeofday(&tv) < 0) { + return UINT32_MAX; + } + + cpu->env.regs[R_ESI] = (uint32_t)((uint64_t)tv.tv_sec >> 32); + cpu->env.regs[R_EDX] = (uint32_t)tv.tv_sec; + cpu->env.regs[R_EBX] = (uint32_t)tv.tv_usec; + cpu->env.regs[R_ECX] = 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); } } 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 = 39, VMPORT_CMD_VMMOUSE_STATUS = 40, VMPORT_CMD_VMMOUSE_COMMAND = 41, + VMPORT_CMD_GETTIMEFULL = 46, VMPORT_ENTRIES } VMPortCommand; From patchwork Tue Mar 10 16:53:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F4A514B7 for ; Tue, 10 Mar 2020 17:01:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3569B21D7E for ; Tue, 10 Mar 2020 17:01:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="VKC9UDD6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3569B21D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiFw-0004CY-CZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 13:01:24 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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; +/* 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) typedef struct VMPortState { @@ -188,6 +195,11 @@ static uint32_t vmport_cmd_time_full(void *opaque, uint32_t addr) return VMPORT_MAGIC; } +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); } } 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 = 40, VMPORT_CMD_VMMOUSE_COMMAND = 41, VMPORT_CMD_GETTIMEFULL = 46, + VMPORT_CMD_GET_VCPU_INFO = 68, VMPORT_ENTRIES } VMPortCommand; From patchwork Tue Mar 10 16:53:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED35592A for ; Tue, 10 Mar 2020 17:00:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C261521D7E for ; Tue, 10 Mar 2020 17:00:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="nvm2LW5Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C261521D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiFB-0003A0-0y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 13:00:37 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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, uint32_t addr) static uint32_t vmport_cmd_get_vcpu_info(void *opaque, uint32_t addr) { - return 1 << VCPU_INFO_RESERVED_BIT; + X86CPU *cpu = X86_CPU(current_cpu); + uint32_t ret = 0; + + if (cpu->env.features[FEAT_1_ECX] & CPUID_EXT_X2APIC) { + ret |= 1 << VCPU_INFO_LEGACY_X2APIC_BIT; + } + + return ret; } /* vmmouse helpers */ From patchwork Tue Mar 10 16:53:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3ED4592A for ; Tue, 10 Mar 2020 17:02:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 150D921D7E for ; Tue, 10 Mar 2020 17:02:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="bwXbOksO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 150D921D7E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBiHG-0005dB-BO for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 13:02:46 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 +/* 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 @@ -1496,6 +1500,8 @@ int kvm_arch_init_vcpu(CPUState *cs) } } + env->apic_bus_freq = KVM_APIC_BUS_FREQUENCY; + /* Paravirtualization CPUIDs */ r = hyperv_handle_properties(cs, cpuid_data.entries); if (r < 0) { @@ -1800,9 +1806,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; c->function = KVM_CPUID_SIGNATURE | 0x10; c->eax = env->tsc_khz; - /* LAPIC resolution of 1ns (freq: 1GHz) is hardcoded in KVM's - * APIC_BUS_CYCLE_NS */ - c->ebx = 1000000; + c->ebx = env->apic_bus_freq / 1000; /* Hz to KHz */ c->ecx = c->edx = 0; c = cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); From patchwork Tue Mar 10 16:53:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 905A7139A for ; Tue, 10 Mar 2020 16:52:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6652C20873 for ; Tue, 10 Mar 2020 16:52:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cYc/oiJk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6652C20873 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36907 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi7j-0000TA-Jn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:52:55 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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, uint32_t addr) return ram_size; } +static uint32_t vmport_cmd_get_hz(void *opaque, uint32_t addr) +{ + X86CPU *cpu = X86_CPU(current_cpu); + + if (cpu->env.tsc_khz && cpu->env.apic_bus_freq) { + uint64_t tsc_freq = (uint64_t)cpu->env.tsc_khz * 1000; + + cpu->env.regs[R_ECX] = cpu->env.apic_bus_freq; + cpu->env.regs[R_EBX] = (uint32_t)(tsc_freq >> 32); + cpu->env.regs[R_EAX] = (uint32_t)tsc_freq; + } else { + /* Signal cmd as not supported */ + cpu->env.regs[R_EBX] = UINT32_MAX; + } + + return cpu->env.regs[R_EAX]; +} + static uint32_t vmport_cmd_time(void *opaque, uint32_t addr) { X86CPU *cpu = 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 = 39, VMPORT_CMD_VMMOUSE_STATUS = 40, VMPORT_CMD_VMMOUSE_COMMAND = 41, + VMPORT_CMD_GETHZ = 45, VMPORT_CMD_GETTIMEFULL = 46, VMPORT_CMD_GET_VCPU_INFO = 68, VMPORT_ENTRIES From patchwork Tue Mar 10 16:53:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11429917 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E25C9139A for ; Tue, 10 Mar 2020 16:54:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7F7A222C3 for ; Tue, 10 Mar 2020 16:54:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZziFfvhx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7F7A222C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBi9X-0003f2-0Z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 Mar 2020 12:54:47 -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 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== 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 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 *opaque) { assert(command < VMPORT_ENTRIES); + assert(port_state); + trace_vmport_register(command, func, opaque); port_state->func[command] = func; port_state->opaque[command] = opaque;