Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202355
b: refs/heads/master
c: d1ac91d
h: refs/heads/master
i:
  202353: 42a703b
  202351: 6d58b3a
v: v3
  • Loading branch information
Avi Kivity committed Aug 1, 2010
1 parent 2e70680 commit 36a9576
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a1a005f36e0defea7c5490772c318c6af2261d31
refs/heads/master: d1ac91d8a2f00dc6a3954f7e8971339b0893edc4
62 changes: 32 additions & 30 deletions trunk/arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -2436,25 +2436,29 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
struct kvm_vcpu *vcpu = filp->private_data;
void __user *argp = (void __user *)arg;
int r;
struct kvm_lapic_state *lapic = NULL;
struct kvm_xsave *xsave = NULL;
struct kvm_xcrs *xcrs = NULL;
union {
struct kvm_lapic_state *lapic;
struct kvm_xsave *xsave;
struct kvm_xcrs *xcrs;
void *buffer;
} u;

u.buffer = NULL;
switch (ioctl) {
case KVM_GET_LAPIC: {
r = -EINVAL;
if (!vcpu->arch.apic)
goto out;
lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
u.lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);

r = -ENOMEM;
if (!lapic)
if (!u.lapic)
goto out;
r = kvm_vcpu_ioctl_get_lapic(vcpu, lapic);
r = kvm_vcpu_ioctl_get_lapic(vcpu, u.lapic);
if (r)
goto out;
r = -EFAULT;
if (copy_to_user(argp, lapic, sizeof(struct kvm_lapic_state)))
if (copy_to_user(argp, u.lapic, sizeof(struct kvm_lapic_state)))
goto out;
r = 0;
break;
Expand All @@ -2463,14 +2467,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r = -EINVAL;
if (!vcpu->arch.apic)
goto out;
lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
u.lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
r = -ENOMEM;
if (!lapic)
if (!u.lapic)
goto out;
r = -EFAULT;
if (copy_from_user(lapic, argp, sizeof(struct kvm_lapic_state)))
if (copy_from_user(u.lapic, argp, sizeof(struct kvm_lapic_state)))
goto out;
r = kvm_vcpu_ioctl_set_lapic(vcpu, lapic);
r = kvm_vcpu_ioctl_set_lapic(vcpu, u.lapic);
if (r)
goto out;
r = 0;
Expand Down Expand Up @@ -2634,68 +2638,66 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
break;
}
case KVM_GET_XSAVE: {
xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);
u.xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);
r = -ENOMEM;
if (!xsave)
if (!u.xsave)
break;

kvm_vcpu_ioctl_x86_get_xsave(vcpu, xsave);
kvm_vcpu_ioctl_x86_get_xsave(vcpu, u.xsave);

r = -EFAULT;
if (copy_to_user(argp, xsave, sizeof(struct kvm_xsave)))
if (copy_to_user(argp, u.xsave, sizeof(struct kvm_xsave)))
break;
r = 0;
break;
}
case KVM_SET_XSAVE: {
xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);
u.xsave = kzalloc(sizeof(struct kvm_xsave), GFP_KERNEL);
r = -ENOMEM;
if (!xsave)
if (!u.xsave)
break;

r = -EFAULT;
if (copy_from_user(xsave, argp, sizeof(struct kvm_xsave)))
if (copy_from_user(u.xsave, argp, sizeof(struct kvm_xsave)))
break;

r = kvm_vcpu_ioctl_x86_set_xsave(vcpu, xsave);
r = kvm_vcpu_ioctl_x86_set_xsave(vcpu, u.xsave);
break;
}
case KVM_GET_XCRS: {
xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);
u.xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);
r = -ENOMEM;
if (!xcrs)
if (!u.xcrs)
break;

kvm_vcpu_ioctl_x86_get_xcrs(vcpu, xcrs);
kvm_vcpu_ioctl_x86_get_xcrs(vcpu, u.xcrs);

r = -EFAULT;
if (copy_to_user(argp, xcrs,
if (copy_to_user(argp, u.xcrs,
sizeof(struct kvm_xcrs)))
break;
r = 0;
break;
}
case KVM_SET_XCRS: {
xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);
u.xcrs = kzalloc(sizeof(struct kvm_xcrs), GFP_KERNEL);
r = -ENOMEM;
if (!xcrs)
if (!u.xcrs)
break;

r = -EFAULT;
if (copy_from_user(xcrs, argp,
if (copy_from_user(u.xcrs, argp,
sizeof(struct kvm_xcrs)))
break;

r = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, xcrs);
r = kvm_vcpu_ioctl_x86_set_xcrs(vcpu, u.xcrs);
break;
}
default:
r = -EINVAL;
}
out:
kfree(lapic);
kfree(xsave);
kfree(xcrs);
kfree(u.buffer);
return r;
}

Expand Down

0 comments on commit 36a9576

Please sign in to comment.