diff options
author | Avi Kivity <avi@qumranet.com> | 2007-10-22 10:50:39 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 11:01:20 -0500 |
commit | b209749f528488c4c0d20a42c0fbcbf49e6933b3 (patch) | |
tree | 0e0a24225a5c6bca1c1986cc0daaf8753424cfe6 /arch/x86/kvm/x86.c | |
parent | 565f1fbd9d2f766dcfed5db90b89ef80afe8b49a (diff) |
KVM: local APIC TPR access reporting facility
Add a facility to report on accesses to the local apic tpr even if the
local apic is emulated in the kernel. This is basically a hack that
allows userspace to patch Windows which tends to bang on the tpr a lot.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 513258c797ca..c2b80884447e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -684,6 +684,7 @@ int kvm_dev_ioctl_check_extension(long ext) | |||
684 | case KVM_CAP_USER_MEMORY: | 684 | case KVM_CAP_USER_MEMORY: |
685 | case KVM_CAP_SET_TSS_ADDR: | 685 | case KVM_CAP_SET_TSS_ADDR: |
686 | case KVM_CAP_EXT_CPUID: | 686 | case KVM_CAP_EXT_CPUID: |
687 | case KVM_CAP_VAPIC: | ||
687 | r = 1; | 688 | r = 1; |
688 | break; | 689 | break; |
689 | default: | 690 | default: |
@@ -1055,6 +1056,15 @@ static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, | |||
1055 | return 0; | 1056 | return 0; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1059 | static int vcpu_ioctl_tpr_access_reporting(struct kvm_vcpu *vcpu, | ||
1060 | struct kvm_tpr_access_ctl *tac) | ||
1061 | { | ||
1062 | if (tac->flags) | ||
1063 | return -EINVAL; | ||
1064 | vcpu->arch.tpr_access_reporting = !!tac->enabled; | ||
1065 | return 0; | ||
1066 | } | ||
1067 | |||
1058 | long kvm_arch_vcpu_ioctl(struct file *filp, | 1068 | long kvm_arch_vcpu_ioctl(struct file *filp, |
1059 | unsigned int ioctl, unsigned long arg) | 1069 | unsigned int ioctl, unsigned long arg) |
1060 | { | 1070 | { |
@@ -1148,6 +1158,21 @@ long kvm_arch_vcpu_ioctl(struct file *filp, | |||
1148 | case KVM_SET_MSRS: | 1158 | case KVM_SET_MSRS: |
1149 | r = msr_io(vcpu, argp, do_set_msr, 0); | 1159 | r = msr_io(vcpu, argp, do_set_msr, 0); |
1150 | break; | 1160 | break; |
1161 | case KVM_TPR_ACCESS_REPORTING: { | ||
1162 | struct kvm_tpr_access_ctl tac; | ||
1163 | |||
1164 | r = -EFAULT; | ||
1165 | if (copy_from_user(&tac, argp, sizeof tac)) | ||
1166 | goto out; | ||
1167 | r = vcpu_ioctl_tpr_access_reporting(vcpu, &tac); | ||
1168 | if (r) | ||
1169 | goto out; | ||
1170 | r = -EFAULT; | ||
1171 | if (copy_to_user(argp, &tac, sizeof tac)) | ||
1172 | goto out; | ||
1173 | r = 0; | ||
1174 | break; | ||
1175 | }; | ||
1151 | default: | 1176 | default: |
1152 | r = -EINVAL; | 1177 | r = -EINVAL; |
1153 | } | 1178 | } |