From: "Justin Terry (VM)" <juterry@microsoft.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com,
"Justin Terry (VM)" <juterry@microsoft.com>
Subject: [Qemu-devel] [PATCH 6/8] Fix WHPX issue leaking tpr values
Date: Mon, 26 Feb 2018 09:13:34 -0800 [thread overview]
Message-ID: <1519665216-1078-7-git-send-email-juterry@microsoft.com> (raw)
In-Reply-To: <1519665216-1078-1-git-send-email-juterry@microsoft.com>
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) <juterry@microsoft.com>
---
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;
--
2.13.6
next prev parent reply other threads:[~2018-02-26 17:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 17:13 [Qemu-devel] [PATCH 0/8] WHPX updates based on the 17095 insider sdk Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 1/8] Fixing WHPX casing to match SDK Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 2/8] Resolves WHPX breaking changes in SDK 17095 Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 3/8] Remove unnecessary WHPX __debugbreak(); Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 4/8] Fix WHPX additional lock acquisition Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 5/8] Fix WHPX typo in 'mmio' Justin Terry (VM)
2018-02-26 17:13 ` Justin Terry (VM) [this message]
2018-02-26 17:13 ` [Qemu-devel] [PATCH 7/8] WHXP Removes the use of WHvGetExitContextSize Justin Terry (VM)
2018-02-26 17:13 ` [Qemu-devel] [PATCH 8/8] WHPX improve interrupt notification registration Justin Terry (VM)
2018-03-02 15:18 ` [Qemu-devel] [PATCH 0/8] WHPX updates based on the 17095 insider sdk Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1519665216-1078-7-git-send-email-juterry@microsoft.com \
--to=juterry@microsoft.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).