Re: [PATCH v4 12/25] KVM: arm64: Add infrastructure to create and track pKVM instances at EL2

Quentin Perret
2022-10-18T16:46:41Z

On Monday 17 Oct 2022 at 12:51:56 (+0100), Will Deacon wrote:
> +static int find_free_vm_table_entry(struct kvm *host_kvm)
> +{
> + int i, ret = -ENOMEM;
> +
> + for (i = 0; i < KVM_MAX_PVMS; ++i) {
> + struct pkvm_hyp_vm *vm = vm_table[i];
> +
> + if (!vm) {
> + if (ret < 0)
> + ret = i;
> + continue;
> + }
> +
> + if (unlikely(vm->host_kvm == host_kvm)) {
> + ret = -EEXIST;
> + break;
> + }

That would be funny if the host passed the same struct twice, but do we
care? If the host wants to shoot itself in the foot, it's not our
problem I guess :) ? Also, we don't do the same check for vCPUs so ...