Skip to content

Commit 099b765

Browse files
Frank MunzertMartin Schwidefsky
authored andcommitted
[S390] Automatic IPL after dump
Provide new shutdown action "dump_reipl" for automatic ipl after dump. Signed-off-by: Frank Munzert <munzert@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
1 parent d7fd5f1 commit 099b765

6 files changed

Lines changed: 172 additions & 26 deletions

File tree

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111

112112
#define __LC_PASTE 0xE40
113113

114-
#define __LC_PANIC_MAGIC 0xE00
114+
#define __LC_DUMP_REIPL 0xE00
115115
#ifndef __s390x__
116116
#define __LC_PFAULT_INTPARM 0x080
117117
#define __LC_CPU_TIMER_SAVE_AREA 0x0D8
@@ -286,12 +286,14 @@ struct _lowcore
286286
__u64 int_clock; /* 0xc98 */
287287
__u8 pad11[0xe00-0xca0]; /* 0xca0 */
288288

289-
/* 0xe00 is used as indicator for dump tools */
290-
/* whether the kernel died with panic() or not */
291-
__u32 panic_magic; /* 0xe00 */
289+
/* 0xe00 contains the address of the IPL Parameter */
290+
/* Information block. Dump tools need IPIB for IPL */
291+
/* after dump. */
292+
__u32 ipib; /* 0xe00 */
293+
__u32 ipib_checksum; /* 0xe04 */
292294

293295
/* Align to the top 1k of prefix area */
294-
__u8 pad12[0x1000-0xe04]; /* 0xe04 */
296+
__u8 pad12[0x1000-0xe08]; /* 0xe08 */
295297
#else /* !__s390x__ */
296298
/* prefix area: defined by architecture */
297299
__u32 ccw1[2]; /* 0x000 */
@@ -379,12 +381,14 @@ struct _lowcore
379381
__u64 int_clock; /* 0xde8 */
380382
__u8 pad12[0xe00-0xdf0]; /* 0xdf0 */
381383

382-
/* 0xe00 is used as indicator for dump tools */
383-
/* whether the kernel died with panic() or not */
384-
__u32 panic_magic; /* 0xe00 */
384+
/* 0xe00 contains the address of the IPL Parameter */
385+
/* Information block. Dump tools need IPIB for IPL */
386+
/* after dump. */
387+
__u64 ipib; /* 0xe00 */
388+
__u32 ipib_checksum; /* 0xe08 */
385389

386390
/* Per cpu primary space access list */
387-
__u8 pad_0xe04[0xe38-0xe04]; /* 0xe04 */
391+
__u8 pad_0xe0c[0xe38-0xe0c]; /* 0xe0c */
388392
__u64 vdso_per_cpu_data; /* 0xe38 */
389393
__u32 paste[16]; /* 0xe40 */
390394

@@ -433,8 +437,6 @@ static inline __u32 store_prefix(void)
433437
return address;
434438
}
435439

436-
#define __PANIC_MAGIC 0xDEADC0DE
437-
438440
#endif
439441

440442
#endif

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,22 @@ static inline unsigned short stap(void)
458458
return cpu_address;
459459
}
460460

461+
static inline u32 cksm(void *addr, unsigned long len)
462+
{
463+
register unsigned long _addr asm("0") = (unsigned long) addr;
464+
register unsigned long _len asm("1") = len;
465+
unsigned long accu = 0;
466+
467+
asm volatile(
468+
"0:\n"
469+
" cksm %0,%1\n"
470+
" jnz 0b\n"
471+
: "+d" (accu), "+d" (_addr), "+d" (_len)
472+
:
473+
: "cc", "memory");
474+
return accu;
475+
}
476+
461477
extern void (*_machine_restart)(char *command);
462478
extern void (*_machine_halt)(void);
463479
extern void (*_machine_power_off)(void);

‎arch/s390/kernel/ipl.c‎

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ struct shutdown_trigger {
5656
};
5757

