From patchwork Fri Sep 21 08:22: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: 10609383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33FEA14BD for ; Fri, 21 Sep 2018 09:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255882D890 for ; Fri, 21 Sep 2018 09:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1954B2D895; Fri, 21 Sep 2018 09:00:19 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,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 9F4A82D890 for ; Fri, 21 Sep 2018 09:00:18 +0000 (UTC) Received: from localhost ([::1]:54617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3HIQ-0002D1-0h for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Sep 2018 05:00:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g3Ghu-0006gu-T5 for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g3Ght-0001ox-Tb for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:34 -0400 Received: from mail-eopbgr70117.outbound.protection.outlook.com ([40.107.7.117]:46849 helo=EUR04-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 1g3Ght-0001gn-Er for qemu-devel@nongnu.org; Fri, 21 Sep 2018 04:22:33 -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:X-MS-Exchange-SenderADCheck; bh=Umm7zqALZepBA3r39fFbRfOAgcpGqt8dAEBvVAI/jo4=; b=JJ4OGoysERCB97Y8iDGJTQLSUKNh3oiuzL+2y2+nmR3X3nx74fSQO6UcnuJUUCTvzrZAycxwpvjaTTQ1RWXcmnhqRxmGN8JiPnGH+2bQxI1dj7/8XLeyRbCBTZqWi8myrcfnQDVzt2w9rTgr+SNkCp1tJIr6g07yLbUzPTmSGAo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (185.231.240.5) by AM0PR08MB3588.eurprd08.prod.outlook.com (2603:10a6:208:e1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Fri, 21 Sep 2018 08:22:29 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2018 11:22:08 +0300 Message-Id: <20180921082217.29481-2-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921082217.29481-1-rkagan@virtuozzo.com> References: <20180921082217.29481-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1P193CA0003.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::13) To AM0PR08MB3588.eurprd08.prod.outlook.com (2603:10a6:208:e1::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 968f7b65-c6e3-4372-9416-08d61f9b5f9b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3588; X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 3:HcIkK/9II73fi1YeK0YggBfT9/7S2Sp/x5Ues0+ogvrwRg+4HChxiXUOUkAkni/hHozyIjCGzFiiVxhnj1LHDsYm35Z9HAYIzTuDSSTPuDBJRxyjFpx+m3xh3HKw0/MtN6TNsXs0zF+VTFcKbraFuYBGE+eW28Z0E5sEye8MiGcXkNVe7SACL0zs28uYbEyUX/IYu+FFbQhJTwq57g+3A+U+kFyc+nfo00ZTBIkUMqlxGEZdAJlaiHVLCjPVUeIb; 25:9Xgf3RSg3TYSZrm9ryL1mjiBZxG1z92bFOK45HHuIn0TvSfPBF2XxzMmKJF71jQ1WWS1N0wU3Rg9v3BS7gpyRi1ZhzpFXSIEDWmqF3/C1Cv6QMJQwdW1jo0bxQeio5gqXiKmZrbQCC4aL57elYkd2jhU6JV9IKH1QMNLl+VUONlM2TP6I0zdVZkG41YvKE7xbTbSx3IROtbjJb/yxFERR2bkmJk7RjAZjqsmTdl9nlXeanegumhzt/IYIs9kcm9kKivjqagIziI/uzj8ZO3whsaksUfTpZfzZ6+L486sViEKiYtDEL4KXlgonLc9wSO0coQohr3RoH31u9hB18C8iA==; 31:1yN2ooiH3wSXEdTYxuxsQnY92NdBztDP6VQySU3pLro4qwWT81g8oVPV+twWeeAtGa+CdjNgYiegMkMdsADVl8gVu7pC8DHH7bGFkCcUuxw+qAoYb34fSaf3ztLMISA9oaThcBfqNuGU8dqU6sa2PHoBs2IhmCMzX29gC4Gr0MBV8HEiuB7RHaj08edzRHMT4Dw5QfzqK/vfb3CycP45yNy+7lcGhk3IVyTdiaFRSJE= X-MS-TrafficTypeDiagnostic: AM0PR08MB3588: X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:EZXOrtDGzw703F5v+1fEgi4b6u9m51wLx9DZHbmvRufj0SC4hrY/pzACW9G83R+i525zsl2Qrr0CN5Yd+AX050GmIAZeKT/eSfThh5LGmCEg/Bh1OjuaDdMpw4o3RFccMwsYBaaEeExldtleSfhSYiYzqg5CCicjKUXWSHpAAxI0xJceU1whOJEWSLZ6d8TseN1IR//SDpxQqrJ6yFiXjLs/WLjW8TEypnlNGv73X12qnqO7vRgR3dsHRyAYuxcvydfn2gFqlIn+vzwibqSAcK0ohqptuLJFwATV5nuOsK4R3B8SX5hyZ6yfzqrsFf+mdFfoi3w9KqlvhH2wKgxElnpC2sJdNCjA3N5gIgaIAMIGXXVRltnUIaUyr7xhaTqTfSMIH9pC0f4n68kuDu1ZGY84TBRfrTN+jz0ouQzb0kyzx3IOB2beT0Ss6UJbr9daDDba9aeYe5oAavc+hVsmjyBOw0UEKpcMfJfddE1WQ+r0ZPAuvCIwcy8M7AZhq0Fk; 4:fTGSmzlO9KH7y1wXGVWYerVeMNeF2OOEZufyh8hzfiClE6Sb1xKyeWeffNloOkQEv4lDBP8CyYfzu7vMCX6K7Z5iv1mbMELfyMJIeTlYv8fJGxKb6ruD+ZDGhFt92mtVyQjhhkH1cw7CkWV911Blw3Z8RnVVfL53qYbaMdFAmQmE7DtHlO88QfDwa2dfKC2+5+5lhSCn0KYESLcFFQ8Awx4kbxLCozvCSUZVAQqtMglMvLDhJmGynWqfIvaKHQ0azJIB5u8xTzZ6vEkBnaNnHQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231355)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699051); SRVR:AM0PR08MB3588; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3588; X-Forefront-PRVS: 0802ADD973 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(136003)(396003)(39850400004)(366004)(376002)(189003)(199004)(6916009)(16526019)(5660300001)(36756003)(3846002)(54906003)(48376002)(6506007)(476003)(486006)(52116002)(446003)(1076002)(76176011)(386003)(51416003)(186003)(6116002)(16586007)(2906002)(66066001)(6512007)(7416002)(50226002)(53936002)(25786009)(106356001)(53416004)(81166006)(47776003)(316002)(956004)(11346002)(2616005)(7736002)(8936002)(305945005)(8676002)(2351001)(105586002)(97736004)(4326008)(86362001)(6666003)(68736007)(478600001)(6486002)(2361001)(50466002)(26005)(69596002)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:AM0PR08MB3588; 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; AM0PR08MB3588; 23:epmtZm8tGbvP9QTKgcpOXHv1sic53EHsBXNqIEqpm?= /R4jNji1oFKtHA2oINZMFTppgv2YhSraTBGHwNB3AmLwZSYl21INZTMDDoWzS8AjkInlhPXexUXtvB0EsD1LmO+ROooohymUHkz5Jc8aNNT50DHdF0ghboCQhjcYVQzREruqI45+cbxM+LmECrzDIfOg/pnB7xo/taha1HKXwQZSZcnoAidHKtiH4xeNoBTo5g4cL5vE/3TG/pC7ab+FAu/yv5zr3LWFKr5PcWjaYyDxCroTfEJ0VsMPpcOBQUX75dW4IZ+9MpiSzaJkweCXMuczpn34zPeMK8wy4lnTD2MduUhdW8EcWKdZH6nZ4Gtyi+waUzeL5HN/RG2dIZ7Kdqi4k3ptLGjEJd+AZY2ThB6aaFJft+qa7FG/+byx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WrPErQjmLkqPt4D7ygthJb/Uot9sppVmP0lulAMlYSOZ6PmQEoqpbONboBb9dJHosHxmEMUiX8eDy7HVkZNAQX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR08MB3588; 20:FxkV2i6IvUEVsVDgCdBFbwYJsoYJGf6+XK8mTh6QlJVeHe0iBeLLWNER8KEGzDAxxE5GNS7j4h6TLyaaTv54SavMEav8iHKni2XjegvCPdXLPe5KC6a9SgWD7/974vb+/X+3jhj2IoKCertQye4yQXPPK8YuuWtV83ZDDB6fh/c= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2018 08:22:29.2837 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 968f7b65-c6e3-4372-9416-08d61f9b5f9b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3588 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.7.117 Subject: [Qemu-devel] [PATCH 01/10] hyperv:synic: split capability testing and setting 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: , Cc: Vijayabhaskar Balakrishna , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Venu Busireddy , Liran Alon , Paolo Bonzini , Si-Wei Liu , Igor Mammedov , Boris Ostrovsky , Karl Heubaum Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Put a bit more consistency into handling KVM_CAP_HYPERV_SYNIC capability, by checking its availability and determining the feasibility of hv-synic property first, and enabling it later. Signed-off-by: Roman Kagan --- target/i386/kvm.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 892d4f46c1..8d956da5d1 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -734,8 +734,9 @@ static int hyperv_handle_properties(CPUState *cs) } if (cpu->hyperv_synic) { if (!has_msr_hv_synic || - kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0)) { - fprintf(stderr, "Hyper-V SynIC is not supported by kernel\n"); + !kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_SYNIC)) { + fprintf(stderr, "Hyper-V SynIC (requested by 'hv-synic' cpu flag) " + "is not supported by kernel\n"); return -ENOSYS; } @@ -753,12 +754,14 @@ static int hyperv_handle_properties(CPUState *cs) static int hyperv_init_vcpu(X86CPU *cpu) { + CPUState *cs = CPU(cpu); + int ret; + if (cpu->hyperv_vpindex && !hv_vpindex_settable) { /* * the kernel doesn't support setting vp_index; assert that its value * is in sync */ - int ret; struct { struct kvm_msrs info; struct kvm_msr_entry entries[1]; @@ -767,7 +770,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) .entries[0].index = HV_X64_MSR_VP_INDEX, }; - ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data); + ret = kvm_vcpu_ioctl(cs, KVM_GET_MSRS, &msr_data); if (ret < 0) { return ret; } @@ -779,6 +782,15 @@ static int hyperv_init_vcpu(X86CPU *cpu) } } + if (cpu->hyperv_synic) { + ret = kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0); + if (ret < 0) { + error_report("failed to turn on HyperV SynIC in KVM: %s", + strerror(-ret)); + return ret; + } + } + return 0; }