zdump: Drop support of 32-bit dump architecture

- Initialize dump and dump-tool architecture to DFI_ARCH_64 at the start
  of dfi_init() and dt_init() respectively.
- Bail out if any dump architecture other than ARCH_64 has been detected
  in s390_ext or s390mv_ext DASD dump header.
- Remove redundant dfi_arch_set() and dt_arch_set() functions.
- Get rid of l.arch local variables in dfi* and dt* source files and
  drop dfi_arch() function.
- Drop the usage of DFI_ARCH_32 and compeletely remove DFI_ARCH_UNKNOWN.
- Drop special register and lowcore processing functions used
  for DFI_ARCH_32.
- Drop df_s390_from_dfi_arch() and df_s390_to_dfi_arch() funcitons.
- Update the man file for zgetdump.

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>
This commit is contained in:
Mikhail Zaslonko
2024-11-04 12:05:52 +01:00
committed by Jan Höppner
parent ee4cb78dc2
commit f821a3c174
20 changed files with 29 additions and 204 deletions

View File

@@ -26,11 +26,10 @@
*/
static int check_addr_max(struct df_s390_hdr *hdr, u64 addr_max)
{
unsigned int i, lc_size;
unsigned int i;
lc_size = dfi_lc_size(df_s390_to_dfi_arch(hdr->arch));
for (i = 0; i < hdr->cpu_cnt; i++) {
if (hdr->lc_vec[i] + lc_size > addr_max)
if (hdr->lc_vec[i] + LOWCORE_SIZE > addr_max)
return -1;
}
return 0;
@@ -91,11 +90,10 @@ void df_s390_hdr_add(struct df_s390_hdr *hdr)
dfi_attr_time_set(&timeval);
}
dfi_attr_version_set(hdr->version);
dfi_arch_set(df_s390_to_dfi_arch(hdr->arch));
if (hdr->cpu_id)
dfi_attr_cpu_id_set(hdr->cpu_id);
if (hdr->build_arch)
dfi_attr_build_arch_set(df_s390_to_dfi_arch(hdr->build_arch));
dfi_attr_build_arch_set(DFI_ARCH_64);
if (hdr->mem_size_real)
dfi_attr_mem_size_real_set(hdr->mem_size_real);
if (hdr->real_cpu_cnt)

View File

@@ -19,22 +19,6 @@
#include "dt.h"
#include "zg.h"
/*
* Convert DFI arch to s390 arch
*/
static inline enum df_s390_arch df_s390_from_dfi_arch(enum dfi_arch dfi_arch)
{
return dfi_arch == DFI_ARCH_64 ? DF_S390_ARCH_64 : DF_S390_ARCH_32;
}
/*
* Convert s390 arch to DFI arch
*/
static inline enum dfi_arch df_s390_to_dfi_arch(enum df_s390_arch df_s390_arch)
{
return df_s390_arch == DF_S390_ARCH_64 ? DFI_ARCH_64 : DFI_ARCH_32;
}
/*
* Dump tool structure
*/

View File

