From patchwork Tue Jun 6 18:19:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 9769521 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 B39B960364 for ; Tue, 6 Jun 2017 18:21:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1478223C7 for ; Tue, 6 Jun 2017 18:21:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4C3727FB8; Tue, 6 Jun 2017 18:21:22 +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 38436223C7 for ; Tue, 6 Jun 2017 18:21:21 +0000 (UTC) Received: from localhost ([::1]:39619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJ6W-0005hE-5S for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Jun 2017 14:21:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJ5G-0005fb-Mf for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJ5D-0007Bq-Bd for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:20:02 -0400 Received: from mail-eopbgr30133.outbound.protection.outlook.com ([40.107.3.133]:4192 helo=EUR03-AM5-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 1dIJ5D-00075V-0L for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:19:59 -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=CXHAg8TCLiDRQ7a5mMwiWLEtY494T+zEpHYie8wQf/0=; b=V3xUIGFWzq9K2e/jqzlB1KF/8QtywP9YLmAqBywUSUxi564JV/JrBHmjVJ7xxsyJF4HVB1QKGgH48i6DnbMqzasQTumrDa/DELRIosourKnhtLC+4eOJx9oGAlvusmpvdC6iupsaB5oXCxK4u+S7CUrQpor63qHAz63dCpTrN04= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10; Tue, 6 Jun 2017 18:19:56 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 21:19:28 +0300 Message-Id: <20170606181948.16238-4-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606181948.16238-1-rkagan@virtuozzo.com> References: <20170606181948.16238-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0042.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::28) To VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB0847: X-MS-Office365-Filtering-Correlation-Id: 22c5b3f7-c0f4-4bbf-590e-08d4ad08a2b8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR08MB0847; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 3:gOfC/mzxWeWlTQw9wEKkvVl1A7m3UeCstJkHk2+bIry7gN2R1j/KDic/yeOMNTyPprWqS4TEOEdmoUecqE1QNqCfNZHMJ3SE7MdGJd7dh1gV3Q+P54VfGNfnxYMMtTCbow2jmNxEOsAAhXGNElZlwycumdcRH5Zyyon36JUsx0tkjyCWuE+GBA23P829eViFNqw8g6LokoTmcYTtYydC+xK62z1GG2rFNTan8M5Kq+5v2YzfQSpdOkioU/hxNoy152QVqqvtYhTeb6wSzG4XuwFA4P3ut2xJ81pARSsGRo0r4GQZRw/EUwgRDa8RE/OX0OIaDv1Bg+dis2g/1J0yRQ==; 25:PksQOtmtEDz8hD9Ckf4GScfi7CM6b76zvlWpsYq9/UrspdWg5bOevYYzA/Z2j5ogx92+kIaNYBN1zzuTfRQuh1oRe2MvrF3xk4HJ7vs7nVIXXmrV308MIX1kHK9fC8NpNLOfHMmuIAv4CzKuHitZUXj9E8jVD6zYq5PjMYgkbLZSveEZm9WIeYgN85SQPpLlnVKWd6sEfnCh3gnH5JpdEnC015fgmIj3Nw7p9d2i7PG91+Ux+kfaGeUv4Yvdaw4WsWoOV/dtdPy0M+bBTdfgYzQk9x2qdOBP4pegK8baUu27/yPSIqlY7StXomfE898z3vhnsK42tAqjJuj6VjDlwzE5QnFjx8ZH4Mnh7o9mr99qTN9Nncht/f0sOjU6mlBh35TPYkh8eRr/oaPbhFD8cUb6WUO8ap+H5p64ziMXpxjgiwKiqc0URw+WnR7IIkXBnoia4EpOSU6ocZqNVmVv8++baZ6ha4a+756ZZpWDFSM= X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 31:YeDxC/eg+V6c6phrxCpokgpQ179XoWx0e25MxF9/gVrsZfdQoOa5tLVQmBgUIzAsNvlH7c/GPZMjmvLTa4Uo+e1b9W1LrvmVyJr28sa5Ayb/FRac2+MWHChztma73RA2rBXK1SARJxbEwk/uC8LnvhwBL0WPIb9YdipQFPGhJf2wKvvol5UBS1Col+ftsAMkcK69ph5b7nsxt+ZwSfKzOQ97fOzH0He2Hj5pjxn2hEo=; 20:iVAXMazm1HbE2uAMZ3BFdEV7gTxhtw+cCLuK98upYki6VTqn3fv9mVKGlNVXTXOg6aaGQZ72QFdkPQ/Uh6rK4xS+H37IItktRgC2RFDxJplO5kqTzURbOTaAgJ+zLb+P8Cir0kTe5phCy3E6W4Cyr6yOsvRWRk/1eCAw9E5tJa0eQ+G0ANGyspd/txU2VZXo0Xtze1FwxXJ4132Y/MDQHvQk77YUdcdL6MMfHrRCfyY9IM+KD/09FjUjuylVcnY37B9nEhJ5qitNg/begPdjtNIWRtNK4+R5Lsg2ISHswNJJ72CCPu+IGVTnm7FQGmNdjtLfjXTOdjeuBkP6TQklp2Ap5X3xJf+CvTxbeLQxgpaaSa8Op3E4Wbjkh2qI+qfIuDsbfuDchMJwYJvoYLDIyYfUEAQBJ7QJrYyKCYeZNyU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR08MB0847; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR08MB0847; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0847; 4:nXqtDOkvZSSF6Hi0nr2HEbsfpxHpgHHhhgRnDhsq4P?= =?us-ascii?Q?GOroDKGK7++HddgUBcWgFzBvmJcdjmtLeqaQMSSdknoEkl+8OKuCD5cqbDVI?= =?us-ascii?Q?8lrtPV8gz3ykAbKoCFAMvt39dTbuTxwlLmEYFuTaQ/Wh89s5cKhacxoOrg36?= =?us-ascii?Q?7Dx3IaNuiFUH+5XW9Yr/0ZFspJP3yIggp9sfiUktuKVvbb4vJGJR5YEaEkTe?= =?us-ascii?Q?pNfyV1EjzevXQ65fmICSWE4siFB3dt36Ii9WHjaC0fhoW+vjNi0+DMZN6hHm?= =?us-ascii?Q?hvsdZaAChjqq6ezVNld/hR0awOToWIyn105lJqK5t6z06pwSXuZ+P4xviJFe?= =?us-ascii?Q?DF++NPvpPLJpnM8G6UVIQYfMSl1Ox8R35X4d1GX3WXCGPhH4f0bMhcWozhFg?= =?us-ascii?Q?EyQ6SeEtOH31kl4Z5ujzrAamUNPTW6PvNd7HOxccnswzaMRKlrKHvhmSWs01?= =?us-ascii?Q?VD2WkG2B6Luu05L9iN/rnkFFlQz3wsx5KkNZQOsns+L+H5w6KTHp0joVY5da?= =?us-ascii?Q?a0tz8MEXo8cYwegtR2Wl3DXSl75RRlFhY8VnPcX6t0Y4AmkfMmMUy/AZ597t?= =?us-ascii?Q?4mxYedgcLMw+ckwXUnQW+xBDtTawFkDbq3d6TUDmxRoswx6JdH7kzlGb1TGG?= =?us-ascii?Q?E7sP2lvOtfE3V5nHGcqOdZIlpo4Ue2Us4YZFvX7HJmMGo0M9S2Nx4WudENOC?= =?us-ascii?Q?S9/idk6nGCr7EimPtO18GNQLK0czNmvI07Z1LFnW9D43FbVV+m/YutXd8ZnF?= =?us-ascii?Q?5WCyMcpAugPmhJYA8heCGWah4ist8csIPw0k38TOLgADR+8q7biHvpjZzgaS?= =?us-ascii?Q?078mr9palCq2uJvJXCnsyqWUwfnl4gcDx+pszFJT/7nsqhKhfjwIIVcBzyCL?= =?us-ascii?Q?Z+JR5/gPauxa1NhLeZOwU897qmzhA1HExqC3R7UZX9EGCVA1bIO5lo3XPoc2?= =?us-ascii?Q?DFE8w/3c9lDAId9xJE7g06bXtWP8gwfjz077qIL5AyVuNh82PwCiAa6Op0hl?= =?us-ascii?Q?AjbTJKUdzX/fDLFo5qIYohs4XenqWUTZscW6lufoW7or6h5652O6LwGQUSv6?= =?us-ascii?Q?iWBKPLr2+2jRjTcWksG6HzxZ4MQ3pHv6BH85y55XAXUqC6vEqYMs8kzMY+jt?= =?us-ascii?Q?g6P/disWLvJpSSMRE4PO4pZbtTkcVj?= X-Forefront-PRVS: 033054F29A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39410400002)(39400400002)(39840400002)(39450400003)(48376002)(33646002)(36756003)(47776003)(6486002)(478600001)(66066001)(5003940100001)(2361001)(2906002)(5660300001)(2351001)(50226002)(81166006)(8676002)(25786009)(1076002)(6512007)(6916009)(53416004)(76176999)(42186005)(189998001)(38730400002)(53936002)(4326008)(50986999)(107886003)(7736002)(110136004)(6666003)(6116002)(3846002)(54906002)(2950100002)(86362001)(6506006)(305945005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0847; H:rkaganb.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0847; 23:7GEAXBsRViGMnuSPcPydivA+vnx/uq3MJokgCExXO?= =?us-ascii?Q?oB7Rb8FjVlTdg3iWzDgdxGSfXASq5Ud/4bduMqpo54ZYh0yJxGBoMnVFub3d?= =?us-ascii?Q?Xw9wtIWZ7i8xtSriatob6JFSWpYks11vJzMTnCybRXBfWc2nBTMO/mQDZKMI?= =?us-ascii?Q?pEmHOuxKsytrG5CsVfX0ZmQsNaznHZ4fBWDDBc10PGHhG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mv2UmBgVh73ZWD86DpllP9SiKqCtotZk8wL0h6RpvSgG+/IMyRak6i7logyZhRIODdP7PK3GAQMK39A; 24:B4FXENifHZ5DqUF42AzKYQ2XoxyXF4o4t9BbMPVZJXJWPZejRiYSYLKZ6lLKsyaMqHT4cBl16M/TIJB4ygLBSM36TcFIGpBYPr/EIyEQmU8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 7:M3qc4CfkMLGIvTWQ87QrvHylYS9qTeNfPRfYnFQBNneBJxGA5/3MFd/7zntEH60iRcJbTlV7FAyyW5XV/FZnV0sIklvjyZVPVCJRjWe3NTABF/cdnigTFRg1T4MzTEeqJVdJzD+Uy4dnlmznO6uck/4R74XQvN9ZZo1V8Ff4aPNbrXqHyVqflz0BPjbS37IbuBUdSnCIAVfo9JSBZOskzDkJRTVfopKWpocosLLRv5AHguiSXydBFjhijt2A/zjMmbEF/TuI/VbALYO91pIza5Zl+aHIB/v8AfdS1sksFKqEh5TUJMEgzkJnuYz2rqml/jglftIMIkHCCM6kVkbbEw==; 20:IxdaBtZhmOxIAWJUD3BDSSszZgRDLhnwQ859zwJr9bfHYvsLHlr+JKplkQIsBuVjFheTa7s55HE9fTbdK6YApMsHx5iZ17Sx3hDG36S+BuJUVH99w1fk8HxO3fg9No4GkQzjQO8+Nr9QMzql4KVJoq0QNgYb5EJApR4ItzybDP0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2017 18:19:56.0072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0847 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.3.133 Subject: [Qemu-devel] [PATCH 03/23] hyperv: set partition-wide MSRs only on first vcpu 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: Paolo Bonzini , Evgeny Yakovlev , Eduardo Habkost , "Denis V . Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Evgeny Yakovlev Hyper-V has a notion of partition-wide MSRs. Those MSRs are read and written as usual on each VCPU, however the hypervisor maintains a single global value for all VCPUs. Thus writing such an MSR from any single VCPU affects the global value that is read by all other VCPUs. This leads to an issue during VCPU hotplug: the zero-initialzied values of those MSRs get synced into KVM and override the global values as has already been set by the guest. This change makes the partition-wide MSRs only be synchronized on the first vcpu. Signed-off-by: Evgeny Yakovlev Signed-off-by: Roman Kagan --- target/i386/cpu.h | 5 ++++- target/i386/kvm.c | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 9335dcc..7af2cce 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1089,10 +1089,13 @@ typedef struct CPUX86State { uint64_t async_pf_en_msr; uint64_t pv_eoi_en_msr; + /* Partition-wide HV MSRs, will be updated only on the first vcpu */ uint64_t msr_hv_hypercall; uint64_t msr_hv_guest_os_id; - uint64_t msr_hv_vapic; uint64_t msr_hv_tsc; + + /* Per-VCPU HV MSRs */ + uint64_t msr_hv_vapic; uint64_t msr_hv_crash_params[HV_CRASH_PARAMS]; uint64_t msr_hv_runtime; uint64_t msr_hv_synic_control; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index a6debbd..3a80913 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1719,19 +1719,23 @@ static int kvm_put_msrs(X86CPU *cpu, int level) kvm_msr_entry_add(cpu, MSR_CORE_PERF_GLOBAL_CTRL, env->msr_global_ctrl); } - if (has_msr_hv_hypercall) { - kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, - env->msr_hv_guest_os_id); - kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, - env->msr_hv_hypercall); + /* Sync partition-wide MSRs only on first VCPU to avoid races */ + if (current_cpu == first_cpu) { + if (has_msr_hv_hypercall) { + kvm_msr_entry_add(cpu, HV_X64_MSR_GUEST_OS_ID, + env->msr_hv_guest_os_id); + kvm_msr_entry_add(cpu, HV_X64_MSR_HYPERCALL, + env->msr_hv_hypercall); + } + if (cpu->hyperv_time) { + kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, + env->msr_hv_tsc); + } } if (cpu->hyperv_vapic) { kvm_msr_entry_add(cpu, HV_X64_MSR_APIC_ASSIST_PAGE, env->msr_hv_vapic); } - if (cpu->hyperv_time) { - kvm_msr_entry_add(cpu, HV_X64_MSR_REFERENCE_TSC, env->msr_hv_tsc); - } if (has_msr_hv_crash) { int j;