From dc2e4395506956a99819484d8938e877c4c2cd88 Mon Sep 17 00:00:00 2001 From: Stefan Haberland Date: Mon, 8 Apr 2019 17:54:32 +0200 Subject: [PATCH] zipl: add dummy section for stage3 heap and stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The firmware needs to know which memory locations are used by the stage 3 loader so that it can allocate its own memory. To indicate the usage of the heap and stack area of the stage 3 loader add a dummy component to block this memory area for the firmware. Signed-off-by: Stefan Haberland Acked-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- zipl/include/zipl.h | 5 +++++ zipl/src/bootmap.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/zipl/include/zipl.h b/zipl/include/zipl.h index d127b297..6f2d1157 100644 --- a/zipl/include/zipl.h +++ b/zipl/include/zipl.h @@ -32,6 +32,11 @@ #define MAXIMUM_PARMLINE_SIZE 0x380 #define MAXIMUM_PHYSICAL_BLOCKSIZE 0x1000 +#define STAGE3_HEAP_SIZE 0x4000 +#define STAGE3_HEAP_ADDRESS 0x2000 +#define STAGE3_STACK_SIZE 0x1000 +#define STAGE3_STACK_ADDRESS 0xF000 + #define PSW_ADDRESS_MASK 0x000000007fffffffLL #define PSW_LOAD 0x0008000080000000LL #define PSW_DISABLED_WAIT 0x000a000000000000LL diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index c9418037..ec845fd2 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -391,6 +391,30 @@ add_component_buffer(int fd, void* buffer, size_t size, component_data data, } +static int +add_dummy_buffer(int fd, size_t size, address_t addr, void *component, + struct disk_info *info, struct component_loc *comp_loc) +{ + char *buffer; + int rc; + + buffer = misc_malloc(size); + if (buffer == NULL) + return -1; + + memset(buffer, 0, size); + rc = add_component_buffer(fd, buffer, size, + (component_data) (uint64_t) addr, + component, info, comp_loc, component_load); + if (rc) { + free(buffer); + return rc; + } + free(buffer); + return 0; +} + + static void print_components(const char *name[], struct component_loc *loc, int num) { @@ -520,8 +544,36 @@ add_ipl_program(int fd, struct job_ipl_data* ipl, disk_blockptr_t* program, } } ramdisk_size = stats.st_size; - if (info->type == disk_type_scsi) + if (info->type == disk_type_scsi) { flags |= STAGE3_FLAG_SCSI; + /* + * Add dummy components for stage 3 heap and stack to block the + * associated memory areas against firmware use. + */ + rc = add_dummy_buffer(fd, STAGE3_HEAP_SIZE, STAGE3_HEAP_ADDRESS, + VOID_ADD(table, offset), info, + &comp_loc[comp_nr]); + if (rc) { + error_text("Could not add stage3 HEAP dummy"); + free(table); + return rc; + } + comp_name[comp_nr] = "heap area"; + offset += sizeof(struct component_entry); + comp_nr++; + rc = add_dummy_buffer(fd, STAGE3_STACK_SIZE, + STAGE3_STACK_ADDRESS, + VOID_ADD(table, offset), info, + &comp_loc[comp_nr]); + if (rc) { + error_text("Could not add stage3 STACK dummy"); + free(table); + return rc; + } + comp_name[comp_nr] = "stack area"; + offset += sizeof(struct component_entry); + comp_nr++; + } if (ipl->is_kdump) flags |= STAGE3_FLAG_KDUMP;