aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2010-01-17 08:51:23 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:36:00 -0500
commit10388a07164c1512b3a3d0273b9adc230f82790e (patch)
tree1a1a5de7c0c639143fbfa4f2b01bb59bc7135882 /arch/x86/kvm/x86.c
parent55cd8e5a4edb8e235163ffe8264b9aaa8d7c050f (diff)
KVM: Add HYPER-V apic access MSRs
Implement HYPER-V apic MSRs. Spec defines three MSRs that speed-up access to EOI/TPR/ICR apic registers for PV guests. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Vadim Rozenfeld <vrozenfe@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 480137db4770..552be51e4d84 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -622,10 +622,11 @@ static inline u32 bit(int bitno)
622 * kvm-specific. Those are put in the beginning of the list. 622 * kvm-specific. Those are put in the beginning of the list.
623 */ 623 */
624 624
625#define KVM_SAVE_MSRS_BEGIN 4 625#define KVM_SAVE_MSRS_BEGIN 5
626static u32 msrs_to_save[] = { 626static u32 msrs_to_save[] = {
627 MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK, 627 MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK,
628 HV_X64_MSR_GUEST_OS_ID, HV_X64_MSR_HYPERCALL, 628 HV_X64_MSR_GUEST_OS_ID, HV_X64_MSR_HYPERCALL,
629 HV_X64_MSR_APIC_ASSIST_PAGE,
629 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP, 630 MSR_IA32_SYSENTER_CS, MSR_IA32_SYSENTER_ESP, MSR_IA32_SYSENTER_EIP,
630 MSR_K6_STAR, 631 MSR_K6_STAR,
631#ifdef CONFIG_X86_64 632#ifdef CONFIG_X86_64
@@ -1067,10 +1068,36 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1067 1068
1068static int set_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 data) 1069static int set_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1069{ 1070{
1070 pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x data 0x%llx\n", 1071 switch (msr) {
1071 msr, data); 1072 case HV_X64_MSR_APIC_ASSIST_PAGE: {
1073 unsigned long addr;
1072 1074
1073 return 1; 1075 if (!(data & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE)) {
1076 vcpu->arch.hv_vapic = data;
1077 break;
1078 }
1079 addr = gfn_to_hva(vcpu->kvm, data >>
1080 HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT);
1081 if (kvm_is_error_hva(addr))
1082 return 1;
1083 if (clear_user((void __user *)addr, PAGE_SIZE))
1084 return 1;
1085 vcpu->arch.hv_vapic = data;
1086 break;
1087 }
1088 case HV_X64_MSR_EOI:
1089 return kvm_hv_vapic_msr_write(vcpu, APIC_EOI, data);
1090 case HV_X64_MSR_ICR:
1091 return kvm_hv_vapic_msr_write(vcpu, APIC_ICR, data);
1092 case HV_X64_MSR_TPR:
1093 return kvm_hv_vapic_msr_write(vcpu, APIC_TASKPRI, data);
1094 default:
1095 pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
1096 "data 0x%llx\n", msr, data);
1097 return 1;
1098 }
1099
1100 return 0;
1074} 1101}
1075 1102
1076int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) 1103int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
@@ -1330,6 +1357,12 @@ static int get_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1330 data = r; 1357 data = r;
1331 break; 1358 break;
1332 } 1359 }
1360 case HV_X64_MSR_EOI:
1361 return kvm_hv_vapic_msr_read(vcpu, APIC_EOI, pdata);
1362 case HV_X64_MSR_ICR:
1363 return kvm_hv_vapic_msr_read(vcpu, APIC_ICR, pdata);
1364 case HV_X64_MSR_TPR:
1365 return kvm_hv_vapic_msr_read(vcpu, APIC_TASKPRI, pdata);
1333 default: 1366 default:
1334 pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr); 1367 pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
1335 return 1; 1368 return 1;
@@ -1530,6 +1563,7 @@ int kvm_dev_ioctl_check_extension(long ext)
1530 case KVM_CAP_ADJUST_CLOCK: 1563 case KVM_CAP_ADJUST_CLOCK:
1531 case KVM_CAP_VCPU_EVENTS: 1564 case KVM_CAP_VCPU_EVENTS:
1532 case KVM_CAP_HYPERV: 1565 case KVM_CAP_HYPERV:
1566 case KVM_CAP_HYPERV_VAPIC:
1533 r = 1; 1567 r = 1;
1534 break; 1568 break;
1535 case KVM_CAP_COALESCED_MMIO: 1569 case KVM_CAP_COALESCED_MMIO: