2005-10-10 12:19:43 +08:00
|
|
|
#ifndef _ASM_POWERPC_PROCESSOR_H
|
|
|
|
#define _ASM_POWERPC_PROCESSOR_H
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2005-10-10 12:19:43 +08:00
|
|
|
* Copyright (C) 2001 PPC 64 Team, IBM Corp
|
|
|
|
*
|
|
|
|
* 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-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#include <asm/reg.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-25 12:07:18 +08:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
#define TS_FPRWIDTH 2
|
|
|
|
#else
|
2008-06-26 15:07:48 +08:00
|
|
|
#define TS_FPRWIDTH 1
|
2008-06-25 12:07:18 +08:00
|
|
|
#endif
|
2008-06-26 15:07:48 +08:00
|
|
|
|
2012-12-07 05:49:56 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
/* Default SMT priority is set to 3. Use 11- 13bits to save priority. */
|
|
|
|
#define PPR_PRIORITY 3
|
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
#define INIT_PPR (PPR_PRIORITY << 50)
|
|
|
|
#else
|
|
|
|
#define INIT_PPR ((u64)PPR_PRIORITY << 50)
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/compiler.h>
|
2011-04-23 05:48:27 +08:00
|
|
|
#include <linux/cache.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/types.h>
|
2012-12-20 22:06:44 +08:00
|
|
|
#include <asm/hw_breakpoint.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-10 10:37:51 +08:00
|
|
|
/* We do _not_ want to define new machine types at all, those must die
|
|
|
|
* in favor of using the device-tree
|
|
|
|
* -- BenH.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2005-11-10 10:37:51 +08:00
|
|
|
/* PREP sub-platform types see residual.h for these */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define _PREP_Motorola 0x01 /* motorola prep */
|
|
|
|
#define _PREP_Firm 0x02 /* firmworks prep */
|
|
|
|
#define _PREP_IBM 0x00 /* ibm prep */
|
|
|
|
#define _PREP_Bull 0x03 /* bull prep */
|
|
|
|
|
2005-11-10 10:37:51 +08:00
|
|
|
/* CHRP sub-platform types. These are arbitrary */
|
2005-04-17 06:20:36 +08:00
|
|
|
#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
|
|
|
|
#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
|
|
|
|
#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
|
2006-07-04 12:16:28 +08:00
|
|
|
#define _CHRP_briq 0x07 /* TotalImpact's briQ */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
#if defined(__KERNEL__) && defined(CONFIG_PPC32)
|
|
|
|
|
|
|
|
extern int _chrp_type;
|
2005-11-10 10:37:51 +08:00
|
|
|
|
2006-03-28 07:22:10 +08:00
|
|
|
#ifdef CONFIG_PPC_PREP
|
2005-11-10 10:37:51 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* what kind of prep workstation we are */
|
|
|
|
extern int _prep_type;
|
|
|
|
|
2006-03-28 07:22:10 +08:00
|
|
|
#endif /* CONFIG_PPC_PREP */
|
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
/*
|
|
|
|
* Default implementation of macro that returns current
|
|
|
|
* instruction pointer ("program counter").
|
|
|
|
*/
|
|
|
|
#define current_text_addr() ({ __label__ _l; _l: &&_l;})
|
|
|
|
|
|
|
|
/* Macros for adjusting thread priority (hardware multi-threading) */
|
|
|
|
#define HMT_very_low() asm volatile("or 31,31,31 # very low priority")
|
|
|
|
#define HMT_low() asm volatile("or 1,1,1 # low priority")
|
|
|
|
#define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority")
|
|
|
|
#define HMT_medium() asm volatile("or 2,2,2 # medium priority")
|
|
|
|
#define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority")
|
|
|
|
#define HMT_high() asm volatile("or 3,3,3 # high priority")
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct task_struct;
|
2005-10-10 12:19:43 +08:00
|
|
|
void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
|
2005-04-17 06:20:36 +08:00
|
|
|
void release_thread(struct task_struct *);
|
|
|
|
|
|
|
|
/* Lazy FPU handling on uni-processor */
|
|
|
|
extern struct task_struct *last_task_used_math;
|
|
|
|
extern struct task_struct *last_task_used_altivec;
|
2008-06-25 12:07:18 +08:00
|
|
|
extern struct task_struct *last_task_used_vsx;
|
2005-04-17 06:20:36 +08:00
|
|
|
extern struct task_struct *last_task_used_spe;
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2008-05-23 23:59:15 +08:00
|
|
|
|
|
|
|
#if CONFIG_TASK_SIZE > CONFIG_KERNEL_START
|
|
|
|
#error User TASK_SIZE overlaps with KERNEL_START address
|
|
|
|
#endif
|
2005-10-10 12:19:43 +08:00
|
|
|
#define TASK_SIZE (CONFIG_TASK_SIZE)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* This decides where the kernel will search for a free chunk of vm
|
|
|
|
* space during mmap's.
|
|
|
|
*/
|
|
|
|
#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
|
2005-10-10 12:19:43 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
2012-09-10 10:52:55 +08:00
|
|
|
/* 64-bit user address space is 46-bits (64TB user VM) */
|
|
|
|
#define TASK_SIZE_USER64 (0x0000400000000000UL)
|
2005-10-10 12:19:43 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 32-bit user address space is 4GB - 1 page
|
|
|
|
* (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
|
|
|
|
*/
|
|
|
|
#define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
|
|
|
|
|
2008-02-05 14:28:59 +08:00
|
|
|
#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
|
2005-10-10 12:19:43 +08:00
|
|
|
TASK_SIZE_USER32 : TASK_SIZE_USER64)
|
2008-02-05 14:28:59 +08:00
|
|
|
#define TASK_SIZE TASK_SIZE_OF(current)
|
2005-10-10 12:19:43 +08:00
|
|
|
|
|
|
|
/* This decides where the kernel will search for a free chunk of vm
|
|
|
|
* space during mmap's.
|
|
|
|
*/
|
|
|
|
#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
|
|
|
|
#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
|
|
|
|
|
2010-08-27 11:49:11 +08:00
|
|
|
#define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \
|
2005-10-10 12:19:43 +08:00
|
|
|
TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-08 20:19:26 +08:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
|
|
|
|
#define STACK_TOP_USER64 TASK_SIZE_USER64
|
|
|
|
#define STACK_TOP_USER32 TASK_SIZE_USER32
|
|
|
|
|
2010-08-27 11:49:11 +08:00
|
|
|
#define STACK_TOP (is_32bit_task() ? \
|
2008-02-08 20:19:26 +08:00
|
|
|
STACK_TOP_USER32 : STACK_TOP_USER64)
|
|
|
|
|
|
|
|
#define STACK_TOP_MAX STACK_TOP_USER64
|
|
|
|
|
|
|
|
#else /* __powerpc64__ */
|
|
|
|
|
|
|
|
#define STACK_TOP TASK_SIZE
|
|
|
|
#define STACK_TOP_MAX STACK_TOP
|
|
|
|
|
|
|
|
#endif /* __powerpc64__ */
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
typedef struct {
|
|
|
|
unsigned long seg;
|
|
|
|
} mm_segment_t;
|
|
|
|
|
2008-06-25 12:07:18 +08:00
|
|
|
#define TS_FPROFFSET 0
|
|
|
|
#define TS_VSRLOWOFFSET 1
|
|
|
|
#define TS_FPR(i) fpr[i][TS_FPROFFSET]
|
2008-06-26 15:07:48 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct thread_struct {
|
|
|
|
unsigned long ksp; /* Kernel stack pointer */
|
2008-04-28 14:21:22 +08:00
|
|
|
unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long ksp_vsid;
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
struct pt_regs *regs; /* Pointer to saved register state */
|
|
|
|
mm_segment_t fs; /* for get_fs() validation */
|
2011-04-23 05:48:27 +08:00
|
|
|
#ifdef CONFIG_BOOKE
|
|
|
|
/* BookE base exception scratch space; align on cacheline */
|
|
|
|
unsigned long normsave[8] ____cacheline_aligned;
|
|
|
|
#endif
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2005-04-17 06:20:36 +08:00
|
|
|
void *pgdir; /* root of page-table tree */
|
2005-10-10 12:19:43 +08:00
|
|
|
#endif
|
2010-02-08 19:53:26 +08:00
|
|
|
#ifdef CONFIG_PPC_ADV_DEBUG_REGS
|
|
|
|
/*
|
|
|
|
* The following help to manage the use of Debug Control Registers
|
|
|
|
* om the BookE platforms.
|
|
|
|
*/
|
|
|
|
unsigned long dbcr0;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long dbcr1;
|
2010-02-08 19:53:26 +08:00
|
|
|
#ifdef CONFIG_BOOKE
|
|
|
|
unsigned long dbcr2;
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* The stored value of the DBSR register will be the value at the
|
|
|
|
* last debug interrupt. This register can only be read from the
|
|
|
|
* user (will never be written to) and has value while helping to
|
|
|
|
* describe the reason for the last debug trap. Torez
|
|
|
|
*/
|
|
|
|
unsigned long dbsr;
|
|
|
|
/*
|
|
|
|
* The following will contain addresses used by debug applications
|
|
|
|
* to help trace and trap on particular address locations.
|
|
|
|
* The bits in the Debug Control Registers above help define which
|
|
|
|
* of the following registers will contain valid data and/or addresses.
|
|
|
|
*/
|
|
|
|
unsigned long iac1;
|
|
|
|
unsigned long iac2;
|
|
|
|
#if CONFIG_PPC_ADV_DEBUG_IACS > 2
|
|
|
|
unsigned long iac3;
|
|
|
|
unsigned long iac4;
|
|
|
|
#endif
|
|
|
|
unsigned long dac1;
|
|
|
|
unsigned long dac2;
|
|
|
|
#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
|
|
|
|
unsigned long dvc1;
|
|
|
|
unsigned long dvc2;
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2008-06-25 12:07:18 +08:00
|
|
|
/* FP and VSX 0-31 register set */
|
|
|
|
double fpr[32][TS_FPRWIDTH];
|
|
|
|
struct {
|
[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
|
|
|
|
|
|
|
unsigned int pad;
|
|
|
|
unsigned int val; /* Floating point status */
|
|
|
|
} fpscr;
|
2005-10-10 12:19:43 +08:00
|
|
|
int fpexc_mode; /* floating-point exception mode */
|
2006-06-07 14:15:39 +08:00
|
|
|
unsigned int align_ctl; /* alignment handling control */
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long start_tb; /* Start purr when proc switched in */
|
|
|
|
unsigned long accum_tb; /* Total accumilated purr for process */
|
2010-06-15 14:05:19 +08:00
|
|
|
#ifdef CONFIG_HAVE_HW_BREAKPOINT
|
|
|
|
struct perf_event *ptrace_bps[HBP_NUM];
|
|
|
|
/*
|
|
|
|
* Helps identify source of single-step exception and subsequent
|
|
|
|
* hw-breakpoint enablement
|
|
|
|
*/
|
|
|
|
struct perf_event *last_hit_ubp;
|
|
|
|
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
|
2005-10-10 12:19:43 +08:00
|
|
|
#endif
|
2012-12-20 22:06:44 +08:00
|
|
|
struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */
|
2012-08-24 05:27:09 +08:00
|
|
|
unsigned long trap_nr; /* last trap # on this thread */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_ALTIVEC
|
|
|
|
/* Complete AltiVec register set */
|
2007-07-15 11:36:09 +08:00
|
|
|
vector128 vr[32] __attribute__((aligned(16)));
|
2005-04-17 06:20:36 +08:00
|
|
|
/* AltiVec status */
|
2007-07-15 11:36:09 +08:00
|
|
|
vector128 vscr __attribute__((aligned(16)));
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long vrsave;
|
|
|
|
int used_vr; /* set if process has used altivec */
|
|
|
|
#endif /* CONFIG_ALTIVEC */
|
2008-06-25 12:07:18 +08:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
/* VSR status */
|
|
|
|
int used_vsr; /* set if process has used altivec */
|
|
|
|
#endif /* CONFIG_VSX */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_SPE
|
|
|
|
unsigned long evr[32]; /* upper 32-bits of SPE regs */
|
|
|
|
u64 acc; /* Accumulator */
|
|
|
|
unsigned long spefscr; /* SPE & eFP status */
|
|
|
|
int used_spe; /* set if process has used spe */
|
|
|
|
#endif /* CONFIG_SPE */
|
2010-04-16 06:11:51 +08:00
|
|
|
#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
|
|
|
|
void* kvm_shadow_vcpu; /* KVM internal data */
|
|
|
|
#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */
|
2011-12-20 23:34:43 +08:00
|
|
|
#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE)
|
|
|
|
struct kvm_vcpu *kvm_vcpu;
|
|
|
|
#endif
|
2011-03-02 23:18:48 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long dscr;
|
|
|
|
int dscr_inherit;
|
2012-12-07 05:49:56 +08:00
|
|
|
unsigned long ppr; /* used to save/restore SMT priority */
|
2011-03-02 23:18:48 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ARCH_MIN_TASKALIGN 16
|
|
|
|
|
|
|
|
#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
|
2008-04-28 14:21:22 +08:00
|
|
|
#define INIT_SP_LIMIT \
|
|
|
|
(_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-10-28 11:50:21 +08:00
|
|
|
#ifdef CONFIG_SPE
|
|
|
|
#define SPEFSCR_INIT .spefscr = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE,
|
|
|
|
#else
|
|
|
|
#define SPEFSCR_INIT
|
|
|
|
#endif
|
2005-10-10 12:19:43 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC32
|
2005-04-17 06:20:36 +08:00
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
2008-04-28 14:21:22 +08:00
|
|
|
.ksp_limit = INIT_SP_LIMIT, \
|
2005-04-17 06:20:36 +08:00
|
|
|
.fs = KERNEL_DS, \
|
|
|
|
.pgdir = swapper_pg_dir, \
|
|
|
|
.fpexc_mode = MSR_FE0 | MSR_FE1, \
|
2008-10-28 11:50:21 +08:00
|
|
|
SPEFSCR_INIT \
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-10-10 12:19:43 +08:00
|
|
|
#else
|
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
2008-04-28 14:21:22 +08:00
|
|
|
.ksp_limit = INIT_SP_LIMIT, \
|
2005-10-10 12:19:43 +08:00
|
|
|
.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
|
|
|
|
.fs = KERNEL_DS, \
|
2008-07-01 15:00:39 +08:00
|
|
|
.fpr = {{0}}, \
|
[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
|
|
|
.fpscr = { .val = 0, }, \
|
[POWERPC] disable floating point exceptions for init
Floating point exceptions should not be enabled by default,
as this setting impacts the performance on some CPUs, in
particular the Cell BE. Since the bits are inherited from
parent processes, the place to change the default is the
thread struct used for init.
glibc sets this up correctly per thread in its fesetenv
function, so user space should not be impacted by this
setting. None of the other common libc implementations
(uClibc, dietlibc, newlib, klibc) has support for fp
exceptions, so they are unlikely to be hit by this either.
There is a small risk that somebody wrote their own
application that manually sets the fpscr bits instead
of calling fesetenv, without changing the MSR bits as well.
Those programs will break with this change.
It probably makes sense to change glibc in the future
to be more clever about FE bits, so that when running
on a CPU where this is expensive, it disables exceptions
ASAP, while it keeps them enabled on CPUs where running
with exceptions on is cheaper than changing the state
often.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-06-20 08:30:33 +08:00
|
|
|
.fpexc_mode = 0, \
|
2012-12-07 05:49:56 +08:00
|
|
|
.ppr = INIT_PPR, \
|
2005-10-10 12:19:43 +08:00
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return saved PC of a blocked thread. For now, this is the "user" PC
|
|
|
|
*/
|
2005-10-10 12:19:43 +08:00
|
|
|
#define thread_saved_pc(tsk) \
|
|
|
|
((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-07 22:22:27 +08:00
|
|
|
#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long get_wchan(struct task_struct *p);
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
|
|
|
|
#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Get/set floating-point exception mode */
|
2005-10-10 12:19:43 +08:00
|
|
|
#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
|
|
|
|
#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
|
|
|
|
extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
|
|
|
|
|
2006-06-07 14:14:40 +08:00
|
|
|
#define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr))
|
|
|
|
#define SET_ENDIAN(tsk, val) set_endian((tsk), (val))
|
|
|
|
|
|
|
|
extern int get_endian(struct task_struct *tsk, unsigned long adr);
|
|
|
|
extern int set_endian(struct task_struct *tsk, unsigned int val);
|
|
|
|
|
2006-06-07 14:15:39 +08:00
|
|
|
#define GET_UNALIGN_CTL(tsk, adr) get_unalign_ctl((tsk), (adr))
|
|
|
|
#define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val))
|
|
|
|
|
|
|
|
extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr);
|
|
|
|
extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val);
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
static inline unsigned int __unpack_fe01(unsigned long msr_bits)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
|
|
|
|
}
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
static inline unsigned long __pack_fe01(unsigned int fpmode)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
|
|
|
|
}
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
|
|
|
|
#else
|
2005-04-17 06:20:36 +08:00
|
|
|
#define cpu_relax() barrier()
|
2005-10-10 12:19:43 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-27 08:46:18 +08:00
|
|
|
/* Check that a certain kernel stack pointer is valid in task_struct p */
|
|
|
|
int validate_sp(unsigned long sp, struct task_struct *p,
|
|
|
|
unsigned long nbytes);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Prefetch macros.
|
|
|
|
*/
|
|
|
|
#define ARCH_HAS_PREFETCH
|
|
|
|
#define ARCH_HAS_PREFETCHW
|
|
|
|
#define ARCH_HAS_SPINLOCK_PREFETCH
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
static inline void prefetch(const void *x)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-10-10 12:19:43 +08:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
static inline void prefetchw(const void *x)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-10-10 12:19:43 +08:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#define spin_lock_prefetch(x) prefetchw(x)
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define HAVE_ARCH_PICK_MMAP_LAYOUT
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-03-25 14:23:59 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32)
|
|
|
|
{
|
|
|
|
unsigned long sp;
|
|
|
|
|
|
|
|
if (is_32)
|
|
|
|
sp = regs->gpr[1] & 0x0ffffffffUL;
|
|
|
|
else
|
|
|
|
sp = regs->gpr[1];
|
|
|
|
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static inline unsigned long get_clean_sp(struct pt_regs *regs, int is_32)
|
|
|
|
{
|
|
|
|
return regs->gpr[1];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-30 10:47:03 +08:00
|
|
|
extern unsigned long cpuidle_disable;
|
2011-11-30 10:46:31 +08:00
|
|
|
enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
|
|
|
|
|
2012-03-29 01:30:02 +08:00
|
|
|
extern int powersave_nap; /* set if nap mode can be used in idle loop */
|
2012-07-27 02:51:09 +08:00
|
|
|
extern void power7_nap(void);
|
2012-03-29 01:30:02 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_PSERIES_IDLE
|
2012-10-04 02:42:18 +08:00
|
|
|
extern void update_smt_snooze_delay(int cpu, int residency);
|
2012-03-29 01:30:02 +08:00
|
|
|
#else
|
2012-10-04 02:42:18 +08:00
|
|
|
static inline void update_smt_snooze_delay(int cpu, int residency) {}
|
2012-03-29 01:30:02 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void flush_instruction_cache(void);
|
|
|
|
extern void hard_reset_now(void);
|
|
|
|
extern void poweroff_now(void);
|
|
|
|
extern int fix_alignment(struct pt_regs *);
|
|
|
|
extern void cvt_fd(float *from, double *to);
|
|
|
|
extern void cvt_df(double *from, float *to);
|
|
|
|
extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
/*
|
|
|
|
* We handle most unaligned accesses in hardware. On the other hand
|
|
|
|
* unaligned DMA can be very expensive on some ppc64 IO chips (it does
|
|
|
|
* powers of 2 writes until it reaches sufficient alignment).
|
|
|
|
*
|
|
|
|
* Based on this we disable the IP header alignment in network drivers.
|
|
|
|
*/
|
|
|
|
#define NET_IP_ALIGN 0
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __KERNEL__ */
|
2005-10-10 12:19:43 +08:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_POWERPC_PROCESSOR_H */
|