Skip to content

Commit 0b642ed

Browse files
oberparLinus Torvalds
authored andcommitted
[PATCH] s390: default storage key
Provide an easy way to define a non-zero storage key at compile time. This is useful for debugging purposes. Signed-off-by: Martin Schwidefsky <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c9e3735 commit 0b642ed

8 files changed

Lines changed: 41 additions & 16 deletions

File tree

arch/s390/kernel/s390_ksyms.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ EXPORT_SYMBOL(__clear_user_asm);
3434
EXPORT_SYMBOL(__strncpy_from_user_asm);
3535
EXPORT_SYMBOL(__strnlen_user_asm);
3636
EXPORT_SYMBOL(diag10);
37-
EXPORT_SYMBOL(default_storage_key);
3837

3938
/*
4039
* semaphore ops

arch/s390/kernel/setup.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include <asm/cpcmd.h>
4545
#include <asm/lowcore.h>
4646
#include <asm/irq.h>
47+
#include <asm/page.h>
48+
#include <asm/ptrace.h>
4749

4850
/*
4951
* Machine setup..
@@ -53,7 +55,6 @@ unsigned int console_devno = -1;
5355
unsigned int console_irq = -1;
5456
unsigned long memory_size = 0;
5557
unsigned long machine_flags = 0;
56-
unsigned int default_storage_key = 0;
5758
struct {
5859
unsigned long addr, size, type;
5960
} memory_chunk[MEMORY_CHUNKS] = { { 0 } };
@@ -402,7 +403,7 @@ setup_lowcore(void)
402403
lc = (struct _lowcore *)
403404
__alloc_bootmem(lc_pages * PAGE_SIZE, lc_pages * PAGE_SIZE, 0);
404405
memset(lc, 0, lc_pages * PAGE_SIZE);
405-
lc->restart_psw.mask = PSW_BASE_BITS;
406+
lc->restart_psw.mask = PSW_BASE_BITS | PSW_DEFAULT_KEY;
406407
lc->restart_psw.addr =
407408
PSW_ADDR_AMODE | (unsigned long) restart_int_handler;
408409
lc->external_new_psw.mask = PSW_KERNEL_BITS;
@@ -470,7 +471,7 @@ static void __init
470471
setup_memory(void)
471472
{
472473
unsigned long bootmap_size;
473-
unsigned long start_pfn, end_pfn;
474+
unsigned long start_pfn, end_pfn, init_pfn;
474475
unsigned long last_rw_end;
475476
int i;
476477

@@ -481,6 +482,10 @@ setup_memory(void)
481482
start_pfn = (__pa(&_end) + PAGE_SIZE - 1) >> PAGE_SHIFT;
482483
end_pfn = max_pfn = memory_end >> PAGE_SHIFT;
483484

485+
/* Initialize storage key for kernel pages */
486+
for (init_pfn = 0 ; init_pfn < start_pfn; init_pfn++)
487+
page_set_storage_key(init_pfn << PAGE_SHIFT, PAGE_DEFAULT_KEY);
488+
484489
/*
485490
* Initialize the boot-time allocator (with low memory only):
486491
*/
@@ -491,7 +496,7 @@ setup_memory(void)
491496
*/
492497
last_rw_end = start_pfn;
493498

494-
for (i = 0; i < 16 && memory_chunk[i].size > 0; i++) {
499+
for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
495500
unsigned long start_chunk, end_chunk;
496501

497502
if (memory_chunk[i].type != CHUNK_READ_WRITE)
@@ -505,6 +510,11 @@ setup_memory(void)
505510
if (end_chunk > end_pfn)
506511
end_chunk = end_pfn;
507512
if (start_chunk < end_chunk) {
513+
/* Initialize storage key for RAM pages */
514+
for (init_pfn = start_chunk ; init_pfn < end_chunk;
515+
init_pfn++)
516+
page_set_storage_key(init_pfn << PAGE_SHIFT,
517+
PAGE_DEFAULT_KEY);
508518
free_bootmem(start_chunk << PAGE_SHIFT,
509519
(end_chunk - start_chunk) << PAGE_SHIFT);
510520
if (last_rw_end < start_chunk)
@@ -513,6 +523,8 @@ setup_memory(void)
513523
}
514524
}
515525

526+
psw_set_key(PAGE_DEFAULT_KEY);
527+
516528
if (last_rw_end < end_pfn - 1)
517529
add_memory_hole(last_rw_end, end_pfn - 1);
518530

drivers/s390/cio/cio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* drivers/s390/cio/cio.c
33
* S/390 common I/O routines -- low level i/o calls
4-
* $Revision: 1.131 $
4+
* $Revision: 1.133 $
55
*
66
* Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
77
* IBM Corporation
@@ -228,7 +228,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */
228228
int
229229
cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
230230
{
231-
return cio_start_key(sch, cpa, lpm, default_storage_key);
231+
return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
232232
}
233233

