From patchwork Mon Mar 9 23:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428191 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 7121014BC for ; Mon, 9 Mar 2020 23:54: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 439432146E for ; Mon, 9 Mar 2020 23:54: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="A0NVaput" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 439432146E 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]:51600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSEH-0008U6-Gz for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:54:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35037) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCA-00051g-FC for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSC9-0006JQ-Fa for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55096) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSC9-0006Id-9A for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:25 -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 029NqOid028646; Mon, 9 Mar 2020 23:52:24 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=RiGzcldj+3+tktzDcpK75N8cjWY3hW0sB90AU/C1KRI=; b=A0NVaput3oU8d5xhNyfVSuzfo0XZ3KZVdIL5hIv1cnKjR0s0UfjnbCnXZ7WcGM86aaFA 8yEJ+rBFhMW9A9sRR7Gda2n7b7ZwveUNg+/M+JATjyyWBDgBKSidEBy3xA+GccZdiHLb P65+1jUi23+LZAj0VQ4yXNUCb/VPQjwRFS+AVS/P/bx2Lek/NWuXXo4CGM2tdPuKKu6v EK9sOMUtUw5hE79jyHBGYmb0MKZkARAkuld9d1EUsxL0DTXqzFU6EdMGkPytPv2T8w0z muq7k3Uw2Zk6OwELASBcsPweKqbBjW1BRgSUwrzYUBWRxQkjdHfAM2O4TqOY+NkNFD1I Uw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2ym3jqj5kt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:24 +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 029Nh6MC037556; Mon, 9 Mar 2020 23:52:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2ymndg0bfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:17 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqGl4010809; Mon, 9 Mar 2020 23:52:16 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:16 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 02/14] hw/i386/vmport: Set EAX to -1 on failed and unsupported commands Date: Tue, 10 Mar 2020 01:53:59 +0200 Message-Id: <20200309235411.76587-3-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=1 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 9319720e8204..a78e20040a79 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -72,6 +72,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, eax = env->regs[R_EAX]; if (eax != VMPORT_MAGIC) { + eax = UINT32_MAX; goto out; } @@ -79,6 +80,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr addr, trace_vmport_command(command); if (command >= VMPORT_ENTRIES || !s->func[command]) { qemu_log_mask(LOG_UNIMP, "vmport: unknown command %x\n", command); + eax = UINT32_MAX; goto out; } From patchwork Mon Mar 9 23:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428197 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 138AE92A for ; Mon, 9 Mar 2020 23:56:00 +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 DCAEA2146E for ; Mon, 9 Mar 2020 23:55:59 +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="y60/kXvM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCAEA2146E 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]:51656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSFb-0002bK-2j for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35051) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCA-00051h-SH for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSC9-0006K7-S4 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:26 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59942) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSC9-0006FG-Jy for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:25 -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 029NhE3S016506; Mon, 9 Mar 2020 23:52:21 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=UVlAki5BrSxj+rUNTGM3HT7wk0gYhvDL4hu8kYSSeLA=; b=y60/kXvMSawHrvtUxlMKfJItRQHuMH2N9TdukJJmwOIwEYxMQFb/GtKo+53yUjwV52MB QBlVm26oz9c3iRHUa40yniFGsDN6fa+1r+TQ0bdPXvsuLQ2PMRKw1oLEFaj6Wp9vU6Xp U+RWyJYDlwwy1h6IIuC/sELkqQZ3xLPwJr30rx/QaF6r8dXNtbOFsg5Pvl7Vk/lYZxlF BfHCR9UqT3gGH+3zX3k9zBtw0UWdQO5oKWYlE+RM5Q9Xv/ioHem6REY1NbEXk5PH1QIn 7AmdSTGCBdlqb18nj+j3FOEIoW3LWweNL/VD2gS2ZzA+331VR2godlRdMEvTDFKtFSrB Ew== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2ym48st17d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:21 +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 029Nh46c037433; Mon, 9 Mar 2020 23:52:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ymndg0bnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:20 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqIIq008340; Mon, 9 Mar 2020 23:52:18 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:18 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 03/14] hw/i386/vmport: Add device properties Date: Tue, 10 Mar 2020 01:54:00 +0200 Message-Id: <20200309235411.76587-4-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=1 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 a78e20040a79..7c21e56081b0 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" @@ -167,6 +168,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); @@ -174,6 +179,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 Mon Mar 9 23:54:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428187 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 420521731 for ; Mon, 9 Mar 2020 23:53:11 +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 C364124655 for ; Mon, 9 Mar 2020 23:53:10 +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="MVLX2yLk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C364124655 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]:51534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCr-00068V-E6 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:53:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35053) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCA-00051i-Sg for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSC9-0006Jn-Ov for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSC9-0006Io-GU for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:25 -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 029NqOu7028643; Mon, 9 Mar 2020 23:52:24 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=OFUlKCstA1w3vOK18OxhdCFfRTEmtmBiXOvstPi0cP8=; b=MVLX2yLkCWSPQqCXNl1NhKZC8QDHC7LZuk5AVxw9hr/DW6B4L9BWlNjx35TVVIIPHP6+ ooToBIgmzhHXBg4oPoxxK9PLJQljFNBfUZj3reYAXswjUbfE9JsuipdQ0vyuUjksRAZi 6cPsiGkOzOo+VGAqRQPeLXzfdw5VybAG3r6WAEbnn/LvnYdYVqrH4SlQ9zuDu3fc6vnH +tbM1HF54SB0qd3R50ZDADTzbvr0xePfA+XOG5wB6nM2SA6NHnSydzReHiIcJ9cBDuP0 k5lT4Y3IUjweF4POHn2SWeeVyvVdQqEr3TsrhVx9pOIh9wOazcAF0QxYjHjMwFoGiGv1 Bg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2ym3jqj5kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:24 +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 029NpvHY101571; Mon, 9 Mar 2020 23:52:22 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2ymun81c5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:22 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqLgd008343; Mon, 9 Mar 2020 23:52:21 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:20 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 04/14] hw/i386/vmport: Introduce vmx-version property Date: Tue, 10 Mar 2020 01:54:01 +0200 Message-Id: <20200309235411.76587-5-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=1 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of hard-coding the VMX version, make it 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 7c21e56081b0..a2c8ff4b59cf 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]; + + uint32_t vmx_version; } VMPortState; static VMPortState *port_state; @@ -112,7 +114,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) @@ -169,6 +171,8 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) } 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_END_OF_LIST(), }; From patchwork Mon Mar 9 23:54:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428201 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 7A8EB92A for ; Mon, 9 Mar 2020 23:57: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 4FD7E24655 for ; Mon, 9 Mar 2020 23:57: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="fb41a+uF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FD7E24655 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]:51684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSGy-0004Rr-FZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35081) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCB-00051w-VP for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCA-0006L5-R1 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCA-0006KI-Hj for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:26 -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 029NqOmT028674; Mon, 9 Mar 2020 23:52:24 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=YuoeCKeVFtn8DTMNE+e1YDELpF+RzZuG2WO4G1108RM=; b=fb41a+uFJ0+QePvX3ABo3UrV+YIj2DnbtDVFyEAaaMfP5B65DF2KiN+2dFdmmv5xac3l PPGk0tGaEvOsCrpMiVcRJn8S1IqxauV6kJVp5JEYxl30xmScafVmY/9O4UQ8pMVtAc0g TlSneTA9elQYjVzLqqdnGaOtvNIRnqqrdW+uzwUCHDTo3OQR2d4sKHWA8dbYy5CDSj9s q7aelaorgBBqR8FSNhUEE2FhaFESVC06XVSJnboNen2vwsOyp8xbmTvKdZC0gnTOcmBv BBc5+X3Zerv779bSQQx5Mvsgm99PrZo28SxlqrVOi9VIvQbTBKoIRZQ+tDPb/IkxBLAz eA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2ym3jqj5m1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:24 +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 029Nq1GR101651; Mon, 9 Mar 2020 23:52:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2ymun81cca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:24 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqNqq027293; Mon, 9 Mar 2020 23:52:23 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:23 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 05/14] hw/i386/vmport: Report VMX type in CMD_GETVERSION Date: Tue, 10 Mar 2020 01:54:02 +0200 Message-Id: <20200309235411.76587-6-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=1 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index a2c8ff4b59cf..c03f57f2f636 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -36,6 +36,15 @@ #define VMPORT_ENTRIES 0x2c #define VMPORT_MAGIC 0x564D5868 +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 */ +} VMX_Type; + #define VMPORT(obj) OBJECT_CHECK(VMPortState, (obj), TYPE_VMPORT) typedef struct VMPortState { @@ -46,6 +55,7 @@ typedef struct VMPortState { void *opaque[VMPORT_ENTRIES]; uint32_t vmx_version; + uint8_t vmx_type; } VMPortState; static VMPortState *port_state; @@ -114,6 +124,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; + cpu->env.regs[R_ECX] = port_state->vmx_type; return port_state->vmx_version; } @@ -173,6 +184,8 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) 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 Mon Mar 9 23:54:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428211 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 3DEBC139A for ; Tue, 10 Mar 2020 00:01:48 +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 128032146E for ; Tue, 10 Mar 2020 00:01:48 +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="GcMKgC+Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 128032146E 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]:51774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSLD-0000aR-9J for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 20:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36719) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSEA-0008JR-O5 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSE9-0008HU-FT for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:30 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33468) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSE9-0008H9-7j for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:29 -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 029NrN7A077661; Mon, 9 Mar 2020 23:54:27 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=AI8fsWz4vAA3zeztXvmKiyZ4peItDxs1dxwAZoFxQw4=; b=GcMKgC+Znjp+BD2kFwa1N4o8eFQFNKYfCy2SkBe3vecWWeNuRJXP9cUBN+2dYp57AtvO xCgvmwexJnZ9ksXNWRNN+hDGkC7QoOZ1LYPLvVp03vaPPvlHS3q3PMofRNJ7qCNwzfCk nUcLjtrB1UhSOQUKQsDGlSDnFmJaLtoafCgrgrPm8Xn8QTPzLZaweyfYKOIHRu9Jn7Pd kiqa4DwROzxEMn8+A4BOp2OKXr0GbL0FIoAi6dUEWIlOTyLqu1+aF+yI/2+V0q2Htlar kpyuUHkZprru0jIOwwIDlJmI4MPLmyQgQMVJol8YgWPHgou3nHQjdjNYEtXhTt5ath6/ vw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2ym48st1b7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:54:27 +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 029Nh7MS120687; Mon, 9 Mar 2020 23:52:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2ymn3hcg7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:27 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqQWO008473; Mon, 9 Mar 2020 23:52:26 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:25 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 06/14] hw/i386/vmport: Define enum for all commands Date: Tue, 10 Mar 2020 01:54:03 +0200 Message-Id: <20200309235411.76587-7-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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/pc.h | 11 ++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index e8e62bd96b8c..a61042fc0c5e 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -33,12 +33,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 @@ -196,10 +190,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); @@ -218,7 +212,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: @@ -275,9 +269,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 c03f57f2f636..2ae5afc42b50 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -30,10 +30,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 typedef enum { @@ -60,12 +56,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/pc.h b/include/hw/i386/pc.h index d5ac76d54e1f..7f15a01137b1 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -138,12 +138,21 @@ GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled); #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 Mon Mar 9 23:54:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428213 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 3C49B92A for ; Tue, 10 Mar 2020 00:02:43 +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 104912146E for ; Tue, 10 Mar 2020 00:02:43 +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="QrHvxUny" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 104912146E 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]:51792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSM6-0001Rz-8w for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 20:02:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36801) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSEG-0008TE-AS for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSEF-0008Lo-BK for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:36 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSEF-0008LO-3K for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54: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 029NqOBF028656; Mon, 9 Mar 2020 23:54:33 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=usXpjf9SgX44iK30z296nwFn4wbvkZ91KHKXLheMRDY=; b=QrHvxUnyjd2crOkxr99rV3gJAndjm34pQ2d7oPlUFMWQxpMuWCsqxs9xK/7GWdv5ZVgR INLUH/OkgiqIzhFX/GtdOLQByBeIx/O3nzaqEJeB8Mqb4poY0TM9YvEPmBM9uYZJdNbG XQYiRU/yqf4UqiNkEG4eR1YRNtX9qHehWwAGkwHxgu/et9F6Oh44eiLsv3g0/EtDo8AK 6IgYauS6m3IUxM20V7PDBYroOIFNBMWJQEWsWubw3fAsVCGiijbpiZJ7HBdee5Is5kKY zG8qNnyJItcQNX2Vj8f8WGUn9qmXN6grs7fNK1faY4I/lIw8hE+QOhzV17NfqSDFfT2e 9A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2ym3jqj5qq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:54:33 +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 029NhI5U120943; Mon, 9 Mar 2020 23:52:32 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2ymn3hcggs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:32 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqV87010916; Mon, 9 Mar 2020 23:52:31 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:31 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 07/14] hw/i386/vmport: Add support for CMD_GETBIOSUUID Date: Tue, 10 Mar 2020 01:54:04 +0200 Message-Id: <20200309235411.76587-8-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=1 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 | 14 ++++++++++++++ include/hw/i386/pc.h | 1 + 2 files changed, 15 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 2ae5afc42b50..7687f3368a55 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -26,6 +26,7 @@ #include "hw/i386/pc.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" @@ -121,6 +122,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] = uuid_parts[0]; + cpu->env.regs[R_EBX] = uuid_parts[1]; + cpu->env.regs[R_ECX] = uuid_parts[2]; + cpu->env.regs[R_EDX] = 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); @@ -171,6 +184,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) port_state = s; /* Register some generic port commands */ vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); + vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 7f15a01137b1..ea87eb93511e 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -140,6 +140,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 Mon Mar 9 23:54:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428195 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 5B00B138D for ; Mon, 9 Mar 2020 23:55: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 2D44C2146E for ; Mon, 9 Mar 2020 23:55: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="yftAGqTP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D44C2146E 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]:51632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSF1-0001O3-Cu for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:55:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36833) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSEI-00004x-Ap for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSEH-0008Mw-6D for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:38 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33596) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSEG-0008MT-V9 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:54:37 -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 029NrLth077552; Mon, 9 Mar 2020 23:54:35 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=QSP5saFzEDgsn5bThEih2l0XfjK5e/tXIVv97DZzaxU=; b=yftAGqTPVMpsDu6QkeqwQMmblCtgYV7pSJnxs3OPFghevMu4axoaB3O3o80kJ+yYQKmf DYlJXgjOvUaYq+OYRjBC7oK8G9Ouhe6OjejO9pmMaP6fllj1oYiNC5TOc1VIBRapxt1Q AXdB+kBL8MhA2Qqa7svUebxp6rl6bbF4KuVU8Z3mshomhbP+bK46J+TUmASMlH536MRl 4qGPhih17y/vClDK/B6tOZZeM+XJ17w/+JMPRYOlAWY5xQuB9wers/5PPO9HDKhwnWc5 3q4ecaPj3bVqiDxpdvKXmMJP6f3NHkcKcHvJB4Q2/esAAX0lZp1xhA3Rzj8w0pByMb4K tw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2ym48st1bh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:54:35 +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 029NhI9G120936; Mon, 9 Mar 2020 23:52:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2ymn3hcgm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:34 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqXCr027364; Mon, 9 Mar 2020 23:52:33 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:33 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 08/14] hw/i386/vmport: Add support for CMD_GETTIME Date: Tue, 10 Mar 2020 01:54:05 +0200 Message-Id: <20200309235411.76587-9-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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/pc.h | 1 + 2 files changed, 22 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 7687f3368a55..21253933215b 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -53,6 +53,7 @@ typedef struct VMPortState { uint32_t vmx_version; uint8_t vmx_type; + uint32_t max_time_lag_us; } VMPortState; static VMPortState *port_state; @@ -142,6 +143,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) { @@ -186,6 +201,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); + vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); } static Property vmport_properties[] = { @@ -193,6 +209,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/pc.h b/include/hw/i386/pc.h index ea87eb93511e..3ab3541b3a90 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -142,6 +142,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 Mon Mar 9 23:54:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428207 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 5B026138D for ; Mon, 9 Mar 2020 23:59:15 +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 2FF4A2146E for ; Mon, 9 Mar 2020 23:59:15 +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="LMuZLQUo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FF4A2146E 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]:51716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSIk-0006ma-BQ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:59:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35308) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCP-0005K5-0G for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCO-0006cC-1j for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:40 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47558) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCN-0006bP-Q1 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:39 -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 029NqU9k147088; Mon, 9 Mar 2020 23:52:38 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=I5npdYFmXraRVLDDtm1dc6rep91PsCndpTDMy4mO0yQ=; b=LMuZLQUoDqT/352gwR5l8WyDMu7vUP5+Zc3rVXkGguHsPIHs8xoR+2v2+x98WT2qe/Yz h5zPUwTk9uc7R77oENF/Zato0Fi1cE7hZfc0W40qHPVqL4QkIoF1OTk21sbRbdMEDzbf 7iPsl+vdVzAjiUFMWbE06G2c5FSoom8UgbHu/m5XKGH/leJiJv66CW4LWcuEYhRQXoKS zjZxAL4z0LpHroCa23YhhpWym5KafT1wDdXIz6oJrOGqOKo9yRQnQEiw/8v5yfZ0xCSL R2qyMn19dUDAXINLCSzaQ4XzF8iN5yvKTn4hC2YMaT0RyJ/99ENmh2JoP1rm56Z2QxL9 SA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2ym31ua65j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:37 +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 029NhI5V120943; Mon, 9 Mar 2020 23:52:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2ymn3hcgrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:37 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqalC008367; Mon, 9 Mar 2020 23:52:36 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:36 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 09/14] hw/i386/vmport: Add support for CMD_GETTIMEFULL Date: Tue, 10 Mar 2020 01:54:06 +0200 Message-Id: <20200309235411.76587-10-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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/pc.h | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 21253933215b..26231fc9d718 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -157,6 +157,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) { @@ -202,6 +218,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); + vmport_register(VMPORT_CMD_GETTIMEFULL, vmport_cmd_time_full, NULL); } static Property vmport_properties[] = { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 3ab3541b3a90..14d321e3cbbe 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -146,6 +146,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 Mon Mar 9 23:54:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428189 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 CFC75138D for ; Mon, 9 Mar 2020 23:53:32 +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 A44912146E for ; Mon, 9 Mar 2020 23:53: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="GQ8Y8jr0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A44912146E 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]:51541 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSDD-0006hE-Ov for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35357) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCR-0005OB-Gj for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCQ-0006fO-Fk for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:43 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47606) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCQ-0006eJ-7o for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:42 -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 029NqePh147313; Mon, 9 Mar 2020 23:52: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=4fT4sH3CM+0bfjxe/9m0bbXFNx4zOlz71rDmJ+Z877k=; b=GQ8Y8jr0q3pT54JGOJc4Pgk7gkfXKs84ZVCpToZb+yWFtiFUvk6dR5KWGi1QDFnMJTGd 2pW7SfLFFtpbhF2Xrzm+VmRlp5zYelZ6z2CTa9JFq7GytmJk6a3UwZ4lDp/Pf34aGe2N niITPjW20M5SCgdOYxOgtlWyKZPjcIYslVFFgrB3vQqwZN7kh0X5ij4P04XYzDOKcPkD 1+AIb9i1DvUJLhf32poV3vczOj/oLK9TLCj0m/O89fDzuImBSXZwJ4RIUv3MeTSDeMRs Ha1edmXf59OEVCkJshE+87FwGWc3lEn3lFqotVSVhojsgMFoU9lIcHPnx+kGDcuRv903 qA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ym31ua65q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:40 +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 029NqF8D102211; Mon, 9 Mar 2020 23:52:39 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ymun81d99-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:39 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqdiQ008501; Mon, 9 Mar 2020 23:52:39 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:38 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 10/14] hw/i386/vmport: Add support for CMD_GET_VCPU_INFO Date: Tue, 10 Mar 2020 01:54:07 +0200 Message-Id: <20200309235411.76587-11-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=1 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 | 13 +++++++++++++ include/hw/i386/pc.h | 1 + 2 files changed, 14 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 26231fc9d718..b33ef9c01d65 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -42,6 +42,13 @@ typedef enum { VMX_TYPE_WORKSTATION_ENTERPRISE /* Deprecated type used for ACE 1.x */ } VMX_Type; +/* 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 { @@ -173,6 +180,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) { @@ -219,6 +231,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, 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); } static Property vmport_properties[] = { diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 14d321e3cbbe..e880ca39ee3b 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -147,6 +147,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 Mon Mar 9 23:54:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428193 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 E7A2814BC for ; Mon, 9 Mar 2020 23:54: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 BC0142146E for ; Mon, 9 Mar 2020 23:54: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="fsqjprsc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC0142146E 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]:51620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSEZ-0000bS-UV for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:54:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35400) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCT-0005SH-Po for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCS-0006hw-SA for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47632) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCS-0006hF-Kc for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:52:44 -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 029NqePi147313; Mon, 9 Mar 2020 23:52:43 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=2wjVYVusXqahreDVrx8ai5a0+xGSxKRX3/lG+CE5nvI=; b=fsqjprscASjLhyXo3a9TUJunT0kQXmlQCVBrlfs4loanP/OFntIdCkpQfBXkSdKDfEuG UD+0Nt/8+5R59lEgh158R5Ett/+Tw/fv6egmMI5zS9GLEJbQD+1jQJAYylBvp3CKPPi7 mALiPcBPvhaqhTgkIZ9Ol687hK/plqBxbF4GtxIqVHKfNjLLeJWleOxd6My4IWp7cOxv 17mBJHcCTkw725GiqNfhI9RYS3x1gorTOuqC0QKjTu+PrTSE99nPXdeb2fhX6xfruVuu lFL380oCALLpyre9asCVPtKZHhIYQ31FncLGb3jEf3SpLRtpitsDT4iRutocL8AWy7Sk 2A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2ym31ua65s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:42 +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 029Npi2f101380; Mon, 9 Mar 2020 23:52:42 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2ymun81dcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:42 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029Nqffb027463; Mon, 9 Mar 2020 23:52:41 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:41 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 11/14] hw/i386/vmport: Allow x2apic without IR Date: Tue, 10 Mar 2020 01:54:08 +0200 Message-Id: <20200309235411.76587-12-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 mlxlogscore=799 phishscore=0 adultscore=0 suspectscore=1 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=863 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 b33ef9c01d65..2b0a623f19c1 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -182,7 +182,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 Mon Mar 9 23:54:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428199 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 874E592A for ; Mon, 9 Mar 2020 23:56:16 +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 5C6832146E for ; Mon, 9 Mar 2020 23:56:16 +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="ZExoTwHr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C6832146E 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]:51664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSFr-00034Q-KP for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:56:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35608) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCk-0005x8-PC for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCj-0006ym-Ox for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:02 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCj-0006xj-Gs for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:01 -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 029NhFXD016965; Mon, 9 Mar 2020 23:53:00 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=CZple/MNn1m0Ap+EilGNEJvBr/MWvXgtRAyz9gI0rvA=; b=ZExoTwHrM8TsurelaychaA75yh1IWwV4i9fobTGBrwYYPUoxV+7TFG3WPMtS8RPlJkO2 aeD61tmYAMBl65hUZ1UGYYnqGkgklCsq67rl2mWZ5RWm8fGb5mfQZwSgK3SMKp8xUOAw e4ugAZl/OhktGYyJAMLs71UNlgibPLNnP52sVoNLCIrRWRK+KnVWAshADIY6eXPP7tCv ZVh9oDv7AYlGBQ0KHdBvQsNco0h5VqqGATyiQsL/SM8DLICE1lGSYaG6vdUy7lqJiql7 7ckwPTj4U6R/vCl57VatsOQmXcPcjZQFtxvffodNFW70yDupi1jJBVdWRdDVhX7ygza+ qg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2ym48st188-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:59 +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 029NqxpT095582; Mon, 9 Mar 2020 23:52:59 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2ymnb1karr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:59 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 029NqiWu008509; Mon, 9 Mar 2020 23:52:44 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:43 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 12/14] i386/cpu: Store LAPIC bus frequency in CPU structure Date: Tue, 10 Mar 2020 01:54:09 +0200 Message-Id: <20200309235411.76587-13-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=1 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 --- linux-headers/asm-x86/kvm.h | 4 ++++ target/i386/cpu.h | 1 + target/i386/kvm.c | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 503d3f42da16..99eeaaf2f0b4 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -446,4 +446,8 @@ struct kvm_pmu_event_filter { #define KVM_PMU_EVENT_ALLOW 0 #define KVM_PMU_EVENT_DENY 1 +/* From arch/x86/kvm/lapic.h */ +#define KVM_APIC_BUS_CYCLE_NS 1 +#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS) + #endif /* _ASM_X86_KVM_H */ 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..00917196dffb 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1496,6 +1496,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 +1802,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 Mon Mar 9 23:54:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428209 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 0AD0392A for ; Tue, 10 Mar 2020 00:00:43 +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 D38052146E for ; Tue, 10 Mar 2020 00:00:42 +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="rrrl1qWp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D38052146E 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]:51748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSKA-00082N-3Z for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 20:00:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCn-00063Y-Ui for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCm-00072B-OX for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:05 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCm-00070l-Go for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:04 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029NqUus147112; Mon, 9 Mar 2020 23:53:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=xeXTfkCIs233YAHIBuNOs5RVrM+SnIVuZZRDkCcUbG8=; b=rrrl1qWpMGGG89rzRbjnZnfdaojjnaRIBAD9jOBuCh6K38uptGNjoM1knYgmTej1Thos 9QBRfWqT6oT97O7MUi0WX7fe1N/OGgr5XRlX4Y1xuBniMnfPpsvNkp1tG81jcqjiuNV1 avH9eFIATpMPQruPTtHAMzh8O2NNqZM6tTFKMVN8mvhuS4WQCLaKgdHdqXGBHfqkSoqC KmmbaU3XP9XyxxG0DChrHGPlAvrdhBqA2ahKMDFEbS8y79e84o3a44PIA3opyxh0/X9e yAg9f8TDTgxISo6jP/RJ+qeKLNz987YKOut8C8zQ7QCwPsb/S7T8REqSU6noiLupuJe3 Ew== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ym31ua669-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:53:02 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 029NqxYu095547; Mon, 9 Mar 2020 23:53:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2ymnb1kas9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:53:02 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqkGp027472; Mon, 9 Mar 2020 23:52:46 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:46 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 13/14] hw/i386/vmport: Add support for CMD_GETHZ Date: Tue, 10 Mar 2020 01:54:10 +0200 Message-Id: <20200309235411.76587-14-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=1 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 suspectscore=1 phishscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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/pc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/i386/vmport.c b/hw/i386/vmport.c index 2b0a623f19c1..95d4a23ce9ba 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -150,6 +150,24 @@ static uint32_t vmport_cmd_ram_size(void *opaque, 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); @@ -237,6 +255,7 @@ static void vmport_realizefn(DeviceState *dev, Error **errp) vmport_register(VMPORT_CMD_GETBIOSUUID, vmport_cmd_get_bios_uuid, NULL); vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); vmport_register(VMPORT_CMD_GETTIME, vmport_cmd_time, NULL); + vmport_register(VMPORT_CMD_GETHZ, vmport_cmd_get_hz, NULL); vmport_register(VMPORT_CMD_GETTIMEFULL, vmport_cmd_time_full, NULL); vmport_register(VMPORT_CMD_GET_VCPU_INFO, vmport_cmd_get_vcpu_info, NULL); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index e880ca39ee3b..679bf429c6a5 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -146,6 +146,7 @@ typedef enum { VMPORT_CMD_VMMOUSE_DATA = 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 Mon Mar 9 23:54:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 11428203 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 B97571874 for ; Mon, 9 Mar 2020 23:57:46 +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 8EF1024655 for ; Mon, 9 Mar 2020 23:57:46 +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="pHxkTscA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8EF1024655 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]:51688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSHJ-0004tW-RC for patchwork-qemu-devel@patchwork.kernel.org; Mon, 09 Mar 2020 19:57:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35646) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSCm-00060W-GO for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSCl-00070N-HH for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53:04 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSCl-0006zX-7U for qemu-devel@nongnu.org; Mon, 09 Mar 2020 19:53: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 029NjlrM072340; Mon, 9 Mar 2020 23:53: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=xNTTI5x1kaKVAyyBglmkCirKohEDRlK9NBufy8H3NOk=; b=pHxkTscAUIHQ+UCPsQTHZ0G7XnmeKK+g6ftQuDA45OHIkzzN3rSMObOPKET4KmzVM3pC oKrOPygMimDV3/YkyPwWszG9wL1rO+dg4zUJWCarbVpBtX+uYzTtrBBp6Xpg1SihJBKB v/LPMqdaQp8c5baiBTzB9wlfXDAHNPa0hqqzpdIelE5mV9mzCrxrCTTvoWtVBxRB9eEI 5BGojiULc2iehANkuHdeplPL/YFXwCNgcEZgtsO1oG1uYoq/x89L59P+FR4zDymZSsGG L53tuXsLJ+4SG4qEgKvx7jv7j0DmXheyOVVxsGGb7LvscW0hwv8lvPGxv20AhR1iHJj2 fw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2ym48st18f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:53:01 +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 029Nr1Ns095807; Mon, 9 Mar 2020 23:53:01 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2ymnb1kat3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 09 Mar 2020 23:52:59 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 029NqnNP010995; Mon, 9 Mar 2020 23:52:49 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 16:52:49 -0700 From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH 14/14] hw/i386/vmport: Assert vmport initialized before registering commands Date: Tue, 10 Mar 2020 01:54:11 +0200 Message-Id: <20200309235411.76587-15-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200309235411.76587-1-liran.alon@oracle.com> References: <20200309235411.76587-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=1 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090144 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 mlxlogscore=999 suspectscore=1 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2003090143 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Liran Alon , Nikita Leshenko , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+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 95d4a23ce9ba..659a323e8448 100644 --- a/hw/i386/vmport.c +++ b/hw/i386/vmport.c @@ -68,6 +68,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;