Skip to content

Commit 3ab121a

Browse files
Michael HolzheuMartin Schwidefsky
authored andcommitted
[S390] kernel: Add z/VM LGR detection
Currently the following mechanisms are available to move active Linux on System z instances between machines: * z/VM 6.2 SSI (Single System Image) * Suspend/resume For moving Linux instances in this patch the term LGR (Linux Guest Relocation) is used. Because such an operation is critical, it should be detectable from Linux. With this patch for both, a live system and a kernel dump, the information about LGRs is accessible. To identify a guest, stsi and stfle data is used. A new function lgr_info_log() compares the current data (lgr_info_cur) with the last recorded one (lgr_info_last). In case the two data sets differ, lgr_info_cur is logged to the "lgr" s390dbf. The following trigger points call lgr_info_log(): * panic * die * kdump * LGR timer * PSW restart * QDIO recovery * resume This patch also changes the s390dbf hex_ascii view. Now only printable ASCII characters are shown. Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent fde15c3 commit 3ab121a

13 files changed

Lines changed: 297 additions & 31 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ void debug_unregister(debug_info_t* id);
131131

132132
void debug_set_level(debug_info_t* id, int new_level);
133133

134+
void debug_set_critical(void);
134135
void debug_stop_all(void);
135136

136137
static inline debug_entry_t*

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,6 @@ enum diag308_rc {
169169
extern int diag308(unsigned long subcode, void *addr);
170170
extern void diag308_reset(void);
171171
extern void store_status(void);
172+
extern void lgr_info_log(void);
172173

173174
#endif /* _ASM_S390_IPL_H */

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
#ifndef __ASM_SYSTEM_H
88
#define __ASM_SYSTEM_H
99

10+
#include <linux/preempt.h>
1011
#include <linux/kernel.h>
1112
#include <linux/errno.h>
13+
#include <linux/string.h>
1214
#include <asm/types.h>
1315
#include <asm/ptrace.h>
1416
#include <asm/setup.h>
@@ -248,6 +250,38 @@ static inline int test_facility(unsigned long nr)
248250
return (*ptr & (0x80 >> (nr & 7))) != 0;
249251
}
250252

253+
/**
254+
* stfle - Store facility list extended
255+
* @stfle_fac_list: array where facility list can be stored
256+
* @size: size of passed in array in double words
257+
*/
258+
static inline void stfle(u64 *stfle_fac_list, int size)
259+
{
260+
unsigned long nr;
261+
262+
preempt_disable();
263+
S390_lowcore.stfl_fac_list = 0;
264+
asm volatile(
265+
" .insn s,0xb2b10000,0(0)\n" /* stfl */
266+
"0:\n"
267+
EX_TABLE(0b, 0b)
268+
: "=m" (S390_lowcore.stfl_fac_list));
269+
nr = 4; /* bytes stored by stfl */
270+
memcpy(stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
271+
if (S390_lowcore.stfl_fac_list & 0x01000000) {
272+
/* More facility bits available with stfle */
273+
register unsigned long reg0 asm("0") = size - 1;
274+
275+
asm volatile(".insn s,0xb2b00000,0(%1)" /* stfle */
276+
: "+d" (reg0)
277+
: "a" (stfle_fac_list)
278+
: "memory", "cc");
279+
nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
280+
}
281+
memset((char *) stfle_fac_list + nr, 0, size * 8 - nr);
282+
preempt_enable();
283+
}
284+
251285
static inline unsigned short stap(void)
252286
{
253287
unsigned short cpu_address;

‎arch/s390/kernel/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w
2323
obj-y := bitmap.o traps.o time.o process.o base.o early.o setup.o vtime.o \
2424
processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o \
2525
debug.o irq.o ipl.o dis.o diag.o mem_detect.o sclp.o vdso.o \
26-
sysinfo.o jump_label.o
26+
sysinfo.o jump_label.o lgr.o
2727

2828
obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o)
2929
obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o)

‎arch/s390/kernel/debug.c‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* arch/s390/kernel/debug.c
33
* S/390 debug facility
44
*
5-
* Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
6-
* IBM Corporation
5+
* Copyright IBM Corp. 1999, 2012
6+
*
77
* Author(s): Michael Holzheu (holzheu@de.ibm.com),
88
* Holger Smolinski (Holger.Smolinski@de.ibm.com)
99
*
@@ -167,6 +167,7 @@ static debug_info_t *debug_area_last = NULL;
167167
static DEFINE_MUTEX(debug_mutex);
168168

169169
static int initialized;
170+
static int debug_critical;
170171

171172
static const struct file_operations debug_file_ops = {
172173
.owner = THIS_MODULE,
@@ -932,6 +933,11 @@ debug_stop_all(void)
932933
}
933934

934935

