aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2014-10-16 10:40:53 -0400
committerChristoffer Dall <christoffer.dall@linaro.org>2014-12-13 08:15:26 -0500
commitf7fa034dc8559c7d7326bfc8bd1a26175abd931a (patch)
treeaa0458365535fcc65662a40fef2dec95a43a47a0 /arch/arm64
parentb856a59141b1066d3c896a0d0231f84dabd040af (diff)
arm/arm64: KVM: Clarify KVM_ARM_VCPU_INIT ABI
It is not clear that this ioctl can be called multiple times for a given vcpu. Userspace already does this, so clarify the ABI. Also specify that userspace is expected to always make secondary and subsequent calls to the ioctl with the same parameters for the VCPU as the initial call (which userspace also already does). Add code to check that userspace doesn't violate that ABI in the future, and move the kvm_vcpu_set_target() function which is currently duplicated between the 32-bit and 64-bit versions in guest.c to a common static function in arm.c, shared between both architectures. Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/include/asm/kvm_host.h2
-rw-r--r--arch/arm64/kvm/guest.c25
2 files changed, 0 insertions, 27 deletions
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 2012c4ba8d67..65c615294589 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -165,8 +165,6 @@ struct kvm_vcpu_stat {
165 u32 halt_wakeup; 165 u32 halt_wakeup;
166}; 166};
167 167
168int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
169 const struct kvm_vcpu_init *init);
170int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init); 168int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
171unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); 169unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
172int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); 170int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
index 84d5959ff874..9535bd555d1d 100644
--- a/arch/arm64/kvm/guest.c
+++ b/arch/arm64/kvm/guest.c
@@ -296,31 +296,6 @@ int __attribute_const__ kvm_target_cpu(void)
296 return -EINVAL; 296 return -EINVAL;
297} 297}
298 298
299int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
300 const struct kvm_vcpu_init *init)
301{
302 unsigned int i;
303 int phys_target = kvm_target_cpu();
304
305 if (init->target != phys_target)
306 return -EINVAL;
307
308 vcpu->arch.target = phys_target;
309 bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES);
310
311 /* -ENOENT for unknown features, -EINVAL for invalid combinations. */
312 for (i = 0; i < sizeof(init->features) * 8; i++) {
313 if (init->features[i / 32] & (1 << (i % 32))) {
314 if (i >= KVM_VCPU_MAX_FEATURES)
315 return -ENOENT;
316 set_bit(i, vcpu->arch.features);
317 }
318 }
319
320 /* Now we know what it is, we can reset it. */
321 return kvm_reset_vcpu(vcpu);
322}
323
324int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init) 299int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
325{ 300{
326 int target = kvm_target_cpu(); 301 int target = kvm_target_cpu();