mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
For the stage2 of zipl's boot loaders only 3 heap pages are available
[0x6000, 0x6000 + 0x3000]. Therefore, stage2 code needs to be very careful
when and for how long it allocates a heap page.
The heap OOM problem in stage2 was hidden until the commit 252be376
("zipl/boot: fix potential heap overflow in stage2"). Before this commit,
stage2 assumed that heap is 4 pages large which is apparently very wrong
but get_zeroed_page() still allowed allocating an extra 4th page by
overriding the memory segment following the heap area of stage2 (stage3
parameter area).
Try to avoid allocating a heap page and keeping it allocated over a long
period of time in the DASD dumpers. Free a heap page as soon as possible
if not required anymore.
And be extra careful with printf() because it always tries to allocate
a free heap page.
Fixes: 252be376 ("zipl/boot: fix potential heap overflow in stage2")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
/*
|
|
* zipl - zSeries Initial Program Loader tool
|
|
*
|
|
* Common ECKD dump I/O functions
|
|
*
|
|
* Copyright IBM Corp. 2013, 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.
|
|
*/
|
|
#ifndef ECKD2DUMP_H
|
|
#define ECKD2DUMP_H
|
|
|
|
#include "cio.h"
|
|
#include "stage2dump.h"
|
|
|
|
struct eckd_device {
|
|
uint32_t blk_start;
|
|
uint32_t blk_end;
|
|
uint16_t blk_size;
|
|
uint8_t num_heads;
|
|
uint8_t bpt;
|
|
struct subchannel_id sid;
|
|
uint16_t devno;
|
|
};
|
|
|
|
extern struct eckd_device device;
|
|
extern unsigned long eckd_blk_max;
|
|
|
|
/*
|
|
* Convert memory size to number of blocks
|
|
*/
|
|
static inline unsigned long m2b(unsigned long mem)
|
|
{
|
|
return mem / device.blk_size;
|
|
}
|
|
|
|
/*
|
|
* Convert number of blocks to memory size
|
|
*/
|
|
static inline unsigned long b2m(unsigned long blk)
|
|
{
|
|
return blk * device.blk_size;
|
|
}
|
|
|
|
void stage2dump_eckd_init();
|
|
void writeblock(unsigned long blk, unsigned long addr, unsigned long blk_count,
|
|
unsigned long zero_page);
|
|
void readblock(unsigned long blk, unsigned long addr, unsigned long blk_count);
|
|
unsigned long write_dump_segment(unsigned long blk,
|
|
struct df_s390_dump_segm_hdr *segm);
|
|
|
|
#endif /* ECKD2DUMP_H */
|