u64 *vncr_array;
};
-struct cpu_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. */
- __u8 sve_regs[];
-};
-
/*
* This structure is instantiated on a per-CPU basis, and contains
* data that is:
/*
* Hyp VA.
- * sve_state is only used in pKVM and if system_supports_sve().
+ * sve_regs is only used in pKVM and if system_supports_sve().
*/
- struct cpu_sve_state *sve_state;
+ u8 *sve_regs;
/* Ownership of the FP regs */
enum {
if (!system_supports_sve())
return 0;
- return size_add(sizeof(struct cpu_sve_state),
- SVE_SIG_REGS_SIZE(sve_vq_from_vl(kvm_host_sve_max_vl)));
+ return SVE_SIG_REGS_SIZE(sve_vq_from_vl(kvm_host_sve_max_vl));
}
struct pkvm_mapping {
continue;
if (free_sve) {
- struct cpu_sve_state *sve_state;
+ u8 *sve_regs;
- sve_state = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state;
- free_pages((unsigned long) sve_state, pkvm_host_sve_state_order());
+ sve_regs = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_regs;
+ free_pages((unsigned long) sve_regs, pkvm_host_sve_state_order());
}
free_pages(kvm_nvhe_sym(kvm_arm_hyp_percpu_base)[cpu], nvhe_percpu_order());
if (!page)
return -ENOMEM;
- per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state = page_address(page);
+ per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_regs = page_address(page);
}
/*
if (system_supports_sve() && is_protected_kvm_enabled()) {
for_each_possible_cpu(cpu) {
- struct cpu_sve_state *sve_state;
+ u8 *sve_regs;
- sve_state = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state;
- per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_state =
- kern_hyp_va(sve_state);
+ sve_regs = per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_regs;
+ per_cpu_ptr_nvhe_sym(kvm_host_data, cpu)->sve_regs =
+ kern_hyp_va(sve_regs);
}
}
}
static inline void __hyp_sve_save_host(void)
{
- struct cpu_sve_state *sve_state = *host_data_ptr(sve_state);
+ struct kvm_cpu_context *hctxt = host_data_ptr(host_ctxt);
+ u8 *sve_regs = *host_data_ptr(sve_regs);
- sve_state->zcr_el1 = read_sysreg_el1(SYS_ZCR);
+ ctxt_sys_reg(hctxt, ZCR_EL1) = read_sysreg_el1(SYS_ZCR);
write_sysreg_s(sve_vq_from_vl(kvm_host_sve_max_vl) - 1, SYS_ZCR_EL2);
- __sve_save_state(sve_state->sve_regs + sve_ffr_offset(kvm_host_sve_max_vl),
- &sve_state->fpsr,
+ __sve_save_state(sve_regs + sve_ffr_offset(kvm_host_sve_max_vl),
+ &hctxt->fp_regs.fpsr,
true);
}
static void __hyp_sve_restore_host(void)
{
- struct cpu_sve_state *sve_state = *host_data_ptr(sve_state);
+ struct kvm_cpu_context *hctxt = host_data_ptr(host_ctxt);
+ u8 *sve_regs = *host_data_ptr(sve_regs);
/*
* On saving/restoring host sve state, always use the maximum VL for
* need to be revisited.
*/
write_sysreg_s(sve_vq_from_vl(kvm_host_sve_max_vl) - 1, SYS_ZCR_EL2);
- __sve_restore_state(sve_state->sve_regs + sve_ffr_offset(kvm_host_sve_max_vl),
- &sve_state->fpsr,
+ __sve_restore_state(sve_regs + sve_ffr_offset(kvm_host_sve_max_vl),
+ &hctxt->fp_regs.fpsr,
true);
- write_sysreg_el1(sve_state->zcr_el1, SYS_ZCR);
+ write_sysreg_el1(ctxt_sys_reg(hctxt, ZCR_EL1), SYS_ZCR);
}
static void fpsimd_sve_flush(void)
for (i = 0; i < hyp_nr_cpus; i++) {
struct kvm_host_data *host_data = per_cpu_ptr(&kvm_host_data, i);
- struct cpu_sve_state *sve_state = host_data->sve_state;
+ u8 *sve_regs = host_data->sve_regs;
- start = kern_hyp_va(sve_state);
+ start = kern_hyp_va(sve_regs);
end = start + PAGE_ALIGN(pkvm_host_sve_state_size());
ret = pkvm_create_mappings(start, end, PAGE_HYP);
if (ret)