5858
/*
59-
* Five shutdown action types are supported:
59+
* The following shutdown action types are supported:
6060
*/
6161
#define SHUTDOWN_ACTION_IPL_STR "ipl"
6262
#define SHUTDOWN_ACTION_REIPL_STR "reipl"
6363
#define SHUTDOWN_ACTION_DUMP_STR "dump"
6464
#define SHUTDOWN_ACTION_VMCMD_STR "vmcmd"
6565
#define SHUTDOWN_ACTION_STOP_STR "stop"
66+
#define SHUTDOWN_ACTION_DUMP_REIPL_STR "dump_reipl"
6667

6768
struct shutdown_action {
6869
char *name;
@@ -146,6 +147,7 @@ static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT;
146147
static struct ipl_parameter_block *reipl_block_fcp;
147148
static struct ipl_parameter_block *reipl_block_ccw;
148149
static struct ipl_parameter_block *reipl_block_nss;
150+
static struct ipl_parameter_block *reipl_block_actual;
149151

150152
static int dump_capabilities = DUMP_TYPE_NONE;
151153
static enum dump_type dump_type = DUMP_TYPE_NONE;
@@ -835,6 +837,7 @@ static int reipl_set_type(enum ipl_type type)
835837
reipl_method = REIPL_METHOD_CCW_VM;
836838
else
837839
reipl_method = REIPL_METHOD_CCW_CIO;
840+
reipl_block_actual = reipl_block_ccw;
838841
break;
839842
case IPL_TYPE_FCP:
840843
if (diag308_set_works)
@@ -843,6 +846,7 @@ static int reipl_set_type(enum ipl_type type)
843846
reipl_method = REIPL_METHOD_FCP_RO_VM;
844847
else
845848
reipl_method = REIPL_METHOD_FCP_RO_DIAG;
849+
reipl_block_actual = reipl_block_fcp;
846850
break;
847851
case IPL_TYPE_FCP_DUMP:
848852
reipl_method = REIPL_METHOD_FCP_DUMP;
@@ -852,6 +856,7 @@ static int reipl_set_type(enum ipl_type type)
852856
reipl_method = REIPL_METHOD_NSS_DIAG;
853857
else
854858
reipl_method = REIPL_METHOD_NSS;
859+
reipl_block_actual = reipl_block_nss;
855860
break;
856861
case IPL_TYPE_UNKNOWN:
857862
reipl_method = REIPL_METHOD_DEFAULT;
@@ -1332,6 +1337,48 @@ static struct shutdown_action __refdata dump_action = {
13321337
.init = dump_init,
13331338
};
13341339

1340+
static void dump_reipl_run(struct shutdown_trigger *trigger)
1341+
{
1342+
preempt_disable();
1343+
/*
1344+
* Bypass dynamic address translation (DAT) when storing IPL parameter
1345+
* information block address and checksum into the prefix area
1346+
* (corresponding to absolute addresses 0-8191).
1347+
* When enhanced DAT applies and the STE format control in one,
1348+
* the absolute address is formed without prefixing. In this case a
1349+
* normal store (stg/st) into the prefix area would no more match to
1350+
* absolute addresses 0-8191.
1351+
*/
1352+
#ifdef CONFIG_64BIT
1353+
asm volatile("sturg %0,%1"
1354+
:: "a" ((unsigned long) reipl_block_actual),
1355+
"a" (&lowcore_ptr[smp_processor_id()]->ipib));
1356+
#else
1357+
asm volatile("stura %0,%1"
1358+
:: "a" ((unsigned long) reipl_block_actual),
1359+
"a" (&lowcore_ptr[smp_processor_id()]->ipib));
1360+
#endif
1361+
asm volatile("stura %0,%1"
1362+
:: "a" (cksm(reipl_block_actual, reipl_block_actual->hdr.len)),
1363+
"a" (&lowcore_ptr[smp_processor_id()]->ipib_checksum));
1364+
preempt_enable();
1365+
dump_run(trigger);
1366+
}
1367+
1368+
static int __init dump_reipl_init(void)
1369+
{
1370+
if (!diag308_set_works)
1371+
return -EOPNOTSUPP;
1372+
else
1373+
return 0;
1374+
}
1375+
1376+
static struct shutdown_action __refdata dump_reipl_action = {
1377+
.name = SHUTDOWN_ACTION_DUMP_REIPL_STR,
1378+
.fn = dump_reipl_run,
1379+
.init = dump_reipl_init,
1380+
};
1381+
13351382
/*
13361383
* vmcmd shutdown action: Trigger vm command on shutdown.
13371384
*/
@@ -1421,7 +1468,8 @@ static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR,
14211468
/* action list */
14221469

14231470
static struct shutdown_action *shutdown_actions_list[] = {
1424-
&ipl_action, &reipl_action, &dump_action, &vmcmd_action, &stop_action};
1471+
&ipl_action, &reipl_action, &dump_reipl_action, &dump_action,
1472+
&vmcmd_action, &stop_action};
14251473
#define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *))
14261474

