From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH] Fix tpr patching to get cpu index from Windows per cpu area.
Date: Tue, 2 Jun 2009 14:52:40 +0300 [thread overview]
Message-ID: <20090602115240.GB25846@redhat.com> (raw)
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.
next reply other threads:[~2009-06-02 11:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-02 11:52 Gleb Natapov [this message]
2009-06-02 11:57 ` [PATCH] Fix tpr patching to get cpu index from Windows per cpu area Avi Kivity
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=20090602115240.GB25846@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.