Skip to content

Commit b5b85bd

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Move guest_owns_fp_regs() to increase its scope
guest_owns_fp_regs() will be used to check fpsimd state ownership across kvm/arm64. Therefore, move it to kvm_host.h to widen its scope. Moreover, the host state is not per-vcpu anymore, the vcpu parameter isn't used, so remove it as well. No functional change intended. Signed-off-by: Fuad Tabba <tabba@google.com> Reviewed-by: Mark Brown <broonie@kernel.org> Acked-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240423150538.2103045-3-tabba@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 4c22a40 commit b5b85bd

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

arch/arm64/include/asm/kvm_host.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,12 @@ DECLARE_KVM_HYP_PER_CPU(struct kvm_host_data, kvm_host_data);
12071207
&this_cpu_ptr_hyp_sym(kvm_host_data)->f)
12081208
#endif
12091209

1210+
/* Check whether the FP regs are owned by the guest */
1211+
static inline bool guest_owns_fp_regs(void)
1212+
{
1213+
return *host_data_ptr(fp_owner) == FP_STATE_GUEST_OWNED;
1214+
}
1215+
12101216
static inline void kvm_init_host_cpu_context(struct kvm_cpu_context *cpu_ctxt)
12111217
{
12121218
/* The host's MPIDR is immutable, so let's set it up at boot time */

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ struct kvm_exception_table_entry {
3939
extern struct kvm_exception_table_entry __start___kvm_ex_table;
4040
extern struct kvm_exception_table_entry __stop___kvm_ex_table;
4141

42-
/* Check whether the FP regs are owned by the guest */
43-
static inline bool guest_owns_fp_regs(struct kvm_vcpu *vcpu)
44-
{
45-
return *host_data_ptr(fp_owner) == FP_STATE_GUEST_OWNED;
46-
}
47-
4842
/* Save the 32-bit only FPSIMD system register state */
4943
static inline void __fpsimd_save_fpexc32(struct kvm_vcpu *vcpu)
5044
{

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
5353
val |= CPTR_EL2_TSM;
5454
}
5555

56-
if (!guest_owns_fp_regs(vcpu)) {
56+
if (!guest_owns_fp_regs()) {
5757
if (has_hvhe())
5858
val &= ~(CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN |
5959
CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN);

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
7575

7676
val |= CPTR_EL2_TAM;
7777

78-
if (guest_owns_fp_regs(vcpu)) {
78+
if (guest_owns_fp_regs()) {
7979
if (vcpu_has_sve(vcpu))
8080
val |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
8181
} else {

0 commit comments

Comments
 (0)