2005-10-10 11:19:43 +07:00
|
|
|
#ifndef _ASM_POWERPC_PROCESSOR_H
|
|
|
|
#define _ASM_POWERPC_PROCESSOR_H
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
2005-10-10 11:19:43 +07: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 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
#include <asm/reg.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-06-25 11:07:18 +07:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
#define TS_FPRWIDTH 2
|
2013-09-23 09:04:37 +07: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 11:07:18 +07:00
|
|
|
#else
|
2008-06-26 14:07:48 +07:00
|
|
|
#define TS_FPRWIDTH 1
|
2013-09-23 09:04:37 +07:00
|
|
|
#define TS_FPROFFSET 0
|
2008-06-25 11:07:18 +07:00
|
|
|
#endif
|
2008-06-26 14:07:48 +07:00
|
|
|
|
2012-12-07 04:49:56 +07: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 11:19:43 +07:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/compiler.h>
|
2011-04-23 04:48:27 +07:00
|
|
|
#include <linux/cache.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/types.h>
|
2012-12-20 21:06:44 +07:00
|
|
|
#include <asm/hw_breakpoint.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-10 09:37:51 +07: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 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2013-03-27 07:47:03 +07:00
|
|
|
/* PREP sub-platform types. Unused */
|
2005-04-17 05:20:36 +07: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 09:37:51 +07:00
|
|
|
/* CHRP sub-platform types. These are arbitrary */
|
2005-04-17 05:20:36 +07: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 11:16:28 +07:00
|
|
|
#define _CHRP_briq 0x07 /* TotalImpact's briQ */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-03-28 19:15:54 +07:00
|
|
|
#if defined(__KERNEL__) && defined(CONFIG_PPC32)
|
|
|
|
|
|
|
|
extern int _chrp_type;
|
2005-11-10 09:37:51 +07:00
|
|
|
|
2006-03-28 19:15:54 +07:00
|
|
|
#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
|
|
|
|
|
2005-10-10 11:19:43 +07: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 05:20:36 +07:00
|
|
|
struct task_struct;
|
2005-10-10 11:19:43 +07:00
|
|
|
void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
|
2005-04-17 05:20:36 +07:00
|
|
|
void release_thread(struct task_struct *);
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
#ifdef CONFIG_PPC32
|
2008-05-23 22:59:15 +07:00
|
|
|
|
|
|
|
#if CONFIG_TASK_SIZE > CONFIG_KERNEL_START
|
|
|
|
#error User TASK_SIZE overlaps with KERNEL_START address
|
|
|
|
#endif
|
2005-10-10 11:19:43 +07:00
|
|
|
#define TASK_SIZE (CONFIG_TASK_SIZE)
|
|
|
|
|
2005-04-17 05:20:36 +07: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 11:19:43 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC64
|
2017-03-22 10:36:57 +07: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)
|
|
|
|
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
|
|
|
/*
|
|
|
|
* Max value currently used:
|
|
|
|
*/
|
2017-03-30 18:05:21 +07:00
|
|
|
#define TASK_SIZE_USER64 TASK_SIZE_512TB
|
2017-03-22 10:36:57 +07:00
|
|
|
#else
|
2017-03-30 18:05:21 +07:00
|
|
|
#define TASK_SIZE_USER64 TASK_SIZE_64TB
|
2017-03-22 10:36:57 +07:00
|
|
|
#endif
|
2005-10-10 11:19:43 +07:00
|
|
|
|
2017-03-22 10:36:57 +07:00
|
|
|
/*
|
|
|
|
* 32-bit user address space is 4GB - 1 page
|
2005-10-10 11:19:43 +07:00
|
|
|
* (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
|
|
|
|
*/
|
|
|
|
#define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
|
|
|
|
|
2008-02-05 13:28:59 +07:00
|
|
|
#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
|
2005-10-10 11:19:43 +07:00
|
|
|
TASK_SIZE_USER32 : TASK_SIZE_USER64)
|
2008-02-05 13:28:59 +07:00
|
|
|
#define TASK_SIZE TASK_SIZE_OF(current)
|
2005-10-10 11:19:43 +07: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-03-30 18:05:21 +07:00
|
|
|
#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_128TB / 4))
|
2005-10-10 11:19:43 +07:00
|
|
|
|
2010-08-27 10:49:11 +07:00
|
|
|
#define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \
|
2005-10-10 11:19:43 +07:00
|
|
|
TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-03-30 18:05:21 +07: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
|
|
|
|
#define DEFAULT_MAP_WINDOW ((is_32bit_task()) ? \
|
|
|
|
TASK_SIZE_USER32 : TASK_SIZE_128TB)
|
|
|
|
#else
|
|
|
|
#define DEFAULT_MAP_WINDOW TASK_SIZE
|
|
|
|
#endif
|
|
|
|
|
2008-02-08 19:19:26 +07:00
|
|
|
#ifdef __powerpc64__
|
|
|
|
|
2017-03-30 18:05:21 +07:00
|
|
|
/* Limit stack to 128TB */
|
|
|
|
#define STACK_TOP_USER64 TASK_SIZE_128TB
|
2008-02-08 19:19:26 +07:00
|
|
|
#define STACK_TOP_USER32 TASK_SIZE_USER32
|
|
|
|
|
2010-08-27 10:49:11 +07:00
|
|
|
#define STACK_TOP (is_32bit_task() ? \
|
2008-02-08 19:19:26 +07:00
|
|
|
STACK_TOP_USER32 : STACK_TOP_USER64)
|
|
|
|
|
2017-03-30 18:05:21 +07:00
|
|
|
#define STACK_TOP_MAX TASK_SIZE_USER64
|
2008-02-08 19:19:26 +07:00
|
|
|
|
|
|
|
#else /* __powerpc64__ */
|
|
|
|
|
|
|
|
#define STACK_TOP TASK_SIZE
|
|
|
|
#define STACK_TOP_MAX STACK_TOP
|
|
|
|
|
|
|
|
#endif /* __powerpc64__ */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
typedef struct {
|
|
|
|
unsigned long seg;
|
|
|
|
} mm_segment_t;
|
|
|
|
|
2013-09-10 17:20:42 +07:00
|
|
|
#define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
|
2016-09-23 13:18:25 +07:00
|
|
|
#define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET]
|
2013-09-10 17:20:42 +07: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 14:07:48 +07:00
|
|
|
|
2013-07-04 13:15:46 +07:00
|
|
|
struct debug_reg {
|
2010-02-08 18:53:26 +07: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 11:20:58 +07:00
|
|
|
uint32_t dbcr0;
|
|
|
|
uint32_t dbcr1;
|
2010-02-08 18:53:26 +07:00
|
|
|
#ifdef CONFIG_BOOKE
|
2013-05-22 11:20:58 +07:00
|
|
|
uint32_t dbcr2;
|
2010-02-08 18:53:26 +07: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 11:20:58 +07:00
|
|
|
uint32_t dbsr;
|
2010-02-08 18:53:26 +07: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 05:20:36 +07:00
|
|
|
#endif
|
2013-07-04 13:15:46 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct thread_struct {
|
|
|
|
unsigned long ksp; /* Kernel stack pointer */
|
2013-06-26 12:42:22 +07:00
|
|
|
|
2013-07-04 13:15:46 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long ksp_vsid;
|
|
|
|
#endif
|
|
|
|
struct pt_regs *regs; /* Pointer to saved register state */
|
|
|
|
mm_segment_t fs; /* for get_fs() validation */
|
|
|
|
#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 12:42:22 +07:00
|
|
|
/* Debug Registers */
|
2013-07-04 13:15:46 +07:00
|
|
|
struct debug_reg debug;
|
2013-09-10 17:20:42 +07:00
|
|
|
struct thread_fp_state fp_state;
|
2013-09-10 17:21:10 +07:00
|
|
|
struct thread_fp_state *fp_save_area;
|
2005-10-10 11:19:43 +07:00
|
|
|
int fpexc_mode; /* floating-point exception mode */
|
2006-06-07 13:15:39 +07:00
|
|
|
unsigned int align_ctl; /* alignment handling control */
|
2005-10-10 11:19:43 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long start_tb; /* Start purr when proc switched in */
|
2016-06-01 13:34:37 +07:00
|
|
|
unsigned long accum_tb; /* Total accumulated purr for process */
|
2016-11-29 15:52:13 +07:00
|
|
|
#endif
|
2010-06-15 13:05:19 +07: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 21:06:44 +07:00
|
|
|
struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */
|
2012-08-24 04:27:09 +07:00
|
|
|
unsigned long trap_nr; /* last trap # on this thread */
|
2016-02-29 13:53:47 +07:00
|
|
|
u8 load_fp;
|
2005-04-17 05:20:36 +07:00
|
|
|
#ifdef CONFIG_ALTIVEC
|
2016-02-29 13:53:47 +07:00
|
|
|
u8 load_vec;
|
2013-09-10 17:20:42 +07:00
|
|
|
struct thread_vr_state vr_state;
|
2013-09-10 17:21:10 +07:00
|
|
|
struct thread_vr_state *vr_save_area;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long vrsave;
|
|
|
|
int used_vr; /* set if process has used altivec */
|
|
|
|
#endif /* CONFIG_ALTIVEC */
|
2008-06-25 11:07:18 +07:00
|
|
|
#ifdef CONFIG_VSX
|
|
|
|
/* VSR status */
|
2016-03-25 00:12:21 +07:00
|
|
|
int used_vsr; /* set if process has used VSX */
|
2008-06-25 11:07:18 +07:00
|
|
|
#endif /* CONFIG_VSX */
|
2005-04-17 05:20:36 +07: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 06:07:45 +07:00
|
|
|
unsigned long spefscr_last; /* SPEFSCR value on last prctl
|
|
|
|
call or trap return */
|
2005-04-17 05:20:36 +07:00
|
|
|
int used_spe; /* set if process has used spe */
|
|
|
|
#endif /* CONFIG_SPE */
|
2013-02-13 23:21:31 +07:00
|
|
|
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
|
2016-09-14 15:02:16 +07:00
|
|
|
u8 load_tm;
|
2013-02-13 23:21:31 +07: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 14:29:31 +07:00
|
|
|
unsigned long tm_tar;
|
|
|
|
unsigned long tm_ppr;
|
|
|
|
unsigned long tm_dscr;
|
|
|
|
|
2013-02-13 23:21:31 +07:00
|
|
|
/*
|
2016-09-23 13:18:24 +07:00
|
|
|
* Checkpointed FP and VSX 0-31 register set.
|
2013-02-13 23:21:31 +07: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 13:18:24 +07:00
|
|
|
* These are analogous to how ckpt_regs and pt_regs work
|
2013-02-13 23:21:31 +07:00
|
|
|
*/
|
2016-09-23 13:18:25 +07: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-13 23:21:31 +07:00
|
|
|
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
|
2010-04-16 05:11:51 +07:00
|
|
|
#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
|
|
|
|
void* kvm_shadow_vcpu; /* KVM internal data */
|
|
|
|
#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */
|
2011-12-20 22:34:43 +07:00
|
|
|
#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE)
|
|
|
|
struct kvm_vcpu *kvm_vcpu;
|
|
|
|
#endif
|
2011-03-02 22:18:48 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
unsigned long dscr;
|
2015-10-29 07:43:55 +07:00
|
|
|
unsigned long fscr;
|
2015-05-21 13:43:04 +07: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 22:18:48 +07:00
|
|
|
int dscr_inherit;
|
2012-12-07 04:49:56 +07:00
|
|
|
unsigned long ppr; /* used to save/restore SMT priority */
|
2011-03-02 22:18:48 +07:00
|
|
|
#endif
|
2013-02-07 22:46:58 +07:00
|
|
|
#ifdef CONFIG_PPC_BOOK3S_64
|
|
|
|
unsigned long tar;
|
2013-05-01 03:17:04 +07:00
|
|
|
unsigned long ebbrr;
|
|
|
|
unsigned long ebbhr;
|
|
|
|
unsigned long bescr;
|
2013-05-21 23:31:12 +07:00
|
|
|
unsigned long siar;
|
|
|
|
unsigned long sdar;
|
|
|
|
unsigned long sier;
|
|
|
|
unsigned long mmcr2;
|
2013-06-28 15:15:16 +07:00
|
|
|
unsigned mmcr0;
|
|
|
|
unsigned used_ebb;
|
2013-02-07 22:46:58 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ARCH_MIN_TASKALIGN 16
|
|
|
|
|
|
|
|
#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
|
2008-04-28 13:21:22 +07:00
|
|
|
#define INIT_SP_LIMIT \
|
|
|
|
(_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-10-28 10:50:21 +07: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 06:07:45 +07: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 10:50:21 +07:00
|
|
|
#else
|
|
|
|
#define SPEFSCR_INIT
|
|
|
|
#endif
|
2005-10-10 11:19:43 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_PPC32
|
2005-04-17 05:20:36 +07:00
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
2008-04-28 13:21:22 +07:00
|
|
|
.ksp_limit = INIT_SP_LIMIT, \
|
2005-04-17 05:20:36 +07:00
|
|
|
.fs = KERNEL_DS, \
|
|
|
|
.pgdir = swapper_pg_dir, \
|
|
|
|
.fpexc_mode = MSR_FE0 | MSR_FE1, \
|
2008-10-28 10:50:21 +07:00
|
|
|
SPEFSCR_INIT \
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2005-10-10 11:19:43 +07:00
|
|
|
#else
|
|
|
|
#define INIT_THREAD { \
|
|
|
|
.ksp = INIT_SP, \
|
|
|
|
.regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
|
|
|
|
.fs = 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 07:30:33 +07:00
|
|
|
.fpexc_mode = 0, \
|
2012-12-07 04:49:56 +07:00
|
|
|
.ppr = INIT_PPR, \
|
2016-06-09 09:31:08 +07:00
|
|
|
.fscr = FSCR_TAR | FSCR_EBB \
|
2005-10-10 11:19:43 +07:00
|
|
|
}
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return saved PC of a blocked thread. For now, this is the "user" PC
|
|
|
|
*/
|
2005-10-10 11:19:43 +07:00
|
|
|
#define thread_saved_pc(tsk) \
|
|
|
|
((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-07-07 21:22:27 +07:00
|
|
|
#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long get_wchan(struct task_struct *p);
|
|
|
|
|
2005-10-10 11:19:43 +07: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 05:20:36 +07:00
|
|
|
|
|
|
|
/* Get/set floating-point exception mode */
|
2005-10-10 11:19:43 +07: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 05:20:36 +07: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 13:14:40 +07: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 13:15:39 +07: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 17:21:10 +07: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 11:19:43 +07:00
|
|
|
static inline unsigned int __unpack_fe01(unsigned long msr_bits)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
|
|
|
|
}
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
static inline unsigned long __pack_fe01(unsigned int fpmode)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
|
|
|
|
}
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
|
|
|
|
#else
|
2005-04-17 05:20:36 +07:00
|
|
|
#define cpu_relax() barrier()
|
2005-10-10 11:19:43 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-03-27 07:46:18 +07: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 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Prefetch macros.
|
|
|
|
*/
|
|
|
|
#define ARCH_HAS_PREFETCH
|
|
|
|
#define ARCH_HAS_PREFETCHW
|
|
|
|
#define ARCH_HAS_SPINLOCK_PREFETCH
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
static inline void prefetch(const void *x)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-10-10 11:19:43 +07:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
static inline void prefetchw(const void *x)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2005-10-10 11:19:43 +07:00
|
|
|
if (unlikely(!x))
|
|
|
|
return;
|
|
|
|
|
|
|
|
__asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define spin_lock_prefetch(x) prefetchw(x)
|
|
|
|
|
2005-10-10 11:19:43 +07:00
|
|
|
#define HAVE_ARCH_PICK_MMAP_LAYOUT
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-25 13:23:59 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
2013-05-27 01:09:41 +07:00
|
|
|
static inline unsigned long get_clean_sp(unsigned long sp, int is_32)
|
2009-03-25 13:23:59 +07:00
|
|
|
{
|
|
|
|
if (is_32)
|
2013-05-27 01:09:41 +07:00
|
|
|
return sp & 0x0ffffffffUL;
|
2009-03-25 13:23:59 +07:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
#else
|
2013-05-27 01:09:41 +07:00
|
|
|
static inline unsigned long get_clean_sp(unsigned long sp, int is_32)
|
2009-03-25 13:23:59 +07:00
|
|
|
{
|
2013-05-27 01:09:41 +07:00
|
|
|
return sp;
|
2009-03-25 13:23:59 +07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-30 09:47:03 +07:00
|
|
|
extern unsigned long cpuidle_disable;
|
2011-11-30 09:46:31 +07:00
|
|
|
enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
|
|
|
|
|
2012-03-29 00:30:02 +07:00
|
|
|
extern int powersave_nap; /* set if nap mode can be used in idle loop */
|
powerpc/powernv: Return to cpu offline loop when finished in KVM guest
When a secondary hardware thread has finished running a KVM guest, we
currently put that thread into nap mode using a nap instruction in
the KVM code. This changes the code so that instead of doing a nap
instruction directly, we instead cause the call to power7_nap() that
put the thread into nap mode to return. The reason for doing this is
to avoid having the KVM code having to know what low-power mode to
put the thread into.
In the case of a secondary thread used to run a KVM guest, the thread
will be offline from the point of view of the host kernel, and the
relevant power7_nap() call is the one in pnv_smp_cpu_disable().
In this case we don't want to clear pending IPIs in the offline loop
in that function, since that might cause us to miss the wakeup for
the next time the thread needs to run a guest. To tell whether or
not to clear the interrupt, we use the SRR1 value returned from
power7_nap(), and check if it indicates an external interrupt. We
arrange that the return from power7_nap() when we have finished running
a guest returns 0, so pending interrupts don't get flushed in that
case.
Note that it is important a secondary thread that has finished
executing in the guest, or that didn't have a guest to run, should
not return to power7_nap's caller while the kvm_hstate.hwthread_req
flag in the PACA is non-zero, because the return from power7_nap
will reenable the MMU, and the MMU might still be in guest context.
In this situation we spin at low priority in real mode waiting for
hwthread_req to become zero.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2014-12-03 10:48:40 +07:00
|
|
|
extern unsigned long power7_nap(int check_irq);
|
2014-12-10 01:56:52 +07:00
|
|
|
extern unsigned long power7_sleep(void);
|
2014-12-10 01:56:53 +07:00
|
|
|
extern unsigned long power7_winkle(void);
|
powernv: Pass PSSCR value and mask to power9_idle_stop
The power9_idle_stop method currently takes only the requested stop
level as a parameter and picks up the rest of the PSSCR bits from a
hand-coded macro. This is not a very flexible design, especially when
the firmware has the capability to communicate the psscr value and the
mask associated with a particular stop state via device tree.
This patch modifies the power9_idle_stop API to take as parameters the
PSSCR value and the PSSCR mask corresponding to the stop state that
needs to be set. These PSSCR value and mask are respectively obtained
by parsing the "ibm,cpu-idle-state-psscr" and
"ibm,cpu-idle-state-psscr-mask" fields from the device tree.
In addition to this, the patch adds support for handling stop states
for which ESL and EC bits in the PSSCR are zero. As per the
architecture, a wakeup from these stop states resumes execution from
the subsequent instruction as opposed to waking up at the System
Vector.
The older firmware sets only the Requested Level (RL) field in the
psscr and psscr-mask exposed in the device tree. For older firmware
where psscr-mask=0xf, this patch will set the default sane values that
the set for for remaining PSSCR fields (i.e PSLL, MTL, ESL, EC, and
TR). For the new firmware, the patch will validate that the invariants
required by the ISA for the psscr values are maintained by the
firmware.
This skiboot patch that exports fully populated PSSCR values and the
mask for all the stop states can be found here:
https://lists.ozlabs.org/pipermail/skiboot/2016-September/004869.html
[Optimize the number of instructions before entering STOP with
ESL=EC=0, validate the PSSCR values provided by the firimware
maintains the invariants required as per the ISA suggested by Balbir
Singh]
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-01-25 15:36:28 +07:00
|
|
|
extern unsigned long power9_idle_stop(unsigned long stop_psscr_val,
|
|
|
|
unsigned long stop_psscr_mask);
|
2016-07-08 13:20:49 +07:00
|
|
|
|
2012-03-29 00:30:02 +07: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 05:20:36 +07:00
|
|
|
#endif /* __KERNEL__ */
|
2005-10-10 11:19:43 +07:00
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* _ASM_POWERPC_PROCESSOR_H */
|