summaryrefslogtreecommitdiffstats
path: root/arch/s390/include/asm/fpu-insn.h
blob: 32d2894b60ca558b1a902df99f40388109c3b754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* 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 */