14271475
/*
@@ -1434,11 +1482,11 @@ static int set_trigger(const char *buf, struct shutdown_trigger *trigger,
14341482
size_t len)
14351483
{
14361484
int i;
1485+
14371486
for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) {
14381487
if (!shutdown_actions_list[i])
14391488
continue;
1440-
if (strncmp(buf, shutdown_actions_list[i]->name,
1441-
strlen(shutdown_actions_list[i]->name)) == 0) {
1489+
if (sysfs_streq(buf, shutdown_actions_list[i]->name)) {
14421490
trigger->action = shutdown_actions_list[i];
14431491
return len;
14441492
}

‎arch/s390/kernel/setup.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ volatile int __cpu_logical_map[NR_CPUS]; /* logical cpu to cpu address */
8686
int __initdata memory_end_set;
8787
unsigned long __initdata memory_end;
8888

89+
/* An array with a pointer to the lowcore of every CPU. */
90+
struct _lowcore *lowcore_ptr[NR_CPUS];
91+
EXPORT_SYMBOL(lowcore_ptr);
92+
8993
/*
9094
* This is set up by the setup-routine at boot-time
9195
* for S390 need to find out, what we have to setup
@@ -434,6 +438,7 @@ setup_lowcore(void)
434438
lc->vdso_per_cpu_data = (unsigned long) &lc->paste[0];
435439
#endif
436440
set_prefix((u32)(unsigned long) lc);
441+
lowcore_ptr[0] = lc;
437442
}
438443

439444
static void __init

‎arch/s390/kernel/smp.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@
5050
#include <asm/vdso.h>
5151
#include "entry.h"
5252

53-
/*
54-
* An array with a pointer the lowcore of every CPU.
55-
*/
56-
struct _lowcore *lowcore_ptr[NR_CPUS];
57-
EXPORT_SYMBOL(lowcore_ptr);
58-
5953
static struct task_struct *current_set[NR_CPUS];
6054

6155
static u8 smp_cpu_type;
@@ -82,9 +76,6 @@ void smp_send_stop(void)
8276
/* Disable all interrupts/machine checks */
8377
__load_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK);
8478

