aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c33a4578132c..621a8e362fe7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1504,6 +1504,23 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
1504 return r; 1504 return r;
1505} 1505}
1506 1506
1507static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps)
1508{
1509 int r = 0;
1510
1511 memcpy(ps, &kvm->arch.vpit->pit_state, sizeof(struct kvm_pit_state));
1512 return r;
1513}
1514
1515static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps)
1516{
1517 int r = 0;
1518
1519 memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state));
1520 kvm_pit_load_count(kvm, 0, ps->channels[0].count);
1521 return r;
1522}
1523
1507/* 1524/*
1508 * Get (and clear) the dirty memory log for a memory slot. 1525 * Get (and clear) the dirty memory log for a memory slot.
1509 */ 1526 */
@@ -1657,6 +1674,37 @@ long kvm_arch_vm_ioctl(struct file *filp,
1657 r = 0; 1674 r = 0;
1658 break; 1675 break;
1659 } 1676 }
1677 case KVM_GET_PIT: {
1678 struct kvm_pit_state ps;
1679 r = -EFAULT;
1680 if (copy_from_user(&ps, argp, sizeof ps))
1681 goto out;
1682 r = -ENXIO;
1683 if (!kvm->arch.vpit)
1684 goto out;
1685 r = kvm_vm_ioctl_get_pit(kvm, &ps);
1686 if (r)
1687 goto out;
1688 r = -EFAULT;
1689 if (copy_to_user(argp, &ps, sizeof ps))
1690 goto out;
1691 r = 0;
1692 break;
1693 }
1694 case KVM_SET_PIT: {
1695 struct kvm_pit_state ps;
1696 r = -EFAULT;
1697 if (copy_from_user(&ps, argp, sizeof ps))
1698 goto out;
1699 r = -ENXIO;
1700 if (!kvm->arch.vpit)
1701 goto out;
1702 r = kvm_vm_ioctl_set_pit(kvm, &ps);
1703 if (r)
1704 goto out;
1705 r = 0;
1706 break;
1707 }
1660 default: 1708 default:
1661 ; 1709 ;
1662 } 1710 }