powerpc: Provide for giveup_fpu/altivec to save state in alternate location
This provides a facility which is intended for use by KVM, where the contents of the FP/VSX and VMX (Altivec) registers can be saved away to somewhere other than the thread_struct when kernel code wants to use floating point or VMX instructions. This is done by providing a pointer in the thread_struct to indicate where the state should be saved to. The giveup_fpu() and giveup_altivec() functions test these pointers and save state to the indicated location if they are non-NULL. Note that the MSR_FP/VEC bits in task->thread.regs->msr are still used to indicate whether the CPU register state is live, even when an alternate save location is being used. This also provides load_fp_state() and load_vr_state() functions, which load up FP/VSX and VMX state from memory into the CPU registers, and corresponding store_fp_state() and store_vr_state() functions, which store FP/VSX and VMX state into memory from the CPU registers. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:

committed by
Benjamin Herrenschmidt

parent
de79f7b9f6
commit
18461960cb
@@ -36,6 +36,28 @@ _GLOBAL(do_load_up_transact_altivec)
|
||||
blr
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load state from memory into VMX registers including VSCR.
|
||||
* Assumes the caller has enabled VMX in the MSR.
|
||||
*/
|
||||
_GLOBAL(load_vr_state)
|
||||
li r4,VRSTATE_VSCR
|
||||
lvx vr0,r4,r3
|
||||
mtvscr vr0
|
||||
REST_32VRS(0,r4,r3)
|
||||
blr
|
||||
|
||||
/*
|
||||
* Store VMX state into memory, including VSCR.
|
||||
* Assumes the caller has enabled VMX in the MSR.
|
||||
*/
|
||||
_GLOBAL(store_vr_state)
|
||||
SAVE_32VRS(0, r4, r3)
|
||||
mfvscr vr0
|
||||
li r4, VRSTATE_VSCR
|
||||
stvx vr0, r4, r3
|
||||
blr
|
||||
|
||||
/*
|
||||
* Disable VMX for the task which had it previously,
|
||||
* and save its vector registers in its thread_struct.
|
||||
@@ -144,9 +166,12 @@ _GLOBAL(giveup_altivec)
|
||||
PPC_LCMPI 0,r3,0
|
||||
beqlr /* if no previous owner, done */
|
||||
addi r3,r3,THREAD /* want THREAD of task */
|
||||
addi r7,r3,THREAD_VRSTATE
|
||||
PPC_LL r7,THREAD_VRSAVEAREA(r3)
|
||||
PPC_LL r5,PT_REGS(r3)
|
||||
PPC_LCMPI 0,r5,0
|
||||
PPC_LCMPI 0,r7,0
|
||||
bne 2f
|
||||
addi r7,r3,THREAD_VRSTATE
|
||||
2: PPC_LCMPI 0,r5,0
|
||||
SAVE_32VRS(0,r4,r7)
|
||||
mfvscr vr0
|
||||
li r4,VRSTATE_VSCR
|
||||
|
Reference in New Issue
Block a user