diff options
author | Robin Luk <lubin.lu@antgroup.com> | 2021-01-14 19:06:46 +0800 |
---|---|---|
committer | Robin Luk <lubin.lu@antgroup.com> | 2021-02-03 11:50:36 +0000 |
commit | 6eb80b2e2df4a7e0a0b9dcfc99906a84fd8fc3f0 (patch) | |
tree | 4b04266e0608caf4c661b56d4ef7cb7731ba334d /pkg/ring0/kernel_arm64.go | |
parent | 25130d6183d399fc3bfa93385aeba6819437ea6c (diff) |
arm64 kvm:implement basic lazy save and restore for FPSIMD registers
Implement basic lazy save and restore for FPSIMD registers, which only
restore FPSIMD state on el0_fpsimd_acc and save FPSIMD state in switch().
Signed-off-by: Robin Luk <lubin.lu@antgroup.com>
Diffstat (limited to 'pkg/ring0/kernel_arm64.go')
-rw-r--r-- | pkg/ring0/kernel_arm64.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/ring0/kernel_arm64.go b/pkg/ring0/kernel_arm64.go index c05284641..41909b3a0 100644 --- a/pkg/ring0/kernel_arm64.go +++ b/pkg/ring0/kernel_arm64.go @@ -62,6 +62,8 @@ func IsCanonical(addr uint64) bool { //go:nosplit func (c *CPU) SwitchToUser(switchOpts SwitchOpts) (vector Vector) { storeAppASID(uintptr(switchOpts.UserASID)) + storeEl0Fpstate(switchOpts.FloatingPointState) + if switchOpts.Flush { FlushTlbByASID(uintptr(switchOpts.UserASID)) } @@ -71,13 +73,17 @@ func (c *CPU) SwitchToUser(switchOpts SwitchOpts) (vector Vector) { regs.Pstate &= ^uint64(PsrFlagsClear) regs.Pstate |= UserFlagsSet - EnableVFP() - LoadFloatingPoint(switchOpts.FloatingPointState) + fpDisableTrap := CPACREL1() + if fpDisableTrap != 0 { + FPSIMDEnableTrap() + } kernelExitToEl0() - SaveFloatingPoint(switchOpts.FloatingPointState) - DisableVFP() + fpDisableTrap = CPACREL1() + if fpDisableTrap != 0 { + SaveFloatingPoint(switchOpts.FloatingPointState) + } vector = c.vecCode |