[PATCH v19 05/20] KVM: arm64: Track the type of VM in kvm_arch

Jonathan Cameron jonathan.cameron at oss.qualcomm.com
Tue Sep 22 12:40:33 PDT 2026


On Sun, 20 Sep 2026 22:28:30 +0100
Suzuki K Poulose <suzuki.poulose at arm.com> wrote:

> KVM arm64 has different types of VMs with all the different modes in which
> the hypervisor code can be run. e.g., VHE, nVHE, pKVM etc. Then there is
> protected VM and normal VMs with pKVM. We might soon add other types,
> e.g., Arm CCA Realm.

Let's have some optimism!  


> 
> Realms support is restricted to VHE host and thus "kvm_vm_is_protected()"
> checks in the pkvm hyp specific code doesn't need to change, as the only
> protected guests it deals with is "protected pKVM" guests. To tighten this
> init_pkvm_hyp_vm() restricts the hyp copy of the vm_flavor to the ones it
> supports.
> 
> Suggested-by: Marc Zyngier <maz at kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose at arm.com>

Seems sensible to me.  One trivial thing inline.
Reviewed-by: Jonathan Cameron <jonathan.cameron at oss.qualcomm.com>

> ---
>  arch/arm64/include/asm/kvm_host.h | 22 +++++++++++++++++++---
>  arch/arm64/include/asm/kvm_pkvm.h |  4 ++--
>  arch/arm64/kvm/arm.c              | 31 ++++++++++++++++++++++++++-----
>  arch/arm64/kvm/handle_exit.c      |  2 +-
>  arch/arm64/kvm/hyp/nvhe/pkvm.c    |  6 +++++-
>  arch/arm64/kvm/mmu.c              |  2 +-
>  arch/arm64/kvm/pkvm.c             |  6 ++----
>  7 files changed, 56 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index 286489a69dff5..9b1cf9c59e81f 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -257,7 +257,6 @@ struct kvm_protected_vm {
>  	pkvm_handle_t handle;
>  	struct kvm_hyp_memcache teardown_mc;
>  	struct kvm_hyp_memcache stage2_teardown_mc;
> -	bool is_protected;
>  	bool is_created;
>  
>  	/*
> @@ -306,9 +305,19 @@ enum fgt_group_id {
>  	__NR_FGT_GROUP_IDS__
>  };
>  
> +enum kvm_arm_vm_flavor {
> +	VM_NVHE,
> +	VM_VHE,
> +	VM_PKVM,		/* Normal guests on pKVM */
> +	MARKER(__VM_PROTECTED),
> +	VM_PROTECTED_PKVM,	/* Protected VM */
> +	VM_FLAVOR_MAX,
Trivial but given whole point is this is an end marker, drop the
trailing ,  No point in making it easy to break the ordering!

> +};
> +



More information about the linux-arm-kernel mailing list