aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 61dff55f137e..a012d70d9eff 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2642,6 +2642,27 @@ static int kvm_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
2642 return 0; 2642 return 0;
2643} 2643}
2644 2644
2645static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,
2646 struct kvm_lapic_state *s)
2647{
2648 vcpu_load(vcpu);
2649 memcpy(s->regs, vcpu->apic->regs, sizeof *s);
2650 vcpu_put(vcpu);
2651
2652 return 0;
2653}
2654
2655static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
2656 struct kvm_lapic_state *s)
2657{
2658 vcpu_load(vcpu);
2659 memcpy(vcpu->apic->regs, s->regs, sizeof *s);
2660 kvm_apic_post_state_restore(vcpu);
2661 vcpu_put(vcpu);
2662
2663 return 0;
2664}
2665
2645static long kvm_vcpu_ioctl(struct file *filp, 2666static long kvm_vcpu_ioctl(struct file *filp,
2646 unsigned int ioctl, unsigned long arg) 2667 unsigned int ioctl, unsigned long arg)
2647{ 2668{
@@ -2811,6 +2832,31 @@ static long kvm_vcpu_ioctl(struct file *filp,
2811 r = 0; 2832 r = 0;
2812 break; 2833 break;
2813 } 2834 }
2835 case KVM_GET_LAPIC: {
2836 struct kvm_lapic_state lapic;
2837
2838 memset(&lapic, 0, sizeof lapic);
2839 r = kvm_vcpu_ioctl_get_lapic(vcpu, &lapic);
2840 if (r)
2841 goto out;
2842 r = -EFAULT;
2843 if (copy_to_user(argp, &lapic, sizeof lapic))
2844 goto out;
2845 r = 0;
2846 break;
2847 }
2848 case KVM_SET_LAPIC: {
2849 struct kvm_lapic_state lapic;
2850
2851 r = -EFAULT;
2852 if (copy_from_user(&lapic, argp, sizeof lapic))
2853 goto out;
2854 r = kvm_vcpu_ioctl_set_lapic(vcpu, &lapic);;
2855 if (r)
2856 goto out;
2857 r = 0;
2858 break;
2859 }
2814 default: 2860 default:
2815 ; 2861 ;
2816 } 2862 }