Files
s390-tools/zdump/dt_s390sv.c
T
Mikhail Zaslonko 2c5d4073a7 zdump: Drop support of obsolete dumps and dumpers
Drop support of obsolete dump and dump-tool versions (single-volume DASD,
FBA and Tape) in order to simplify zgetdump logic:
- CCW dumpers written in assembler instructions as well as stage2 dumpers
  of size less than 0x3000 (STAGE2_DUMPER_SIZE_V1 or STAGE2_DUMPER_SIZE_V2)
  haven't been used for years. Remove its traces completely as a cleanup.
  Keep the last version (version 5) of non-extended DASD dumper as well as
  newer extended DASD dumpers.
- Rename STAGE2_DUMPER_SIZE_V3 and STAGE2_DUMPER_SIZE_ZLIB constants.
- Drop support of non-extended s390 dumps of version < 5. Dump files
  of s390 format version 5 can be still produced by zgetdump (dfo_s390).
- Drop excessive dump version checking in df_s390_cpu_info_add() and
  df_s390_hdr_add() considering that obsolete s390 dumps of version lower
  than 5 no longer supported.
- Use cpu_cnt field in s390 dump header instead of the s390 dump version to
  indicate no cpu info available (DFI_CPU_CONTENT_NONE) for dfo_s390.
- Make df_s390_dumper_read() return error code upon unknown dumper
  version/magic detection.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-04-07 17:42:18 +02:00

141 lines
3.2 KiB
C

/*
* zgetdump - Tool for copying and converting System z dumps
*
* S390 single-volume DASD dump tool
*
* Copyright IBM Corp. 2001, 2018
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <errno.h>
#include <linux/fs.h>
#include "zgetdump.h"
#include "zg.h"
#include "dt.h"
#include "df_s390.h"
/*
* File local static data
*/
static struct {
struct df_s390_dumper dumper;
enum dfi_arch dumper_arch;
bool extended; /* Extended dump-tool */
} l;
/*
* Read dump tool from ECKD DASD device
*/
static int dumper_read_eckd(int blk_size)
{
if (df_s390_dumper_read(g.fh, blk_size, &l.dumper))
return -ENODEV;
if (l.extended) {
if (strncmp(l.dumper.magic, DF_S390_DUMPER_MAGIC_EXT,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
} else {
if (strncmp(l.dumper.magic, DF_S390_DUMPER_MAGIC64,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
}
l.dumper_arch = DFI_ARCH_64;
return 0;
}
/*
* Check FBA dump tool magic number and set architecture attribute
*/
static int dumper_check_fba(struct df_s390_dumper *dumper)
{
if (l.extended) {
if (strncmp(dumper->magic, DF_S390_DUMPER_MAGIC_FBA_EXT,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
} else {
if (strncmp(dumper->magic, DF_S390_DUMPER_MAGIC64_FBA,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
}
l.dumper_arch = DFI_ARCH_64;
return 0;
}
/*
* Read dump tool on FBA disk and check its magic number
*/
static int dumper_read_fba(void)
{
struct df_s390_dumper *dumper = &l.dumper;
int bytes_to_read;
/*
* On FBA device the dumper is written at the end of the volume because
* there is not enough space to place it at the beginning due to the
* linux disk layout.
* First read 2 fields at the start of the dumper. The magic number
* and the version.
*/
zg_seek_end(g.fh, -STAGE2_DUMPER_SIZE_SV, ZG_CHECK);
bytes_to_read = offsetof(struct df_s390_dumper, size);
zg_read(g.fh, dumper, bytes_to_read, ZG_CHECK);
if (dumper_check_fba(dumper) != 0)
return -ENODEV;
dumper->size = STAGE2_DUMPER_SIZE_SV;
/* Read force and mem fields in the end of the dumper */
bytes_to_read = sizeof(dumper->force) + sizeof(dumper->mem);
zg_seek_end(g.fh, -bytes_to_read, ZG_CHECK);
zg_read(g.fh, &dumper->force, bytes_to_read, ZG_CHECK);
return 0;
}
/*
* Read single volume dumper from disk
*/
static int sv_dumper_read(void)
{
int blk_size;
if (zg_type(g.fh) == ZG_TYPE_DASD_PART)
return -ENODEV;
zg_ioctl(g.fh, BLKSSZGET, &blk_size, "BLKSSZGET", ZG_CHECK);
if (dumper_read_eckd(blk_size) == 0) {
dt_attr_dasd_type_set("ECKD");
return 0;
}
if (dumper_read_fba() == 0) {
dt_attr_dasd_type_set("FBA");
return 0;
}
return -ENODEV;
}
/*
* Initialize s390 single-volume dump tool (for -d option)
*/
int dt_s390sv_init_gen(bool extended)
{
l.extended = extended;
if (sv_dumper_read() != 0)
return -ENODEV;
dt_arch_set(l.dumper_arch);
dt_version_set(l.dumper.version);
dt_attr_mem_limit_set(l.dumper.mem);
return 0;
}
static int dt_s390sv_init(void)
{
return dt_s390sv_init_gen(DUMP_NON_EXTENDED);
}
/*
* s390 single-volume DT (non-extended) operations
*/
struct dt dt_s390sv = {
.desc = "Single-volume DASD dump tool",
.init = dt_s390sv_init,
};