936+
void debug_set_critical(void)
937+
{
938+
debug_critical = 1;
939+
}
940+
935941
/*
936942
* debug_event_common:
937943
* - write debug entry with given size
@@ -945,7 +951,11 @@ debug_event_common(debug_info_t * id, int level, const void *buf, int len)
945951

946952
if (!debug_active || !id->areas)
947953
return NULL;
948-
spin_lock_irqsave(&id->lock, flags);
954+
if (debug_critical) {
955+
if (!spin_trylock_irqsave(&id->lock, flags))
956+
return NULL;
957+
} else
958+
spin_lock_irqsave(&id->lock, flags);
949959
active = get_active_entry(id);
950960
memset(DEBUG_DATA(active), 0, id->buf_size);
951961
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
@@ -968,7 +978,11 @@ debug_entry_t
968978

969979
if (!debug_active || !id->areas)
970980
return NULL;
971-
spin_lock_irqsave(&id->lock, flags);
981+
if (debug_critical) {
982+
if (!spin_trylock_irqsave(&id->lock, flags))
983+
return NULL;
984+
} else
985+
spin_lock_irqsave(&id->lock, flags);
972986
active = get_active_entry(id);
973987
memset(DEBUG_DATA(active), 0, id->buf_size);
974988
memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
@@ -1013,7 +1027,11 @@ debug_sprintf_event(debug_info_t* id, int level,char *string,...)
10131027
return NULL;
10141028
numargs=debug_count_numargs(string);
10151029

1016-
spin_lock_irqsave(&id->lock, flags);
1030+
if (debug_critical) {
1031+
if (!spin_trylock_irqsave(&id->lock, flags))
1032+
return NULL;
1033+
} else
1034+
spin_lock_irqsave(&id->lock, flags);
10171035
active = get_active_entry(id);
10181036
curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active);
10191037
va_start(ap,string);
@@ -1047,7 +1065,11 @@ debug_sprintf_exception(debug_info_t* id, int level,char *string,...)
10471065

10481066
numargs=debug_count_numargs(string);
10491067

1050-
spin_lock_irqsave(&id->lock, flags);
1068+
if (debug_critical) {
1069+
if (!spin_trylock_irqsave(&id->lock, flags))
1070+
return NULL;
1071+
} else
1072+
spin_lock_irqsave(&id->lock, flags);
10511073
active = get_active_entry(id);
10521074
curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active);
10531075
va_start(ap,string);
@@ -1428,10 +1450,10 @@ debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
14281450
rc += sprintf(out_buf + rc, "| ");
14291451
for (i = 0; i < id->buf_size; i++) {
14301452
unsigned char c = in_buf[i];
1431-
if (!isprint(c))
1432-
rc += sprintf(out_buf + rc, ".");
1433-
else
1453+
if (isascii(c) && isprint(c))
14341454
rc += sprintf(out_buf + rc, "%c", c);
1455+
else
1456+
rc += sprintf(out_buf + rc, ".");
14351457
}
14361458
rc += sprintf(out_buf + rc, "\n");
14371459
return rc;

‎arch/s390/kernel/early.c‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <asm/sysinfo.h>
3030
#include <asm/cpcmd.h>
3131
#include <asm/sclp.h>
32+
#include <asm/system.h>
3233
#include "entry.h"
3334

3435
/*
@@ -262,25 +263,8 @@ static noinline __init void setup_lowcore_early(void)
262263

263264
static noinline __init void setup_facility_list(void)
264265
{
265-
unsigned long nr;
266-
267-
S390_lowcore.stfl_fac_list = 0;
268-
asm volatile(
269-
" .insn s,0xb2b10000,0(0)\n" /* stfl */
270-
"0:\n"
271-
EX_TABLE(0b,0b) : "=m" (S390_lowcore.stfl_fac_list));
272-
memcpy(&S390_lowcore.stfle_fac_list, &S390_lowcore.stfl_fac_list, 4);
273-
nr = 4; /* # bytes stored by stfl */
274-
if (test_facility(7)) {
275-
/* More facility bits available with stfle */
276-
register unsigned long reg0 asm("0") = MAX_FACILITY_BIT/64 - 1;
277-
asm volatile(".insn s,0xb2b00000,%0" /* stfle */
278-
: "=m" (S390_lowcore.stfle_fac_list), "+d" (reg0)
279-
: : "cc");
280-
nr = (reg0 + 1) * 8; /* # bytes stored by stfle */
281-
}
282-
memset((char *) S390_lowcore.stfle_fac_list + nr, 0,
283-
MAX_FACILITY_BIT/8 - nr);
266+
stfle(S390_lowcore.stfle_fac_list,
267+
ARRAY_SIZE(S390_lowcore.stfle_fac_list));
284268
}
285269

286270
static noinline __init void setup_hpage(void)

‎arch/s390/kernel/ipl.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/fs.h>
1818
#include <linux/gfp.h>
1919
#include <linux/crash_dump.h>
20+
#include <linux/debug_locks.h>
2021
#include <asm/ipl.h>
2122
#include <asm/smp.h>
2223
#include <asm/setup.h>
@@ -26,6 +27,7 @@
2627
#include <asm/reset.h>
2728
#include <asm/sclp.h>
2829
#include <asm/checksum.h>
30+
#include <asm/debug.h>
2931
#include "entry.h"
3032

3133
#define IPL_PARM_BLOCK_VERSION 0
@@ -1692,6 +1694,7 @@ static struct kobj_attribute on_panic_attr =
16921694

16931695
static void do_panic(void)
16941696
{
1697+
lgr_info_log();
16951698
on_panic_trigger.action->fn(&on_panic_trigger);
16961699
stop_run(&on_panic_trigger);
16971700
}
@@ -1729,6 +1732,9 @@ static void __do_restart(void *ignore)
17291732

17301733
void do_restart(void)
17311734
{
1735+
tracing_off();
1736+
debug_locks_off();
1737+
lgr_info_log();
17321738
smp_call_online_cpu(__do_restart, NULL);
17331739
}
17341740

0 commit comments

Comments
 (0)