@@ -81,7 +81,6 @@ struct attr {
* File local static data
*/
static struct {
enum dfi_arch arch;
struct attr attr;
struct cpus cpus;
struct dfi *dfi;
@@ -133,7 +132,7 @@ void dfi_info_print(void)
if (l.attr.build_arch)
STDERR(" Build arch.........: %s\n",
dfi_arch_str(*l.attr.build_arch));
STDERR(" System arch........: %s\n", dfi_arch_str(l.arch));
STDERR(" System arch........: %s\n", dfi_arch_str(DFI_ARCH_64));
if (l.cpus.cnt)
STDERR(" CPU count (online).: %u\n", l.cpus.cnt);
if (l.attr.real_cpu_cnt)
@@ -240,22 +239,6 @@ int dfi_cpu_content_fac_check(int flags)
return l.cpus.fac & flags;
}
/*
* Set DFI architecture
*/
void dfi_arch_set(enum dfi_arch arch)
{
l.arch = arch;
}
/*
* Return DFI architecture
*/
enum dfi_arch dfi_arch(void)
{
return l.arch;
}
/*
* Return DFI CPU list
*/
@@ -298,8 +281,6 @@ const char *dfi_arch_str(enum dfi_arch arch)
return "s390 (32 bit)";
case DFI_ARCH_64:
return "s390x (64 bit)";
case DFI_ARCH_UNKNOWN:
return "unknown";
}
ABORT("dfi_arch_str: Invalid dfi arch: %d", arch);
return NULL; /* UNREACHABLE */
@@ -481,48 +462,6 @@ unsigned int *dfi_attr_real_cpu_cnt(void)
return l.attr.real_cpu_cnt;
}
/*
* Convert 32 bit CPU register set to 64 bit
*/
static void cpu_32_to_64(struct dfi_cpu *cpu_64, struct dfi_cpu_32 *cpu_32)
{
int i;
for (i = 0; i < 16; i++) {
cpu_64->gprs[i] = cpu_32->gprs[i];
cpu_64->ctrs[i] = cpu_32->ctrs[i];
cpu_64->acrs[i] = cpu_32->acrs[i];
if (i < 4)
cpu_64->fprs[i] = cpu_32->fprs[i];
}
cpu_64->psw[0] = cpu_32->psw[0];
cpu_64->psw[1] = cpu_32->psw[1];
cpu_64->prefix = cpu_32->prefix;
cpu_64->timer = cpu_32->timer;
cpu_64->todcmp = cpu_32->todcmp;
}
/*
* Convert 64 bit CPU register set to 32 bit
*/
void dfi_cpu_64_to_32(struct dfi_cpu_32 *cpu_32, struct dfi_cpu *cpu_64)
{
int i;
for (i = 0; i < 16; i++) {
cpu_32->gprs[i] = (u32) cpu_64->gprs[i];
cpu_32->ctrs[i] = (u32) cpu_64->ctrs[i];
cpu_32->acrs[i] = (u32) cpu_64->acrs[i];
if (i < 4)
cpu_32->fprs[i] = (u32) cpu_64->fprs[i];
}
cpu_32->psw[0] = (u32) cpu_64->psw[0];
cpu_32->psw[1] = (u32) cpu_64->psw[1];
cpu_32->prefix = cpu_64->prefix;
cpu_32->timer = cpu_64->timer;
cpu_32->todcmp = cpu_64->todcmp;
}
/*
* Copy 64 bit lowcore to internal register set
*/
@@ -554,21 +493,6 @@ static void lc2cpu_64(struct dfi_cpu *cpu, struct dfi_lowcore_64 *lc)
dfi_cpu_content_fac_add(DFI_CPU_CONTENT_FAC_VX);
}
/*
* Copy 32 bit lowcore to internal 32 bit cpu
*/
static void lc2cpu_32(struct dfi_cpu_32 *cpu, struct dfi_lowcore_32 *lc)
{
memcpy(&cpu->gprs, lc->gpregs_save_area, sizeof(cpu->gprs));
memcpy(&cpu->ctrs, lc->cregs_save_area, sizeof(cpu->ctrs));
memcpy(&cpu->acrs, lc->access_regs_save_area, sizeof(cpu->acrs));
memcpy(&cpu->fprs, lc->floating_pt_save_area, sizeof(cpu->fprs));
memcpy(&cpu->psw, lc->st_status_fixed_logout, sizeof(cpu->psw));
memcpy(&cpu->prefix, &lc->prefixreg_save_area, sizeof(cpu->prefix));
memcpy(&cpu->timer, lc->timer_save_area, sizeof(cpu->timer));
memcpy(&cpu->todcmp, lc->clock_comp_save_area, sizeof(cpu->todcmp));
}
/*
* Initialize and add a new CPU with given lowcore pointer
*
@@ -578,6 +502,7 @@ static void lc2cpu_32(struct dfi_cpu_32 *cpu, struct dfi_lowcore_32 *lc)
int dfi_cpu_add_from_lc(u32 lc_addr)
{
struct dfi_cpu *cpu = dfi_cpu_alloc();
struct dfi_lowcore_64 lc;
cpu->cpu_id = l.cpus.cnt;
switch (l.cpus.content) {
@@ -585,19 +510,9 @@ int dfi_cpu_add_from_lc(u32 lc_addr)
cpu->prefix = lc_addr;
break;
case DFI_CPU_CONTENT_ALL:
if (l.arch == DFI_ARCH_32) {
struct dfi_cpu_32 cpu_32;
struct dfi_lowcore_32 lc;
if (dfi_mem_virt_read(lc_addr, &lc, sizeof(lc)))
return -EINVAL;
lc2cpu_32(&cpu_32, &lc);
cpu_32_to_64(cpu, &cpu_32);
} else {
struct dfi_lowcore_64 lc;
if (dfi_mem_virt_read(lc_addr, &lc, sizeof(lc)))
return -EINVAL;
lc2cpu_64(cpu, &lc);
}
if (dfi_mem_virt_read(lc_addr, &lc, sizeof(lc)))
return -EINVAL;
lc2cpu_64(cpu, &lc);
break;
case DFI_CPU_CONTENT_NONE:
ABORT("dfi_cpu_add_from_lc() called for CONTENT_NONE");
@@ -613,8 +528,6 @@ int dfi_cpu_lc_has_vx_sa(void *_lc)
{
struct dfi_lowcore_64 *lc = _lc;
if (l.arch == DFI_ARCH_32)
return 0;
if (lc->vector_save_area_addr == 0)
return 0;
if (lc->vector_save_area_addr % 1024 != 0)
@@ -700,7 +613,6 @@ static void kdump_select_prod_init(void)
ERR_EXIT("The \"--select\" option is not possible with this "
"dump");
attr_init();
dfi_arch_set(DFI_ARCH_64);
dfi_cpu_info_init(DFI_CPU_CONTENT_NONE);
if (dfi_vmcoreinfo_symbol(&ptr, "lowcore_ptr"))
return;
@@ -797,7 +709,6 @@ int dfi_init(void)
util_log_print(UTIL_LOG_TRACE, "DFI initialization\n");
l.arch = DFI_ARCH_UNKNOWN;
rc = dfi_mem_chunk_init();
if (rc)
return rc;

View File

@@ -25,7 +25,6 @@
enum dfi_arch {
DFI_ARCH_32 = 0,
DFI_ARCH_64 = 1,
DFI_ARCH_UNKNOWN = 2,
};
struct dfi_lowcore_32 {
@@ -72,14 +71,6 @@ struct dfi_lowcore_64 {
u8 pad_0x1400[0x2000-0x1400]; /* 0x1400 */
} __packed;
static inline u64 dfi_lc_size(enum dfi_arch arch)
{
if (arch == DFI_ARCH_64)
return 0x2000;
else
return 0x1000;
}
struct dfi_vxrs {
u64 low;
u64 high;
@@ -126,8 +117,6 @@ struct dfi_cpu_32 {
void dfi_cpu_64_to_32(struct dfi_cpu_32 *cpu_32, struct dfi_cpu *cpu_64);
enum dfi_arch dfi_arch(void);
void dfi_arch_set(enum dfi_arch arch);
const char *dfi_arch_str(enum dfi_arch arch);
enum dfi_cpu_content {

View File

@@ -111,18 +111,16 @@ static int detect_mem_chunks(int check)
}
/*
* Return architecture of running system
* Verify architecture of running system
*/
static enum dfi_arch system_arch(void)
static void check_system_arch(void)
{
struct utsname utsname;
uname(&utsname);
if (memcmp(utsname.machine, "s390x", 5) == 0)
return DFI_ARCH_64;
if (memcmp(utsname.machine, "s390", 4) == 0)
return DFI_ARCH_32;
return DFI_ARCH_UNKNOWN;
if (memcmp(utsname.machine, "s390x", 5) != 0)
ERR_EXIT("Dump architecture \"%s\" is not supported",
utsname.machine);
}
/*
@@ -133,7 +131,8 @@ static int dfi_devmem_init(void)
if (strcmp(g.fh->path, "/dev/mem") != 0 &&
strcmp(g.fh->path, "/dev/crash") != 0)
return -ENODEV;
dfi_arch_set(system_arch());
check_system_arch();
dfi_cpu_info_init(DFI_CPU_CONTENT_NONE);
detect_mem_chunks(0);
dfi_attr_dump_method_set(DFI_DUMP_METHOD_LIVE);

View File

@@ -248,7 +248,6 @@ static int dfi_elf_init(void)
goto free_ehdr;
df_elf_ensure_s390x();
dfi_arch_set(DFI_ARCH_64);
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
phdrs = read_elf_phdrs(g.fh, ehdr, &phnum);

View File

@@ -111,7 +111,6 @@ static int init_kdump_hdr(struct df_kdump_hdr *hdr)
dfi_attr_real_cpu_cnt_set(hdr->nr_cpus);
dfi_attr_utsname_set(&hdr->utsname);
dfi_attr_time_set(&hdr->timestamp);
dfi_arch_set(DFI_ARCH_64);
dfi_mem_chunk_add(0, (unsigned long) hdr->max_mapnr * PAGE_SIZE,
NULL, NULL, NULL);
return 0;

View File

@@ -312,11 +312,7 @@ static int read_lkcd_hdr(void)
/* Read asm header */
zg_seek(g.fh, l.hdr.hdr_size, ZG_CHECK);
zg_read(g.fh, &l.hdr_asm, sizeof(l.hdr_asm), ZG_CHECK);
if (strncmp(l.hdr.utsname_machine, "s390x", sizeof("s390x")) == 0)
dfi_arch_set(DFI_ARCH_64);
else if (strncmp(l.hdr.utsname_machine, "s390", sizeof("s390")) == 0)
dfi_arch_set(DFI_ARCH_32);
else
if (strncmp(l.hdr.utsname_machine, "s390x", sizeof("s390x")) != 0)
ERR_EXIT("Dump architecture \"%s\" is not supported",
l.hdr.utsname_machine);
if (l.hdr_asm.magic == DF_LKCD_MAGIC_ASM)

View File

@@ -239,7 +239,6 @@ static int dfi_pv_elf_init(void)
return -ENODEV;
df_elf_ensure_s390x();
dfi_arch_set(DFI_ARCH_64);
dfi_cpu_info_init(DFI_CPU_CONTENT_ALL);
/* Try to read the customer communication key */

View File

@@ -198,6 +198,8 @@ static int read_s390_hdr(void)
return -ENODEV;
if (l.hdr.magic != magic_number)
return -ENODEV;
if (l.hdr.arch != DF_S390_ARCH_64)
ERR_EXIT("Dump architecture is not supported!");
if (l.hdr.cpu_cnt > DF_S390_CPU_MAX)
return -ENODEV;
if (l.hdr.zlib_version_s390 && l.hdr.version != 2)

View File

@@ -501,6 +501,8 @@ static int dfi_s390mv_ext_init(void)
volumes_init();
if (vol_online_check() != 0)
zg_exit(1);
if (l.hdr.arch != DF_S390_ARCH_64)
ERR_EXIT("Dump architecture is not supported!");
if (l.hdr.mem_size == 0)
return -ENODEV;
df_s390_hdr_add(&l.hdr);
@@ -531,7 +533,6 @@ int dt_s390mv_ext_init(void)
if (open_dump() != 0)
return -ENODEV;
volumes_init();
dt_arch_set(DFI_ARCH_64);
dt_version_set(l.dumper.version);
dt_attr_mem_limit_set(l.dumper.mem);
dt_attr_force_set(l.dumper.force);

View File

@@ -488,7 +488,6 @@ static int dfi_vmdump_init(void)
vmdump64big_init();
dfi_attr_version_set(l.fir.fir_format);
dfi_arch_set(DFI_ARCH_64);
dfi_attr_real_cpu_cnt_set(l.fir.online_cpus + 1);
mem_init();
cpu_init();

View File

@@ -112,17 +112,6 @@ static void dump_chunks_init(void *hdr, u64 hdr_size)
}
}
/*
* ELF DFO is only supported for 64 bit (s390x)
*/
static void ensure_s390x(void)
{
if (dfi_arch() != DFI_ARCH_64)
ERR_EXIT("Error: The ELF dump format is only supported for "
"s390x source dumps");
df_elf_ensure_s390x();
}
/*
* Initialize ELF output dump format
*/
@@ -133,7 +122,7 @@ static void dfo_elf_init(void)
void *buf, *ptr;
u64 hdr_off;
ensure_s390x();
df_elf_ensure_s390x();
alloc_size = HDR_BASE_SIZE + dfi_cpu_cnt() * get_max_note_size_per_cpu() +
dfi_mem_chunk_cnt() * HDR_PER_MEMC_SIZE;
buf = zg_alloc(alloc_size);

