Commit 34f3941c authored by Radim Krčmář's avatar Radim Krčmář Committed by Paolo Bonzini

KVM: i8254: don't assume layout of kvm_kpit_state

channels has offset 0 and correct size now, but that can change.
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 4a2095df
...@@ -3604,9 +3604,13 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip) ...@@ -3604,9 +3604,13 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps) static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps)
{ {
mutex_lock(&kvm->arch.vpit->pit_state.lock); struct kvm_kpit_state *kps = &kvm->arch.vpit->pit_state;
memcpy(ps, &kvm->arch.vpit->pit_state, sizeof(struct kvm_pit_state));
mutex_unlock(&kvm->arch.vpit->pit_state.lock); BUILD_BUG_ON(sizeof(*ps) != sizeof(kps->channels));
mutex_lock(&kps->lock);
memcpy(ps, &kps->channels, sizeof(*ps));
mutex_unlock(&kps->lock);
return 0; return 0;
} }
...@@ -3616,7 +3620,7 @@ static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) ...@@ -3616,7 +3620,7 @@ static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps)
struct kvm_pit *pit = kvm->arch.vpit; struct kvm_pit *pit = kvm->arch.vpit;
mutex_lock(&pit->pit_state.lock); mutex_lock(&pit->pit_state.lock);
memcpy(&pit->pit_state, ps, sizeof(struct kvm_pit_state)); memcpy(&pit->pit_state.channels, ps, sizeof(*ps));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
kvm_pit_load_count(pit, i, ps->channels[i].count, 0); kvm_pit_load_count(pit, i, ps->channels[i].count, 0);
mutex_unlock(&pit->pit_state.lock); mutex_unlock(&pit->pit_state.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment