KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
Subsystems (2)
RFC PATCH 6/32 KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm which allows the caller to indicate whether it wants the nonvolatile register state to be preserved across the call, as required by the C calling conventions. This parameter being non-zero also causes the MSR bits that enable TM, FP, VMX and VSX to be preserved. The condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called from C code provided the 3rd parameter is non-zero. So that these functions can be called from modules, they now include code to set the TOC pointer (r2) on entry, as they can call other built-in C functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to assume that treclaim in fake-suspend state does not modify any registers, which is the case on POWER9. This enables the code to be simplified quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with this change, since they now only need to save and restore TAR and pass 1 for the 3rd argument to __kvmppc_{save,restore}_tm.
--- arch/powerpc/include/asm/asm-prototypes.h | 10 ++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 49 +++--- arch/powerpc/kvm/tm.S | 250 ++++++++++++++++-------------- 3 files changed, 169 insertions(+), 140 deletions(-)
arch/powerpc/include/asm/asm-prototypes.h +10 -0
@@ -150,6 +150,16 @@ extern s32 patch__memset_nocache, patch__memcpy_nocache;extern long flush_count_cache; +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM +void kvmppc_save_tm_hv (struct kvm_vcpu *vcpu,u64 msr,bool preserve_nv); +void kvmppc_restore_tm_hv (struct kvm_vcpu *vcpu,u64 msr,bool preserve_nv); +#else +static inline void kvmppc_save_tm_hv (struct kvm_vcpu *vcpu,u64 msr, +bool preserve_nv) { } +static inline void kvmppc_restore_tm_hv (struct kvm_vcpu *vcpu,u64 msr, +bool preserve_nv) { } +#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ +void kvmhv_save_host_pmu (void );void kvmhv_load_host_pmu (void );void kvmhv_save_guest_pmu (struct kvm_vcpu *vcpu,bool pmu_in_use);
arch/powerpc/kvm/book3s_hv_rmhandlers.S +23 -26
121 lines not on this page · raw message
arch/powerpc/kvm/tm.S +136 -114
383 lines not on this page · raw message
Signature · 1 line
2.7.4