ANDROID: KVM: arm64: Allocate memory at hyp for host sve state
Allocate memory and donate it to hyp at setup time for tracking the host sve state at hyp in protected mode. This memory is used in the subsequent patch. Signed-off-by: Fuad Tabba <tabba@google.com> Bug: 267291591 Change-Id: If07eec9ea9c7b216d02e2d1ea69bd62d99f08081
This commit is contained in:
parent
a752b269cb
commit
6a8b1d4934
@ -13,6 +13,23 @@
|
||||
#include <asm/kvm_pgtable.h>
|
||||
#include <asm/sysreg.h>
|
||||
|
||||
/*
|
||||
* Stores the sve state for the host in protected mode.
|
||||
*/
|
||||
struct kvm_host_sve_state {
|
||||
u64 zcr_el1;
|
||||
|
||||
/*
|
||||
* Ordering is important since __sve_save_state/__sve_restore_state
|
||||
* relies on it.
|
||||
*/
|
||||
u32 fpsr;
|
||||
u32 fpcr;
|
||||
|
||||
/* Must be SVE_VQ_BYTES (128 bit) aligned. */
|
||||
char sve_regs[];
|
||||
};
|
||||
|
||||
/* Maximum number of VMs that can co-exist under pKVM. */
|
||||
#define KVM_MAX_PVMS 255
|
||||
|
||||
@ -385,10 +402,19 @@ static inline unsigned long hyp_ffa_proxy_pages(void)
|
||||
return (2 * KVM_FFA_MBOX_NR_PAGES) + DIV_ROUND_UP(desc_max, PAGE_SIZE);
|
||||
}
|
||||
|
||||
static inline size_t pkvm_host_fp_state_size(void)
|
||||
{
|
||||
if (system_supports_sve())
|
||||
return size_add(sizeof(struct kvm_host_sve_state),
|
||||
SVE_SIG_REGS_SIZE(sve_vq_from_vl(kvm_host_sve_max_vl)));
|
||||
else
|
||||
return sizeof(struct user_fpsimd_state);
|
||||
}
|
||||
|
||||
static inline unsigned long hyp_host_fp_pages(unsigned long nr_cpus)
|
||||
{
|
||||
return PAGE_ALIGN(nr_cpus * sizeof(struct user_fpsimd_state)) >>
|
||||
PAGE_SHIFT;
|
||||
return PAGE_ALIGN(size_mul(nr_cpus, pkvm_host_fp_state_size())) >>
|
||||
PAGE_SHIFT;
|
||||
}
|
||||
|
||||
#endif /* __ARM64_KVM_PKVM_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user