* [PATCH] Fix tpr patching to get cpu index from Windows per cpu area.
@ 2009-06-02 11:52 Gleb Natapov
2009-06-02 11:57 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2009-06-02 11:52 UTC (permalink / raw)
To: avi; +Cc: kvm
Using cpu_index for this purpose work only by luck.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kvm-tpr-opt.c b/kvm-tpr-opt.c
index 246e08d..bdbc742 100644
--- a/kvm-tpr-opt.c
+++ b/kvm-tpr-opt.c
@@ -220,13 +220,29 @@ static int bios_is_mapped(CPUState *env, uint64_t rip)
return 1;
}
+static int get_pcr_cpu(CPUState *env)
+{
+ struct kvm_sregs sregs;
+ uint8_t b;
+
+ kvm_save_registers(env);
+
+ if (cpu_memory_rw_debug(env, env->segs[R_FS].base + 0x51, &b, 1, 0) < 0)
+ return -1;
+
+ return (int)b;
+}
+
static int enable_vapic(CPUState *env)
{
static uint8_t one = 1;
+ int pcr_cpu = get_pcr_cpu(env);
+
+ if (pcr_cpu < 0)
+ return 0;
- kvm_enable_vapic(kvm_context, env->cpu_index,
- vapic_phys + (env->cpu_index << 7));
- cpu_physical_memory_rw(vapic_phys + (env->cpu_index << 7) + 4, &one, 1, 1);
+ kvm_enable_vapic(kvm_context, env->cpu_index, vapic_phys + (pcr_cpu << 7));
+ cpu_physical_memory_rw(vapic_phys + (pcr_cpu << 7) + 4, &one, 1, 1);
bios_enabled = 1;
return 1;
--
Gleb.
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-02 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 11:52 [PATCH] Fix tpr patching to get cpu index from Windows per cpu area Gleb Natapov
2009-06-02 11:57 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox