ANDROID: arm64: kvm: Add new module functions used by s2mpu.

Add functions needed by S2MPU el2 module:
 -pkvm_host_donate_hyp/pkvm_hyp_donate_host: get and return SMPT from
  host kernel.
 -memcpy/memset: common functions used by s2mpu module.
 -hyp_pa: convert hyp address to PA, to get DMA address of SMPT.
 -kern_hyp_va: convert kernel address to hyp VA, used by the
  module to get the VA of SMPTs allocated from the kernel.

Bug: 261857213
Change-Id: Idceccf0ac38444e7f267f50c476b99f01a613372
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Mostafa Saleh
2022-12-09 14:57:13 +00:00
committed by Quentin Perret
parent e5d280f3d4
commit d46c47acf9
2 changed files with 12 additions and 0 deletions

View File

@@ -34,6 +34,12 @@ struct pkvm_module_ops {
int (*register_illegal_abt_notifier)(void (*cb)(struct kvm_cpu_context *));
int (*register_psci_notifier)(void (*cb)(enum pkvm_psci_notification, struct kvm_cpu_context *));
int (*register_hyp_panic_notifier)(void (*cb)(struct kvm_cpu_context *host_ctxt));
int (*host_donate_hyp)(u64 pfn, u64 nr_pages);
int (*hyp_donate_host)(u64 pfn, u64 nr_pages);
void* (*memcpy)(void *to, const void *from, size_t count);
void* (*memset)(void *dst, int c, size_t count);
phys_addr_t (*hyp_pa)(void *x);
unsigned long (*kern_hyp_va)(unsigned long x);
};
int __pkvm_load_el2_module(struct module *this, unsigned long *token);

View File

@@ -110,6 +110,12 @@ const struct pkvm_module_ops module_ops = {
.register_illegal_abt_notifier = __pkvm_register_illegal_abt_notifier,
.register_psci_notifier = __pkvm_register_psci_notifier,
.register_hyp_panic_notifier = __pkvm_register_hyp_panic_notifier,
.host_donate_hyp = __pkvm_host_donate_hyp,
.hyp_donate_host = __pkvm_hyp_donate_host,
.memcpy = memcpy,
.memset = memset,
.hyp_pa = hyp_virt_to_phys,
.kern_hyp_va = __kern_hyp_va,
};
int __pkvm_init_module(void *module_init)