From patchwork Mon Feb 26 17:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev\" via" X-Patchwork-Id: 10242869 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 6F3C4602A0 for ; Mon, 26 Feb 2018 17:21:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 638D92A194 for ; Mon, 26 Feb 2018 17:21:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 580FA2A1FA; Mon, 26 Feb 2018 17:21:49 +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 CB0802A194 for ; Mon, 26 Feb 2018 17:21:48 +0000 (UTC) Received: from localhost ([::1]:60497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqMTB-0004Wo-SM for patchwork-qemu-devel@patchwork.kernel.org; Mon, 26 Feb 2018 12:21:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqMLw-0007Lk-6t for qemu-devel@nongnu.org; Mon, 26 Feb 2018 12:14:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqMLs-0004fL-3L for qemu-devel@nongnu.org; Mon, 26 Feb 2018 12:14:16 -0500 Received: from mail-sn1nam02on0111.outbound.protection.outlook.com ([104.47.36.111]:45325 helo=NAM02-SN1-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 1eqMLr-0004es-Rf for qemu-devel@nongnu.org; Mon, 26 Feb 2018 12:14:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cRWHX6nGZJP0Ab7+EeXzYymIXAT2PKvm+J1VOqrC8fY=; b=JdrcHCk704W7FlHW1sq/c0LCfJH5N8dIcyiuRZ+Joc/0dlpKke6FTSfYgb+GqlyAknkI5fvtOgqVLuybBpA7tvZAFehpockGIa/iZu0z1APjjWQm3+AhrtDdC+9E7FSFpRrO8hZSfikKVf/kKEeHbL8lWaqSlkdZ04gtE1izm7Y= Received: from DESKTOP-CS4P60I.corp.microsoft.com (2001:4898:80e8:9::75b) by CY4PR21MB0168.namprd21.prod.outlook.com (2603:10b6:903:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Mon, 26 Feb 2018 17:14:09 +0000 To: qemu-devel@nongnu.org Date: Mon, 26 Feb 2018 09:13:34 -0800 Message-Id: <1519665216-1078-7-git-send-email-juterry@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519665216-1078-1-git-send-email-juterry@microsoft.com> References: <1519665216-1078-1-git-send-email-juterry@microsoft.com> MIME-Version: 1.0 X-Originating-IP: [2001:4898:80e8:9::75b] X-ClientProxiedBy: DM5PR1401CA0003.namprd14.prod.outlook.com (2603:10b6:4:4a::13) To CY4PR21MB0168.namprd21.prod.outlook.com (2603:10b6:903:b9::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 021576a2-274e-472b-6c7a-08d57d3c59d5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7193020); SRVR:CY4PR21MB0168; X-Microsoft-Exchange-Diagnostics: 1; CY4PR21MB0168; 3:6HD7e5BE5klpcuzdGJVB+mP2GHljIiM7tHZUS25ohLebAjy6Vrj15KTlS1GA+sLThAg9sne0iddawhF+bf4tzoMjJXy69UJUjXEdE8/v/ZCwBVbye8XZvNQgzY0s9K6IHXKwikNVaB4bulFycWE77cNSlzVTB/orGWm9vLaPIA8AR/JDhqZtBcgleO1T6mEoNzOtcnjhTY7Hh2e91KUtzKHrWJrFNetZWk16sYjl4MaFNI8JIYOsE/4t/yPwHl/l; 25:q2hoqCdfohd3cGSik9u6f7JlCH9whjQs2d7nBGrrY98L0wbh0+L1hC6Ebo+1aUZ89/7cdjzT/p3h+rlH3LBs0oAHv+Ex2tGxLWHsa/H1lMSXLOp4RGPb8tRWj7NZ7Je43R/Hq3wczGCysMvna+S8qbmOpHNyWDeS38AwCNSslPYAjzwMgcGL4+W+8/bc9y5DMC87azk6+zNzy4BS7nRTROuc+d5k+LPvnGlYbouo1girtrLKTwaGyfZJie5c3FcP2e8sFB07/07kHCrcoXcm9Lqt94H9MStHNxAfUzwRbt1BU1XWjbL4Y6D937TsFhixLFqMbmyvXMDAINUMKMNhaQ==; 31:bGYBt308nTPwL5uhKivPk1dpLowpUrWVGRG2bXubXXqa/4EcxAg0fXkphYYnbxoRb0kcZrU1wfqk4P8YgWn4+W9rUNc5bFTfVJVBzjqmcCINEBs2oFYaIup+AV7wnL5gBYy/9ByKzzLun4UnZDZtIn23NwZfhR/fNwLjPH2Hq1RBiW3loKRWpo6r3cjBcXymEpwMF3Rw4nGKakvkyX1Bgb/nHRLH1CJX8MRPkIMM6PQ= X-MS-TrafficTypeDiagnostic: CY4PR21MB0168: X-Microsoft-Exchange-Diagnostics: 1; CY4PR21MB0168; 20:0bnUfWjPGJ52vp9/jkS3DMrOHBkkq3mBTEVomvNcS9NyTc9egMSd/mAU8XHtW1dskuNNzX1VrkjhMZAMaXl0AdzK4Ovye8fgme56YQuXHpdpfa41Sy6P8cmCS1T2sTk7YXMEGJdQrdFTI6B+kcG6624rnhJgKWsZ3GT1u8vF20542RcDbIkMPo8A6w7EqKxmiZxVoRjHxqtMeBMkmUVCN2ZyXkgd35Pa6jVH4A5Jvh29EfQ9tMAaniWobJ6X5VI7wwBsOugTUKNNhbOTLf7iYnpo98+YsuaBjcUL0tTeniKR7FdSnOqbGAVg6/d5OpmH83vRbdIftBzNcrULiRUmQN/CM50CAEjq67FvpQ7gt4Nsq/pd0+nRaDnFsLv7d95ErsWVWpWh6v0Zf1FindpLl/2gMrIzglx17uqHL5zkLfSRJT+jnZI1G3r+m+SFqyOJRwoL5HzmU2nCbkxtqAsrQ2ZtiNX1xdBw36SlAEoC/75r+v7bng9XV3rl0tAfaIx4; 4:uF/zCsOdY80HLxho2NOUPKB7TYKycwoFPwM4G6j6fzPP0fHxd4Fw7MBeigQyK8NK/QqXrfDAC/LT3zTZ9OHVUBlCVpRGZa7JiEBfzZ9ubsOgWxzrJjabQrXzmivLpfTlUv/Q457WyZDxkVBpXu4iPx/sYJiLjZYeN1uZddzRV0hajq++oFrrRDzBPwrC+oEVWJg7RZNyEz/pn8jEz2FxwNW9gP1RMWTxUrVzzTcmJp3bDqolf7LjG1WH7jiBTHzIQ5rAWhl0yhpbbnzrcS1a4BuqgUe6IXegeT4lBJXjOsO5wnLmStj3Vo+D/oAeULOwtSyj1TByS7Rp3aOMPeKRJ3D9MvnOFoRffDNRXm/RJEc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(28532068793085)(89211679590171); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231220)(944501187)(52105095)(3002001)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:CY4PR21MB0168; BCL:0; PCL:0; RULEID:; SRVR:CY4PR21MB0168; X-Forefront-PRVS: 05954A7C45 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(396003)(39860400002)(366004)(346002)(39380400002)(189003)(199004)(5660300001)(36756003)(53936002)(10290500003)(7736002)(6116002)(105586002)(478600001)(6666003)(8936002)(8676002)(81166006)(47776003)(2950100002)(81156014)(50226002)(10090500001)(6916009)(106356001)(2906002)(52396003)(50466002)(51416003)(6486002)(48376002)(52116002)(7696005)(97736004)(76176011)(68736007)(86612001)(6346003)(107886003)(386003)(25786009)(86362001)(22452003)(2351001)(2361001)(316002)(305945005)(16526019)(59450400001)(4326008)(186003)(16586007); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR21MB0168; H:DESKTOP-CS4P60I.corp.microsoft.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=juterry@microsoft.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR21MB0168; 23:eigvGOdiWdTlMDc2jcdgq2b0zFA4d+0YHFgq3LOPu?= =?us-ascii?Q?YMm8wNC0NpG8I2y3R2Si0GW58gm84WxIRSLscl3XeP+9q1xNZNLlxY6SRDCJ?= =?us-ascii?Q?Hi+9/LDsKqwC6ZkKFeoSV594yAtklsoXRGHWlLcCQVaGxKUorM9rQ3bpgoHg?= =?us-ascii?Q?LlPIuLEGfyWVpoxn3knFt/9W7pPlMKAYXDLlULPllt/vOSBOw41NBzgUdWih?= =?us-ascii?Q?yEs1b2gHjcxhl9gDgWKkuQf6gwq6HjvBq1xZTjorWZ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a6EQrsiuLCctqfIPy354al SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2018 17:14:09.6308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 021576a2-274e-472b-6c7a-08d57d3c59d5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0168 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.111 Subject: [Qemu-devel] [PATCH 6/8] Fix WHPX issue leaking tpr values 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: , X-Patchwork-Original-From: "Justin Terry \(VM\) via Qemu-devel" From: "Denis V. Lunev\" via" Reply-To: "Justin Terry \(VM\)" Cc: pbonzini@redhat.com, "Justin Terry \(VM\)" , ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixes an issue where if the tpr is assigned to the array but not a different value from what is already expected on the vp the code will skip incrementing the reg_count. In this case its possible that we set an invalid memory section of the next call for DeliverabilityNotifications that was not expected. The fix is to use a local variable to store the temporary tpr and only update the array if the local tpr value is different than the vp context. Signed-off-by: Justin Terry (VM) --- target/i386/whpx-all.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/i386/whpx-all.c b/target/i386/whpx-all.c index 7e58d5f68c..47a6935288 100644 --- a/target/i386/whpx-all.c +++ b/target/i386/whpx-all.c @@ -687,6 +687,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) struct CPUX86State *env = (CPUArchState *)(cpu->env_ptr); X86CPU *x86_cpu = X86_CPU(cpu); int irq; + uint8_t tpr; WHV_X64_PENDING_INTERRUPTION_REGISTER new_int = {0}; UINT32 reg_count = 0; WHV_REGISTER_VALUE reg_values[3] = {0}; @@ -746,9 +747,10 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } /* Sync the TPR to the CR8 if was modified during the intercept */ - reg_values[reg_count].Reg64 = cpu_get_apic_tpr(x86_cpu->apic_state); - if (reg_values[reg_count].Reg64 != vcpu->tpr) { - vcpu->tpr = reg_values[reg_count].Reg64; + tpr = cpu_get_apic_tpr(x86_cpu->apic_state); + if (tpr != vcpu->tpr) { + vcpu->tpr = tpr; + reg_values[reg_count].Reg64 = tpr; cpu->exit_request = 1; reg_names[reg_count] = WHvX64RegisterCr8; reg_count += 1;