85-
/* write magic number to zero page (absolute 0) */
86-
lowcore_ptr[smp_processor_id()]->panic_magic = __PANIC_MAGIC;
87-
8879
/* stop all processors */
8980
for_each_online_cpu(cpu) {
9081
if (cpu == smp_processor_id())

‎drivers/s390/char/zcore.c‎

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* For more information please refer to Documentation/s390/zfcpdump.txt
77
*
8-
* Copyright IBM Corp. 2003,2007
8+
* Copyright IBM Corp. 2003,2008
99
* Author(s): Michael Holzheu
1010
*/
1111

@@ -48,12 +48,19 @@ struct sys_info {
4848
union save_area lc_mask;
4949
};
5050

51+
struct ipib_info {
52+
unsigned long ipib;
53+
u32 checksum;
54+
} __attribute__((packed));
55+
5156
static struct sys_info sys_info;
5257
static struct debug_info *zcore_dbf;
5358
static int hsa_available;
5459
static struct dentry *zcore_dir;
5560
static struct dentry *zcore_file;
5661
static struct dentry *zcore_memmap_file;
62+
static struct dentry *zcore_reipl_file;
63+
static struct ipl_parameter_block *ipl_block;
5764

5865
/*
5966
* Copy memory from HSA to kernel or user memory (not reentrant):
@@ -527,6 +534,33 @@ static const struct file_operations zcore_memmap_fops = {
527534
.release = zcore_memmap_release,
528535
};
529536

537+
static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
538+
size_t count, loff_t *ppos)
539+
{
540+
if (ipl_block) {
541+
diag308(DIAG308_SET, ipl_block);
542+
diag308(DIAG308_IPL, NULL);
543+
}
544+
return count;
545+
}
546+
547+
static int zcore_reipl_open(struct inode *inode, struct file *filp)
548+
{
549+
return 0;
550+
}
551+
552+
static int zcore_reipl_release(struct inode *inode, struct file *filp)
553+
{
554+
return 0;
555+
}
556+
557+
static const struct file_operations zcore_reipl_fops = {
558+
.owner = THIS_MODULE,
559+
.write = zcore_reipl_write,
560+
.open = zcore_reipl_open,
561+
.release = zcore_reipl_release,
562+
};
563+
530564

531565
static void __init set_s390_lc_mask(union save_area *map)
532566
{
@@ -645,6 +679,39 @@ static int __init zcore_header_init(int arch, struct zcore_header *hdr)
645679
return 0;
646680
}
647681

682+
/*
683+
* Provide IPL parameter information block from either HSA or memory
684+
* for future reipl
685+
*/
686+
static int __init zcore_reipl_init(void)
687+
{
688+
struct ipib_info ipib_info;
689+
int rc;
690+
691+
rc = memcpy_hsa_kernel(&ipib_info, __LC_DUMP_REIPL, sizeof(ipib_info));
692+
if (rc)
693+
return rc;
694+
if (ipib_info.ipib == 0)
695+
return 0;
696+
ipl_block = (void *) __get_free_page(GFP_KERNEL);
697+
if (!ipl_block)
698+
return -ENOMEM;
699+
if (ipib_info.ipib < ZFCPDUMP_HSA_SIZE)
700+
rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE);
701+
else
702+
rc = memcpy_real(ipl_block, ipib_info.ipib, PAGE_SIZE);
703+
if (rc) {
704+
free_page((unsigned long) ipl_block);
705+
return rc;
706+
}
707+
if (cksm(ipl_block, ipl_block->hdr.len) != ipib_info.checksum) {
708+
TRACE("Checksum does not match\n");
709+
free_page((unsigned long) ipl_block);
710+
ipl_block = NULL;
711+
}
712+
return 0;
713+
}
714+
648715
static int __init zcore_init(void)
649716
{
650717
unsigned char arch;
@@ -690,6 +757,10 @@ static int __init zcore_init(void)
690757
if (rc)
691758
goto fail;
692759

760+
rc = zcore_reipl_init();
761+
if (rc)
762+
goto fail;
763+
693764
zcore_dir = debugfs_create_dir("zcore" , NULL);
694765
if (!zcore_dir) {
695766
rc = -ENOMEM;
@@ -707,9 +778,17 @@ static int __init zcore_init(void)
707778
rc = -ENOMEM;
708779
goto fail_file;
709780
}
781+
zcore_reipl_file = debugfs_create_file("reipl", S_IRUSR, zcore_dir,
782+
NULL, &zcore_reipl_fops);
783+
if (!zcore_reipl_file) {
784+
rc = -ENOMEM;
785+
goto fail_memmap_file;
786+
}
710787
hsa_available = 1;
711788
return 0;
712789

790+
fail_memmap_file:
791+
debugfs_remove(zcore_memmap_file);
713792
fail_file:
714793
debugfs_remove(zcore_file);
715794
fail_dir:
@@ -723,10 +802,15 @@ static void __exit zcore_exit(void)
723802
{
724803
debug_unregister(zcore_dbf);
725804
sclp_sdias_exit();
805+
free_page((unsigned long) ipl_block);
806+
debugfs_remove(zcore_reipl_file);
807+
debugfs_remove(zcore_memmap_file);
808+
debugfs_remove(zcore_file);
809+
debugfs_remove(zcore_dir);
726810
diag308(DIAG308_REL_HSA, NULL);
727811
}
728812

729-
MODULE_AUTHOR("Copyright IBM Corp. 2003,2007");
813+
MODULE_AUTHOR("Copyright IBM Corp. 2003,2008");
730814
MODULE_DESCRIPTION("zcore module for zfcpdump support");
731815
MODULE_LICENSE("GPL");
732816

0 commit comments

Comments
 (0)