diff options
author | Gleb Natapov <gleb@redhat.com> | 2009-06-02 14:52:40 +0300 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-06-02 15:30:54 +0300 |
commit | 5a4dc5adb2f9b981f07ce6e4f2a3a7e8f20fb195 (patch) | |
tree | 152caf6e3fccd0d9360fbaf680a83e64473f3424 /kvm-tpr-opt.c | |
parent | Regenerate BIOS for _MAT rework (diff) | |
download | qemu-kvm-5a4dc5adb2f9b981f07ce6e4f2a3a7e8f20fb195.tar.gz qemu-kvm-5a4dc5adb2f9b981f07ce6e4f2a3a7e8f20fb195.tar.bz2 qemu-kvm-5a4dc5adb2f9b981f07ce6e4f2a3a7e8f20fb195.zip |
Fix tpr patching to get cpu index from Windows per cpu area.
Using cpu_index for this purpose work only by luck.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'kvm-tpr-opt.c')
-rw-r--r-- | kvm-tpr-opt.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/kvm-tpr-opt.c b/kvm-tpr-opt.c index 246e08d3c..8f7e1e587 100644 --- a/kvm-tpr-opt.c +++ b/kvm-tpr-opt.c @@ -220,13 +220,28 @@ static int bios_is_mapped(CPUState *env, uint64_t rip) return 1; } +static int get_pcr_cpu(CPUState *env) +{ + 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; |