Commit 80703617 authored by Martin Schwidefsky's avatar Martin Schwidefsky

s390: add support for vector extension

The vector extension introduces 32 128-bit vector registers and a set of
instruction to operate on the vector registers.

The kernel can control the use of vector registers for the problem state
program with a bit in control register 0. Once enabled for a process the
kernel needs to retain the content of the vector registers on context
switch. The signal frame is extended to include the vector registers.
Two new register sets NT_S390_VXRS_LOW and NT_S390_VXRS_HIGH are added
to the regset interface for the debugger and core dumps.
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 42f4dd61
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
#define HWCAP_S390_ETF3EH 256 #define HWCAP_S390_ETF3EH 256
#define HWCAP_S390_HIGH_GPRS 512 #define HWCAP_S390_HIGH_GPRS 512
#define HWCAP_S390_TE 1024 #define HWCAP_S390_TE 1024
#define HWCAP_S390_VXRS 2048
/* /*
* These are used to set parameters in the core dumps. * These are used to set parameters in the core dumps.
......
...@@ -310,7 +310,10 @@ struct _lowcore { ...@@ -310,7 +310,10 @@ struct _lowcore {
/* Extended facility list */ /* Extended facility list */
__u64 stfle_fac_list[32]; /* 0x0f00 */ __u64 stfle_fac_list[32]; /* 0x0f00 */
__u8 pad_0x1000[0x11b8-0x1000]; /* 0x1000 */ __u8 pad_0x1000[0x11b0-0x1000]; /* 0x1000 */
/* Pointer to vector register save area */
__u64 vector_save_area_addr; /* 0x11b0 */
/* 64 bit extparam used for pfault/diag 250: defined by architecture */ /* 64 bit extparam used for pfault/diag 250: defined by architecture */
__u64 ext_params2; /* 0x11B8 */ __u64 ext_params2; /* 0x11B8 */
...@@ -334,9 +337,10 @@ struct _lowcore { ...@@ -334,9 +337,10 @@ struct _lowcore {
/* Transaction abort diagnostic block */ /* Transaction abort diagnostic block */
__u8 pgm_tdb[256]; /* 0x1800 */ __u8 pgm_tdb[256]; /* 0x1800 */
__u8 pad_0x1900[0x1c00-0x1900]; /* 0x1900 */
/* align to the top of the prefix area */ /* Software defined save area for vector registers */
__u8 pad_0x1900[0x2000-0x1900]; /* 0x1900 */ __u8 vector_save_area[1024]; /* 0x1c00 */
} __packed; } __packed;
#endif /* CONFIG_32BIT */ #endif /* CONFIG_32BIT */
......
...@@ -38,7 +38,7 @@ struct mci { ...@@ -38,7 +38,7 @@ struct mci {
__u32 pm : 1; /* 22 psw program mask and cc validity */ __u32 pm : 1; /* 22 psw program mask and cc validity */
__u32 ia : 1; /* 23 psw instruction address validity */ __u32 ia : 1; /* 23 psw instruction address validity */
__u32 fa : 1; /* 24 failing storage address validity */ __u32 fa : 1; /* 24 failing storage address validity */
__u32 : 1; /* 25 */ __u32 vr : 1; /* 25 vector register validity */
__u32 ec : 1; /* 26 external damage code validity */ __u32 ec : 1; /* 26 external damage code validity */
__u32 fp : 1; /* 27 floating point register validity */ __u32 fp : 1; /* 27 floating point register validity */
__u32 gr : 1; /* 28 general register validity */ __u32 gr : 1; /* 28 general register validity */
......
...@@ -117,6 +117,7 @@ struct thread_struct { ...@@ -117,6 +117,7 @@ struct thread_struct {
int ri_signum; int ri_signum;
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
unsigned char trap_tdb[256]; /* Transaction abort diagnose block */ unsigned char trap_tdb[256]; /* Transaction abort diagnose block */
__vector128 *vxrs; /* Vector register save area */
#endif #endif
}; };
......
...@@ -56,6 +56,7 @@ extern void detect_memory_memblock(void); ...@@ -56,6 +56,7 @@ extern void detect_memory_memblock(void);
#define MACHINE_FLAG_TOPOLOGY (1UL << 14) #define MACHINE_FLAG_TOPOLOGY (1UL << 14)
#define MACHINE_FLAG_TE (1UL << 15) #define MACHINE_FLAG_TE (1UL << 15)
#define MACHINE_FLAG_TLB_LC (1UL << 17) #define MACHINE_FLAG_TLB_LC (1UL << 17)
#define MACHINE_FLAG_VX (1UL << 18)
#define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM) #define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM)
#define MACHINE_IS_KVM (S390_lowcore.machine_flags & MACHINE_FLAG_KVM) #define MACHINE_IS_KVM (S390_lowcore.machine_flags & MACHINE_FLAG_KVM)
...@@ -78,6 +79,7 @@ extern void detect_memory_memblock(void); ...@@ -78,6 +79,7 @@ extern void detect_memory_memblock(void);
#define MACHINE_HAS_TOPOLOGY (0) #define MACHINE_HAS_TOPOLOGY (0)
#define MACHINE_HAS_TE (0) #define MACHINE_HAS_TE (0)
#define MACHINE_HAS_TLB_LC (0) #define MACHINE_HAS_TLB_LC (0)
#define MACHINE_HAS_VX (0)
#else /* CONFIG_64BIT */ #else /* CONFIG_64BIT */
#define MACHINE_HAS_IEEE (1) #define MACHINE_HAS_IEEE (1)
#define MACHINE_HAS_CSP (1) #define MACHINE_HAS_CSP (1)
...@@ -90,6 +92,7 @@ extern void detect_memory_memblock(void); ...@@ -90,6 +92,7 @@ extern void detect_memory_memblock(void);
#define MACHINE_HAS_TOPOLOGY (S390_lowcore.machine_flags & MACHINE_FLAG_TOPOLOGY) #define MACHINE_HAS_TOPOLOGY (S390_lowcore.machine_flags & MACHINE_FLAG_TOPOLOGY)
#define MACHINE_HAS_TE (S390_lowcore.machine_flags & MACHINE_FLAG_TE) #define MACHINE_HAS_TE (S390_lowcore.machine_flags & MACHINE_FLAG_TE)
#define MACHINE_HAS_TLB_LC (S390_lowcore.machine_flags & MACHINE_FLAG_TLB_LC) #define MACHINE_HAS_TLB_LC (S390_lowcore.machine_flags & MACHINE_FLAG_TLB_LC)
#define MACHINE_HAS_VX (S390_lowcore.machine_flags & MACHINE_FLAG_VX)
#endif /* CONFIG_64BIT */ #endif /* CONFIG_64BIT */
/* /*
......
...@@ -103,6 +103,48 @@ static inline void restore_fp_regs(freg_t *fprs) ...@@ -103,6 +103,48 @@ static inline void restore_fp_regs(freg_t *fprs)
asm volatile("ld 15,%0" : : "Q" (fprs[15])); asm volatile("ld 15,%0" : : "Q" (fprs[15]));
} }
static inline void save_vx_regs(__vector128 *vxrs)
{
typedef struct { __vector128 _[__NUM_VXRS]; } addrtype;
asm volatile(
" la 1,%0\n"
" .word 0xe70f,0x1000,0x003e\n" /* vstm 0,15,0(1) */
" .word 0xe70f,0x1100,0x0c3e\n" /* vstm 16,31,256(1) */
: "=Q" (*(addrtype *) vxrs) : : "1");
}
static inline void restore_vx_regs(__vector128 *vxrs)
{
typedef struct { __vector128 _[__NUM_VXRS]; } addrtype;
asm volatile(
" la 1,%0\n"
" .word 0xe70f,0x1000,0x0036\n" /* vlm 0,15,0(1) */
" .word 0xe70f,0x1100,0x0c36\n" /* vlm 16,31,256(1) */
: : "Q" (*(addrtype *) vxrs) : "1");
}
static inline void save_fp_vx_regs(struct task_struct *task)
{
#ifdef CONFIG_64BIT
if (task->thread.vxrs)
save_vx_regs(task->thread.vxrs);
else
#endif
save_fp_regs(task->thread.fp_regs.fprs);
}
static inline void restore_fp_vx_regs(struct task_struct *task)
{
#ifdef CONFIG_64BIT
if (task->thread.vxrs)
restore_vx_regs(task->thread.vxrs);
else
#endif
restore_fp_regs(task->thread.fp_regs.fprs);
}
static inline void save_access_regs(unsigned int *acrs) static inline void save_access_regs(unsigned int *acrs)
{ {
typedef struct { int _[NUM_ACRS]; } acrstype; typedef struct { int _[NUM_ACRS]; } acrstype;
...@@ -120,16 +162,16 @@ static inline void restore_access_regs(unsigned int *acrs) ...@@ -120,16 +162,16 @@ static inline void restore_access_regs(unsigned int *acrs)
#define switch_to(prev,next,last) do { \ #define switch_to(prev,next,last) do { \
if (prev->mm) { \ if (prev->mm) { \
save_fp_ctl(&prev->thread.fp_regs.fpc); \ save_fp_ctl(&prev->thread.fp_regs.fpc); \
save_fp_regs(prev->thread.fp_regs.fprs); \ save_fp_vx_regs(prev); \
save_access_regs(&prev->thread.acrs[0]); \ save_access_regs(&prev->thread.acrs[0]); \
save_ri_cb(prev->thread.ri_cb); \ save_ri_cb(prev->thread.ri_cb); \
} \ } \
if (next->mm) { \ if (next->mm) { \
update_cr_regs(next); \
restore_fp_ctl(&next->thread.fp_regs.fpc); \ restore_fp_ctl(&next->thread.fp_regs.fpc); \
restore_fp_regs(next->thread.fp_regs.fprs); \ restore_fp_vx_regs(next); \
restore_access_regs(&next->thread.acrs[0]); \ restore_access_regs(&next->thread.acrs[0]); \
restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \ restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
update_cr_regs(next); \
} \ } \
prev = __switch_to(prev,next); \ prev = __switch_to(prev,next); \
} while (0) } while (0)
......
...@@ -7,10 +7,14 @@ ...@@ -7,10 +7,14 @@
#define _ASM_S390_SIGCONTEXT_H #define _ASM_S390_SIGCONTEXT_H
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/types.h>
#define __NUM_GPRS 16 #define __NUM_GPRS 16
#define __NUM_FPRS 16 #define __NUM_FPRS 16
#define __NUM_ACRS 16 #define __NUM_ACRS 16
#define __NUM_VXRS 32
#define __NUM_VXRS_LOW 16
#define __NUM_VXRS_HIGH 16
#ifndef __s390x__ #ifndef __s390x__
...@@ -59,6 +63,16 @@ typedef struct ...@@ -59,6 +63,16 @@ typedef struct
_s390_fp_regs fpregs; _s390_fp_regs fpregs;
} _sigregs; } _sigregs;
typedef struct
{
#ifndef __s390x__
unsigned long gprs_high[__NUM_GPRS];
#endif
unsigned long long vxrs_low[__NUM_VXRS_LOW];
__vector128 vxrs_high[__NUM_VXRS_HIGH];
unsigned char __reserved[128];
} _sigregs_ext;
struct sigcontext struct sigcontext
{ {
unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS]; unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS];
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
typedef unsigned long addr_t; typedef unsigned long addr_t;
typedef __signed__ long saddr_t; typedef __signed__ long saddr_t;
typedef struct {
__u32 u[4];
} __vector128;
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* _UAPI_S390_TYPES_H */ #endif /* _UAPI_S390_TYPES_H */
...@@ -7,10 +7,15 @@ ...@@ -7,10 +7,15 @@
#ifndef _ASM_S390_UCONTEXT_H #ifndef _ASM_S390_UCONTEXT_H
#define _ASM_S390_UCONTEXT_H #define _ASM_S390_UCONTEXT_H
#define UC_EXTENDED 0x00000001 #define UC_GPRS_HIGH 1 /* uc_mcontext_ext has valid high gprs */
#define UC_VXRS 2 /* uc_mcontext_ext has valid vector regs */
#ifndef __s390x__
/*
* The struct ucontext_extended describes how the registers are stored
* on a rt signal frame. Please note that the structure is not fixed,
* if new CPU registers are added to the user state the size of the
* struct ucontext_extended will increase.
*/
struct ucontext_extended { struct ucontext_extended {
unsigned long uc_flags; unsigned long uc_flags;
struct ucontext *uc_link; struct ucontext *uc_link;
...@@ -19,11 +24,9 @@ struct ucontext_extended { ...@@ -19,11 +24,9 @@ struct ucontext_extended {
sigset_t uc_sigmask; sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
unsigned char __unused[128 - sizeof(sigset_t)]; unsigned char __unused[128 - sizeof(sigset_t)];
unsigned long uc_gprs_high[16]; _sigregs_ext uc_mcontext_ext;
}; };
#endif
struct ucontext { struct ucontext {
unsigned long uc_flags; unsigned long uc_flags;
struct ucontext *uc_link; struct ucontext *uc_link;
......
...@@ -50,6 +50,14 @@ typedef struct ...@@ -50,6 +50,14 @@ typedef struct
_s390_fp_regs32 fpregs; _s390_fp_regs32 fpregs;
} _sigregs32; } _sigregs32;
typedef struct
{
__u32 gprs_high[__NUM_GPRS];
__u64 vxrs_low[__NUM_VXRS_LOW];
__vector128 vxrs_high[__NUM_VXRS_HIGH];
__u8 __reserved[128];
} _sigregs_ext32;
#define _SIGCONTEXT_NSIG32 64 #define _SIGCONTEXT_NSIG32 64
#define _SIGCONTEXT_NSIG_BPW32 32 #define _SIGCONTEXT_NSIG_BPW32 32
#define __SIGNAL_FRAMESIZE32 96 #define __SIGNAL_FRAMESIZE32 96
...@@ -72,6 +80,7 @@ struct ucontext32 { ...@@ -72,6 +80,7 @@ struct ucontext32 {
compat_sigset_t uc_sigmask; compat_sigset_t uc_sigmask;
/* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
unsigned char __unused[128 - sizeof(compat_sigset_t)]; unsigned char __unused[128 - sizeof(compat_sigset_t)];
_sigregs_ext32 uc_mcontext_ext;
}; };
struct stat64_emu31; struct stat64_emu31;
......
This diff is collapsed.
...@@ -392,6 +392,8 @@ static __init void detect_machine_facilities(void) ...@@ -392,6 +392,8 @@ static __init void detect_machine_facilities(void)
S390_lowcore.machine_flags |= MACHINE_FLAG_TE; S390_lowcore.machine_flags |= MACHINE_FLAG_TE;
if (test_facility(51)) if (test_facility(51))
S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_LC; S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_LC;
if (test_facility(129))
S390_lowcore.machine_flags |= MACHINE_FLAG_VX;
#endif #endif
} }
......
...@@ -21,6 +21,8 @@ void psw_idle(struct s390_idle_data *, unsigned long); ...@@ -21,6 +21,8 @@ void psw_idle(struct s390_idle_data *, unsigned long);
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs); asmlinkage long do_syscall_trace_enter(struct pt_regs *regs);
asmlinkage void do_syscall_trace_exit(struct pt_regs *regs); asmlinkage void do_syscall_trace_exit(struct pt_regs *regs);
int alloc_vector_registers(struct task_struct *tsk);
void do_protection_exception(struct pt_regs *regs); void do_protection_exception(struct pt_regs *regs);
void do_dat_exception(struct pt_regs *regs); void do_dat_exception(struct pt_regs *regs);
...@@ -43,6 +45,7 @@ void special_op_exception(struct pt_regs *regs); ...@@ -43,6 +45,7 @@ void special_op_exception(struct pt_regs *regs);
void specification_exception(struct pt_regs *regs); void specification_exception(struct pt_regs *regs);
void transaction_exception(struct pt_regs *regs); void transaction_exception(struct pt_regs *regs);
void translation_exception(struct pt_regs *regs); void translation_exception(struct pt_regs *regs);
void vector_exception(struct pt_regs *regs);
void do_per_trap(struct pt_regs *regs); void do_per_trap(struct pt_regs *regs);
void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str); void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <asm/cputime.h> #include <asm/cputime.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/crw.h> #include <asm/crw.h>
#include <asm/switch_to.h>
struct mcck_struct { struct mcck_struct {
int kill_task; int kill_task;
...@@ -163,6 +164,21 @@ static int notrace s390_revalidate_registers(struct mci *mci) ...@@ -163,6 +164,21 @@ static int notrace s390_revalidate_registers(struct mci *mci)
" ld 15,120(%0)\n" " ld 15,120(%0)\n"
: : "a" (fpt_save_area)); : : "a" (fpt_save_area));
} }
#ifdef CONFIG_64BIT
/* Revalidate vector registers */
if (MACHINE_HAS_VX && current->thread.vxrs) {
if (!mci->vr) {
/*
* Vector registers can't be restored and therefore
* the process needs to be terminated.
*/
kill_task = 1;
}
restore_vx_regs((__vector128 *)
S390_lowcore.vector_save_area_addr);
}
#endif
/* Revalidate access registers */ /* Revalidate access registers */
asm volatile( asm volatile(
" lam 0,15,0(%0)" " lam 0,15,0(%0)"
......
...@@ -49,7 +49,7 @@ PGM_CHECK_DEFAULT /* 17 */ ...@@ -49,7 +49,7 @@ PGM_CHECK_DEFAULT /* 17 */
PGM_CHECK_64BIT(transaction_exception) /* 18 */ PGM_CHECK_64BIT(transaction_exception) /* 18 */
PGM_CHECK_DEFAULT /* 19 */ PGM_CHECK_DEFAULT /* 19 */
PGM_CHECK_DEFAULT /* 1a */ PGM_CHECK_DEFAULT /* 1a */
PGM_CHECK_DEFAULT /* 1b */ PGM_CHECK_64BIT(vector_exception) /* 1b */
PGM_CHECK(space_switch_exception) /* 1c */ PGM_CHECK(space_switch_exception) /* 1c */
PGM_CHECK(hfp_sqrt_exception) /* 1d */ PGM_CHECK(hfp_sqrt_exception) /* 1d */
PGM_CHECK_DEFAULT /* 1e */ PGM_CHECK_DEFAULT /* 1e */
......
...@@ -39,7 +39,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) ...@@ -39,7 +39,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
{ {
static const char *hwcap_str[] = { static const char *hwcap_str[] = {
"esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp", "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
"edat", "etf3eh", "highgprs", "te" "edat", "etf3eh", "highgprs", "te", "vx"
}; };
unsigned long n = (unsigned long) v - 1; unsigned long n = (unsigned long) v - 1;
int i; int i;
......
...@@ -38,15 +38,6 @@ ...@@ -38,15 +38,6 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h> #include <trace/events/syscalls.h>
enum s390_regset {
REGSET_GENERAL,
REGSET_FP,
REGSET_LAST_BREAK,
REGSET_TDB,
REGSET_SYSTEM_CALL,
REGSET_GENERAL_EXTENDED,
};
void update_cr_regs(struct task_struct *task) void update_cr_regs(struct task_struct *task)
{ {
struct pt_regs *regs = task_pt_regs(task); struct pt_regs *regs = task_pt_regs(task);
...@@ -55,21 +46,32 @@ void update_cr_regs(struct task_struct *task) ...@@ -55,21 +46,32 @@ void update_cr_regs(struct task_struct *task)
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
/* Take care of the enable/disable of transactional execution. */ /* Take care of the enable/disable of transactional execution. */
if (MACHINE_HAS_TE) { if (MACHINE_HAS_TE || MACHINE_HAS_VX) {
unsigned long cr, cr_new; unsigned long cr, cr_new;
__ctl_store(cr, 0, 0); __ctl_store(cr, 0, 0);
cr_new = cr;
if (MACHINE_HAS_TE) {
/* Set or clear transaction execution TXC bit 8. */ /* Set or clear transaction execution TXC bit 8. */
cr_new = cr | (1UL << 55); cr_new |= (1UL << 55);
if (task->thread.per_flags & PER_FLAG_NO_TE) if (task->thread.per_flags & PER_FLAG_NO_TE)
cr_new &= ~(1UL << 55); cr_new &= ~(1UL << 55);
}
if (MACHINE_HAS_VX) {
/* Enable/disable of vector extension */
cr_new &= ~(1UL << 17);
if (task->thread.vxrs)
cr_new |= (1UL << 17);
}
if (cr_new != cr) if (cr_new != cr)
__ctl_load(cr_new, 0, 0); __ctl_load(cr_new, 0, 0);
/* Set or clear transaction execution TDC bits 62 and 63. */ if (MACHINE_HAS_TE) {
/* Set/clear transaction execution TDC bits 62/63. */
__ctl_store(cr, 2, 2); __ctl_store(cr, 2, 2);
cr_new = cr & ~3UL; cr_new = cr & ~3UL;
if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) { if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND) {
if (task->thread.per_flags & PER_FLAG_TE_ABORT_RAND_TEND) if (task->thread.per_flags &
PER_FLAG_TE_ABORT_RAND_TEND)
cr_new |= 1UL; cr_new |= 1UL;
else else
cr_new |= 2UL; cr_new |= 2UL;
...@@ -77,6 +79,7 @@ void update_cr_regs(struct task_struct *task) ...@@ -77,6 +79,7 @@ void update_cr_regs(struct task_struct *task)
if (cr_new != cr) if (cr_new != cr)
__ctl_load(cr_new, 2, 2); __ctl_load(cr_new, 2, 2);
} }
}
#endif #endif
/* Copy user specified PER registers */ /* Copy user specified PER registers */
new.control = thread->per_user.control; new.control = thread->per_user.control;
...@@ -926,7 +929,15 @@ static int s390_fpregs_get(struct task_struct *target, ...@@ -926,7 +929,15 @@ static int s390_fpregs_get(struct task_struct *target,
save_fp_ctl(&target->thread.fp_regs.fpc); save_fp_ctl(&target->thread.fp_regs.fpc);
save_fp_regs(target->thread.fp_regs.fprs); save_fp_regs(target->thread.fp_regs.fprs);
} }
#ifdef CONFIG_64BIT
else if (target->thread.vxrs) {
int i;
for (i = 0; i < __NUM_VXRS_LOW; i++)
target->thread.fp_regs.fprs[i] =
*(freg_t *)(target->thread.vxrs + i);
}
#endif
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
&target->thread.fp_regs, 0, -1); &target->thread.fp_regs, 0, -1);
} }
...@@ -960,10 +971,21 @@ static int s390_fpregs_set(struct task_struct *target, ...@@ -960,10 +971,21 @@ static int s390_fpregs_set(struct task_struct *target,
target->thread.fp_regs.fprs, target->thread.fp_regs.fprs,
offsetof(s390_fp_regs, fprs), -1); offsetof(s390_fp_regs, fprs), -1);
if (rc == 0 && target == current) { if (rc == 0) {
if (target == current) {
restore_fp_ctl(&target->thread.fp_regs.fpc); restore_fp_ctl(&target->thread.fp_regs.fpc);
restore_fp_regs(target->thread.fp_regs.fprs); restore_fp_regs(target->thread.fp_regs.fprs);
} }
#ifdef CONFIG_64BIT
else if (target->thread.vxrs) {
int i;
for (i = 0; i < __NUM_VXRS_LOW; i++)
*(freg_t *)(target->thread.vxrs + i) =
target->thread.fp_regs.fprs[i];
}
#endif
}
return rc; return rc;
} }
...@@ -1018,6 +1040,95 @@ static int s390_tdb_set(struct task_struct *target, ...@@ -1018,6 +1040,95 @@ static int s390_tdb_set(struct task_struct *target,
return 0; return 0;
} }
static int s390_vxrs_active(struct task_struct *target,
const struct user_regset *regset)
{
return !!target->thread.vxrs;
}
static int s390_vxrs_low_get(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
void *kbuf, void __user *ubuf)
{
__u64 vxrs[__NUM_VXRS_LOW];
int i;
if (target->thread.vxrs) {
if (target == current)
save_vx_regs(target->thread.vxrs);
for (i = 0; i < __NUM_VXRS_LOW; i++)
vxrs[i] = *((__u64 *)(target->thread.vxrs + i) + 1);
} else
memset(vxrs, 0, sizeof(vxrs));
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1);
}
static int s390_vxrs_low_set(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *kbuf, const void __user *ubuf)
{
__u64 vxrs[__NUM_VXRS_LOW];
int i, rc;
if (!target->thread.vxrs) {
rc = alloc_vector_registers(target);
if (rc)
return rc;
} else if (target == current)
save_vx_regs(target->thread.vxrs);
rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1);
if (rc == 0) {
for (i = 0; i < __NUM_VXRS_LOW; i++)
*((__u64 *)(target->thread.vxrs + i) + 1) = vxrs[i];
if (target == current)
restore_vx_regs(target->thread.vxrs);
}
return rc;
}
static int s390_vxrs_high_get(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
void *kbuf, void __user *ubuf)
{
__vector128 vxrs[__NUM_VXRS_HIGH];
if (target->thread.vxrs) {
if (target == current)
save_vx_regs(target->thread.vxrs);
memcpy(vxrs, target->thread.vxrs + __NUM_VXRS_LOW,
sizeof(vxrs));
} else
memset(vxrs, 0, sizeof(vxrs));
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, vxrs, 0, -1);
}
static int s390_vxrs_high_set(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
const void *kbuf, const void __user *ubuf)
{
int rc;
if (!target->thread.vxrs) {
rc = alloc_vector_registers(target);
if (rc)
return rc;
} else if (target == current)
save_vx_regs(target->thread.vxrs);
rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
target->thread.vxrs + __NUM_VXRS_LOW, 0, -1);
if (rc == 0 && target == current)
restore_vx_regs(target->thread.vxrs);
return rc;
}
#endif #endif
static int s390_system_call_get(struct task_struct *target, static int s390_system_call_get(struct task_struct *target,
...@@ -1041,7 +1152,7 @@ static int s390_system_call_set(struct task_struct *target, ...@@ -1041,7 +1152,7 @@ static int s390_system_call_set(struct task_struct *target,
} }
static const struct user_regset s390_regsets[] = { static const struct user_regset s390_regsets[] = {
[REGSET_GENERAL] = { {
.core_note_type = NT_PRSTATUS, .core_note_type = NT_PRSTATUS,
.n = sizeof(s390_regs) / sizeof(long), .n = sizeof(s390_regs) / sizeof(long),
.size = sizeof(long), .size = sizeof(long),
...@@ -1049,7 +1160,7 @@ static const struct user_regset s390_regsets[] = { ...@@ -1049,7 +1160,7 @@ static const struct user_regset s390_regsets[] = {
.get = s390_regs_get, .get = s390_regs_get,
.set = s390_regs_set, .set = s390_regs_set,
}, },
[REGSET_FP] = { {
.core_note_type = NT_PRFPREG, .core_note_type = NT_PRFPREG,
.n = sizeof(s390_fp_regs) / sizeof(long), .n = sizeof(s390_fp_regs) / sizeof(long),
.size = sizeof(long), .size = sizeof(long),
...@@ -1057,8 +1168,16 @@ static const struct user_regset s390_regsets[] = { ...@@ -1057,8 +1168,16 @@ static const struct user_regset s390_regsets[] = {
.get = s390_fpregs_get, .get = s390_fpregs_get,
.set = s390_fpregs_set, .set = s390_fpregs_set,
}, },
{
.core_note_type = NT_S390_SYSTEM_CALL,
.n = 1,
.size = sizeof(unsigned int),
.align = sizeof(unsigned int),
.get = s390_system_call_get,
.set = s390_system_call_set,
},
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
[REGSET_LAST_BREAK] = { {
.core_note_type = NT_S390_LAST_BREAK, .core_note_type = NT_S390_LAST_BREAK,
.n = 1, .n = 1,
.size = sizeof(long), .size = sizeof(long),
...@@ -1066,7 +1185,7 @@ static const struct user_regset s390_regsets[] = { ...@@ -1066,7 +1185,7 @@ static const struct user_regset s390_regsets[] = {
.get = s390_last_break_get, .get = s390_last_break_get,
.set = s390_last_break_set, .set = s390_last_break_set,
}, },
[REGSET_TDB] = { {
.core_note_type = NT_S390_TDB, .core_note_type = NT_S390_TDB,
.n = 1, .n = 1,
.size = 256, .size = 256,
...@@ -1074,15 +1193,25 @@ static const struct user_regset s390_regsets[] = { ...@@ -1074,15 +1193,25 @@ static const struct user_regset s390_regsets[] = {
.get = s390_tdb_get, .get = s390_tdb_get,
.set = s390_tdb_set, .set = s390_tdb_set,
}, },
#endif {
[REGSET_SYSTEM_CALL] = { .core_note_type = NT_S390_VXRS_LOW,
.core_note_type = NT_S390_SYSTEM_CALL, .n = __NUM_VXRS_LOW,
.n = 1, .size = sizeof(__u64),
.size = sizeof(unsigned int), .align = sizeof(__u64),
.align = sizeof(unsigned int), .active = s390_vxrs_active,
.get = s390_system_call_get, .get = s390_vxrs_low_get,
.set = s390_system_call_set, .set = s390_vxrs_low_set,
},
{
.core_note_type = NT_S390_VXRS_HIGH,
.n = __NUM_VXRS_HIGH,
.size = sizeof(__vector128),
.align = sizeof(__vector128),
.active = s390_vxrs_active,
.get = s390_vxrs_high_get,
.set = s390_vxrs_high_set,
}, },
#endif
}; };
static const struct user_regset_view user_s390_view = { static const struct user_regset_view user_s390_view = {
...@@ -1247,7 +1376,7 @@ static int s390_compat_last_break_set(struct task_struct *target, ...@@ -1247,7 +1376,7 @@ static int s390_compat_last_break_set(struct task_struct *target,
} }
static const struct user_regset s390_compat_regsets[] = { static const struct user_regset s390_compat_regsets[] = {
[REGSET_GENERAL] = { {
.core_note_type = NT_PRSTATUS, .core_note_type = NT_PRSTATUS,
.n = sizeof(s390_compat_regs) / sizeof(compat_long_t), .n = sizeof(s390_compat_regs) / sizeof(compat_long_t),
.size = sizeof(compat_long_t), .size = sizeof(compat_long_t),
...@@ -1255,7 +1384,7 @@ static const struct user_regset s390_compat_regsets[] = { ...@@ -1255,7 +1384,7 @@ static const struct user_regset s390_compat_regsets[] = {
.get = s390_compat_regs_get, .get = s390_compat_regs_get,
.set = s390_compat_regs_set, .set = s390_compat_regs_set,
}, },
[REGSET_FP] = { {
.core_note_type = NT_PRFPREG, .core_note_type = NT_PRFPREG,
.n = sizeof(s390_fp_regs) / sizeof(compat_long_t), .n = sizeof(s390_fp_regs) / sizeof(compat_long_t),
.size = sizeof(compat_long_t), .size = sizeof(compat_long_t),
...@@ -1263,7 +1392,15 @@ static const struct user_regset s390_compat_regsets[] = { ...@@ -1263,7 +1392,15 @@ static const struct user_regset s390_compat_regsets[] = {
.get = s390_fpregs_get, .get = s390_fpregs_get,
.set = s390_fpregs_set, .set = s390_fpregs_set,
}, },
[REGSET_LAST_BREAK] = { {
.core_note_type = NT_S390_SYSTEM_CALL,
.n = 1,
.size = sizeof(compat_uint_t),
.align = sizeof(compat_uint_t),
.get = s390_system_call_get,
.set = s390_system_call_set,
},
{
.core_note_type = NT_S390_LAST_BREAK, .core_note_type = NT_S390_LAST_BREAK,
.n = 1, .n = 1,
.size = sizeof(long), .size = sizeof(long),
...@@ -1271,7 +1408,7 @@ static const struct user_regset s390_compat_regsets[] = { ...@@ -1271,7 +1408,7 @@ static const struct user_regset s390_compat_regsets[] = {
.get = s390_compat_last_break_get, .get = s390_compat_last_break_get,
.set = s390_compat_last_break_set, .set = s390_compat_last_break_set,
}, },
[REGSET_TDB] = { {
.core_note_type = NT_S390_TDB, .core_note_type = NT_S390_TDB,
.n = 1, .n = 1,
.size = 256, .size = 256,
...@@ -1279,15 +1416,25 @@ static const struct user_regset s390_compat_regsets[] = { ...@@ -1279,15 +1416,25 @@ static const struct user_regset s390_compat_regsets[] = {
.get = s390_tdb_get, .get = s390_tdb_get,
.set = s390_tdb_set, .set = s390_tdb_set,
}, },
[REGSET_SYSTEM_CALL] = { {
.core_note_type = NT_S390_SYSTEM_CALL, .core_note_type = NT_S390_VXRS_LOW,
.n = 1, .n = __NUM_VXRS_LOW,
.size = sizeof(compat_uint_t), .size = sizeof(__u64),
.align = sizeof(compat_uint_t), .align = sizeof(__u64),
.get = s390_system_call_get, .active = s390_vxrs_active,
.set = s390_system_call_set, .get = s390_vxrs_low_get,
.set = s390_vxrs_low_set,
},
{
.core_note_type = NT_S390_VXRS_HIGH,
.n = __NUM_VXRS_HIGH,
.size = sizeof(__vector128),
.align = sizeof(__vector128),
.active = s390_vxrs_active,
.get = s390_vxrs_high_get,
.set = s390_vxrs_high_set,
}, },
[REGSET_GENERAL_EXTENDED] = { {
.core_note_type = NT_S390_HIGH_GPRS, .core_note_type = NT_S390_HIGH_GPRS,
.n = sizeof(s390_compat_regs_high) / sizeof(compat_long_t), .n = sizeof(s390_compat_regs_high) / sizeof(compat_long_t),
.size = sizeof(compat_long_t), .size = sizeof(compat_long_t),
......
...@@ -343,6 +343,9 @@ static void __init setup_lowcore(void) ...@@ -343,6 +343,9 @@ static void __init setup_lowcore(void)
__ctl_set_bit(14, 29); __ctl_set_bit(14, 29);
} }
#else #else
if (MACHINE_HAS_VX)
lc->vector_save_area_addr =
(unsigned long) &lc->vector_save_area;
lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0]; lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0];
#endif #endif
lc->sync_enter_timer = S390_lowcore.sync_enter_timer; lc->sync_enter_timer = S390_lowcore.sync_enter_timer;
...@@ -765,6 +768,12 @@ static void __init setup_hwcaps(void) ...@@ -765,6 +768,12 @@ static void __init setup_hwcaps(void)
*/ */
if (test_facility(50) && test_facility(73)) if (test_facility(50) && test_facility(73))
elf_hwcap |= HWCAP_S390_TE; elf_hwcap |= HWCAP_S390_TE;
/*
* Vector extension HWCAP_S390_VXRS is bit 11.
*/
if (test_facility(129))
elf_hwcap |= HWCAP_S390_VXRS;
#endif #endif
get_cpu_id(&cpu_id); get_cpu_id(&cpu_id);
......
This diff is collapsed.
...@@ -179,6 +179,9 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) ...@@ -179,6 +179,9 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
goto out; goto out;
} }
#else #else
if (MACHINE_HAS_VX)
lc->vector_save_area_addr =
(unsigned long) &lc->vector_save_area;
if (vdso_alloc_per_cpu(lc)) if (vdso_alloc_per_cpu(lc))
goto out; goto out;
#endif #endif
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h>
#include <asm/switch_to.h>
#include "entry.h" #include "entry.h"
int show_unhandled_signals = 1; int show_unhandled_signals = 1;
...@@ -303,6 +305,74 @@ DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN, ...@@ -303,6 +305,74 @@ DO_ERROR_INFO(specification_exception, SIGILL, ILL_ILLOPN,
"specification exception"); "specification exception");
#endif #endif
#ifdef CONFIG_64BIT
int alloc_vector_registers(struct task_struct *tsk)
{
__vector128 *vxrs;
int i;
/* Allocate vector register save area. */
vxrs = kzalloc(sizeof(__vector128) * __NUM_VXRS,
GFP_KERNEL|__GFP_REPEAT);
if (!vxrs)
return -ENOMEM;
preempt_disable();
if (tsk == current)
save_fp_regs(tsk->thread.fp_regs.fprs);
/* Copy the 16 floating point registers */
for (i = 0; i < 16; i++)
*(freg_t *) &vxrs[i] = tsk->thread.fp_regs.fprs[i];
tsk->thread.vxrs = vxrs;
if (tsk == current) {
__ctl_set_bit(0, 17);
restore_vx_regs(vxrs);
}
preempt_enable();
return 0;
}
void vector_exception(struct pt_regs *regs)
{
int si_code, vic;
if (!MACHINE_HAS_VX) {
do_trap(regs, SIGILL, ILL_ILLOPN, "illegal operation");
return;
}
/* get vector interrupt code from fpc */
asm volatile("stfpc %0" : "=m" (current->thread.fp_regs.fpc));
vic = (current->thread.fp_regs.fpc & 0xf00) >> 8;
switch (vic) {
case 1: /* invalid vector operation */
si_code = FPE_FLTINV;
break;
case 2: /* division by zero */
si_code = FPE_FLTDIV;
break;
case 3: /* overflow */
si_code = FPE_FLTOVF;
break;
case 4: /* underflow */
si_code = FPE_FLTUND;
break;
case 5: /* inexact */
si_code = FPE_FLTRES;
break;
default: /* unknown cause */
si_code = 0;
}
do_trap(regs, SIGFPE, si_code, "vector exception");
}
static int __init disable_vector_extension(char *str)
{
S390_lowcore.machine_flags &= ~MACHINE_FLAG_VX;
return 1;
}
__setup("novx", disable_vector_extension);
#endif
void data_exception(struct pt_regs *regs) void data_exception(struct pt_regs *regs)
{ {
__u16 __user *location; __u16 __user *location;
...@@ -368,6 +438,18 @@ void data_exception(struct pt_regs *regs) ...@@ -368,6 +438,18 @@ void data_exception(struct pt_regs *regs)
} }
} }
#endif #endif
#ifdef CONFIG_64BIT
/* Check for vector register enablement */
if (MACHINE_HAS_VX && !current->thread.vxrs &&
(current->thread.fp_regs.fpc & FPC_DXC_MASK) == 0xfe00) {
alloc_vector_registers(current);
/* Vector data exception is suppressing, rewind psw. */
regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16);
clear_pt_regs_flag(regs, PIF_PER_TRAP);
return;
}
#endif
if (current->thread.fp_regs.fpc & FPC_DXC_MASK) if (current->thread.fp_regs.fpc & FPC_DXC_MASK)
signal = SIGFPE; signal = SIGFPE;
else else
......
...@@ -391,6 +391,8 @@ typedef struct elf64_shdr { ...@@ -391,6 +391,8 @@ typedef struct elf64_shdr {
#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */ #define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */ #define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */ #define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 upper half */
#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */
#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */ #define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
#define NT_ARM_TLS 0x401 /* ARM TLS register */ #define NT_ARM_TLS 0x401 /* ARM TLS register */
#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */ #define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment