From patchwork Fri Mar 30 17:02:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10318121 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 6251560383 for ; Fri, 30 Mar 2018 17:05:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 502EB2A5C6 for ; Fri, 30 Mar 2018 17:05:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F552A5F8; Fri, 30 Mar 2018 17:05:33 +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 8F1992A5C6 for ; Fri, 30 Mar 2018 17:05:32 +0000 (UTC) Received: from localhost ([::1]:53691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1xT1-0005MU-NT for patchwork-qemu-devel@patchwork.kernel.org; Fri, 30 Mar 2018 13:05:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1xQ1-0002i4-83 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 1f1xPx-0006xl-ME 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 1f1xPx-0006si-55 for qemu-devel@nongnu.org; Fri, 30 Mar 2018 13:02:21 -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=2lbTUgtKJch9FzHI3y+xgOyLrLRi42ggxjshiIWmvP0=; b=XGHzsUfBajy0HXXdR5KmtT3Vzf+8x6pAhKtCSb7mLsntLdvUyYqek0PUvPIpCcwpDBBiW1ojvpJM8tp3O1RyV965eicA61wRp0g+MFzpVoM100IRkvXe+CJ+E5kp6J8WxOCbGCxbP0+RZ7Y/bRA9uiiaBIUjUGFJvyfu6IjOawA= 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:18 +0000 From: Roman Kagan To: qemu-devel@nongnu.org, Paolo Bonzini , Eduardo Habkost , Vitaly Kuznetsov Date: Fri, 30 Mar 2018 20:02:09 +0300 Message-Id: <20180330170209.20627-3-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: a4cffa49-c751-44ff-cea6-08d5965ffef3 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:E5c+Z2/SFcK2ChVD6PMR/vOSg/TbnJD+kyfMfKzMopiGhYttkjQ1888ZykbQrgV0JRXeqY7n79NPl0ltcaFwd7aiHdQPF41m7FWtRg6Mp5Tf/hum5IJXs+W8r7I7yt+1Pttjr5cB5uv2KT7kfIodrWdLA6i7mb685RyEXybOgmN4VjYaNoVOIAf0Ujc11AVpdPoiSB2VW2DOJ7BRkZtpoanRsO+1A3hD94Edhz2EnaFInYT7BK63FoT8qN3brRNl; 25:tNTd668mcLck+h8qCASjeq9lmpmQfTPVKlh1J9XnmsTETuQMiZsLeT1Fe9xTOhuxSRmpubF8hxqpLVfW3BdUxHAN3X+WxZkC1RFvSTgTaw1suYsz8AYN/Zc3H3SU2tTPGNOTr5gNG9rXQldmTm/xQaiO1e/i2BF9PJQwPIuuVWDuB56//bromG8JDJZwzVv8CeAWB5KEL9IgROAdMjVTQTkbudxjQc3j6qkjhsPgyy3Jh1hEFKJjv2AFbpu9CoAptdueaBIFE56OBKNawVsICLkLcera2Ao2qukZN87YZF+p6QKENhXPFz1VBKdePAON15vxh/OpeBP3mS2VmFOenw==; 31:wyM6Dprm9e9cjq/VBvlxt0YsMo2OBF5wXKCaigPgWSBtwc+XGm4pKP2NhVUVdeEnpFAdWpGG0HmFmkYiK577bRHzdJxMWQkQX3wEv8PTu8+VVJkPN6sWOn0uUFt9iR/WgWL5elI87dnjvrIjpmPre1T8PEMxEE9bqnMsGsqzNwez/6vnmn91b6L/X1sXfeQcRR5iXbIJl5bCo/435QXZYPpo30Am9wvgXfGoXujhxyM= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1970: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 20:tVnluCW/RnbdCGLVbZQoYfccDy6XFUrP5Z5DMV48Sjgn2Fwbp3UNWLSv8vHujva2+rKTNgxV0Y+Q0yKEl2rqH7gMig36YtAxZk9uO6iwmQ9j6JUfxL1HBExhdPynWnUvU1RRBsCFr70MCBtmZhpkqHfaZStEDhqIopyFsBZbefkodiJ08CRe1GNIvWmiW19xp52FgnriVtQJf54/NqOLqLdP0FXecHudIqsfBf0Gh6uFO1e126zCrl8EGu4sC1w61oJuDFGCqSBshvcPgJwA7V8Nw3VKZ5BUTX5svc+b116fPpA+nbQ2pf2SccwdEwApA+c1tnYtP0K3agFBJaSHtyAC8+jdYjsXLCicnStXUuJT+U92BAGPdp/u/Y6e7xSCiajZ6Un4f5E7bw/78TSjX9+QZ/yDi02KzIlJ5580hPzV6rYVFdkMJqJgXMffaJNeACT4TJ0I7N9/tKYFwX/kF3uki+jVbuEUlQXE0T+a1gNzUvMBEpM8cpV7s1tV+wfv; 4:HgYEU6USXWWfECuHLm8Ep5awI9DR6NdV8pM0xyPXoCA1N5dAxIp+87YG2exZ4I8DFC2uBjXknWZRnWIOe4n29c/istPNJF+Ec/WoV3vEjZdWA9HSX+W+oBKBKGivtfJURJqRNDjNksCIFDPeS4vkvvX4EzXosF1n5+0NqCeW6lzMRer4K72gjLI1DmrqqxNgwvHuVyTEJwlnTTRyYL4w18dWZF7WZEc6LctmY+TqOIea6FV4lSJHdQY+8njKdqNksM3tuLQjCgofTirIDDfCQQ== 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:EA6hsl5+nZ2PgmPYIzLEbAogn3WC4TGdNUaTW+X?= =?us-ascii?Q?PUue81Udxb2Fl3pNFtHOOKNu1PUa/g8uKRLqn2BhstozVQ5B7kLLJUpn0BW8?= =?us-ascii?Q?tYXzYk1rNc7Wwk8JIVnGKEtO1sCyKHc575H0wnv9HxoCICUfmRqZkXBUCuNI?= =?us-ascii?Q?9R136+eGE+vl6T+QkHg/jBib/L9aEYrNtTkYNyQjDwQ/MLzTOpj+qN8abP5J?= =?us-ascii?Q?LNrh05kV/+9jbAoa6JRCMn0fNWULMHRtNtNO2JS25/E5EKkvLzlOgJUY/Yf2?= =?us-ascii?Q?Q02ugwI7AkWZXRQUpkpq1ocYeU51gBfr09kdlZQDVPF1X/zO/3sAWnkAITTb?= =?us-ascii?Q?Dr4fzuBCmp/rBMTmI5wYkCzE4bkvUZE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CmR4Zga5MoCLAk/puAsUHaNdSrbKxlD5cMM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1970; 7:wgXIExqEN3csp8zvQKNoySZXxNPW1xAX42o91N192TSaj89GoH7tfGj0ld1K5CJHYNzUqIS+UwqEE53jUpfveNlZkat46q+v4yjM6k5cjZdZURouyFTRhJJ+os2dbSHjs0JSOhNjiAYKAllzBM3qnYmvP6A247/ca2TWDtQxTxmhflcoa8+VH40a7YWzBXR0DXv8JQS9+YI4eFR9airbB7XKvzOEPCBAu8oWOtBuKZ2ge9Gf4NH36TcU6GQQX5Ri; 20:zFwPaQgYt6Yb0Kw5ZcUf2wuofG3mrOGUy/XghYxK2AZkt+zP88sGmmFEKOR+OM6T4yvqkM56SKF49JXcplRgSEQWuBgO8jNVYf3KvkMNNgDtsp0QFeJjs0fj6Nd7PGIjhxGVjptS12KPEfqdn8LF6Gf6MdaCE0kByjhdgI/6Zt8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2018 17:02:18.2790 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4cffa49-c751-44ff-cea6-08d5965ffef3 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 2/2] i386/hyperv: error out if features requested but unsupported 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, for a number of Hyper-V-related cpu properties, if the corresponding feature is not supported by the underlying KVM, the propery is silently ignored and the feature is not announced to the guest. Refuse to start with an error instead. Signed-off-by: Roman Kagan Reviewed-by: Eduardo Habkost --- v2 -> v3: - include the fix for 'hv-time' missed previously v1 -> v2: - indicate what flag requested the feature that can't be enabled in the error message - fix a typo in the error message for VP_RUNTIME target/i386/kvm.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b35623ae24..6c49954e68 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -632,11 +632,6 @@ static int hyperv_handle_properties(CPUState *cs) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; - if (cpu->hyperv_time && - kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_TIME) <= 0) { - cpu->hyperv_time = false; - } - if (cpu->hyperv_relaxed_timing) { env->features[FEAT_HYPERV_EAX] |= HV_HYPERCALL_AVAILABLE; } @@ -645,6 +640,12 @@ static int hyperv_handle_properties(CPUState *cs) env->features[FEAT_HYPERV_EAX] |= HV_APIC_ACCESS_AVAILABLE; } if (cpu->hyperv_time) { + if (kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_TIME) <= 0) { + fprintf(stderr, "Hyper-V clocksources " + "(requested by 'hv-time' cpu flag) " + "are not supported by kernel\n"); + return -ENOSYS; + } 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; @@ -659,17 +660,41 @@ static int hyperv_handle_properties(CPUState *cs) 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) { + if (cpu->hyperv_crash) { + if (!has_msr_hv_crash) { + fprintf(stderr, "Hyper-V crash MSRs " + "(requested by 'hv-crash' cpu flag) " + "are not supported by kernel\n"); + return -ENOSYS; + } env->features[FEAT_HYPERV_EDX] |= HV_GUEST_CRASH_MSR_AVAILABLE; } env->features[FEAT_HYPERV_EDX] |= HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE; - if (cpu->hyperv_reset && has_msr_hv_reset) { + if (cpu->hyperv_reset) { + if (!has_msr_hv_reset) { + fprintf(stderr, "Hyper-V reset MSR " + "(requested by 'hv-reset' cpu flag) " + "is not supported by kernel\n"); + return -ENOSYS; + } env->features[FEAT_HYPERV_EAX] |= HV_RESET_AVAILABLE; } - if (cpu->hyperv_vpindex && has_msr_hv_vpindex) { + if (cpu->hyperv_vpindex) { + if (!has_msr_hv_vpindex) { + fprintf(stderr, "Hyper-V VP_INDEX MSR " + "(requested by 'hv-vpindex' cpu flag) " + "is not supported by kernel\n"); + return -ENOSYS; + } env->features[FEAT_HYPERV_EAX] |= HV_VP_INDEX_AVAILABLE; } - if (cpu->hyperv_runtime && has_msr_hv_runtime) { + if (cpu->hyperv_runtime) { + if (!has_msr_hv_runtime) { + fprintf(stderr, "Hyper-V VP_RUNTIME MSR " + "(requested by 'hv-runtime' cpu flag) " + "is not supported by kernel\n"); + return -ENOSYS; + } env->features[FEAT_HYPERV_EAX] |= HV_VP_RUNTIME_AVAILABLE; } if (cpu->hyperv_synic) {