Re: [PATCH v18 05/23] KVM: arm64: Track the type of VM in kvm_arch
From: Suzuki K Poulose
Date: Fri Sep 18 2026 - 05:47:29 EST
On 18/09/2026 10:14, Fuad Tabba wrote:
Hi Suzuki,
On <date>, Suzuki K Poulose <suzuki.poulose@xxxxxxx> wrote:
[...]
+ if (WARN_ON_ONCE(!kvm))
+ return false;
+
+ /* Cover both pKVM host and Realm VMs */
+ if (!kvm_vm_hyp_is_distrusting(kvm))
+ return true;
I'd drop the WARN_ON_ONCE.
I would say, we need it. i.e., we are filtering kvm_arch_vm_ioctl(),
where it is called from the kvm instance ioctl. So, kvm must be !NULL.
And this early return needs the `>=` from
patch 13, or non-protected pKVM VMs skip the filter.
Of course, This snippet is for Patch 20 and I have fixed the comparison.
I resorted to is_protected_kvm_enabled() to make it faster than using
the vm_flavor checks. I could rever those anyways.
Agreed it's the faster test. I'd just call it by name at the three
sites rather than through a macro.
Do you mean something like :
if (kvm_vm_is_protected_pkvm(host_kvm))
hyp_vm->kvm.arch.vm_flavor = VM_PROTECTED_PKVM;
else
hyp_vm->kvm.arch.vm_flavor = VM_PKVM;
Yes, exactly that.
Do we additionally need to WARN_ON() if we encounter a VM_REALM ?
No, the host shouldn't be able to trigger a WARN at EL2.
Alright.
Apologies, I thought this one didn't change, but later patches changes
them, which is why I kept this.
No worries. With those two in, please keep the tag.
Thanks
Suzuki
Cheers,
/fuad