From: Dor Laor Date: Mon, 12 Feb 2007 08:54:39 +0000 (-0800) Subject: [PATCH] kvm: Two-way apic tpr synchronization X-Git-Tag: v2.6.21-rc1~274^2~56 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54810342f1372afdaf6cb9a6aea0c35df187db12;p=linux-2.6 [PATCH] kvm: Two-way apic tpr synchronization 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 Signed-off-by: Avi Kivity Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 099f0afd39..eb3931ca68 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -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; diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 1be148f0fc..6a5f6f49e0 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -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;