Skip to content

Commit a0616cd

Browse files
committed
Disintegrate asm/system.h for S390
Disintegrate asm/system.h for S390. Signed-off-by: David Howells <dhowells@redhat.com> cc: linux-s390@vger.kernel.org
1 parent ae3a197 commit a0616cd

39 files changed

Lines changed: 369 additions & 335 deletions

‎arch/s390/crypto/crypt_s390.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define _CRYPTO_ARCH_S390_CRYPT_S390_H
1818

1919
#include <asm/errno.h>
20+
#include <asm/facility.h>
2021

2122
#define CRYPT_S390_OP_MASK 0xFF00
2223
#define CRYPT_S390_FUNC_MASK 0x00FF

‎arch/s390/include/asm/atomic.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <linux/compiler.h>
1717
#include <linux/types.h>
18-
#include <asm/system.h>
18+
#include <asm/cmpxchg.h>
1919

2020
#define ATOMIC_INIT(i) { (i) }
2121

‎arch/s390/include/asm/barrier.h‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright IBM Corp. 1999, 2009
3+
*
4+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5+
*/
6+
7+
#ifndef __ASM_BARRIER_H
8+
#define __ASM_BARRIER_H
9+
10+
/*
11+
* Force strict CPU ordering.
12+
* And yes, this is required on UP too when we're talking
13+
* to devices.
14+
*
15+
* This is very similar to the ppc eieio/sync instruction in that is
16+
* does a checkpoint syncronisation & makes sure that
17+
* all memory ops have completed wrt other CPU's ( see 7-15 POP DJB ).
18+
*/
19+
20+
#define eieio() asm volatile("bcr 15,0" : : : "memory")
21+
#define SYNC_OTHER_CORES(x) eieio()
22+
#define mb() eieio()
23+
#define rmb() eieio()
24+
#define wmb() eieio()
25+
#define read_barrier_depends() do { } while(0)
26+
#define smp_mb() mb()
27+
#define smp_rmb() rmb()
28+
#define smp_wmb() wmb()
29+
#define smp_read_barrier_depends() read_barrier_depends()
30+
#define smp_mb__before_clear_bit() smp_mb()
31+
#define smp_mb__after_clear_bit() smp_mb()
32+
33+
#define set_mb(var, value) do { var = value; mb(); } while (0)
34+
35+
#endif /* __ASM_BARRIER_H */

‎arch/s390/include/asm/ctl_reg.h‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright IBM Corp. 1999, 2009
3+
*
4+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5+
*/
6+
7+
#ifndef __ASM_CTL_REG_H
8+
#define __ASM_CTL_REG_H
9+
10+
#ifdef __s390x__
11+
12+
#define __ctl_load(array, low, high) ({ \
13+
typedef struct { char _[sizeof(array)]; } addrtype; \
14+
asm volatile( \
15+
" lctlg %1,%2,%0\n" \
16+
: : "Q" (*(addrtype *)(&array)), \
17+
"i" (low), "i" (high)); \
18+
})
19+
20+
#define __ctl_store(array, low, high) ({ \
21+
typedef struct { char _[sizeof(array)]; } addrtype; \
22+
asm volatile( \
23+
" stctg %1,%2,%0\n" \
24+
: "=Q" (*(addrtype *)(&array)) \
25+
: "i" (low), "i" (high)); \
26+
})
27+
28+
#else /* __s390x__ */
29+
30+
#define __ctl_load(array, low, high) ({ \
31+
typedef struct { char _[sizeof(array)]; } addrtype; \
32+
asm volatile( \
33+
" lctl %1,%2,%0\n" \
34+
: : "Q" (*(addrtype *)(&array)), \
35+
"i" (low), "i" (high)); \
36+
})
37+
38+
#define __ctl_store(array, low, high) ({ \
39+
typedef struct { char _[sizeof(array)]; } addrtype; \
40+
asm volatile( \
41+
" stctl %1,%2,%0\n" \
42+
: "=Q" (*(addrtype *)(&array)) \
43+
: "i" (low), "i" (high)); \
44+
})
45+
46+
#endif /* __s390x__ */
47+
48+
#define __ctl_set_bit(cr, bit) ({ \
49+
unsigned long __dummy; \
50+
__ctl_store(__dummy, cr, cr); \
51+
__dummy |= 1UL << (bit); \
52+
__ctl_load(__dummy, cr, cr); \
53+
})
54+
55+
#define __ctl_clear_bit(cr, bit) ({ \
56+
unsigned long __dummy; \
57+
__ctl_store(__dummy, cr, cr); \
58+
__dummy &= ~(1UL << (bit)); \
59+
__ctl_load(__dummy, cr, cr); \
60+
})
61+
62+
#ifdef CONFIG_SMP
63+
64+
extern void smp_ctl_set_bit(int cr, int bit);
65+
extern void smp_ctl_clear_bit(int cr, int bit);
66+
#define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
67+
#define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
68+
69+
#else
70+
71+
#define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
72+
#define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
73+
74+
#endif /* CONFIG_SMP */
75+
76+
#endif /* __ASM_CTL_REG_H */

‎arch/s390/include/asm/elf.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ typedef s390_fp_regs compat_elf_fpregset_t;
129129
typedef s390_compat_regs compat_elf_gregset_t;
130130

