[PATCH v18 20/23] KVM: arm64: CCA: Don't expose unsupported capabilities for realm guests

Suzuki K Poulose suzuki.poulose at arm.com
Thu Sep 17 07:56:25 PDT 2026


On 17/09/2026 14:16, Fuad Tabba wrote:
> Hi Suzuki,
> 
> On Tue, 15 Sep 2026 17:01:38 +0100, Suzuki K Poulose
> <suzuki.poulose at arm.com> wrote:
> [...]
>> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> [...]
>> +static inline bool kvm_realm_ext_allowed(long ext)
>> +{
>> +        switch (ext) {
>> +        case KVM_CAP_ARM_PSCI:
>> +        case KVM_CAP_ARM_PSCI_0_2:
>> +        case KVM_CAP_NR_VCPUS:
>> +        case KVM_CAP_MAX_VCPUS:
>> +        case KVM_CAP_MAX_VCPU_ID:
>> +        case KVM_CAP_MSI_DEVID:
>> +        case KVM_CAP_ARM_VM_IPA_SIZE:
>> +        case KVM_CAP_ARM_SVE:
>> +        case KVM_CAP_ONE_REG:
>> +        case KVM_CAP_ARM_PTRAUTH_ADDRESS:
>> +        case KVM_CAP_ARM_PTRAUTH_GENERIC:
>> +        case KVM_CAP_SYNC_MMU:
>> +                return true;
>> +        }
>> +        return false;
>> +}
> 
> I'd keep KVM_CAP_IRQCHIP in this list. api.rst has it advertising
> KVM_IRQ_LINE as well as KVM_CREATE_IRQCHIP, so the cap means in-kernel
> irqchip rather than GICv2, and the GICv2 case is already rejected by
> patch 18 in kvm_vgic_create(). It also keeps the two protected lists

Ack

> the same where the support is the same. And could this live in
> kvm_rmi.h, next to where kvm_pkvm_ext_allowed() lives in kvm_pkvm.h,
> rather than in arm.c?

 From what I remember, it creates weird header file dependencies. I
will see if I can resolve them.

> 
> [...]
>> +static inline bool kvm_arch_vm_ioctl_allowed(struct kvm *kvm, unsigned int ioctl)
>> +{
>> +        long ext;
>> +        int r;
>> +
>> +        r = kvm_get_cap_for_kvm_ioctl(ioctl, &ext);
>> +        if (WARN_ON_ONCE(r < 0))
>> +                return false;
> 
> You told Sashiko my fix covers this one [1], but that fix changes
> kvm_pkvm_ioctl_allowed(), which this patch deletes, so the `if (r <
> 0)` has to go into this copy too. The guard you posted for the second
> finding still leaves the WARN reachable on pKVM and Realm hosts, which
> is the case the fix removed.

I had the chat with Marc about this and his recommendation was to
post my changes as they are and he would resolve the changes
while managing the conflict.

> 
> nit: kvm_arch_ is the prefix generic KVM uses for the hooks it calls
> into the arch. For two static helpers in arm.c, kvm_vm_ext_allowed()
> and kvm_vm_ioctl_allowed() would avoid the collision, and the same for
> kvm_arch_vm_ext_allowed() above.

Ack

Suzuki

> 
> Cheers,
> /fuad
> 
> [1] https://lore.kernel.org/all/20260914093838.1082637-1-fuad.tabba@linux.dev/




More information about the linux-arm-kernel mailing list