diff options
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5d450cc6f841..bb842db3ee7c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -857,6 +857,38 @@ static int set_msr_mce(struct kvm_vcpu *vcpu, u32 msr, u64 data) | |||
857 | return 0; | 857 | return 0; |
858 | } | 858 | } |
859 | 859 | ||
860 | static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data) | ||
861 | { | ||
862 | struct kvm *kvm = vcpu->kvm; | ||
863 | int lm = is_long_mode(vcpu); | ||
864 | u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64 | ||
865 | : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32; | ||
866 | u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64 | ||
867 | : kvm->arch.xen_hvm_config.blob_size_32; | ||
868 | u32 page_num = data & ~PAGE_MASK; | ||
869 | u64 page_addr = data & PAGE_MASK; | ||
870 | u8 *page; | ||
871 | int r; | ||
872 | |||
873 | r = -E2BIG; | ||
874 | if (page_num >= blob_size) | ||
875 | goto out; | ||
876 | r = -ENOMEM; | ||
877 | page = kzalloc(PAGE_SIZE, GFP_KERNEL); | ||
878 | if (!page) | ||
879 | goto out; | ||
880 | r = -EFAULT; | ||
881 | if (copy_from_user(page, blob_addr + (page_num * PAGE_SIZE), PAGE_SIZE)) | ||
882 | goto out_free; | ||
883 | if (kvm_write_guest(kvm, page_addr, page, PAGE_SIZE)) | ||
884 | goto out_free; | ||
885 | r = 0; | ||
886 | out_free: | ||
887 | kfree(page); | ||
888 | out: | ||
889 | return r; | ||
890 | } | ||
891 | |||
860 | int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) | 892 | int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) |
861 | { | 893 | { |
862 | switch (msr) { | 894 | switch (msr) { |
@@ -972,6 +1004,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) | |||
972 | "0x%x data 0x%llx\n", msr, data); | 1004 | "0x%x data 0x%llx\n", msr, data); |
973 | break; | 1005 | break; |
974 | default: | 1006 | default: |
1007 | if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr)) | ||
1008 | return xen_hvm_config(vcpu, data); | ||
975 | if (!ignore_msrs) { | 1009 | if (!ignore_msrs) { |
976 | pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n", | 1010 | pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n", |
977 | msr, data); | 1011 | msr, data); |
@@ -1246,6 +1280,7 @@ int kvm_dev_ioctl_check_extension(long ext) | |||
1246 | case KVM_CAP_PIT2: | 1280 | case KVM_CAP_PIT2: |
1247 | case KVM_CAP_PIT_STATE2: | 1281 | case KVM_CAP_PIT_STATE2: |
1248 | case KVM_CAP_SET_IDENTITY_MAP_ADDR: | 1282 | case KVM_CAP_SET_IDENTITY_MAP_ADDR: |
1283 | case KVM_CAP_XEN_HVM: | ||
1249 | r = 1; | 1284 | r = 1; |
1250 | break; | 1285 | break; |
1251 | case KVM_CAP_COALESCED_MMIO: | 1286 | case KVM_CAP_COALESCED_MMIO: |
@@ -2441,6 +2476,17 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
2441 | r = 0; | 2476 | r = 0; |
2442 | break; | 2477 | break; |
2443 | } | 2478 | } |
2479 | case KVM_XEN_HVM_CONFIG: { | ||
2480 | r = -EFAULT; | ||
2481 | if (copy_from_user(&kvm->arch.xen_hvm_config, argp, | ||
2482 | sizeof(struct kvm_xen_hvm_config))) | ||
2483 | goto out; | ||
2484 | r = -EINVAL; | ||
2485 | if (kvm->arch.xen_hvm_config.flags) | ||
2486 | goto out; | ||
2487 | r = 0; | ||
2488 | break; | ||
2489 | } | ||
2444 | default: | 2490 | default: |
2445 | ; | 2491 | ; |
2446 | } | 2492 | } |