@@ -153,7 +153,7 @@ struct kvm_vcpu_stat {
struct kvm_vcpu_init;
int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
- const struct kvm_vcpu_init *init);
+ struct kvm_vcpu_init *init);
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
struct kvm_one_reg;
@@ -63,6 +63,7 @@ struct kvm_regs {
/* Supported Processor Types */
#define KVM_ARM_TARGET_CORTEX_A15 0
+#define KVM_ARM_TARGET_HOST 0x0FFFFFFF
#define KVM_ARM_NUM_TARGETS 1
/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
@@ -698,6 +698,7 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
long kvm_arch_vcpu_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
+ int err;
struct kvm_vcpu *vcpu = filp->private_data;
void __user *argp = (void __user *)arg;
@@ -708,8 +709,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
if (copy_from_user(&init, argp, sizeof(init)))
return -EFAULT;
- return kvm_vcpu_set_target(vcpu, &init);
+ err = kvm_vcpu_set_target(vcpu, &init);
+ if (err)
+ return err;
+
+ if (copy_to_user(argp, &init, sizeof(init)))
+ return -EFAULT;
+ return 0;
}
case KVM_SET_ONE_REG:
case KVM_GET_ONE_REG: {
@@ -198,12 +198,19 @@ int __attribute_const__ kvm_target_cpu(void)
}
int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
- const struct kvm_vcpu_init *init)
+ struct kvm_vcpu_init *init)
{
unsigned int i;
+ int phys_target = kvm_target_cpu();
+
+ if (phys_target < 0) {
+ return phys_target;
+ }
/* We can only do a cortex A15 for now. */
- if (init->target != kvm_target_cpu())
+ if (init->target == KVM_ARM_TARGET_HOST)
+ init->target = phys_target;
+ else if (init->target != phys_target)
return -EINVAL;
vcpu->arch.target = init->target;