234234
/*

drivers/s390/cio/device_ops.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* drivers/s390/cio/device_ops.c
33
*
4-
* $Revision: 1.55 $
4+
* $Revision: 1.56 $
55
*
66
* Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
77
* IBM Corporation
@@ -128,7 +128,7 @@ ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa,
128128
unsigned long intparm, __u8 lpm, unsigned long flags)
129129
{
130130
return ccw_device_start_key(cdev, cpa, intparm, lpm,
131-
default_storage_key, flags);
131+
PAGE_DEFAULT_KEY, flags);
132132
}
133133

134134
int
@@ -137,7 +137,7 @@ ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa,
137137
int expires)
138138
{
139139
return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm,
140-
default_storage_key, flags,
140+
PAGE_DEFAULT_KEY, flags,
141141
expires);
142142
}
143143

drivers/s390/cio/qdio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef _CIO_QDIO_H
22
#define _CIO_QDIO_H
33

4-
#define VERSION_CIO_QDIO_H "$Revision: 1.26 $"
4+
#include <asm/page.h>
5+
6+
#define VERSION_CIO_QDIO_H "$Revision: 1.32 $"
57

68
#ifdef CONFIG_QDIO_DEBUG
79
#define QDIO_VERBOSE_LEVEL 9
@@ -42,7 +44,7 @@
4244

4345
#define QDIO_Q_LAPS 5
4446

45-
#define QDIO_STORAGE_KEY 0
47+
#define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
4648

4749
#define L2_CACHELINE_SIZE 256
4850
#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))

include/asm-s390/page.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define PAGE_SHIFT 12
1717
#define PAGE_SIZE (1UL << PAGE_SHIFT)
1818
#define PAGE_MASK (~(PAGE_SIZE-1))
19+
#define PAGE_DEFAULT_ACC 0
20+
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
1921

2022
#ifdef __KERNEL__
2123
#ifndef __ASSEMBLY__

include/asm-s390/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static inline void enabled_wait(void)
245245
psw_t wait_psw;
246246

247247
wait_psw.mask = PSW_BASE_BITS | PSW_MASK_IO | PSW_MASK_EXT |
248-
PSW_MASK_MCHECK | PSW_MASK_WAIT;
248+
PSW_MASK_MCHECK | PSW_MASK_WAIT | PSW_DEFAULT_KEY;
249249
#ifndef __s390x__
250250
asm volatile (
251251
" basr %0,0\n"

include/asm-s390/ptrace.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
#include <linux/stddef.h>
186186
#include <linux/types.h>
187187
#include <asm/setup.h>
188+
#include <asm/page.h>
188189

189190
typedef union
190191
{
@@ -235,6 +236,7 @@ typedef struct
235236
#define PSW_ADDR_INSN 0x7FFFFFFFUL
236237

237238
#define PSW_BASE_BITS 0x00080000UL
239+
#define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 20)
238240

239241
#define PSW_ASC_PRIMARY 0x00000000UL
240242
#define PSW_ASC_ACCREG 0x00004000UL
@@ -260,6 +262,7 @@ typedef struct
260262

261263
#define PSW_BASE_BITS 0x0000000180000000UL
262264
#define PSW_BASE32_BITS 0x0000000080000000UL
265+
#define PSW_DEFAULT_KEY (((unsigned long) PAGE_DEFAULT_ACC) << 52)
263266

264267
#define PSW_ASC_PRIMARY 0x0000000000000000UL
265268
#define PSW_ASC_ACCREG 0x0000400000000000UL
@@ -268,14 +271,15 @@ typedef struct
268271

269272
#define PSW_USER32_BITS (PSW_BASE32_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \
270273
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \
271-
PSW_MASK_PSTATE)
274+
PSW_MASK_PSTATE | PSW_DEFAULT_KEY)
272275

273276
#endif /* __s390x__ */
274277

275-
#define PSW_KERNEL_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY)
278+
#define PSW_KERNEL_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_PRIMARY | \
279+
PSW_DEFAULT_KEY)
276280
#define PSW_USER_BITS (PSW_BASE_BITS | PSW_MASK_DAT | PSW_ASC_HOME | \
277281
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK | \
278-
PSW_MASK_PSTATE)
282+
PSW_MASK_PSTATE | PSW_DEFAULT_KEY)
279283

280284
/* This macro merges a NEW PSW mask specified by the user into
281285
the currently active PSW mask CURRENT, modifying only those
@@ -470,6 +474,12 @@ struct user_regs_struct
470474
extern void show_regs(struct pt_regs * regs);
471475
#endif
472476

477+
static inline void
478+
psw_set_key(unsigned int key)
479+
{
480+
asm volatile ( "spka 0(%0)" : : "d" (key) );
481+
}
482+
473483
#endif /* __ASSEMBLY__ */
474484

475485
#endif /* _S390_PTRACE_H */

0 commit comments

Comments
 (0)