[PATCH] kvm: Two-way apic tpr synchronization
authorDor Laor <dor.laor@qumranet.com>
Mon, 12 Feb 2007 08:54:39 +0000 (00:54 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 12 Feb 2007 17:48:40 +0000 (09:48 -0800)
We report the value of cr8 to userspace on an exit.  Also let userspace change
cr8 when we re-enter the guest.  The lets 64-bit guest code maintain the tpr
correctly.

Thanks for Yaniv Kamay for the idea.

Signed-off-by: Dor Laor <dor.laor@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/kvm/kvm_main.c
include/linux/kvm.h

index 099f0afd394d16cf84fee390aa8b42fe6ec22fa4..eb3931ca680add4b8cfe2823e3145a7f8cd43877 100644 (file)
@@ -1360,6 +1360,9 @@ static int kvm_dev_ioctl_run(struct kvm *kvm, struct kvm_run *kvm_run)
        if (!vcpu)
                return -ENOENT;
 
+       /* re-sync apic's tpr */
+       vcpu->cr8 = kvm_run->cr8;
+
        if (kvm_run->emulated) {
                kvm_arch_ops->skip_emulated_instruction(vcpu);
                kvm_run->emulated = 0;
index 1be148f0fce4aa4cdb156038e4b96be8d8231603..6a5f6f49e0371a6395c153bd3813b15f2859f038 100644 (file)
@@ -65,6 +65,8 @@ struct kvm_run {
        __u8 ready_for_interrupt_injection;
        __u8 if_flag;
        __u16 padding2;
+
+       /* in (pre_kvm_run), out (post_kvm_run) */
        __u64 cr8;
        __u64 apic_base;