Commit fd2527f2 authored by Heiko Carstens's avatar Heiko Carstens

s390/fpu: move, rename, and merge header files

Move, rename, and merge the fpu and vx header files. This way fpu header
files have a consistent naming scheme (fpu*.h).

Also get rid of the fpu subdirectory and move header files to asm
directory, so that all fpu and vx header files can be found at the same
location.

Merge internal.h header file into other header files, since the internal
helpers are used at many locations. so those helper functions are really
not internal.
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 31d3ec15
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/sizes.h> #include <linux/sizes.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include "chacha-s390.h" #include "chacha-s390.h"
static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src, static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/nospec-insn.h> #include <asm/nospec-insn.h>
#include <asm/vx-insn.h> #include <asm/fpu-insn.h>
#define SP %r15 #define SP %r15
#define FRAME (16 * 8 + 4 * 8) #define FRAME (16 * 8 + 4 * 8)
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/cpufeature.h> #include <linux/cpufeature.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <crypto/internal/hash.h> #include <crypto/internal/hash.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#define CRC32_BLOCK_SIZE 1 #define CRC32_BLOCK_SIZE 1
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/nospec-insn.h> #include <asm/nospec-insn.h>
#include <asm/vx-insn.h> #include <asm/fpu-insn.h>
/* Vector register range containing CRC-32 constants */ /* Vector register range containing CRC-32 constants */
#define CONST_R1R2 %v9 #define CONST_R1R2 %v9
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/nospec-insn.h> #include <asm/nospec-insn.h>
#include <asm/vx-insn.h> #include <asm/fpu-insn.h>
/* Vector register range containing CRC-32 constants */ /* Vector register range containing CRC-32 constants */
#define CONST_PERM_LE2BE %v9 #define CONST_PERM_LE2BE %v9
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <linux/kvm_host.h> #include <linux/kvm_host.h>
#include <linux/ftrace.h> #include <linux/ftrace.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm-generic/asm-prototypes.h> #include <asm-generic/asm-prototypes.h>
__int128_t __ashlti3(__int128_t a, int b); __int128_t __ashlti3(__int128_t a, int b);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/processor.h> #include <linux/processor.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/timex.h> #include <asm/timex.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm/pai.h> #include <asm/pai.h>
#define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP) #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP)
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
*/ */
#ifndef __ASM_S390_VX_INSN_INTERNAL_H #ifndef __ASM_S390_FPU_INSN_ASM_H
#define __ASM_S390_VX_INSN_INTERNAL_H #define __ASM_S390_FPU_INSN_ASM_H
#ifndef __ASM_S390_VX_INSN_H #ifndef __ASM_S390_FPU_INSN_H
#error only <asm/vx-insn.h> can be included directly #error only <asm/fpu-insn.h> can be included directly
#endif #endif
#ifdef __ASSEMBLY__ #ifdef __ASSEMBLY__
...@@ -700,4 +700,4 @@ ...@@ -700,4 +700,4 @@
.endm .endm
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __ASM_S390_VX_INSN_INTERNAL_H */ #endif /* __ASM_S390_FPU_INSN_ASM_H */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Support for Floating Point and Vector Instructions
*
*/
#ifndef __ASM_S390_FPU_INSN_H
#define __ASM_S390_FPU_INSN_H
#include <asm/fpu-insn-asm.h>
#ifndef __ASSEMBLY__
#include <asm/asm-extable.h>
asm(".include \"asm/fpu-insn-asm.h\"\n");
/**
* sfpc_safe - Set floating point control register safely.
* @fpc: new value for floating point control register
*
* Set floating point control register. This may lead to an exception,
* since a saved value may have been modified by user space (ptrace,
* signal return, kvm registers) to an invalid value. In such a case
* set the floating point control register to zero.
*/
static inline void sfpc_safe(u32 fpc)
{
asm volatile("\n"
"0: sfpc %[fpc]\n"
"1: nopr %%r7\n"
".pushsection .fixup, \"ax\"\n"
"2: lghi %[fpc],0\n"
" jg 0b\n"
".popsection\n"
EX_TABLE(1b, 2b)
: [fpc] "+d" (fpc)
: : "memory");
}
#endif /* __ASSEMBLY__ */
#endif /* __ASM_S390_FPU_INSN_H */
...@@ -41,40 +41,26 @@ ...@@ -41,40 +41,26 @@
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
*/ */
#ifndef _ASM_S390_FPU_API_H #ifndef _ASM_S390_FPU_H
#define _ASM_S390_FPU_API_H #define _ASM_S390_FPU_H
#include <linux/processor.h>
#include <linux/preempt.h> #include <linux/preempt.h>
#include <asm/asm-extable.h> #include <linux/string.h>
#include <asm/fpu/internal.h> #include <asm/sigcontext.h>
#include <asm/fpu-types.h>
#include <asm/fpu-insn.h>
#include <asm/facility.h>
static inline bool cpu_has_vx(void)
{
return likely(test_facility(129));
}
void save_fpu_regs(void); void save_fpu_regs(void);
void load_fpu_regs(void); void load_fpu_regs(void);
void __load_fpu_regs(void); void __load_fpu_regs(void);
/**
* sfpc_safe - Set floating point control register safely.
* @fpc: new value for floating point control register
*
* Set floating point control register. This may lead to an exception,
* since a saved value may have been modified by user space (ptrace,
* signal return, kvm registers) to an invalid value. In such a case
* set the floating point control register to zero.
*/
static inline void sfpc_safe(u32 fpc)
{
asm volatile("\n"
"0: sfpc %[fpc]\n"
"1: nopr %%r7\n"
".pushsection .fixup, \"ax\"\n"
"2: lghi %[fpc],0\n"
" jg 0b\n"
".popsection\n"
EX_TABLE(1b, 2b)
: [fpc] "+d" (fpc)
: : "memory");
}
#define KERNEL_FPC 1 #define KERNEL_FPC 1
#define KERNEL_VXR_V0V7 2 #define KERNEL_VXR_V0V7 2
#define KERNEL_VXR_V8V15 4 #define KERNEL_VXR_V8V15 4
...@@ -88,8 +74,6 @@ static inline void sfpc_safe(u32 fpc) ...@@ -88,8 +74,6 @@ static inline void sfpc_safe(u32 fpc)
#define KERNEL_VXR (KERNEL_VXR_LOW | KERNEL_VXR_HIGH) #define KERNEL_VXR (KERNEL_VXR_LOW | KERNEL_VXR_HIGH)
#define KERNEL_FPR (KERNEL_FPC | KERNEL_VXR_LOW) #define KERNEL_FPR (KERNEL_FPC | KERNEL_VXR_LOW)
struct kernel_fpu;
/* /*
* Note the functions below must be called with preemption disabled. * Note the functions below must be called with preemption disabled.
* Do not enable preemption before calling __kernel_fpu_end() to prevent * Do not enable preemption before calling __kernel_fpu_end() to prevent
...@@ -124,4 +108,48 @@ static inline void kernel_fpu_end(struct kernel_fpu *state, u32 flags) ...@@ -124,4 +108,48 @@ static inline void kernel_fpu_end(struct kernel_fpu *state, u32 flags)
preempt_enable(); preempt_enable();
} }
#endif /* _ASM_S390_FPU_API_H */ static inline void save_vx_regs(__vector128 *vxrs)
{
asm volatile("\n"
" 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" (*(struct vx_array *)vxrs) : : "1");
}
static inline void convert_vx_to_fp(freg_t *fprs, __vector128 *vxrs)
{
int i;
for (i = 0; i < __NUM_FPRS; i++)
fprs[i].ui = vxrs[i].high;
}
static inline void convert_fp_to_vx(__vector128 *vxrs, freg_t *fprs)
{
int i;
for (i = 0; i < __NUM_FPRS; i++)
vxrs[i].high = fprs[i].ui;
}
static inline void fpregs_store(_s390_fp_regs *fpregs, struct fpu *fpu)
{
fpregs->pad = 0;
fpregs->fpc = fpu->fpc;
if (cpu_has_vx())
convert_vx_to_fp((freg_t *)&fpregs->fprs, fpu->vxrs);
else
memcpy((freg_t *)&fpregs->fprs, fpu->fprs, sizeof(fpregs->fprs));
}
static inline void fpregs_load(_s390_fp_regs *fpregs, struct fpu *fpu)
{
fpu->fpc = fpregs->fpc;
if (cpu_has_vx())
convert_fp_to_vx(fpu->vxrs, (freg_t *)&fpregs->fprs);
else
memcpy(fpu->fprs, (freg_t *)&fpregs->fprs, sizeof(fpregs->fprs));
}
#endif /* _ASM_S390_FPU_H */
/* SPDX-License-Identifier: GPL-2.0 */
/*
* FPU state and register content conversion primitives
*
* Copyright IBM Corp. 2015
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
*/
#ifndef _ASM_S390_FPU_INTERNAL_H
#define _ASM_S390_FPU_INTERNAL_H
#include <linux/string.h>
#include <asm/facility.h>
#include <asm/fpu/types.h>
static inline bool cpu_has_vx(void)
{
return likely(test_facility(129));
}
static inline void save_vx_regs(__vector128 *vxrs)
{
asm volatile("\n"
" 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" (*(struct vx_array *)vxrs) : : "1");
}
static inline void convert_vx_to_fp(freg_t *fprs, __vector128 *vxrs)
{
int i;
for (i = 0; i < __NUM_FPRS; i++)
fprs[i].ui = vxrs[i].high;
}
static inline void convert_fp_to_vx(__vector128 *vxrs, freg_t *fprs)
{
int i;
for (i = 0; i < __NUM_FPRS; i++)
vxrs[i].high = fprs[i].ui;
}
static inline void fpregs_store(_s390_fp_regs *fpregs, struct fpu *fpu)
{
fpregs->pad = 0;
fpregs->fpc = fpu->fpc;
if (cpu_has_vx())
convert_vx_to_fp((freg_t *)&fpregs->fprs, fpu->vxrs);
else
memcpy((freg_t *)&fpregs->fprs, fpu->fprs, sizeof(fpregs->fprs));
}
static inline void fpregs_load(_s390_fp_regs *fpregs, struct fpu *fpu)
{
fpu->fpc = fpregs->fpc;
if (cpu_has_vx())
convert_fp_to_vx(fpu->vxrs, (freg_t *)&fpregs->fprs);
else
memcpy(fpu->fprs, (freg_t *)&fpregs->fprs, sizeof(fpregs->fprs));
}
#endif /* _ASM_S390_FPU_INTERNAL_H */
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <linux/mmu_notifier.h> #include <linux/mmu_notifier.h>
#include <asm/debug.h> #include <asm/debug.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm/isc.h> #include <asm/isc.h>
#include <asm/guarded_storage.h> #include <asm/guarded_storage.h>
......
...@@ -33,13 +33,12 @@ ...@@ -33,13 +33,12 @@
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/irqflags.h> #include <linux/irqflags.h>
#include <asm/fpu-types.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/runtime_instr.h> #include <asm/runtime_instr.h>
#include <asm/fpu/types.h>
#include <asm/fpu/internal.h>
#include <asm/irqflags.h> #include <asm/irqflags.h>
typedef long (*sys_call_ptr_t)(struct pt_regs *regs); typedef long (*sys_call_ptr_t)(struct pt_regs *regs);
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Support for Vector Instructions
*
* This wrapper header file allows to use the vector instruction macros in
* both assembler files as well as in inline assemblies in C files.
*/
#ifndef __ASM_S390_VX_INSN_H
#define __ASM_S390_VX_INSN_H
#include <asm/vx-insn-asm.h>
#ifndef __ASSEMBLY__
asm(".include \"asm/vx-insn-asm.h\"\n");
#endif /* __ASSEMBLY__ */
#endif /* __ASM_S390_VX_INSN_H */
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/lowcore.h> #include <asm/lowcore.h>
#include <asm/vdso.h> #include <asm/vdso.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include "compat_linux.h" #include "compat_linux.h"
#include "compat_ptrace.h" #include "compat_ptrace.h"
#include "entry.h" #include "entry.h"
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <asm/ipl.h> #include <asm/ipl.h>
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/maccess.h> #include <asm/maccess.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y))) #define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y)))
#define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y))) #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <linux/memblock.h> #include <linux/memblock.h>
#include <asm/access-regs.h> #include <asm/access-regs.h>
#include <asm/fpu/api.h>
#include <asm/diag.h> #include <asm/diag.h>
#include <asm/ebcdic.h> #include <asm/ebcdic.h>
#include <asm/fpu.h>
#include <asm/ipl.h> #include <asm/ipl.h>
#include <asm/lowcore.h> #include <asm/lowcore.h>
#include <asm/processor.h> #include <asm/processor.h>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/sigp.h> #include <asm/sigp.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/vx-insn.h> #include <asm/fpu-insn.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/nospec-insn.h> #include <asm/nospec-insn.h>
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/fpu/types.h> #include <asm/fpu.h>
#include <asm/fpu/api.h>
#include <asm/vx-insn.h>
void __kernel_fpu_begin(struct kernel_fpu *state, u32 flags) void __kernel_fpu_begin(struct kernel_fpu *state, u32 flags)
{ {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <asm/guarded_storage.h> #include <asm/guarded_storage.h>
#include <asm/pfault.h> #include <asm/pfault.h>
#include <asm/cio.h> #include <asm/cio.h>
#include <asm/fpu.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/ipl.h> #include <asm/ipl.h>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <asm/lowcore.h> #include <asm/lowcore.h>
#include <asm/ctlreg.h> #include <asm/ctlreg.h>
#include <asm/fpu.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/stp.h> #include <asm/stp.h>
#include <asm/cputime.h> #include <asm/cputime.h>
...@@ -30,8 +31,6 @@ ...@@ -30,8 +31,6 @@
#include <asm/crw.h> #include <asm/crw.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/pai.h> #include <asm/pai.h>
#include <asm/vx-insn.h>
#include <asm/fpu/api.h>
struct mcck_struct { struct mcck_struct {
unsigned int kill_task : 1; unsigned int kill_task : 1;
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/bug.h> #include <linux/bug.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm/fpu/types.h>
u64 perf_reg_value(struct pt_regs *regs, int idx) u64 perf_reg_value(struct pt_regs *regs, int idx)
{ {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/vtimer.h> #include <asm/vtimer.h>
#include <asm/exec.h> #include <asm/exec.h>
#include <asm/fpu.h>
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/smp.h> #include <asm/smp.h>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/runtime_instr.h> #include <asm/runtime_instr.h>
#include <asm/facility.h> #include <asm/facility.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include "entry.h" #include "entry.h"
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <asm/pfault.h> #include <asm/pfault.h>
#include <asm/diag.h> #include <asm/diag.h>
#include <asm/facility.h> #include <asm/facility.h>
#include <asm/fpu.h>
#include <asm/ipl.h> #include <asm/ipl.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/irq.h> #include <asm/irq.h>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <asm/sysinfo.h> #include <asm/sysinfo.h>
#include <asm/cpcmd.h> #include <asm/cpcmd.h>
#include <asm/topology.h> #include <asm/topology.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
int topology_max_mnest; int topology_max_mnest;
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/entry-common.h> #include <linux/entry-common.h>
#include <asm/asm-extable.h> #include <asm/asm-extable.h>
#include <asm/fpu/api.h>
#include <asm/vtime.h> #include <asm/vtime.h>
#include <asm/fpu.h>
#include "entry.h" #include "entry.h"
static inline void __user *get_trap_ip(struct pt_regs *regs) static inline void __user *get_trap_ip(struct pt_regs *regs)
......
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/cpacf.h> #include <asm/cpacf.h>
#include <asm/timex.h> #include <asm/timex.h>
#include <asm/fpu.h>
#include <asm/ap.h> #include <asm/ap.h>
#include <asm/uv.h> #include <asm/uv.h>
#include <asm/fpu/api.h>
#include "kvm-s390.h" #include "kvm-s390.h"
#include "gaccess.h" #include "gaccess.h"
#include "pci.h" #include "pci.h"
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <asm/sclp.h> #include <asm/sclp.h>
#include <asm/nmi.h> #include <asm/nmi.h>
#include <asm/dis.h> #include <asm/dis.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm/facility.h> #include <asm/facility.h>
#include "kvm-s390.h" #include "kvm-s390.h"
#include "gaccess.h" #include "gaccess.h"
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
*/ */
#include <linux/raid/pq.h> #include <linux/raid/pq.h>
#include <asm/fpu/api.h> #include <asm/fpu.h>
#include <asm/vx-insn.h>
#define NSIZE 16 #define NSIZE 16
......
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