[PATCH v19 11/20] KVM: arm64: Mandate VGIC v3 for for VMs running on hyp that don't trust the host
Suzuki K Poulose
suzuki.poulose at arm.com
Tue Sep 22 16:38:09 PDT 2026
On 22/09/2026 23:42, Jonathan Cameron wrote:
> On Sun, 20 Sep 2026 22:28:36 +0100
> Suzuki K Poulose <suzuki.poulose at arm.com> wrote:
>
>> pKVM and RMM, both do not trust the host. Add a helper to detect the VMs
>
> Maybe don't mention RMM yet, or make it clear that isn't here in this
> patch.
Ack.
>
>> that have "distrusting" hyp. Use this for blocking ioremap of vgic-v2 into
>> stage2 and prevent creation of VGIC other than v3.
>>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose at arm.com>
>
> Reviewed-by: Jonathan Cameron <jonathan.cameron at oss.qualcomm.com>
Thanks
>
> Other than minor comments, it feels to me like these first 11
> patches are good cleanup even without the RMM stuff that follows.
> Perhaps can get these upstream faster than the rest?
>
> Jonathan
>
>> ---
>> Changes since v18:
>> - Cover pKVM guests for VGIC v3 mandate.
>> - Merge the VGIC mandate check in here.
>> ---
>> arch/arm64/include/asm/kvm_host.h | 3 +++
>> arch/arm64/kvm/mmu.c | 2 +-
>> arch/arm64/kvm/vgic/vgic-init.c | 2 ++
>> 3 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
>> index 3211543a85b38..bb156a633ab75 100644
>> --- a/arch/arm64/include/asm/kvm_host.h
>> +++ b/arch/arm64/include/asm/kvm_host.h
>> @@ -328,6 +328,8 @@ enum fgt_group_id {
>> enum kvm_arm_vm_flavor {
>> VM_NVHE,
>> VM_VHE,
>> + /* VMs running on a hyp that doesn't trust */
>> + MARKER(__VM_DISTRUSTING_HYP),
>> VM_PKVM, /* Normal guests on pKVM */
>> MARKER(__VM_PROTECTED),
>> VM_PROTECTED_PKVM, /* Protected VM */
>> @@ -1546,6 +1548,7 @@ struct kvm *kvm_arch_alloc_vm(void);
>> #define kvm_vm_is_unprotected_pkvm(kvm) \
>> (is_protected_kvm_enabled() && ((kvm)->arch.vm_flavor == VM_PKVM))
>>
>> +#define kvm_vm_hyp_is_distrusting(kvm) ((kvm)->arch.vm_flavor >= __VM_DISTRUSTING_HYP)
>>
>> int kvm_arm_vcpu_finalize(struct kvm_vcpu *vcpu, int feature);
>> bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
>> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
>> index cf293d09e940a..413c4b114d75d 100644
>> --- a/arch/arm64/kvm/mmu.c
>> +++ b/arch/arm64/kvm/mmu.c
>> @@ -1251,7 +1251,7 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
>> KVM_PGTABLE_PROT_R |
>> (writable ? KVM_PGTABLE_PROT_W : 0);
>>
>> - if (is_protected_kvm_enabled())
>> + if (kvm_vm_hyp_is_distrusting(kvm))
>> return -EPERM;
>>
>> size += offset_in_page(guest_ipa);
>> diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c
>> index 4012df6002ea6..874025513afcc 100644
>> --- a/arch/arm64/kvm/vgic/vgic-init.c
>> +++ b/arch/arm64/kvm/vgic/vgic-init.c
>> @@ -84,6 +84,8 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
>> !kvm_vgic_global_state.can_emulate_gicv2)
>> return -ENODEV;
>>
>> + if (kvm_vm_hyp_is_distrusting(kvm) && type != KVM_DEV_TYPE_ARM_VGIC_V3)
>> + return -ENODEV;
>> /*
>> * Ensure mutual exclusion with vCPU creation and any vCPU ioctls by:
>> *
>
More information about the linux-arm-kernel
mailing list