Commit 4c22a40d authored by Fuad Tabba's avatar Fuad Tabba Committed by Marc Zyngier

KVM: arm64: Initialize the kvm host data's fpsimd_state pointer in pKVM

Since the host_fpsimd_state has been removed from kvm_vcpu_arch,
it isn't pointing to the hyp's version of the host fp_regs in
protected mode.

Initialize the host_data fpsimd_state point to the host_data's
context fp_regs on pKVM initialization.

Fixes: 51e09b55 ("KVM: arm64: Exclude host_fpsimd_state pointer from kvm_vcpu_arch")
Signed-off-by: default avatarFuad Tabba <tabba@google.com>
Acked-by: default avatarOliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240423150538.2103045-2-tabba@google.comSigned-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 5294afdb
...@@ -54,6 +54,7 @@ pkvm_hyp_vcpu_to_hyp_vm(struct pkvm_hyp_vcpu *hyp_vcpu) ...@@ -54,6 +54,7 @@ pkvm_hyp_vcpu_to_hyp_vm(struct pkvm_hyp_vcpu *hyp_vcpu)
} }
void pkvm_hyp_vm_table_init(void *tbl); void pkvm_hyp_vm_table_init(void *tbl);
void pkvm_host_fpsimd_state_init(void);
int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva, int __pkvm_init_vm(struct kvm *host_kvm, unsigned long vm_hva,
unsigned long pgd_hva); unsigned long pgd_hva);
......
...@@ -247,6 +247,17 @@ void pkvm_hyp_vm_table_init(void *tbl) ...@@ -247,6 +247,17 @@ void pkvm_hyp_vm_table_init(void *tbl)
vm_table = tbl; vm_table = tbl;
} }
void pkvm_host_fpsimd_state_init(void)
{
unsigned long i;
for (i = 0; i < hyp_nr_cpus; i++) {
struct kvm_host_data *host_data = per_cpu_ptr(&kvm_host_data, i);
host_data->fpsimd_state = &host_data->host_ctxt.fp_regs;
}
}
/* /*
* Return the hyp vm structure corresponding to the handle. * Return the hyp vm structure corresponding to the handle.
*/ */
......
...@@ -300,6 +300,7 @@ void __noreturn __pkvm_init_finalise(void) ...@@ -300,6 +300,7 @@ void __noreturn __pkvm_init_finalise(void)
goto out; goto out;
pkvm_hyp_vm_table_init(vm_table_base); pkvm_hyp_vm_table_init(vm_table_base);
pkvm_host_fpsimd_state_init();
out: out:
/* /*
* We tail-called to here from handle___pkvm_init() and will not return, * We tail-called to here from handle___pkvm_init() and will not return,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment