From nobody Thu Nov 13 23:25:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1583800758; cv=none; d=zohomail.com; s=zohoarc; b=AQyIcOK2604YgiEr88kEAj9YLl5TpryTbfwdYorfLe+IidgoJ6fj5PEvv8bQwrKr9FEqce5ONu24vP3fpBByQfdGJTR/9jLpqCW/jYuNoeoLBzfzTnkFN7tkbdDhWbG/SRn81TYM9/vaiMnyf2u25ITpCIqX1F8RnlCxUVIURNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583800758; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fRLOQ0i2fa3f5CcKlbY/dGaHuzyDTPmiV0AbAqY4DZE=; b=iMVtJpiFdWw9wSewuTP1rppxtaLecva2vMmMRpbgOvA8SBf1EOODzkTqPOI5azPJ4/lStyVCrnHUN9rg6Xdf2imPS2IDVf8YTnIeh72UVZUVuZkpAMpvuQUWLNYHFISByP2/n7i31L5NGlraTjNS1TbpNJCoYTPIpLEb7tz9l7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15838007588921005.7383247070566; Mon, 9 Mar 2020 17:39:18 -0700 (PDT) Received: from localhost ([::1]:52000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSvU-0000fS-Ov for importer@patchew.org; Mon, 09 Mar 2020 20:39:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44575) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBSuZ-000805-P2 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 20:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBSuY-00059D-6d for qemu-devel@nongnu.org; Mon, 09 Mar 2020 20:38:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:38366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBSuX-00057r-U1 for qemu-devel@nongnu.org; Mon, 09 Mar 2020 20:38:18 -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 02A0We7I023879; Tue, 10 Mar 2020 00:38:15 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2ym3jqj91w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 00:38:15 +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 02A0VRHn173226; Tue, 10 Mar 2020 00:38:14 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ymun85jt6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Mar 2020 00:38:14 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02A0cDDL001873; Tue, 10 Mar 2020 00:38:13 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Mar 2020 17:38:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=fRLOQ0i2fa3f5CcKlbY/dGaHuzyDTPmiV0AbAqY4DZE=; b=X/QeqwgvYReMPzOjLUs8on/9ZIG6BBQfXf6P2Me6SxrhZEEEL7Y8BNPhUnhmbqxBMRVt XUbhaqwLEuHlBGa73irfvtMFy5QD/oapmcJhKcajzyXEhiWN7W1lrNwjiLnjQJhsBHw3 KhV5FccCmytoHkIQUm/nv76PFnQKNcd0cZ86uu16EctijpPXVE9wS6AjlGOy3gS4IARI rz68OZiXpcZB4sZ3SjOEDN3uRqGk/sgsnnXJSK2H8Vh3oydozjlAk1oGCB6lRBHiamjK u1g0mH0m+058ryQFR7ubuHxTlEOMMoUUwOazaqHwGgb7hRl4DLmjYbwQxEU+eNvv7tze eQ== From: Liran Alon To: qemu-devel@nongnu.org Subject: [PATCH] i386/kvm: Add CPU property to expose VMware CPUID signature Date: Tue, 10 Mar 2020 02:40:17 +0200 Message-Id: <20200310004017.100484-1-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9555 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 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-2003100000 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=1011 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-2003100000 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: pbonzini@redhat.com, mtosatti@redhat.com, Liran Alon , ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Some guests are only familiar with VMware PV interface. Therefore, in order for these guests to run properly on KVM, we need to be able to expose VMware main CPUID leaf. i.e. leaf 0x40000000. E.g. Without exposing this VMware CPUID leaf, some guests will fail to boot. For example, because of guest attempt to calibrate TSC. Signed-off-by: Liran Alon --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm.c | 35 +++++++++++++++++++++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 92fafa265914..694766d45a9b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7127,6 +7127,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), + DEFINE_PROP_BOOL("vmware-cpuid", X86CPU, expose_vmware, false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 9c7cd7cde107..bca626963e25 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1647,6 +1647,7 @@ struct X86CPU { */ bool force_features; bool expose_kvm; + bool expose_vmware; bool expose_tcg; bool migratable; bool migrate_smi_count; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 00917196dffb..2656258b96b3 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1187,6 +1187,15 @@ static int hyperv_handle_properties(CPUState *cs, if (!hyperv_enabled(cpu)) return 0; =20 + /* + * VMware & Hyper-V conflicts in CPUID leafs. + * Therefore, they cannot exists together. + */ + if (cpu->expose_vmware) { + error_report("vmware-cpuid not compatible with hyperv options"); + return -ENOTSUP; + } + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) || cpu->hyperv_passthrough) { uint16_t evmcs_version; @@ -1508,6 +1517,18 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_hv_hypercall =3D true; } =20 + if (cpu->expose_vmware) { + c =3D &cpuid_data.entries[cpuid_i++]; + c->function =3D KVM_CPUID_SIGNATURE; + memcpy(signature, "VMwareVMware", 12); + c->eax =3D KVM_CPUID_SIGNATURE; + c->ebx =3D signature[0]; + c->ecx =3D signature[1]; + c->edx =3D signature[2]; + + kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; + } + if (cpu->expose_kvm) { memcpy(signature, "KVMKVMKVM\0\0\0", 12); c =3D &cpuid_data.entries[cpuid_i++]; @@ -1791,11 +1812,13 @@ int kvm_arch_init_vcpu(CPUState *cs) } } =20 - if (cpu->vmware_cpuid_freq - /* Guests depend on 0x40000000 to detect this feature, so only exp= ose - * it if KVM exposes leaf 0x40000000. (Conflicts with Hyper-V) */ - && cpu->expose_kvm - && kvm_base =3D=3D KVM_CPUID_SIGNATURE + if (cpu->vmware_cpuid_freq && + (cpu->expose_vmware || + /* + * Guests depend on 0x40000000 to detect this feature, so only ex= pose + * it if KVM exposes leaf 0x40000000. (Conflicts with Hyper-V) + */ + (cpu->expose_kvm && kvm_base =3D=3D KVM_CPUID_SIGNATURE)) /* TSC clock must be stable and known for this feature. */ && tsc_is_stable_and_known(env)) { =20 @@ -1805,7 +1828,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c->ebx =3D env->apic_bus_freq / 1000; /* Hz to KHz */ c->ecx =3D c->edx =3D 0; =20 - c =3D cpuid_find_entry(&cpuid_data.cpuid, kvm_base, 0); + c =3D cpuid_find_entry(&cpuid_data.cpuid, KVM_CPUID_SIGNATURE, 0); c->eax =3D MAX(c->eax, KVM_CPUID_SIGNATURE | 0x10); } =20 --=20 2.20.1