From nobody Sat Oct 25 09:04:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520344077680471.2926359648301; Tue, 6 Mar 2018 05:47:57 -0800 (PST) Received: from localhost ([::1]:55870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCwb-0005gJ-Vi for importer@patchew.org; Tue, 06 Mar 2018 08:47:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCVr-0005aw-U7 for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etCVn-0006fl-Pf for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:15 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:50449) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1etCVn-0006ew-IB for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:11 -0500 Received: by mail-wm0-x244.google.com with SMTP id w128so22837323wmw.0 for ; Tue, 06 Mar 2018 05:20:11 -0800 (PST) Received: from 640k.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l38sm25652538wrc.96.2018.03.06.05.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 05:20:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tkz2ongW9kX/Io0mR9VFvFDsSJg0Erq+WrO23N6k6w8=; b=sNKfVIs4IEdMqRCdNIoiSRbGaWkf8taKqnred1jqroNXXlscbfUNoaWt5vu3A0maDp DQk7CFrFBmzRn+jcz+Cl+Osxnjvw4c5Mq8lfKydZ+gcq4kkvYvhclWy/tW95+7aVOaAC 4+N9NVSLMMX0oVw4YUflDlcqb7rCnfxXohzTCiGntg5i293HgZypbIRNy4thXv2MlJ3I n65gKa2ByefZz5d0I2Zcd515IRpnDLBsf1GBcoR6tHEy/4+De3oBtlpdTDOOXtnffUD4 ep4LYBc/dFUe1WoSNLGFoyRxLbLF2UewfjEW9H9VE9dse5MgHket5OppO1xfQpUKBmdr tDCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Tkz2ongW9kX/Io0mR9VFvFDsSJg0Erq+WrO23N6k6w8=; b=X8Xw6dyiy+A7EEqy+6z5eL3/fML/Qq4mMj1dtIMKgl8cFKU9PGUtWj9FUXbYg/zKX/ B5d/st3OJJo5rpqRiH7GYeAh1w8jGV5LhgS4wQIUlLcn4cW/MUsHMw81vRan7hKeRyj5 X0jPGLF3vx5f9tIRASkMGR976oDyBir5CtQAN42wuVk8/kb/gKTC0TnRIpzeL72OtJPo zkLnlyd6KSY7opFCt9yms1F0fXQ0WzzA6PakwUQxVe4CRE3P917uAysewDjFCd6jA+F+ 8CZ1KvmMwG5fxNmSr/k8bBtu0C9z8Iqi4p0mDTrOLKKYb/0ZYjCzi92dxPOYZClwzOj6 FImw== X-Gm-Message-State: AElRT7G0fzKnJhOCjZlKrbZTTyCFnnyNMnsXxZ+cqu23GurVuEQSfLtz Jr+/pz62FpAODnHaE2y0enVXruKJ X-Google-Smtp-Source: AG47ELujMGXfyNBhEWT6zhSwwruetjr0y4jl2q7tIFF2pCdIXNSywEbpj9v6cG6m0BgI5UYvlrzuMw== X-Received: by 10.28.193.134 with SMTP id r128mr10964731wmf.85.1520342410186; Tue, 06 Mar 2018 05:20:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 14:19:26 +0100 Message-Id: <1520342370-123606-31-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> References: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 30/34] 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: , Cc: "Justin Terry \(VM\)" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Justin Terry (VM) via Qemu-devel" 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 incrementi= ng the reg_count. In this case its possible that we set an invalid memory sect= ion 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 upda= te the array if the local tpr value is different than the vp context. Signed-off-by: Justin Terry (VM) Message-Id: <1519665216-1078-7-git-send-email-juterry@microsoft.com> Signed-off-by: Paolo Bonzini Signed-off-by: Justin Terry (VM) via Qemu-devel --- 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 7e58d5f..47a6935 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 =3D (CPUArchState *)(cpu->env_ptr); X86CPU *x86_cpu =3D X86_CPU(cpu); int irq; + uint8_t tpr; WHV_X64_PENDING_INTERRUPTION_REGISTER new_int =3D {0}; UINT32 reg_count =3D 0; WHV_REGISTER_VALUE reg_values[3] =3D {0}; @@ -746,9 +747,10 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } =20 /* Sync the TPR to the CR8 if was modified during the intercept */ - reg_values[reg_count].Reg64 =3D cpu_get_apic_tpr(x86_cpu->apic_state); - if (reg_values[reg_count].Reg64 !=3D vcpu->tpr) { - vcpu->tpr =3D reg_values[reg_count].Reg64; + tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); + if (tpr !=3D vcpu->tpr) { + vcpu->tpr =3D tpr; + reg_values[reg_count].Reg64 =3D tpr; cpu->exit_request =3D 1; reg_names[reg_count] =3D WHvX64RegisterCr8; reg_count +=3D 1; --=20 1.8.3.1