[PATCH v3 11/36] KVM: arm64: Introduce __pkvm_host_donate_guest()

Marc Zyngier maz at kernel.org
Fri Mar 20 05:38:07 PDT 2026


On Thu, 05 Mar 2026 14:43:24 +0000,
Will Deacon <will at kernel.org> wrote:
> 
> In preparation for supporting protected VMs, whose memory pages are
> isolated from the host, introduce a new pKVM hypercall to allow the
> donation of pages to a guest.
> 
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
>  arch/arm64/include/asm/kvm_asm.h              |  1 +
>  arch/arm64/include/asm/kvm_pgtable.h          |  2 +-
>  arch/arm64/kvm/hyp/include/nvhe/mem_protect.h |  2 ++
>  arch/arm64/kvm/hyp/nvhe/hyp-main.c            | 21 +++++++++++++
>  arch/arm64/kvm/hyp/nvhe/mem_protect.c         | 30 +++++++++++++++++++
>  5 files changed, 55 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index df6b661701b6..dfc6625c8269 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -79,6 +79,7 @@ enum __kvm_host_smccc_func {
>  	/* Hypercalls that are available only when pKVM has finalised. */
>  	__KVM_HOST_SMCCC_FUNC___pkvm_host_share_hyp,
>  	__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_hyp,
> +	__KVM_HOST_SMCCC_FUNC___pkvm_host_donate_guest,
>  	__KVM_HOST_SMCCC_FUNC___pkvm_host_share_guest,
>  	__KVM_HOST_SMCCC_FUNC___pkvm_host_unshare_guest,
>  	__KVM_HOST_SMCCC_FUNC___pkvm_host_relax_perms_guest,
> diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h
> index c201168f2857..b6f7595c4979 100644
> --- a/arch/arm64/include/asm/kvm_pgtable.h
> +++ b/arch/arm64/include/asm/kvm_pgtable.h
> @@ -100,7 +100,7 @@ typedef u64 kvm_pte_t;
>  					 KVM_PTE_LEAF_ATTR_HI_S2_XN)
>  
>  #define KVM_INVALID_PTE_OWNER_MASK	GENMASK(9, 2)
> -#define KVM_MAX_OWNER_ID		1
> +#define KVM_MAX_OWNER_ID		3
>  
>  /*
>   * Used to indicate a pte for which a 'break-before-make' sequence is in
> diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
> index 5f9d56754e39..9c0cc53d1dc9 100644
> --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
> +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
> @@ -28,6 +28,7 @@ enum pkvm_component_id {
>  	PKVM_ID_HOST,
>  	PKVM_ID_HYP,
>  	PKVM_ID_FFA,
> +	PKVM_ID_GUEST,

Is KVM_MAX_OWNER_ID being set to 3 related to PKVM_ID_GUEST being
introduced? If so, wouldn't it be better to define one in terms of the
other?

Also, this includes PKVM_ID_FFA as a valid ID, while it wasn't
included until now. Is that expected?

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list