2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* FPU support code, moved here from head.S so that it can be used
|
|
|
|
* by chips which use other head-whatever.S files.
|
|
|
|
*
|
2006-08-30 12:45:35 +08:00
|
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
|
|
|
* Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
|
|
|
|
* Copyright (C) 1996 Paul Mackerras.
|
|
|
|
* Copyright (C) 1997 Dan Malek (dmalek@jlc.net).
|
|
|
|
*
|
2005-09-26 14:04:21 +08:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-10-10 20:20:10 +08:00
|
|
|
#include <asm/reg.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/mmu.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/ppc_asm.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
2010-11-18 23:06:17 +08:00
|
|
|
#include <asm/ptrace.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-06-25 12:07:18 +08:00
|
|
|
#ifdef CONFIG_VSX
|
2012-06-25 21:33:23 +08:00
|
|
|
#define __REST_32FPVSRS(n,c,base) \
|
2008-06-25 12:07:18 +08:00
|
|
|
BEGIN_FTR_SECTION \
|
|
|
|
b 2f; \
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
|
|
|
|
REST_32FPRS(n,base); \
|
|
|
|
b 3f; \
|
|
|
|
2: REST_32VSRS(n,c,base); \
|
|
|
|
3:
|
|
|
|
|
2013-02-14 00:21:32 +08:00
|
|
|
#define __REST_32FPVSRS_TRANSACT(n,c,base) \
|
|
|
|
BEGIN_FTR_SECTION \
|
|
|
|
b 2f; \
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
|
|
|
|
REST_32FPRS_TRANSACT(n,base); \
|
|
|
|
b 3f; \
|
|
|
|
2: REST_32VSRS_TRANSACT(n,c,base); \
|
|
|
|
3:
|
|
|
|
|
2012-06-25 21:33:23 +08:00
|
|
|
#define __SAVE_32FPVSRS(n,c,base) \
|
2008-06-25 12:07:18 +08:00
|
|
|
BEGIN_FTR_SECTION \
|
|
|
|
b 2f; \
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
|
|
|
|
SAVE_32FPRS(n,base); \
|
|
|
|
b 3f; \
|
|
|
|
2: SAVE_32VSRS(n,c,base); \
|
|
|
|
3:
|
|
|
|
#else
|
2012-06-25 21:33:23 +08:00
|
|
|
#define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base)
|
2013-02-14 00:21:32 +08:00
|
|
|
#define __REST_32FPVSRS_TRANSACT(n,b,base) REST_32FPRS(n, base)
|
2012-06-25 21:33:23 +08:00
|
|
|
#define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base)
|
2008-06-25 12:07:18 +08:00
|
|
|
#endif
|
2012-06-25 21:33:23 +08:00
|
|
|
#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
|
2013-02-14 00:21:32 +08:00
|
|
|
#define REST_32FPVSRS_TRANSACT(n,c,base) \
|
|
|
|
__REST_32FPVSRS_TRANSACT(n,__REG_##c,__REG_##base)
|
2012-06-25 21:33:23 +08:00
|
|
|
#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
|
2008-06-25 12:07:18 +08:00
|
|
|
|
2013-02-14 00:21:36 +08:00
|
|
|
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
|
|
|
|
/*
|
|
|
|
* Wrapper to call load_up_fpu from C.
|
|
|
|
* void do_load_up_fpu(struct pt_regs *regs);
|
|
|
|
*/
|
|
|
|
_GLOBAL(do_load_up_fpu)
|
|
|
|
mflr r0
|
|
|
|
std r0, 16(r1)
|
|
|
|
stdu r1, -112(r1)
|
|
|
|
|
|
|
|
subi r6, r3, STACK_FRAME_OVERHEAD
|
|
|
|
/* load_up_fpu expects r12=MSR, r13=PACA, and returns
|
|
|
|
* with r12 = new MSR.
|
|
|
|
*/
|
|
|
|
ld r12,_MSR(r6)
|
|
|
|
GET_PACA(r13)
|
|
|
|
|
|
|
|
bl load_up_fpu
|
|
|
|
std r12,_MSR(r6)
|
|
|
|
|
|
|
|
ld r0, 112+16(r1)
|
|
|
|
addi r1, r1, 112
|
|
|
|
mtlr r0
|
|
|
|
blr
|
|
|
|
|
|
|
|
|
|
|
|
/* void do_load_up_transact_fpu(struct thread_struct *thread)
|
|
|
|
*
|
|
|
|
* This is similar to load_up_fpu but for the transactional version of the FP
|
|
|
|
* register set. It doesn't mess with the task MSR or valid flags.
|
|
|
|
* Furthermore, we don't do lazy FP with TM currently.
|
|
|
|
*/
|
|
|
|
_GLOBAL(do_load_up_transact_fpu)
|
|
|
|
mfmsr r6
|
|
|
|
ori r5,r6,MSR_FP
|
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
BEGIN_FTR_SECTION
|
|
|
|
oris r5,r5,MSR_VSX@h
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
|
|
|
|
#endif
|
|
|
|
SYNC
|
|
|
|
MTMSRD(r5)
|
|
|
|
|
|
|
|
lfd fr0,THREAD_TRANSACT_FPSCR(r3)
|
|
|
|
MTFSF_L(fr0)
|
|
|
|
REST_32FPVSRS_TRANSACT(0, R4, R3)
|
|
|
|
|
|
|
|
/* FP/VSX off again */
|
|
|
|
MTMSRD(r6)
|
|
|
|
SYNC
|
|
|
|
|
|
|
|
blr
|
|
|
|
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
|
|
|
|
|
2005-09-26 14:04:21 +08:00
|
|
|
/*
|
|
|
|
* This task wants to use the FPU now.
|
|
|
|
* On UP, disable FP for the task which had the FPU previously,
|
|
|
|
* and save its floating-point registers in its thread_struct.
|
|
|
|
* Load up this task's FP registers from its thread_struct,
|
|
|
|
* enable the FPU for the current task and return to the task.
|
|
|
|
*/
|
2005-10-06 08:59:19 +08:00
|
|
|
_GLOBAL(load_up_fpu)
|
2005-09-26 14:04:21 +08:00
|
|
|
mfmsr r5
|
|
|
|
ori r5,r5,MSR_FP
|
2008-06-25 12:07:18 +08:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
BEGIN_FTR_SECTION
|
|
|
|
oris r5,r5,MSR_VSX@h
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
SYNC
|
|
|
|
MTMSRD(r5) /* enable use of fpu now */
|
|
|
|
isync
|
|
|
|
/*
|
|
|
|
* For SMP, we don't do lazy FPU switching because it just gets too
|
|
|
|
* horrendously complex, especially when a task switches from one CPU
|
|
|
|
* to another. Instead we call giveup_fpu in switch_to.
|
|
|
|
*/
|
|
|
|
#ifndef CONFIG_SMP
|
2006-01-13 11:56:25 +08:00
|
|
|
LOAD_REG_ADDRBASE(r3, last_task_used_math)
|
2005-10-27 20:44:39 +08:00
|
|
|
toreal(r3)
|
2006-01-13 11:56:25 +08:00
|
|
|
PPC_LL r4,ADDROFF(last_task_used_math)(r3)
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LCMPI 0,r4,0
|
2005-09-26 14:04:21 +08:00
|
|
|
beq 1f
|
2005-10-27 20:44:39 +08:00
|
|
|
toreal(r4)
|
2005-09-26 14:04:21 +08:00
|
|
|
addi r4,r4,THREAD /* want last_task_used_math->thread */
|
2012-06-25 21:33:23 +08:00
|
|
|
SAVE_32FPVSRS(0, R5, R4)
|
2005-09-26 14:04:21 +08:00
|
|
|
mffs fr0
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 14:27:25 +08:00
|
|
|
stfd fr0,THREAD_FPSCR(r4)
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LL r5,PT_REGS(r4)
|
2005-10-27 20:44:39 +08:00
|
|
|
toreal(r5)
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
|
2005-09-26 14:04:21 +08:00
|
|
|
li r10,MSR_FP|MSR_FE0|MSR_FE1
|
|
|
|
andc r4,r4,r10 /* disable FP for previous task */
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
|
2005-09-26 14:04:21 +08:00
|
|
|
1:
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
/* enable use of FP after return */
|
2005-10-06 08:59:19 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2009-07-15 04:52:54 +08:00
|
|
|
mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
|
2005-09-26 14:04:21 +08:00
|
|
|
lwz r4,THREAD_FPEXC_MODE(r5)
|
|
|
|
ori r9,r9,MSR_FP /* enable FP for current */
|
|
|
|
or r9,r9,r4
|
2005-10-06 08:59:19 +08:00
|
|
|
#else
|
|
|
|
ld r4,PACACURRENT(r13)
|
|
|
|
addi r5,r4,THREAD /* Get THREAD */
|
2006-02-07 10:55:30 +08:00
|
|
|
lwz r4,THREAD_FPEXC_MODE(r5)
|
2005-10-06 08:59:19 +08:00
|
|
|
ori r12,r12,MSR_FP
|
|
|
|
or r12,r12,r4
|
|
|
|
std r12,_MSR(r1)
|
|
|
|
#endif
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 14:27:25 +08:00
|
|
|
lfd fr0,THREAD_FPSCR(r5)
|
2006-06-10 18:18:39 +08:00
|
|
|
MTFSF_L(fr0)
|
2012-06-25 21:33:10 +08:00
|
|
|
REST_32FPVSRS(0, R4, R5)
|
2005-09-26 14:04:21 +08:00
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
subi r4,r5,THREAD
|
2005-10-27 20:44:39 +08:00
|
|
|
fromreal(r4)
|
2006-01-13 11:56:25 +08:00
|
|
|
PPC_STL r4,ADDROFF(last_task_used_math)(r3)
|
2005-09-26 14:04:21 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
/* restore registers and return */
|
|
|
|
/* we haven't used ctr or xer or lr */
|
2008-06-25 12:07:18 +08:00
|
|
|
blr
|
2005-09-26 14:04:21 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* giveup_fpu(tsk)
|
|
|
|
* Disable FP for the task given as the argument,
|
|
|
|
* and save the floating-point registers in its thread_struct.
|
|
|
|
* Enables the FPU for use in the kernel on return.
|
|
|
|
*/
|
2005-10-06 08:59:19 +08:00
|
|
|
_GLOBAL(giveup_fpu)
|
2005-09-26 14:04:21 +08:00
|
|
|
mfmsr r5
|
|
|
|
ori r5,r5,MSR_FP
|
2008-06-25 12:07:18 +08:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
BEGIN_FTR_SECTION
|
|
|
|
oris r5,r5,MSR_VSX@h
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
SYNC_601
|
|
|
|
ISYNC_601
|
|
|
|
MTMSRD(r5) /* enable use of fpu now */
|
|
|
|
SYNC_601
|
|
|
|
isync
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LCMPI 0,r3,0
|
2005-09-26 14:04:21 +08:00
|
|
|
beqlr- /* if no previous owner, done */
|
|
|
|
addi r3,r3,THREAD /* want THREAD of task */
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LL r5,PT_REGS(r3)
|
|
|
|
PPC_LCMPI 0,r5,0
|
2012-06-25 21:33:10 +08:00
|
|
|
SAVE_32FPVSRS(0, R4 ,R3)
|
2005-09-26 14:04:21 +08:00
|
|
|
mffs fr0
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 14:27:25 +08:00
|
|
|
stfd fr0,THREAD_FPSCR(r3)
|
2005-09-26 14:04:21 +08:00
|
|
|
beq 1f
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
|
2005-09-26 14:04:21 +08:00
|
|
|
li r3,MSR_FP|MSR_FE0|MSR_FE1
|
2009-04-02 02:02:42 +08:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
BEGIN_FTR_SECTION
|
|
|
|
oris r3,r3,MSR_VSX@h
|
|
|
|
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
|
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
andc r4,r4,r3 /* disable FP for previous task */
|
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 09:56:55 +08:00
|
|
|
PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
|
2005-09-26 14:04:21 +08:00
|
|
|
1:
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
li r5,0
|
2006-01-13 11:56:25 +08:00
|
|
|
LOAD_REG_ADDRBASE(r4,last_task_used_math)
|
|
|
|
PPC_STL r5,ADDROFF(last_task_used_math)(r4)
|
2005-09-26 14:04:21 +08:00
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
blr
|
[PATCH] powerpc: Fix handling of fpscr on 64-bit
The recent merge of fpu.S broken the handling of fpscr for
ARCH=powerpc and CONFIG_PPC64=y. FP registers could be corrupted,
leading to strange random application crashes.
The confusion arises, because the thread_struct has (and requires) a
64-bit area to save the fpscr, because we use load/store double
instructions to get it in to/out of the FPU. However, only the low
32-bits are actually used, so we want to treat it as a 32-bit quantity
when manipulating its bits to avoid extra load/stores on 32-bit. This
patch replaces the current definition with a structure of two 32-bit
quantities (pad and val), to clarify things as much as is possible.
The 'val' field is used when manipulating bits, the structure itself
is used when obtaining the address for loading/unloading the value
from the FPU.
While we're at it, consolidate the 4 (!) almost identical versions of
cvt_fd() and cvt_df() (arch/ppc/kernel/misc.S,
arch/ppc64/kernel/misc.S, arch/powerpc/kernel/misc_32.S,
arch/powerpc/kernel/misc_64.S) into a single version in fpu.S. The
new version takes a pointer to thread_struct and applies the correct
offset itself, rather than a pointer to the fpscr field itself, again
to avoid confusion as to which is the correct field to use.
Finally, this patch makes ARCH=ppc64 also use the consolidated fpu.S
code, which it previously did not.
Built for G5 (ARCH=ppc64 and ARCH=powerpc), 32-bit powermac (ARCH=ppc
and ARCH=powerpc) and Walnut (ARCH=ppc, CONFIG_MATH_EMULATION=y).
Booted on G5 (ARCH=powerpc) and things which previously fell over no
longer do.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-10-27 14:27:25 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These are used in the alignment trap handler when emulating
|
|
|
|
* single-precision loads and stores.
|
|
|
|
*/
|
|
|
|
|
|
|
|
_GLOBAL(cvt_fd)
|
|
|
|
lfs 0,0(r3)
|
|
|
|
stfd 0,0(r4)
|
|
|
|
blr
|
|
|
|
|
|
|
|
_GLOBAL(cvt_df)
|
|
|
|
lfd 0,0(r3)
|
|
|
|
stfs 0,0(r4)
|
|
|
|
blr
|