]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Move FP state ownership from flag to a tristate
authorMarc Zyngier <maz@kernel.org>
Sat, 28 May 2022 11:38:14 +0000 (12:38 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 9 Jun 2022 11:01:58 +0000 (12:01 +0100)
commitba5fab530166ca630cb64dc89bb5bf40040adaf8
tree0003647c880feee2490d29ee51fcf509ed5b8e2e
parent4bf1377f510cc98dcda300ec78799e35fe593647
KVM: arm64: Move FP state ownership from flag to a tristate

The KVM FP code uses a pair of flags to denote three states:

- FP_ENABLED set: the guest owns the FP state
- FP_HOST set: the host owns the FP state
- FP_ENABLED and FP_HOST clear: nobody owns the FP state at all

and both flags set is an illegal state, which nothing ever checks
for...

As it turns out, this isn't really a good match for flags, and
we'd be better off if this was a simpler tristate, each state
having a name that actually reflect the state:

- FP_STATE_FREE
- FP_STATE_HOST_OWNED
- FP_STATE_GUEST_OWNED

Kill the two flags, and move over to an enum encoding these
three states. This results in less confusing code, and less risk of
ending up in the uncharted territory of a 4th state if we forget
to clear one of the two flags.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Reiji Watanabe <reijiw@google.com>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/fpsimd.c
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/switch.c
arch/arm64/kvm/hyp/vhe/switch.c