131131
#include <linux/sched.h> /* for task_struct */
132-
#include <asm/system.h> /* for save_access_regs */
133132
#include <asm/mmu_context.h>
134133

135134
#include <asm/vdso.h>

‎arch/s390/include/asm/exec.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright IBM Corp. 1999, 2009
3+
*
4+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5+
*/
6+
7+
#ifndef __ASM_EXEC_H
8+
#define __ASM_EXEC_H
9+
10+
extern unsigned long arch_align_stack(unsigned long sp);
11+
12+
#endif /* __ASM_EXEC_H */

‎arch/s390/include/asm/facility.h‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright IBM Corp. 1999, 2009
3+
*
4+
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5+
*/
6+
7+
#ifndef __ASM_FACILITY_H
8+
#define __ASM_FACILITY_H
9+
10+
#include <linux/string.h>
11+
#include <linux/preempt.h>
12+
#include <asm/lowcore.h>
13+
14+
#define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */
15+
16+
/*
17+
* The test_facility function uses the bit odering where the MSB is bit 0.
18+
* That makes it easier to query facility bits with the bit number as
19+
* documented in the Principles of Operation.
20+
*/
21+
static inline int test_facility(unsigned long nr)
22+
{
23+
unsigned char *ptr;
24+
25+
if (nr >= MAX_FACILITY_BIT)
26+
return 0;
27+
ptr = (unsigned char *) &S390_lowcore.stfle_fac_list + (nr >> 3);
28+
return (*ptr & (0x80 >> (nr & 7))) != 0;
29+
}
30+
31+
/**
32+
* stfle - Store facility list extended
33+
* @stfle_fac_list: array where facility list can be stored
34+
* @size: size of passed in array in double words
35+
*/
36+
static inline void stfle(u64 *stfle_fac_list, int size)
37+
{
38+
unsigned long nr;
39+
40+
preempt_disable();
41+
S390_lowcore.stfl_fac_list = 0;
42+
asm volatile(
43+
" .insn s,0xb2b10000,0(0)\n" /* stfl */
44+
"0:\n"
45+
EX_TABLE(0b, 0b)
46+
: "=m" (S390_lowcore.stfl_fac_list));
47+
nr = 4; /* bytes stored by stfl */
48+
memcpy(stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
49+
if (S390_lowcore.stfl_fac_list & 0x01000000) {
50+
/* More facility bits available with stfle */
51+
register unsigned long reg0 asm("0") = size - 1;
52+
53+
asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
54+
: "+d" (reg0)
55+
: "a" (stfle_fac_list)
56+
: "memory", "cc");
57+
nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
58+
}
59+
memset((char *) stfle_fac_list + nr, 0, size * 8 - nr);
60+
preempt_enable();
61+
}
62+
63+
#endif /* __ASM_FACILITY_H */

‎arch/s390/include/asm/mmu.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@ typedef struct {
2121
.context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \
2222
.context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list),
2323

24+
static inline int tprot(unsigned long addr)
25+
{
26+
int rc = -EFAULT;
27+
28+
asm volatile(
29+
" tprot 0(%1),0\n"
30+
"0: ipm %0\n"
31+
" srl %0,28\n"
32+
"1:\n"
33+
EX_TABLE(0b,1b)
34+
: "+d" (rc) : "a" (addr) : "cc");
35+
return rc;
36+
}
37+
2438
#endif

‎arch/s390/include/asm/mmu_context.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/pgalloc.h>
1313
#include <asm/uaccess.h>
1414
#include <asm/tlbflush.h>
15+
#include <asm/ctl_reg.h>
1516
#include <asm-generic/mm_hooks.h>
1617

1718
static inline int init_new_context(struct task_struct *tsk,

‎arch/s390/include/asm/processor.h‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define __ASM_S390_PROCESSOR_H
1515

1616
#include <linux/linkage.h>
17+
#include <linux/irqflags.h>
1718
#include <asm/cpu.h>
1819
#include <asm/page.h>
1920
#include <asm/ptrace.h>
@@ -156,6 +157,14 @@ unsigned long get_wchan(struct task_struct *p);
156157
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->psw.addr)
157158
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->gprs[15])
158159

160+
static inline unsigned short stap(void)
161+
{
162+
unsigned short cpu_address;
163+
164+
asm volatile("stap %0" : "=m" (cpu_address));
165+
return cpu_address;
166+
}
167+
159168
/*
160169
* Give up the time slice of the virtual PU.
161170
*/
@@ -303,6 +312,21 @@ static inline void __noreturn disabled_wait(unsigned long code)
303312
while (1);
304313
}
305314

315+
/*
316+
* Use to set psw mask except for the first byte which
317+
* won't be changed by this function.
318+
*/
319+
static inline void
320+
__set_psw_mask(unsigned long mask)
321+
{
322+
__load_psw_mask(mask | (arch_local_save_flags() & ~(-1UL >> 8)));
323+
}
324+
325+
#define local_mcck_enable() \
326+
__set_psw_mask(psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK)
327+
#define local_mcck_disable() \
328+
__set_psw_mask(psw_kernel_bits | PSW_MASK_DAT)
329+
306330
/*
307331
* Basic Machine Check/Program Check Handler.
308332
*/

0 commit comments

Comments
 (0)