From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH v2 5/9] Don't call apic functions directly from kvm code
Date: Mon, 16 Nov 2009 15:12:03 -0200 [thread overview]
Message-ID: <1258391527-18840-6-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1258391527-18840-5-git-send-email-glommer@redhat.com>
It is actually not necessary to call a tpr function to save and load cr8,
as cr8 is part of the processor state, and thus, it is much easier
to just add it to CPUState.
As for apic base, wrap kvm usages, so we can call either the qemu device,
or the in kernel version.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
target-i386/cpu.h | 1 +
target-i386/kvm.c | 25 +++++++++++++++++++------
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 5929d28..e5470f7 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -606,6 +606,7 @@ typedef struct CPUX86State {
SegmentCache idt; /* only base and limit are used */
target_ulong cr[5]; /* NOTE: cr1 is unused */
+ target_ulong cr8;
int32_t a20_mask;
/* FPU state */
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 6613a3f..103defd 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -338,6 +338,19 @@ static void get_seg(SegmentCache *lhs, const struct kvm_segment *rhs)
| (rhs->avl * DESC_AVL_MASK);
}
+static void kvm_set_apic_base(CPUState *env, uint64_t val)
+{
+ if (!kvm_irqchip_in_kernel())
+ cpu_set_apic_base(env, val);
+}
+
+static uint64_t kvm_get_apic_base(CPUState *env)
+{
+ if (!kvm_irqchip_in_kernel())
+ return cpu_get_apic_base(env);
+ return 0;
+}
+
static void kvm_getput_reg(__u64 *kvm_reg, target_ulong *qemu_reg, int set)
{
if (set)
@@ -447,8 +460,8 @@ static int kvm_put_sregs(CPUState *env)
sregs.cr3 = env->cr[3];
sregs.cr4 = env->cr[4];
- sregs.cr8 = cpu_get_apic_tpr(env);
- sregs.apic_base = cpu_get_apic_base(env);
+ sregs.cr8 = env->cr8;
+ sregs.apic_base = kvm_get_apic_base(env);
sregs.efer = env->efer;
@@ -546,7 +559,7 @@ static int kvm_get_sregs(CPUState *env)
env->cr[3] = sregs.cr3;
env->cr[4] = sregs.cr4;
- cpu_set_apic_base(env, sregs.apic_base);
+ kvm_set_apic_base(env, sregs.apic_base);
env->efer = sregs.efer;
//cpu_set_apic_tpr(env, sregs.cr8);
@@ -762,7 +775,7 @@ int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
run->request_interrupt_window = 0;
dprintf("setting tpr\n");
- run->cr8 = cpu_get_apic_tpr(env);
+ run->cr8 = env->cr8;
return 0;
}
@@ -774,8 +787,8 @@ int kvm_arch_post_run(CPUState *env, struct kvm_run *run)
else
env->eflags &= ~IF_MASK;
- cpu_set_apic_tpr(env, run->cr8);
- cpu_set_apic_base(env, run->apic_base);
+ env->cr8 = run->cr8;
+ kvm_set_apic_base(env, run->apic_base);
return 0;
}
--
1.6.2.5
next prev parent reply other threads:[~2009-11-16 17:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 17:11 [Qemu-devel] [PATCH v2 0/9] in-kernel irqchip Glauber Costa
2009-11-16 17:11 ` [Qemu-devel] [PATCH v2 1/9] introduce VMSTATE_U64 Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 2/9] Provide ioapic-kvm Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 3/9] provide apic_set_irq_delivered Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 4/9] provide i8259-kvm Glauber Costa
2009-11-16 17:12 ` Glauber Costa [this message]
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 6/9] export kvm_put_mp_state Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 7/9] provide apic-kvm Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 8/9] Initialize in-kernel irqchip Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 9/9] Do GSI routing Glauber Costa
2009-12-01 16:44 ` [Qemu-devel] [PATCH v2 7/9] provide apic-kvm Alexander Graf
2009-12-01 16:49 ` [Qemu-devel] [PATCH v2 4/9] provide i8259-kvm Alexander Graf
2009-12-01 17:15 ` Glauber Costa
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=1258391527-18840-6-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.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 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).