From patchwork Fri Mar 30 17:02:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10318123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 368C960383 for ; Fri, 30 Mar 2018 17:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2670E2A5C6 for ; Fri, 30 Mar 2018 17:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B4D72A5F8; Fri, 30 Mar 2018 17:05:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 972112A5C6 for ; Fri, 30 Mar 2018 17:05:41 +0000 (UTC) Received: from localhost ([::1]:53701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1xTA-0005Tj-U4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Mar 2018 13:05:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1xQ1-0002i5-8k for qemu-devel@nongnu.org; Fri, 30 Mar 2018 13:02:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1xPw-0006wG-Sg for qemu-devel@nongnu.org; Fri, 30 Mar 2018 13:02:25 -0400 Received: from mail-he1eur01on0711.outbound.protection.outlook.com ([2a01:111:f400:fe1e::711]:39856 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f1xPw-0006si-Kg for qemu-devel@nongnu.org; Fri, 30 Mar 2018 13:02:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eMIAoanFIv3GSCsNhMuGWy3IDQpgs9UONuqqTpmQujc=; b=hXB0OF42xxrgysh0fkcupqDneS1ixvYC+bD7aqezZr0529P6KVh+C0EGUwEF2u3MqAnxlUXxyAQG9S7MHD3k/7/P2SNCJblqI172CFRdnVQ5F5fsOjk3qhRhONwh91O/hkbHnqSU7/1BMw6/mGbhT8fjXI1382UrOsEj+SBfMkQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by AM5PR0801MB1970.eurprd08.prod.outlook.com (2603:10a6:203:4b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.10; Fri, 30 Mar 2018 17:02:17 +0000 From: Roman Kagan To: qemu-devel@nongnu.org, Paolo Bonzini , Eduardo Habkost , Vitaly Kuznetsov Date: Fri, 30 Mar 2018 20:02:08 +0300 Message-Id: <20180330170209.20627-2-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180330170209.20627-1-rkagan@virtuozzo.com> References: <20180330170209.20627-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0501CA0036.eurprd05.prod.outlook.com (2603:10a6:3:1a::46) To AM5PR0801MB1970.eurprd08.prod.outlook.com (2603:10a6:203:4b::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21b8bafb-03a0-497e-7170-08d5965ffe93 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1970; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 3:4iB6ZW9uH5m9cxagxyAerBdRHD9mAfTwhG6VJdj1uKNu9jaQkSdo4rBcu1zUvtFIoK3wLJRRKhFx4YMGHqk+vnvNeLVsAWQmK+Lf76949Y88jLQRFxIg8AanaSCqjyYZ0k1AzGHPB4cUn0NsJ9J/+N42ZTUqV43OjgAUgv7Llj6BTatleZuZfu3fzqV1XIOVXllTjlQ85yXNyyzTMI0LUAj3bVbvEN8Gcmu88dduoxwLEbo/QS7saIv8QlnHdXqs; 25:bNbS1hbtVD3i8u+eD07XIc3VfGgG6WALa5w0Kj6n6stuZXDpGJePUYuvQCPp7uW5wf0R/X4nu1UIdNgM0vkge/qiPazQF62OGcilxAkj3wNplDJGrskJkh9IzxwkHKQhuv+7XjNdMcvf4gddx2ismUJesnelw/5MoL6jC6/N9itSpaxWoOPCdeytYEcfxghzscFJHiqjxxIc9/FaUx0PqVijZfPiKWb5CyeZHr2cLMnRgfa1LKLeXSEsahW/cfOM5aI7F64aVkRWGji8mRdWyjWw2Alv5ANS+gcx8YlLj6KwbHbb1YNWjwEET3cOKZ5IiXRSFeldSdgqdLOPIln5fg==; 31:LWUOXlTfslYihi2J5J7f1ksTR5tOm4+0T59ghOXmGLuTxiLHUBEVtPYwZMKbudjNHysQO7en6+Gy3frd595TzD3FfkBPsOGELzkrkorNxw41kwNrQotff6qpsYDWMi2Xbub6fnMDvOz5iIJZdYi1bC8HnDSgcmd0NQKR9v+Xqk1CwqHhs053n8Nz1v/EpUR5q9Gw25mWNS/g/85zb0b43PIfNcv8a+idwFDzQh8KBNE= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1970: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 20:9oKY+95/edc089JHI6drFbE6nw0S/WT91rPbyxNPm7/VCpQFQ5ay8F6754wI0vmri+LSGtm4OcHtclG5XtyzdswikYq7H5jYMOEODatJwd7XUAfc0y92qgnPKNQRjqBFWM9ZpHSgzKGyjHaqrFMnbVA96V77QuN25ppSksOzpjB2F9efiMjABZt3ndQkXxkV2OxpKW3lkKiGJuGzdPZmgWV8npibYG4WoKmwnVylt4xswxphdBAU409X6Hk1OYpu8hDci8CsqUExMS22sE1C5wYT5Ckhs3JBLOGp6AId0F95uakU0dceDn/fube10h1k9VKR0rJxVaVqPYwMnzslRkkeKTXQ3rGCdHoFI1+ESsUvy1jPF0y+s+mFD5UmsOK2PhFxqqpeesE/Y7B5LYGmiLgtNxAMtK6KbYTFrpuR4dmt285R0Zj0suguJ+wB8Tm/BNNYrYd0coDG57cUWSHamt7v53CvMdKzsdxg+yiB22KfXY4w690HXm4xeg9rhSWl; 4:rWLulxW+6eVz+rFK9sQqxIIpMh/YtmAFWMwHcGwK3zukzoNvVu2YeSSLAGerpGzzM+zC9LmWojui+aI059l5mt9L7ExP12AApz+yV1tDXEnqfnMw/upaEBBO3zaeBFtNsCTBgYGV3Y4jo7F1svA8peZFeEjRyauYkS96gDiahH4O3rJu+lJxXg/E4OFCDUPzGqC13Nw2s0vXMqwgwJHcK8WfsbAZGtbtNodPn/tYbzzRgKyo+Hhubm934YP9S7+dT3eedfnKiDyAATqfEweQyg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(10201501046)(93006095)(93001095)(6041310)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:AM5PR0801MB1970; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1970; X-Forefront-PRVS: 06274D1C43 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39840400004)(396003)(346002)(366004)(376002)(39380400002)(189003)(199004)(6486002)(478600001)(386003)(59450400001)(52116002)(69596002)(51416003)(53936002)(97736004)(76176011)(68736007)(5660300001)(6506007)(105586002)(81166006)(50466002)(8936002)(1076002)(36756003)(305945005)(106356001)(2906002)(486005)(47776003)(6512007)(66066001)(16586007)(486005)(3846002)(48376002)(7736002)(476003)(11346002)(2616005)(316002)(50226002)(446003)(956004)(8676002)(25786009)(86362001)(110136005)(55236004)(6666003)(53416004)(26005)(6116002)(16526019)(186003)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1970; H:rkaganb.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1970; 23:KmMv1nZmaS/viYyctNFiipG9uQ9HJZigjd5kojr?= =?us-ascii?Q?/UacfPj2RzDnU2oZKdmdldrLAqMPnhjv3BuXL3pjFYmXHx4jwCJ+mTae/xAo?= =?us-ascii?Q?a+aewYozsLO5gJVFZ/f4bJJGO6T7/MMxFBemxcxtf2/uoDrk9i+mdstNp7e4?= =?us-ascii?Q?B+DBq6CqFhA8U8sutPhhjMktiSwzXF/ZryQHAXf6WEWUIbI1OR7bnNGC84zB?= =?us-ascii?Q?SteOUkOUmgRcNTpdyqHRdST6QnW7BVo9GS7LIQE5uyKU/NzRJun7WEQNnOav?= =?us-ascii?Q?b6GXK0kas5Zr+xdCkP4Uv2/IZGm0uZb+pG6vKN1P+GZx8+dVn7lk2Rm4mmWh?= =?us-ascii?Q?woCzTw33AkDrDv15H2KxLzfAKmxelzu/tr0ldJGcdOse+e5OiYeLXxa3UFl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VRGHhYPF3331pp90ZRH94nVzh8B7vtrOjXBH4wU?= =?us-ascii?Q?DkQ=3D=3D?= X-Microsoft-Antispam-Message-Info: ta15SqaMkYiLlPyQDKI126128Uye78FwZqbxj0BVz5JdP+0VWpc0MBGtMlHehh16Gb+K68FG6u5BgVd5Xly9zS0oWCYQXkmFmTyv7nqrXGoGaIrz5hQyojhpI3YkJQe5uLqPk3CvbmDxyo6HmwAOWdhFOY4Rl4zZiCilvrlb0t8mvLhELqSb31AbjY2CtdR+ X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 6:JchBS6BCg5iNB+KFBD+nBvKcMk09heDZRKINF0nmix42miPz84LZwSVLv3poW2S0rbbL5Uhbm34xpdd9iYZYwhAHPKtHf/DpeUJKFf/lluuStrIf7Sea6ahEoDNjSghOLSeZWtapQxRk8wm+FrJXPEOFUFKQO+XGjk/wUaPP8nlPgi6lcRbXceVbCnYIM6g4KfrjsVIRhnPeKdgkmiyNM+/ggWfnn4cjwODU75I9YAuhGqk8SV6st/o/qixD374e43DThiPGEgp2r2UnGYI5K6eHOaYtYxjkydnKPFv+voIobheK+m1FXEnPqQXy5NJCytTpGnxOq1C0TQcz8p8C5m7A/eUp+iNbT1fh6r9fQRVJBWvo3S0AZHLxdt+U6WgG22uzegtz6Uw1YbeOOCHJ2S41SpnTOaRqDmoSAmg+uHm7E9gQol7YeKMCYQ0Q80miG0roRz6dRvmEeJTmLYJU2g==; 5:Qd90A53WIM8ud3HjuHZORjbdxtwwlWUVNtnfC4+YH/nVSt+rVTIfxfqxaxHnINfEWmF9h49roNNgTo8csS9OZu9LE/UboQdxCKj52PP89emvCxhwioOvWTtifK4sCs/uD8sLsqfc90aw8lGJhfkOF1ByuYSDST81J21wnc96LnU=; 24:jEiby9sWva3loLbd6QBi/X919bow/f8y3s0sz2wsHOUAXwXe+Tf9+MY4Og31rC19b1ACwBgukdFB9hyk9od9jQyu6U73Z06DoJDoeQSkN2k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 7:BizEwJW9A6yOZxVyYfDOFBomNJI1qHQKaXazUELY0lGV80NU5gvuWBjqb3+aYdN52Su36h1Caa6NavHDdPAJjMqvR2FHSmUHrguHcitx0455Y1db2xZ+jL9nUCYKb37X9F9ACLELotV5twel3KX/TZI1Ubk0rFS9mEd/0+Wa7WVqFBNlM9GiK/GcJbPHHE4gJrpGvApCb7nS2JYMoT2ADf4tC7Z5ykvq7RkqB3EYUPv05LAO190MToxT2/0aFIif; 20:dK+H83jjz8d2bTvTlP6YA7CfFo4Ry+NicOjlhl6JUIHIywmKyQO2TxcbsSKyC6AHBz6iGqPR+0n8ahGbwG91qBpen1q1jra5JqOl92/s1Xt9TYJDVQXGPCh/9nWoV3IMdS36jFC68C2rJ3T63H7CpRw8zHNPbQhfcw26ZTtXUdo= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2018 17:02:17.6475 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21b8bafb-03a0-497e-7170-08d5965ffe93 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1970 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe1e::711 Subject: [Qemu-devel] [PATCH for-2.12 v3 1/2] i386/hyperv: add hv-frequencies cpu property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to guarantee compatibility on migration, QEMU should have complete control over the features it announces to the guest via CPUID. However, the availability of Hyper-V frequency MSRs (HV_X64_MSR_TSC_FREQUENCY and HV_X64_MSR_APIC_FREQUENCY) depends solely on the support for them in the underlying KVM. Introduce "hv-frequencies" cpu property (off by default) which gives QEMU full control over whether these MSRs are announced. While at this, drop the redundant check of the cpu tsc frequency, and decouple this feature from hv-time. Signed-off-by: Roman Kagan Reviewed-by: Eduardo Habkost --- v2 -> v3: - no changes v1 -> v2: - indicate what flag requested the feature that can't be enabled in the error message target/i386/cpu.h | 1 + target/i386/cpu.c | 1 + target/i386/kvm.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 78db1b833a..1b219fafc4 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1296,6 +1296,7 @@ struct X86CPU { bool hyperv_runtime; bool hyperv_synic; bool hyperv_stimer; + bool hyperv_frequencies; bool check_cpuid; bool enforce_cpuid; bool expose_kvm; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 555ae79d29..1a6b082b6f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4761,6 +4761,7 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_BOOL("hv-runtime", X86CPU, hyperv_runtime, false), DEFINE_PROP_BOOL("hv-synic", X86CPU, hyperv_synic, false), DEFINE_PROP_BOOL("hv-stimer", X86CPU, hyperv_stimer, false), + DEFINE_PROP_BOOL("hv-frequencies", X86CPU, hyperv_frequencies, false), DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true), diff --git a/target/i386/kvm.c b/target/i386/kvm.c index d23fff12f5..b35623ae24 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -648,11 +648,16 @@ static int hyperv_handle_properties(CPUState *cs) env->features[FEAT_HYPERV_EAX] |= HV_HYPERCALL_AVAILABLE; env->features[FEAT_HYPERV_EAX] |= HV_TIME_REF_COUNT_AVAILABLE; env->features[FEAT_HYPERV_EAX] |= HV_REFERENCE_TSC_AVAILABLE; - - if (has_msr_hv_frequencies && tsc_is_stable_and_known(env)) { - env->features[FEAT_HYPERV_EAX] |= HV_ACCESS_FREQUENCY_MSRS; - env->features[FEAT_HYPERV_EDX] |= HV_FREQUENCY_MSRS_AVAILABLE; + } + if (cpu->hyperv_frequencies) { + if (!has_msr_hv_frequencies) { + fprintf(stderr, "Hyper-V frequency MSRs " + "(requested by 'hv-frequencies' cpu flag) " + "are not supported by kernel\n"); + return -ENOSYS; } + env->features[FEAT_HYPERV_EAX] |= HV_ACCESS_FREQUENCY_MSRS; + env->features[FEAT_HYPERV_EDX] |= HV_FREQUENCY_MSRS_AVAILABLE; } if (cpu->hyperv_crash && has_msr_hv_crash) { env->features[FEAT_HYPERV_EDX] |= HV_GUEST_CRASH_MSR_AVAILABLE;