ANDROID: KVM: arm64: Restore host FP state before SMCs

Nothing currently prevents a CPU suspend/resume cycle (for example)
while a vCPU is loaded under pKVM. The resume path will disable FP/SVE
traps, which may corrupt the guest FP state if it was in use when
suspend was issued.

To fix this issue and all related problems, proactively restore the host
FP state prior to handling SMCs form the host.

Bug: 266405428
Bug: 265901597
Change-Id: I75f7d18f81f17dfa323d3128d2c66769ef19c591
Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
Quentin Perret
2023-01-24 17:09:47 +00:00
parent 6eb13fb26f
commit 85e63f3b91

View File

@@ -1311,8 +1311,13 @@ inval:
static void handle_host_smc(struct kvm_cpu_context *host_ctxt)
{
struct pkvm_hyp_vcpu *hyp_vcpu;
bool handled;
hyp_vcpu = pkvm_get_loaded_hyp_vcpu();
if (hyp_vcpu && hyp_vcpu->vcpu.arch.fp_state == FP_STATE_GUEST_OWNED)
fpsimd_host_restore();
handled = kvm_host_psci_handler(host_ctxt);
if (!handled)
handled = kvm_host_ffa_handler(host_ctxt);