• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2022 - Google LLC
4  * Author: Andrew Walbran <qwandor@google.com>
5  */
6 #ifndef __KVM_HYP_FFA_H
7 #define __KVM_HYP_FFA_H
8 
9 #include <asm/kvm_host.h>
10 #include <nvhe/pkvm.h>
11 
12 #define FFA_MIN_FUNC_NUM 0x60
13 #define FFA_MAX_FUNC_NUM 0xFF
14 
15 #define FFA_INVALID_HANDLE	(-1LL)
16 
17 /*
18  * "ID value 0 must be returned at the Non-secure physical FF-A instance"
19  * We share this ID with the host.
20  */
21 #define HOST_FFA_ID	0
22 
23 struct ffa_mem_transfer {
24 	struct list_head node;
25 	u64 ffa_handle;
26 	struct list_head translations;
27 };
28 
29 int hyp_ffa_init(void *pages);
30 bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id);
31 bool kvm_guest_ffa_handler(struct pkvm_hyp_vcpu *hyp_vcpu, u64 *exit_code);
32 struct ffa_mem_transfer *find_transfer_by_handle(u64 ffa_handle, struct kvm_ffa_buffers *buf);
33 int kvm_dying_guest_reclaim_ffa_resources(struct pkvm_hyp_vm *vm);
34 int kvm_guest_notify_availability(u32 ffa_handle, struct kvm_ffa_buffers *ffa_buf, bool is_dying);
35 u32 ffa_get_hypervisor_version(void);
36 
is_ffa_call(u64 func_id)37 static inline bool is_ffa_call(u64 func_id)
38 {
39 	return ARM_SMCCC_IS_FAST_CALL(func_id) &&
40 		ARM_SMCCC_OWNER_NUM(func_id) == ARM_SMCCC_OWNER_STANDARD &&
41 		ARM_SMCCC_FUNC_NUM(func_id) >= FFA_MIN_FUNC_NUM &&
42 		ARM_SMCCC_FUNC_NUM(func_id) <= FFA_MAX_FUNC_NUM;
43 }
44 
45 #endif /* __KVM_HYP_FFA_H */
46