View File

@@ -50,25 +50,6 @@ static void cpu2lc_64(void *lc_64, struct dfi_cpu *cpu)
memcpy(lc->clock_comp_save_area, &cpu->todcmp, sizeof(cpu->todcmp));
}
/*
* Copy internal register set to 32 bit lowcore
*/
static void cpu2lc_32(void *lc_32, struct dfi_cpu *cpu_64)
{
struct dfi_lowcore_32 *lc = lc_32;
struct dfi_cpu_32 cpu;
dfi_cpu_64_to_32(&cpu, cpu_64);
memcpy(lc->gpregs_save_area, &cpu.gprs, sizeof(cpu.gprs));
memcpy(lc->cregs_save_area, &cpu.ctrs, sizeof(cpu.ctrs));
memcpy(lc->access_regs_save_area, &cpu.acrs, sizeof(cpu.acrs));
memcpy(lc->floating_pt_save_area, &cpu.fprs, sizeof(cpu.fprs));
memcpy(lc->st_status_fixed_logout, &cpu.psw, sizeof(cpu.psw));
memcpy(&lc->prefixreg_save_area, &cpu.prefix, sizeof(cpu.prefix));
memcpy(lc->timer_save_area, &cpu.timer, sizeof(cpu.timer));
memcpy(lc->clock_comp_save_area, &cpu.todcmp, sizeof(cpu.todcmp));
}
/*
* Convert timeval to s390 TOD clock
*/
@@ -106,10 +87,7 @@ static void dfo_s390_dump_chunk_lc_fn(struct dfo_chunk *dump_chunk,
if (dfi_mem_virt_read(cpu->prefix + off, &lc[off], cnt))
return;
if (dfi_arch() == DFI_ARCH_64)
cpu2lc_64(lc, cpu);
else
cpu2lc_32(lc, cpu);
cpu2lc_64(lc, cpu);
memcpy(buf, &lc[off], cnt);
}
@@ -135,18 +113,16 @@ static void add_cpu_to_dfo(struct dfi_cpu *cpu)
if (dfi_cpu_content() != DFI_CPU_CONTENT_ALL)
return;
if (!dfi_mem_range_valid(cpu->prefix, dfi_lc_size(dfi_arch()))) {
if (!dfi_mem_range_valid(cpu->prefix, LOWCORE_SIZE)) {
STDERR("Info: Could not read CPU prefix page: %x\n",
cpu->prefix);
return;
}
/* Add lowcore to memory */
dfo_chunk_add(cpu->prefix + DF_S390_HDR_SIZE,
dfi_lc_size(dfi_arch()), cpu,
LOWCORE_SIZE, cpu,
dfo_s390_dump_chunk_lc_fn);
/* Add VX save area to memory */
if (dfi_arch() != DFI_ARCH_64)
return;
if (!dfi_cpu_content_fac_check(DFI_CPU_CONTENT_FAC_VX))
return;
if (dfi_mem_virt_read(cpu->prefix, &lc, sizeof(lc)))
@@ -239,9 +215,9 @@ static void df_s390_dump_init(void)
dh->mem_end = dfi_mem_end();
dh->mem_size = dh->mem_end + 1;
dh->num_pages = dh->mem_size / PAGE_SIZE;
dh->arch = df_s390_from_dfi_arch(dfi_arch());
dh->arch = DF_S390_ARCH_64;
if (dfi_attr_build_arch())
dh->build_arch = df_s390_from_dfi_arch(*dfi_attr_build_arch());
dh->build_arch = DF_S390_ARCH_64;
dh->cpu_cnt = dfi_cpu_cnt();
if (dfi_cpu_content() == DFI_CPU_CONTENT_NONE)
dh->cpu_cnt = 0;

View File

@@ -38,7 +38,6 @@ struct attr {
*/
static struct {
int version;
enum dfi_arch arch;
struct attr attr;
struct dt *dt;
} l;
@@ -74,7 +73,7 @@ void dt_info_print(void)
STDERR("Dump device info:\n");
STDERR(" Dump tool.........: %s\n", l.dt->desc);
STDERR(" Version...........: %d\n", l.version);
STDERR(" Architecture......: %s\n", dfi_arch_str(l.arch));
STDERR(" Architecture......: %s\n", dfi_arch_str(DFI_ARCH_64));
if (l.attr.dasd_type)
STDERR(" DASD type.........: %s\n", l.attr.dasd_type);
@@ -97,14 +96,6 @@ void dt_info_print(void)
}
}
/*
* Set DT architecture
*/
void dt_arch_set(enum dfi_arch arch)
{
l.arch = arch;
}
/*
* Set DT version
*/

