Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93821
b: refs/heads/master
c: e0f63cb
h: refs/heads/master
i:
  93819: 354650f
v: v3
  • Loading branch information
Sheng Yang authored and Avi Kivity committed Apr 27, 2008
1 parent f5c034c commit 649f360
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7837699fa6d7adf81f26ab73a5f6897ea1ab9d6a
refs/heads/master: e0f63cb9277b64850854aee301762beeeb463473
7 changes: 7 additions & 0 deletions trunk/arch/x86/kvm/i8254.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ static void pit_load_count(struct kvm *kvm, int channel, u32 val)
}
}

void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val)
{
mutex_lock(&kvm->arch.vpit->pit_state.lock);
pit_load_count(kvm, channel, val);
mutex_unlock(&kvm->arch.vpit->pit_state.lock);
}

static void pit_ioport_write(struct kvm_io_device *this,
gpa_t addr, int len, const void *data)
{
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/kvm/i8254.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct kvm_pit {

void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu);
void kvm_pit_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val);
struct kvm_pit *kvm_create_pit(struct kvm *kvm);
void kvm_free_pit(struct kvm *kvm);

Expand Down
48 changes: 48 additions & 0 deletions trunk/arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,23 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
return r;
}

static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps)
{
int r = 0;

memcpy(ps, &kvm->arch.vpit->pit_state, sizeof(struct kvm_pit_state));
return r;
}

static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps)
{
int r = 0;

memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state));
kvm_pit_load_count(kvm, 0, ps->channels[0].count);
return r;
}

/*
* Get (and clear) the dirty memory log for a memory slot.
*/
Expand Down Expand Up @@ -1657,6 +1674,37 @@ long kvm_arch_vm_ioctl(struct file *filp,
r = 0;
break;
}
case KVM_GET_PIT: {
struct kvm_pit_state ps;
r = -EFAULT;
if (copy_from_user(&ps, argp, sizeof ps))
goto out;
r = -ENXIO;
if (!kvm->arch.vpit)
goto out;
r = kvm_vm_ioctl_get_pit(kvm, &ps);
if (r)
goto out;
r = -EFAULT;
if (copy_to_user(argp, &ps, sizeof ps))
goto out;
r = 0;
break;
}
case KVM_SET_PIT: {
struct kvm_pit_state ps;
r = -EFAULT;
if (copy_from_user(&ps, argp, sizeof ps))
goto out;
r = -ENXIO;
if (!kvm->arch.vpit)
goto out;
r = kvm_vm_ioctl_set_pit(kvm, &ps);
if (r)
goto out;
r = 0;
break;
}
default:
;
}
Expand Down
21 changes: 21 additions & 0 deletions trunk/include/asm-x86/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,25 @@ struct kvm_cpuid2 {
struct kvm_cpuid_entry2 entries[0];
};

/* for KVM_GET_PIT and KVM_SET_PIT */
struct kvm_pit_channel_state {
__u32 count; /* can be 65536 */
__u16 latched_count;
__u8 count_latched;
__u8 status_latched;
__u8 status;
__u8 read_state;
__u8 write_state;
__u8 write_latch;
__u8 rw_mode;
__u8 mode;
__u8 bcd;
__u8 gate;
__s64 count_load_time;
};

struct kvm_pit_state {
struct kvm_pit_channel_state channels[3];
};

#endif
2 changes: 2 additions & 0 deletions trunk/include/linux/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ struct kvm_vapic_addr {
#define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip)
#define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip)
#define KVM_CREATE_PIT _IO(KVMIO, 0x64)
#define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state)
#define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state)

/*
* ioctls for vcpu fds
Expand Down

0 comments on commit 649f360

Please sign in to comment.