Skip to content

Commit 5346f7e

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Always return generic v8 as the preferred target
Userspace selecting an implementation-specific vCPU target has been completely useless for a very long time. Let's go whole hog and start returning the generic v8 target across all implementations as the preferred target. Uphold the pre-existing behavior by tolerating either the generic target or an implementation-specific target if the vCPU happens to be running on one of the lucky few parts. Acked-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230710193140.1706399-5-oliver.upton@linux.dev
1 parent ef98406 commit 5346f7e

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,6 @@ struct kvm_vcpu_stat {
898898
u64 exits;
899899
};
900900

901-
void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
902901
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
903902
int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
904903
int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);

arch/arm64/kvm/arm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,8 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
12501250
{
12511251
int ret;
12521252

1253-
if (init->target != kvm_target_cpu())
1253+
if (init->target != KVM_ARM_TARGET_GENERIC_V8 &&
1254+
init->target != kvm_target_cpu())
12541255
return -EINVAL;
12551256

12561257
ret = kvm_vcpu_init_check_features(vcpu, init);
@@ -1585,9 +1586,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
15851586
return kvm_vm_ioctl_set_device_addr(kvm, &dev_addr);
15861587
}
15871588
case KVM_ARM_PREFERRED_TARGET: {
1588-
struct kvm_vcpu_init init;
1589-
1590-
kvm_vcpu_preferred_target(&init);
1589+
struct kvm_vcpu_init init = {
1590+
.target = KVM_ARM_TARGET_GENERIC_V8,
1591+
};
15911592

15921593
if (copy_to_user(argp, &init, sizeof(init)))
15931594
return -EFAULT;

arch/arm64/kvm/guest.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -884,21 +884,6 @@ u32 __attribute_const__ kvm_target_cpu(void)
884884
return KVM_ARM_TARGET_GENERIC_V8;
885885
}
886886

887-
void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init)
888-
{
889-
u32 target = kvm_target_cpu();
890-
891-
memset(init, 0, sizeof(*init));
892-
893-
/*
894-
* For now, we don't return any features.
895-
* In future, we might use features to return target
896-
* specific features available for the preferred
897-
* target type.
898-
*/
899-
init->target = (__u32)target;
900-
}
901-
902887
int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
903888
{
904889
return -EINVAL;

0 commit comments

Comments
 (0)