View File

@@ -27,7 +27,6 @@ struct dt {
void dt_init(void);
void dt_info_print(void);
void dt_arch_set(enum dfi_arch arch);
void dt_version_set(int version);
void dt_attr_mem_limit_set(u64 mem_limit);
void dt_attr_force_set(int value);

View File

@@ -35,7 +35,6 @@ static int dt_ngdump_init(void)
if (rc)
return -1;
dt_arch_set(DFI_ARCH_64);
dt_version_set(l.meta.version);
return 0;

View File

@@ -21,7 +21,6 @@
*/
static struct {
struct df_s390_dumper dumper;
enum dfi_arch dumper_arch;
} l;
/*
@@ -58,7 +57,6 @@ static int dumper_read_fba(void)
if (strncmp(dumper->magic, DF_S390_DUMPER_MAGIC_FBA_EXT,
DF_S390_DUMPER_MAGIC_SIZE) != 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);
@@ -95,8 +93,6 @@ static int dt_s390sv_ext_init(void)
{
if (sv_dumper_read() != 0)
return -ENODEV;
l.dumper_arch = DFI_ARCH_64;
dt_arch_set(l.dumper_arch);
dt_version_set(l.dumper.version);
dt_attr_mem_limit_set(l.dumper.mem);
return 0;

View File

@@ -128,7 +128,6 @@ static int dt_scsi_init(void)
return -1;
if (check_boot_info(&mbr.boot_info))
return -1;
dt_arch_set(DFI_ARCH_64);
dt_version_set(l.sb.version);
return 0;
}

View File

@@ -256,7 +256,7 @@ The kernel version of the Linux system.
Architecture (s390 or s390x) on which the dump tool was built.
.TP
.BR "System arch"
Architecture (s390 or s390x) of the Linux system.
Architecture of the Linux system (currently only s390x is possible).
.TP
.BR "CPU count (online)"
Number of online CPUs.
@@ -304,7 +304,7 @@ Name of the dump tool.
Version of the dump tool.
.TP
.BR "Architecture"
Architecture (s390 or s390x) of the dump tool.
Architecture of the dump tool (currently only s390x is possible).
.TP
.BR "DASD type"
Type of the DASD where the dump tool is installed (ECKD or FBA).