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
|
2013-09-23 10:04:37 +08:00
|
|
|
|
|
|
|
#ifdef __BIG_ENDIAN__
|
|
|
|
#define TS_FPROFFSET 0
|
|
|
|
#define TS_VSRLOWOFFSET 1
|
|
|
|
#else
|
|
|
|
#define TS_FPROFFSET 1
|
|
|
|
#define TS_VSRLOWOFFSET 0
|
|
|
|
#endif
|
|
|
|
|
2008-06-25 12:07:18 +08:00
|
|
|
#else
|
2008-06-26 15:07:48 +08:00
|
|
|
#define TS_FPRWIDTH 1
|
2013-09-23 10:04:37 +08:00
|
|
|
#define TS_FPROFFSET 0
|
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__
|
2018-07-06 00:25:09 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/thread_info.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/ptrace.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
|
|
|
*/
|
|
|
|
|
2013-03-27 08:47:03 +08:00
|
|
|
/* PREP sub-platform types. Unused */
|
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 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 *);
|
|
|
|
|
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
|
2017-03-22 11:36:57 +08:00
|
|
|
/*
|
|
|
|
* 64-bit user address space can have multiple limits
|
|
|
|
* For now supported values are:
|
|
|
|
*/
|
|
|
|
#define TASK_SIZE_64TB (0x0000400000000000UL)
|
|
|
|
#define TASK_SIZE_128TB (0x0000800000000000UL)
|
|
|
|
#define TASK_SIZE_512TB (0x0002000000000000UL)
|
2018-03-26 18:04:49 +08:00
|
|
|
#define TASK_SIZE_1PB (0x0004000000000000UL)
|
|
|
|
#define TASK_SIZE_2PB (0x0008000000000000UL)
|
|
|
|
/*
|
|
|
|
* With 52 bits in the address we can support
|
|
|
|
* upto 4PB of range.
|
|
|
|
*/
|
|
|
|
#define TASK_SIZE_4PB (0x0010000000000000UL)
|
2017-03-22 11:36:57 +08:00
|
|
|
|
2017-06-01 22:35:04 +08:00
|
|
|
/*
|
|
|
|
* For now 512TB is only supported with book3s and 64K linux page size.
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_64K_PAGES)
|
2017-03-22 11:36:57 +08:00
|
|
|
/*
|
|
|
|
* Max value currently used:
|
|
|
|
*/
|
2018-03-26 18:04:49 +08:00
|
|
|
#define TASK_SIZE_USER64 TASK_SIZE_4PB
|
2017-06-01 22:35:04 +08:00
|
|
|
#define DEFAULT_MAP_WINDOW_USER64 TASK_SIZE_128TB
|
2018-03-26 18:04:48 +08:00
|
|
|
#define TASK_CONTEXT_SIZE TASK_SIZE_512TB
|
2017-03-22 11:36:57 +08:00
|
|
|
#else
|
2017-06-01 22:35:04 +08:00
|
|
|
#define TASK_SIZE_USER64 TASK_SIZE_64TB
|
|
|
|
#define DEFAULT_MAP_WINDOW_USER64 TASK_SIZE_64TB
|
2018-03-26 18:04:48 +08:00
|
|
|
/*
|
|
|
|
* We don't need to allocate extended context ids for 4K page size, because
|
|
|
|
* we limit the max effective address on this config to 64TB.
|
|
|
|
*/
|
|
|
|
#define TASK_CONTEXT_SIZE TASK_SIZE_64TB
|
2017-03-22 11:36:57 +08:00
|
|
|
#endif
|
2005-10-10 12:19:43 +08:00
|
|
|
|
2017-03-22 11:36:57 +08:00
|
|
|
/*
|
|
|
|
* 32-bit user address space is 4GB - 1 page
|
2005-10-10 12:19:43 +08:00
|
|
|
* (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))
|
2017-06-01 22:35:04 +08:00
|
|
|
#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 4))
|
2005-10-10 12:19:43 +08:00
|
|
|
|
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
|
|
|
|
2017-03-30 19:05:21 +08:00
|
|
|
/*
|
|
|
|
* Initial task size value for user applications. For book3s 64 we start
|
|
|
|
* with 128TB and conditionally enable upto 512TB
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
2017-06-01 22:35:04 +08:00
|
|
|
#define DEFAULT_MAP_WINDOW ((is_32bit_task()) ? \
|
|
|
|
TASK_SIZE_USER32 : DEFAULT_MAP_WINDOW_USER64)
|
2017-03-30 19:05:21 +08:00
|
|
|
#else
|
|
|
|
#define DEFAULT_MAP_WINDOW TASK_SIZE
|
|
|
|
#endif
|
|
|
|
|
2008-02-08 20:19:26 +08:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
|
2017-06-01 22:35:04 +08:00
|
|
|
#define STACK_TOP_USER64 DEFAULT_MAP_WINDOW_USER64
|
2008-02-08 20:19:26 +08:00
|
|
|
#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)
|
|
|
|
|
2017-03-30 19:05:21 +08:00
|
|
|
#define STACK_TOP_MAX TASK_SIZE_USER64
|
2008-02-08 20:19:26 +08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2013-09-10 18:20:42 +08:00
|
|
|
#define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
|
2016-09-23 14:18:25 +08:00
|
|
|
#define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET]
|
2013-09-10 18:20:42 +08:00
|
|
|
|
|
|
|
/* FP and VSX 0-31 register set */
|
|
|
|
struct thread_fp_state {
|
|
|
|
u64 fpr[32][TS_FPRWIDTH] __attribute__((aligned(16)));
|
|
|
|
u64 fpscr; /* Floating point status */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Complete AltiVec register set including VSCR */
|
|
|
|
struct thread_vr_state {
|
|
|
|
vector128 vr[32] __attribute__((aligned(16)));
|
|
|
|
vector128 vscr __attribute__((aligned(16)));
|
|
|
|
};
|
2008-06-26 15:07:48 +08:00
|
|
|
|
2013-07-04 14:15:46 +08:00
|
|
|
struct debug_reg {
|
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.
|
|
|
|
*/
|
2013-05-22 12:20:58 +08:00
|
|
|
uint32_t dbcr0;
|
|
|
|
uint32_t dbcr1;
|
2010-02-08 19:53:26 +08:00
|
|
|
#ifdef CONFIG_BOOKE
|
2013-05-22 12:20:58 +08:00
|
|
|
uint32_t dbcr2;
|
2010-02-08 19:53:26 +08:00
|
|
|
#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
|
|
|
|
*/
|
2013-05-22 12:20:58 +08:00
|
|
|
uint32_t dbsr;
|
2010-02-08 19:53:26 +08:00
|
|
|
/*
|
|
|
|
* 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
|
2013-07-04 14:15:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct thread_struct {
|
|
|
|
unsigned long ksp; /* Kernel stack pointer */
|
2013-06-26 13:42:22 +08:00
|
|
|
|
2013-07-04 14:15:46 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long ksp_vsid;
|
|
|
|
#endif
|
|
|
|
struct pt_regs *regs; /* Pointer to saved register state */
|
2018-05-14 21:03:15 +08:00
|
|
|
mm_segment_t addr_limit; /* for get_fs() validation */
|
2013-07-04 14:15:46 +08:00
|
|
|
#ifdef CONFIG_BOOKE
|
|
|
|
/* BookE base exception scratch space; align on cacheline */
|
|
|
|
unsigned long normsave[8] ____cacheline_aligned;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
void *pgdir; /* root of page-table tree */
|
|
|
|
unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
|
|
|
|
#endif
|
2013-06-26 13:42:22 +08:00
|
|
|
/* Debug Registers */
|
2013-07-04 14:15:46 +08:00
|
|
|
struct debug_reg debug;
|
2013-09-10 18:20:42 +08:00
|
|
|
struct thread_fp_state fp_state;
|
2013-09-10 18:21:10 +08:00
|
|
|
struct thread_fp_state *fp_save_area;
|
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 */
|
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 */
|
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 */
|
2016-02-29 14:53:47 +08:00
|
|
|
u8 load_fp;
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_ALTIVEC
|
2016-02-29 14:53:47 +08:00
|
|
|
u8 load_vec;
|
2013-09-10 18:20:42 +08:00
|
|
|
struct thread_vr_state vr_state;
|
2013-09-10 18:21:10 +08:00
|
|
|
struct thread_vr_state *vr_save_area;
|
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 */
|
2016-03-25 01:12:21 +08:00
|
|
|
int used_vsr; /* set if process has used VSX */
|
2008-06-25 12:07:18 +08:00
|
|
|
#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 */
|
powerpc: fix exception clearing in e500 SPE float emulation
The e500 SPE floating-point emulation code clears existing exceptions
(__FPU_FPSCR &= ~FP_EX_MASK;) before ORing in the exceptions from the
emulated operation. However, these exception bits are the "sticky",
cumulative exception bits, and should only be cleared by the user
program setting SPEFSCR, not implicitly by any floating-point
instruction (whether executed purely by the hardware or emulated).
The spurious clearing of these bits shows up as missing exceptions in
glibc testing.
Fixing this, however, is not as simple as just not clearing the bits,
because while the bits may be from previous floating-point operations
(in which case they should not be cleared), the processor can also set
the sticky bits itself before the interrupt for an exception occurs,
and this can happen in cases when IEEE 754 semantics are that the
sticky bit should not be set. Specifically, the "invalid" sticky bit
is set in various cases with non-finite operands, where IEEE 754
semantics do not involve raising such an exception, and the
"underflow" sticky bit is set in cases of exact underflow, whereas
IEEE 754 semantics are that this flag is set only for inexact
underflow. Thus, for correct emulation the kernel needs to know the
setting of these two sticky bits before the instruction being
emulated.
When a floating-point operation raises an exception, the kernel can
note the state of the sticky bits immediately afterwards. Some
<fenv.h> functions that affect the state of these bits, such as
fesetenv and feholdexcept, need to use prctl with PR_GET_FPEXC and
PR_SET_FPEXC anyway, and so it is natural to record the state of those
bits during that call into the kernel and so avoid any need for a
separate call into the kernel to inform it of a change to those bits.
Thus, the interface I chose to use (in this patch and the glibc port)
is that one of those prctl calls must be made after any userspace
change to those sticky bits, other than through a floating-point
operation that traps into the kernel anyway. feclearexcept and
fesetexceptflag duly make those calls, which would not be required
were it not for this issue.
The previous EGLIBC port, and the uClibc code copied from it, is
fundamentally broken as regards any use of prctl for floating-point
exceptions because it didn't use the PR_FP_EXC_SW_ENABLE bit in its
prctl calls (and did various worse things, such as passing a pointer
when prctl expected an integer). If you avoid anything where prctl is
used, the clearing of sticky bits still means it will never give
anything approximating correct exception semantics with existing
kernels. I don't believe the patch makes things any worse for
existing code that doesn't try to inform the kernel of changes to
sticky bits - such code may get incorrect exceptions in some cases,
but it would have done so anyway in other cases.
Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2013-12-11 07:07:45 +08:00
|
|
|
unsigned long spefscr_last; /* SPEFSCR value on last prctl
|
|
|
|
call or trap return */
|
2005-04-17 06:20:36 +08:00
|
|
|
int used_spe; /* set if process has used spe */
|
|
|
|
#endif /* CONFIG_SPE */
|
2013-02-14 00:21:31 +08:00
|
|
|
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
|
2016-09-14 16:02:16 +08:00
|
|
|
u8 load_tm;
|
2013-02-14 00:21:31 +08:00
|
|
|
u64 tm_tfhar; /* Transaction fail handler addr */
|
|
|
|
u64 tm_texasr; /* Transaction exception & summary */
|
|
|
|
u64 tm_tfiar; /* Transaction fail instr address reg */
|
|
|
|
struct pt_regs ckpt_regs; /* Checkpointed registers */
|
|
|
|
|
2013-08-09 15:29:31 +08:00
|
|
|
unsigned long tm_tar;
|
|
|
|
unsigned long tm_ppr;
|
|
|
|
unsigned long tm_dscr;
|
|
|
|
|
2013-02-14 00:21:31 +08:00
|
|
|
/*
|
2016-09-23 14:18:24 +08:00
|
|
|
* Checkpointed FP and VSX 0-31 register set.
|
2013-02-14 00:21:31 +08:00
|
|
|
*
|
|
|
|
* When a transaction is active/signalled/scheduled etc., *regs is the
|
|
|
|
* most recent set of/speculated GPRs with ckpt_regs being the older
|
|
|
|
* checkpointed regs to which we roll back if transaction aborts.
|
|
|
|
*
|
2016-09-23 14:18:24 +08:00
|
|
|
* These are analogous to how ckpt_regs and pt_regs work
|
2013-02-14 00:21:31 +08:00
|
|
|
*/
|
2016-09-23 14:18:25 +08:00
|
|
|
struct thread_fp_state ckfp_state; /* Checkpointed FP state */
|
|
|
|
struct thread_vr_state ckvr_state; /* Checkpointed VR state */
|
|
|
|
unsigned long ckvrsave; /* Checkpointed VRSAVE */
|
2013-02-14 00:21:31 +08:00
|
|
|
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
|
2018-01-19 09:50:31 +08:00
|
|
|
#ifdef CONFIG_PPC_MEM_KEYS
|
|
|
|
unsigned long amr;
|
|
|
|
unsigned long iamr;
|
|
|
|
unsigned long uamor;
|
|
|
|
#endif
|
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;
|
2015-10-29 08:43:55 +08:00
|
|
|
unsigned long fscr;
|
2015-05-21 14:43:04 +08:00
|
|
|
/*
|
|
|
|
* This member element dscr_inherit indicates that the process
|
|
|
|
* has explicitly attempted and changed the DSCR register value
|
|
|
|
* for itself. Hence kernel wont use the default CPU DSCR value
|
|
|
|
* contained in the PACA structure anymore during process context
|
|
|
|
* switch. Once this variable is set, this behaviour will also be
|
|
|
|
* inherited to all the children of this process from that point
|
|
|
|
* onwards.
|
|
|
|
*/
|
2011-03-02 23:18:48 +08:00
|
|
|
int dscr_inherit;
|
2012-12-07 05:49:56 +08:00
|
|
|
unsigned long ppr; /* used to save/restore SMT priority */
|
2017-11-08 10:23:53 +08:00
|
|
|
unsigned long tidr;
|
2011-03-02 23:18:48 +08:00
|
|
|
#endif
|
2013-02-07 23:46:58 +08:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
|
|
|
unsigned long tar;
|
2013-05-01 04:17:04 +08:00
|
|
|
unsigned long ebbrr;
|
|
|
|
unsigned long ebbhr;
|
|
|
|
unsigned long bescr;
|
2013-05-22 00:31:12 +08:00
|
|
|
unsigned long siar;
|
|
|
|
unsigned long sdar;
|
|
|
|
unsigned long sier;
|
|
|
|
unsigned long mmcr2;
|
2013-06-28 16:15:16 +08:00
|
|
|
unsigned mmcr0;
|
2017-11-08 10:23:54 +08:00
|
|
|
|
2013-06-28 16:15:16 +08:00
|
|
|
unsigned used_ebb;
|
2017-11-08 10:23:54 +08:00
|
|
|
unsigned int used_vas;
|
2013-02-07 23:46:58 +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
|
powerpc: fix exception clearing in e500 SPE float emulation
The e500 SPE floating-point emulation code clears existing exceptions
(__FPU_FPSCR &= ~FP_EX_MASK;) before ORing in the exceptions from the
emulated operation. However, these exception bits are the "sticky",
cumulative exception bits, and should only be cleared by the user
program setting SPEFSCR, not implicitly by any floating-point
instruction (whether executed purely by the hardware or emulated).
The spurious clearing of these bits shows up as missing exceptions in
glibc testing.
Fixing this, however, is not as simple as just not clearing the bits,
because while the bits may be from previous floating-point operations
(in which case they should not be cleared), the processor can also set
the sticky bits itself before the interrupt for an exception occurs,
and this can happen in cases when IEEE 754 semantics are that the
sticky bit should not be set. Specifically, the "invalid" sticky bit
is set in various cases with non-finite operands, where IEEE 754
semantics do not involve raising such an exception, and the
"underflow" sticky bit is set in cases of exact underflow, whereas
IEEE 754 semantics are that this flag is set only for inexact
underflow. Thus, for correct emulation the kernel needs to know the
setting of these two sticky bits before the instruction being
emulated.
When a floating-point operation raises an exception, the kernel can
note the state of the sticky bits immediately afterwards. Some
<fenv.h> functions that affect the state of these bits, such as
fesetenv and feholdexcept, need to use prctl with PR_GET_FPEXC and
PR_SET_FPEXC anyway, and so it is natural to record the state of those
bits during that call into the kernel and so avoid any need for a
separate call into the kernel to inform it of a change to those bits.
Thus, the interface I chose to use (in this patch and the glibc port)
is that one of those prctl calls must be made after any userspace
change to those sticky bits, other than through a floating-point
operation that traps into the kernel anyway. feclearexcept and
fesetexceptflag duly make those calls, which would not be required
were it not for this issue.
The previous EGLIBC port, and the uClibc code copied from it, is
fundamentally broken as regards any use of prctl for floating-point
exceptions because it didn't use the PR_FP_EXC_SW_ENABLE bit in its
prctl calls (and did various worse things, such as passing a pointer
when prctl expected an integer). If you avoid anything where prctl is
used, the clearing of sticky bits still means it will never give
anything approximating correct exception semantics with existing
kernels. I don't believe the patch makes things any worse for
existing code that doesn't try to inform the kernel of changes to
sticky bits - such code may get incorrect exceptions in some cases,
but it would have done so anyway in other cases.
Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2013-12-11 07:07:45 +08:00
|
|
|
#define SPEFSCR_INIT \
|
|
|
|
.spefscr = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE, \
|
|
|
|
.spefscr_last = SPEFSCR_FINVE | SPEFSCR_FDBZE | SPEFSCR_FUNFE | SPEFSCR_FOVFE,
|
2008-10-28 11:50:21 +08:00
|
|
|
#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, \
|
2018-05-14 21:03:15 +08:00
|
|
|
.addr_limit = KERNEL_DS, \
|
2005-04-17 06:20:36 +08:00
|
|
|
.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, \
|
|
|
|
.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
|
2018-05-14 21:03:15 +08:00
|
|
|
.addr_limit = KERNEL_DS, \
|
[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, \
|
2016-06-09 10:31:08 +08:00
|
|
|
.fscr = FSCR_TAR | FSCR_EBB \
|
2005-10-10 12:19:43 +08:00
|
|
|
}
|
|
|
|
#endif
|
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);
|
|
|
|
|
2013-09-10 18:21:10 +08:00
|
|
|
extern void load_fp_state(struct thread_fp_state *fp);
|
|
|
|
extern void store_fp_state(struct thread_fp_state *fp);
|
|
|
|
extern void load_vr_state(struct thread_vr_state *vr);
|
|
|
|
extern void store_vr_state(struct thread_vr_state *vr);
|
|
|
|
|
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)
|
2017-06-06 21:08:31 +08:00
|
|
|
|
|
|
|
#define spin_begin() HMT_low()
|
|
|
|
|
|
|
|
#define spin_cpu_relax() barrier()
|
|
|
|
|
|
|
|
#define spin_cpu_yield() spin_cpu_relax()
|
|
|
|
|
|
|
|
#define spin_end() HMT_medium()
|
|
|
|
|
|
|
|
#define spin_until_cond(cond) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(!(cond))) { \
|
|
|
|
spin_begin(); \
|
|
|
|
do { \
|
|
|
|
spin_cpu_relax(); \
|
|
|
|
} while (!(cond)); \
|
|
|
|
spin_end(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2005-10-10 12:19:43 +08:00
|
|
|
#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
|
|
|
#define HAVE_ARCH_PICK_MMAP_LAYOUT
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-03-25 14:23:59 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2013-05-27 02:09:41 +08:00
|
|
|
static inline unsigned long get_clean_sp(unsigned long sp, int is_32)
|
2009-03-25 14:23:59 +08:00
|
|
|
{
|
|
|
|
if (is_32)
|
2013-05-27 02:09:41 +08:00
|
|
|
return sp & 0x0ffffffffUL;
|
2009-03-25 14:23:59 +08:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
#else
|
2013-05-27 02:09:41 +08:00
|
|
|
static inline unsigned long get_clean_sp(unsigned long sp, int is_32)
|
2009-03-25 14:23:59 +08:00
|
|
|
{
|
2013-05-27 02:09:41 +08:00
|
|
|
return sp;
|
2009-03-25 14:23:59 +08:00
|
|
|
}
|
|
|
|
#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 */
|
2017-06-13 21:05:45 +08:00
|
|
|
extern unsigned long power7_idle_insn(unsigned long type); /* PNV_THREAD_NAP/etc*/
|
|
|
|
extern void power7_idle_type(unsigned long type);
|
|
|
|
extern unsigned long power9_idle_stop(unsigned long psscr_val);
|
2017-11-17 22:08:05 +08:00
|
|
|
extern unsigned long power9_offline_stop(unsigned long psscr_val);
|
2017-06-13 21:05:45 +08:00
|
|
|
extern void power9_idle_type(unsigned long stop_psscr_val,
|
|
|
|
unsigned long stop_psscr_mask);
|
2016-07-08 14:20:49 +08:00
|
|
|
|
2012-03-29 01:30:02 +08:00
|
|
|
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 */
|