aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorEddie Dong <eddie.dong@intel.com>2007-09-06 05:22:56 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:25 -0400
commit96ad2cc6132479aa0aea485d0838a13fda765bd5 (patch)
treedc3596b92981332cee0749004b7076a7d52a90b1 /drivers/kvm/kvm_main.c
parent6bf9e962d14deb9e460afbbfd83ea2f450325c2d (diff)
KVM: in-kernel LAPIC save and restore support
This patch adds a new vcpu-based IOCTL to save and restore the local apic registers for a single vcpu. The kernel only copies the apic page as a whole, extraction of registers is left to userspace side. On restore, the APIC timer is restarted from the initial count, this introduces a little delay, but works fine. Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com> Signed-off-by: Qing He <qing.he@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
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 }