ANDROID: KVM: arm64: Store the maximum sve vector length at hyp

The code to determine the maximum sve vector length by the system
isn't trivial. In subsequent patches hyp needs to know it for
allocating memory for the host sve state.

Signed-off-by: Fuad Tabba <tabba@google.com>

Bug: 267291591
Change-Id: I2561af67722a99d8a989b26cb47d073eba3869ff
This commit is contained in:
Fuad Tabba
2023-03-15 15:53:11 +00:00
committed by Lee Jones
parent 2891cd7715
commit 90cc0eea13
5 changed files with 7 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ enum kvm_mode kvm_get_mode(void);
DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use);
extern unsigned int kvm_sve_max_vl;
extern unsigned int kvm_host_sve_max_vl;
int kvm_arm_init_sve(void);
u32 __attribute_const__ kvm_target_cpu(void);

View File

@@ -130,6 +130,7 @@ extern u64 kvm_nvhe_sym(id_aa64mmfr2_el1_sys_val);
extern unsigned long kvm_nvhe_sym(__icache_flags);
extern unsigned int kvm_nvhe_sym(kvm_arm_vmid_bits);
extern bool kvm_nvhe_sym(smccc_trng_available);
extern unsigned int kvm_nvhe_sym(kvm_host_sve_max_vl);
struct kvm_nvhe_clock_data {
u32 mult;

View File

@@ -2018,6 +2018,7 @@ static void kvm_hyp_init_symbols(void)
kvm_nvhe_sym(__icache_flags) = __icache_flags;
kvm_nvhe_sym(kvm_arm_vmid_bits) = kvm_arm_vmid_bits;
kvm_nvhe_sym(smccc_trng_available) = smccc_trng_available;
kvm_nvhe_sym(kvm_host_sve_max_vl) = kvm_host_sve_max_vl;
}
int kvm_hyp_init_events(void);

View File

@@ -25,6 +25,8 @@ unsigned long __icache_flags;
/* Used by kvm_get_vttbr(). */
unsigned int kvm_arm_vmid_bits;
unsigned int kvm_host_sve_max_vl;
/*
* The currently loaded hyp vCPU for each physical CPU. Used only when
* protected KVM is enabled, but for both protected and non-protected VMs.

View File

@@ -33,11 +33,13 @@
static u32 kvm_ipa_limit;
unsigned int kvm_sve_max_vl;
unsigned int kvm_host_sve_max_vl;
int kvm_arm_init_sve(void)
{
if (system_supports_sve()) {
kvm_sve_max_vl = sve_max_virtualisable_vl();
kvm_host_sve_max_vl = sve_max_vl();
/*
* The get_sve_reg()/set_sve_reg() ioctl interface will need