Accepting request 786614 from home:markkp:branches:Base:System

- Added the following patches for bsc#1166850
  zipl: fix secure boot config handling:
  * s390-tools-sles15sp2-01-zipl-Add-missing-options-to-help-output.patch
  * s390-tools-sles15sp2-02-zipl-allow-stand-alone-secure-option-on-command-l.patch
  * s390-tools-sles15sp2-03-zipl-correct-secure-boot-config-handling.patch
  * s390-tools-sles15sp2-04-zipl-fix-zipl.conf-man-page-example-for-secure-boot.patch
- Modified the spec file so that the kernel used for the SCSI dump
  tool is named zfcpdump-image instead of zfcpdump_part.image. This
  is to match the new version of zipl that expects this new file name.
  (bsc#1166851)
- Added the following patches to implement jsc#SLE-7471, Enhanced
  tooling for kvm guest images (bsc#1165549):
  * s390-tools-sles15sp2-01-zipl-fix-Wdiscarded-qualifiers.patch
  * s390-tools-sles15sp2-02-zipl-fix-Waddress-of-packed-member.patch
  * s390-tools-sles15sp2-03-zipl-remove-some-useless-__packed___-attributes.patch
  * s390-tools-sles15sp2-04-zipl-Fix-entry-point-for-stand-alone-kdump.patch
  * s390-tools-sles15sp2-05-zipl-Fix-dependency-generation-in-zipl-boot.patch
  * s390-tools-sles15sp2-06-zipl-Make-use-of-__packed-macro.patch
  * s390-tools-sles15sp2-07-zipl-define-__section-macro-and-make-use-of-it.patch
  * s390-tools-sles15sp2-08-zipl-Make-use-of-__noreturn-macro.patch
  * s390-tools-sles15sp2-09-zipl-Define-__noinline-macro-and-make-use-of-it.patch
  * s390-tools-sles15sp2-10-zipl-stage3-Mark-start_kernel-__noreturn.patch
  * s390-tools-sles15sp2-11-zipl-sclp-Remove-duplicate-macros.patch
  * s390-tools-sles15sp2-12-zipl-Make-address-size-mask-macros-UL.patch
  * s390-tools-sles15sp2-13-zipl-libc-Use-stdint.h-instead-of-self-defined-macro.patch
  * s390-tools-sles15sp2-14-zipl-Consolidate-IMAGE-macros.patch
  * s390-tools-sles15sp2-15-zipl-Consolidate-STAGE-2-3-macros.patch
  * s390-tools-sles15sp2-16-zipl-stfle-use-uint64_t-instead-of-u64.patch
  * s390-tools-sles15sp2-17-zipl-boot-fix-comment-in-stage3.lds.patch
  * s390-tools-sles15sp2-18-lib-zt_common-add-STATIC_ASSERT-macro.patch
  * s390-tools-sles15sp2-19-zipl-use-STATIC_ASSERT-macro-for-no-padding-verifica.patch
  * s390-tools-sles15sp2-20-Support-lib-zt_common.h-to-be-used-in-assembler-and-.patch
  * s390-tools-sles15sp2-21-zipl-move-IPL-related-definitions-into-separate-head.patch
  * s390-tools-sles15sp2-22-zipl-move-SIGP-related-functions-and-definitions-int.patch
  * s390-tools-sles15sp2-23-zipl-add-SIGP_SET_ARCHITECTURE-to-sigp.h-and-use-it.patch
  * s390-tools-sles15sp2-24-zipl-stage3-make-IPL_DEVICE-definition-consistent-wi.patch
  * s390-tools-sles15sp2-25-zipl-move-Linux-layout-definitions-into-separate-hea.patch
  * s390-tools-sles15sp2-26-zipl-tape0-use-constants-defined-in-linux_layout.h.patch
  * s390-tools-sles15sp2-27-zipl-use-STAGE3_ENTRY-for-STAGE3_LOAD_ADDRESS.patch
  * s390-tools-sles15sp2-28-zipl-move-loaders-layout-definitions-into-separate-h.patch
  * s390-tools-sles15sp2-29-zipl-s390.h-rename-inline-macro-into-__always_inline.patch
  * s390-tools-sles15sp2-30-zipl-move-__always_inline-barrier-__pa32-pa-to-zt_co.patch
  * s390-tools-sles15sp2-31-zipl-make-BLK_PWRT-unsigned-int.patch
  * s390-tools-sles15sp2-32-Consolidate-MIN-and-MAX-macros.patch
  * s390-tools-sles15sp2-33-zipl-remove-libc.h-include-in-s390.h.patch
  * s390-tools-sles15sp2-34-zipl-move-s390.h-to-include-boot-s390.h.patch
  * s390-tools-sles15sp2-35-zipl-libc-include-s390.h.patch
  * s390-tools-sles15sp2-36-include-boot-s390.h-move-panic-and-panic_notify-to-l.patch
  * s390-tools-sles15sp2-37-include-boot-s390.h-fixes-for-Werror-sign-conversion.patch
  * s390-tools-sles15sp2-38-zipl-refactor-all-EBCDIC-code-into-separate-files.patch
  * s390-tools-sles15sp2-39-zipl-sclp-add-macros-for-the-control-program-masks.patch
  * s390-tools-sles15sp2-40-zipl-sclp-add-sclp_print_ascii.patch
  * s390-tools-sles15sp2-41-zipl-libc-printf-print-on-linemode-and-ASCII-console.patch
  * s390-tools-sles15sp2-42-Consolidate-ALIGN-__ALIGN_MASK-ARRAY_SIZE-macros.patch
  * s390-tools-sles15sp2-43-genprotimg-boot-initial-bootloader-support.patch
  * s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch
  * s390-tools-sles15sp2-45-genprotimg-add-relocator-for-stage3b.patch
  * s390-tools-sles15sp2-46-README.md-remove-useless-empty-line.patch
  * s390-tools-sles15sp2-47-include-boot-s390.h-add-guard-for-struct-__vector128.patch
  * s390-tools-sles15sp2-48-genprotimg-introduce-new-tool-for-the-creation-of-PV.patch
- Added a BuildRequires for glib2-devel to support the new feature.
- Added a %dir entry for /usr/share/s390-tools/genprotimg

OBS-URL: https://build.opensuse.org/request/show/786614
OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=92
This commit is contained in:
Mark Post 2020-03-19 22:52:46 +00:00 committed by Git OBS Bridge
parent 7230df2ed5
commit 30232e2023
55 changed files with 13196 additions and 2 deletions

View File

@ -1,3 +1,4 @@
addFilter("/var/log/ts-shell")
addFilter("statically-linked-binary /usr/lib/s390-tools/.*")
addFilter("statically-linked-binary /usr/bin/read_values")
addFilter("systemd-service-without-service_.* *@.service")

View File

@ -0,0 +1,63 @@
Subject: [PATCH] [BZ 184396] zipl: Add missing options to help output
From: Stefan Haberland <sth@linux.ibm.com>
Description: zipl: fix secure boot config handling
Symptom: The config file parsing for secure boot worked not as
it was expected to be. For example a config section
setting was not evaluated properly.
It is not possible to specify command line option -S
without other options.
Additionally the man page showed an invalid example.
Problem: The config file parsing was not implemented properly.
Solution: The hierarchy of the secure boot settings in the config
file is:
defaultboot > menu > section
Allow that --secure or -S is specified on command line
without the need to allow all options on the command
line. Also ensure that the command line option
overrules the config option and correctly ensure that
secure boot is only set for SCSI devices.
Fix man page example.
Reproduction: Run zipl with a secure= setting in a configuration
section or specify -S on command line.
Upstream-ID: dcce14923c3e9615df53773d1d8a3a22cbb23b96
Problem-ID: 184396
Upstream-Description:
zipl: Add missing options to help output
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
zipl/src/zipl.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
--- a/zipl/src/zipl.c
+++ b/zipl/src/zipl.c
@@ -68,6 +68,8 @@ static const char* usage_text[] = {
"-P, --parameters PARMLINE Use specified kernel PARMLINE",
"-T, --tape TAPEDEV Install bootloader on tape device TAPEDEV",
"-s, --segment SEGMENT,ADDR Install a segment from file SEGMENT",
+"-k, --kdump=auto Install a kdump kernel that can be used as a",
+" stand-alone dump tool",
"-d, --dumpto DUMPDEV[,SIZE] Install a system dump record on tape device",
" or disk partition DUMPDEV",
"-M, --mvdump DEVLIST[,SIZE] Install a multi-volume dump record on each",
@@ -78,7 +80,12 @@ static const char* usage_text[] = {
"-n, --noninteractive Answer all confirmation questions with 'yes'",
"-V, --verbose Provide more verbose output",
"-a, --add-files Add all referenced files to bootmap file",
-" --dry-run Simulate run but don't modify IPL records"
+" --dry-run Simulate run but don't modify IPL records",
+"-S, --secure SWITCH Control the zIPL secure boot support.",
+" auto (default):",
+" Write signatures if available and supported",
+" 1: Write signatures regardless of support",
+" 0: Do not write signatures"
};

View File

@ -0,0 +1,45 @@
Subject: [PATCH] [FEAT VS1804] zipl: fix -Wdiscarded-qualifiers
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: bbc46edaf53c2c148b5c94a2414f6847f67f856a
Problem-ID: VS1804
Upstream-Description:
zipl: fix -Wdiscarded-qualifiers
Reported by GCC 9.2.1 when building with '-Wdiscarded-qualifiers'.
job.c: In function 'get_job_from_config_file':
job.c:1810:14: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/src/job.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/zipl/src/job.c
+++ b/zipl/src/job.c
@@ -1796,7 +1796,7 @@ get_job_from_config_file(struct command_
{
struct scan_token* scan;
struct scan_token* new_scan;
- char* filename;
+ const char *filename;
char *blsdir;
char* source;
int rc, scan_size;

View File

@ -0,0 +1,170 @@
Subject: [PATCH] [BZ 184396] zipl: allow stand alone secure option on command line
From: Stefan Haberland <sth@linux.ibm.com>
Description: zipl: fix secure boot config handling
Symptom: The config file parsing for secure boot worked not as
it was expected to be. For example a config section
setting was not evaluated properly.
It is not possible to specify command line option -S
without other options.
Additionally the man page showed an invalid example.
Problem: The config file parsing was not implemented properly.
Solution: The hierarchy of the secure boot settings in the config
file is:
defaultboot > menu > section
Allow that --secure or -S is specified on command line
without the need to allow all options on the command
line. Also ensure that the command line option
overrules the config option and correctly ensure that
secure boot is only set for SCSI devices.
Fix man page example.
Reproduction: Run zipl with a secure= setting in a configuration
section or specify -S on command line.
Upstream-ID: 27f6c0a167da8d08f7f3343360528528f85d661f
Problem-ID: 184396
Upstream-Description:
zipl: allow stand alone secure option on command line
Allow that --secure or -S is specified on command line without the need to
allow all options on the command line.
Also ensure that the command line option overrules the config option and
correctly ensure that secure boot is only set for SCSI devices.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
zipl/src/bootmap.c | 6 ++++++
zipl/src/job.c | 52 +++++++++++++++++++++++++---------------------------
2 files changed, 31 insertions(+), 27 deletions(-)
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -1133,6 +1133,12 @@ bootmap_create(struct job_data *job, dis
disk_get_type_name(info->type));
goto out_disk_free_info;
}
+ /* Check if secure boot was enabled only for SCSI */
+ if (job->is_secure == SECURE_BOOT_ENABLED &&
+ info->type != disk_type_scsi) {
+ error_reason("Secure boot forced for non-SCSI disk type");
+ goto out_disk_free_info;
+ }
if (verbose) {
printf("Target device information\n");
disk_print_info(info);
--- a/zipl/src/job.c
+++ b/zipl/src/job.c
@@ -72,6 +72,7 @@ struct command_line {
int add_files;
int dry_run;
int force;
+ int is_secure;
enum scan_section_type type;
};
@@ -89,6 +90,22 @@ store_option(struct command_line* cmdlin
return 0;
}
+static int
+set_secure_ipl(char *keyword, int *is_secure)
+{
+ if (strcmp(keyword, "auto") == 0) {
+ *is_secure = SECURE_BOOT_AUTO;
+ } else if (strcmp(keyword, "0") == 0) {
+ *is_secure = SECURE_BOOT_DISABLED;
+ } else if (strcmp(keyword, "1") == 0) {
+ *is_secure = SECURE_BOOT_ENABLED;
+ } else {
+ error_reason("Invalid secure boot setting '%s'",
+ keyword);
+ return -1;
+ }
+ return 0;
+}
static int
get_command_line(int argc, char* argv[], struct command_line* line)
@@ -217,9 +234,7 @@ get_command_line(int argc, char* argv[],
cmdline.menu = optarg;
break;
case 'S':
- is_keyword = 1;
- rc = store_option(&cmdline, scan_keyword_secure,
- optarg);
+ rc = set_secure_ipl(optarg, &cmdline.is_secure);
break;
case 'h':
cmdline.help = 1;
@@ -1270,27 +1285,6 @@ type_from_target(char *target, disk_type
}
static int
-set_secure_ipl(char *keyword, struct job_data *job)
-{
- if (strcmp(keyword, "auto") == 0) {
- job->is_secure = SECURE_BOOT_AUTO;
- } else if (strcmp(keyword, "0") == 0) {
- job->is_secure = SECURE_BOOT_DISABLED;
- } else if (strcmp(keyword, "1") == 0) {
- if (job->target.targettype != disk_type_scsi) {
- error_reason("Secure boot forced for non-SCSI disk type");
- return -1;
- }
- job->is_secure = SECURE_BOOT_ENABLED;
- } else {
- error_reason("Invalid secure boot setting '%s'",
- keyword);
- return -1;
- }
- return 0;
-}
-
-static int
get_job_from_section_data(char* data[], struct job_data* job, char* section)
{
int rc;
@@ -1374,7 +1368,7 @@ get_job_from_section_data(char* data[],
/* Fill in secure boot */
if (data[(int) scan_keyword_secure] != NULL) {
rc = set_secure_ipl(data[(int) scan_keyword_secure],
- job);
+ &job->is_secure);
if (rc)
return rc;
}
@@ -1538,7 +1532,7 @@ get_menu_job(struct scan_token* scan, ch
case scan_keyword_secure:
rc = set_secure_ipl(
scan[i].content.keyword.value,
- job);
+ &job->is_secure);
if (rc)
return rc;
break;
@@ -1880,7 +1874,6 @@ job_get(int argc, char* argv[], struct j
job->add_files = cmdline.add_files;
job->data.mvdump.force = cmdline.force;
job->dry_run = cmdline.dry_run;
- job->is_secure = SECURE_BOOT_AUTO;
/* Get job data from user input */
if (cmdline.help) {
job->command_line = 1;
@@ -1899,6 +1892,11 @@ job_get(int argc, char* argv[], struct j
job_free(job);
return rc;
}
+ if (cmdline.is_secure)
+ job->is_secure = cmdline.is_secure;
+ else
+ job->is_secure = job->is_secure ? : SECURE_BOOT_AUTO;
+
/* Check job data for validity */
rc = check_job_data(job);
if (rc) {

View File

@ -0,0 +1,102 @@
Subject: [PATCH] [FEAT VS1804] zipl: fix -Waddress-of-packed-member
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: aa09b292483eb2d79247260fccc2b456dee01e8d
Problem-ID: VS1804
Upstream-Description:
zipl: fix -Waddress-of-packed-member
Reported by GCC 9.2.1 when building with '-Waddress-of-packed-member'.
menu.c: In function 'menu_read':
menu.c:30:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
30 | uint16_t *configs = __stage2_params.config;
| ^~~~~~~~~~~~~~~
menu.c: In function 'menu_list':
menu.c:83:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
83 | uint16_t *configs = __stage2_params.config;
| ^~~~~~~~~~~~~~~
menu.c: In function 'menu':
menu.c:139:22: warning: taking address of packed member of 'struct boot_stage2_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
139 | uint16_t *configs = __stage2_params.config;
| ^~~~~~~~~~~~~~~
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/menu.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
--- a/zipl/boot/menu.c
+++ b/zipl/boot/menu.c
@@ -27,7 +27,6 @@ static void menu_prompt(int timeout)
static int menu_read(void)
{
char *temp_area = (char *)get_zeroed_page();
- uint16_t *configs = __stage2_params.config;
int timeout, rc, i, count = 0;
char *endptr;
int value;
@@ -60,7 +59,7 @@ static int menu_read(void)
value = ebcstrtoul((char *)temp_area, &endptr, 10);
if ((endptr != temp_area) && (value < BOOT_MENU_ENTRIES - 1) &&
- (configs[value] != 0)) {
+ (__stage2_params.config[value] != 0)) {
/* valid config found - finish */
break;
} else {
@@ -80,14 +79,13 @@ out_free_page:
static int menu_list(void)
{
- uint16_t *configs = __stage2_params.config;
char *name;
int i;
for (i = 0; i < BOOT_MENU_ENTRIES; i++) {
- if (configs[i] == 0)
+ if (__stage2_params.config[i] == 0)
continue;
- name = configs[i] + ((void *)&__stage2_params);
+ name = __stage2_params.config[i] + ((void *)&__stage2_params);
printf("%s\n", name);
if (i == 0)
printf("\n");
@@ -136,7 +134,6 @@ static int menu_param(unsigned long *val
int menu(void)
{
- uint16_t *configs = __stage2_params.config;
unsigned long value = 0;
char *cmd_line_extra;
char endstring[15];
@@ -181,11 +178,11 @@ int menu(void)
boot:
/* sanity - config entry not valid */
- if (configs[value] == 0)
+ if (__stage2_params.config[value] == 0)
panic(EINTERNAL, "%s", msg_econfig);
printf("Booting %s\n",
- (char *)(configs[value] +
+ (char *)(__stage2_params.config[value] +
(void *)&__stage2_params + TEXT_OFFSET));
/* append 'BOOT_IMAGE=<num>' to parmline */

View File

@ -0,0 +1,187 @@
Subject: [PATCH] [BZ 184396] zipl: correct secure boot config handling
From: Stefan Haberland <sth@linux.ibm.com>
Description: zipl: fix secure boot config handling
Symptom: The config file parsing for secure boot worked not as
it was expected to be. For example a config section
setting was not evaluated properly.
It is not possible to specify command line option -S
without other options.
Additionally the man page showed an invalid example.
Problem: The config file parsing was not implemented properly.
Solution: The hierarchy of the secure boot settings in the config
file is:
defaultboot > menu > section
Allow that --secure or -S is specified on command line
without the need to allow all options on the command
line. Also ensure that the command line option
overrules the config option and correctly ensure that
secure boot is only set for SCSI devices.
Fix man page example.
Reproduction: Run zipl with a secure= setting in a configuration
section or specify -S on command line.
Upstream-ID: 6f9337d1016e00f360cf4a81d39a42df5184b3a2
Problem-ID: 184396
Upstream-Description:
zipl: correct secure boot config handling
The hierarchy of the secure boot settings in the config file should be:
defaultboot > menu > section
This patch implements this hierarchy and adds a check if a valid option is
specified and prints an error message otherwise.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
zipl/include/job.h | 1 +
zipl/include/zipl.h | 1 +
zipl/src/bootmap.c | 8 +++++++-
zipl/src/job.c | 29 ++++++++++++++++++++++++++---
4 files changed, 35 insertions(+), 4 deletions(-)
--- a/zipl/include/job.h
+++ b/zipl/include/job.h
@@ -94,6 +94,7 @@ struct job_menu_entry {
char* name;
enum job_id id;
union job_menu_entry_data data;
+ int is_secure;
};
struct job_menu_data {
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -57,6 +57,7 @@
#define MAX_DUMP_VOLUMES 32
+#define SECURE_BOOT_UNDEFINED -1
#define SECURE_BOOT_DISABLED 0
#define SECURE_BOOT_ENABLED 1
#define SECURE_BOOT_AUTO 2
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -945,6 +945,7 @@ build_program_table(int fd, struct job_d
{
disk_blockptr_t* table;
int entries, component_header;
+ int is_secure;
int i;
int rc;
@@ -1016,13 +1017,18 @@ build_program_table(int fd, struct job_d
component_header_ipl;
printf("\n");
}
+ if (job->is_secure != SECURE_BOOT_UNDEFINED)
+ is_secure = job->is_secure;
+ else
+ is_secure =
+ job->data.menu.entry[i].is_secure;
rc = add_ipl_program(fd,
&job->data.menu.entry[i].data.ipl,
&table[job->data.menu.entry[i].pos],
verbose || job->command_line,
job->add_files, component_header,
info, &job->target,
- job->is_secure);
+ is_secure);
break;
case job_print_usage:
case job_print_version:
--- a/zipl/src/job.c
+++ b/zipl/src/job.c
@@ -119,6 +119,7 @@ get_command_line(int argc, char* argv[],
memset((void *) &cmdline, 0, sizeof(struct command_line));
cmdline.type = section_invalid;
is_keyword = 0;
+ cmdline.is_secure = SECURE_BOOT_UNDEFINED;
/* Process options */
do {
opt = getopt_long(argc, argv, option_string, options, NULL);
@@ -1055,6 +1056,21 @@ check_job_mvdump_data(struct job_mvdump_
return 0;
}
+static int
+check_secure_boot(struct job_data *job)
+{
+ switch (job->is_secure) {
+ case SECURE_BOOT_UNDEFINED:
+ case SECURE_BOOT_DISABLED:
+ case SECURE_BOOT_ENABLED:
+ case SECURE_BOOT_AUTO:
+ return 0;
+ default:
+ error_reason("Invalid secure boot setting '%d'",
+ job->is_secure);
+ return -1;
+ }
+}
static int
check_job_data(struct job_data* job)
@@ -1099,6 +1115,8 @@ check_job_data(struct job_data* job)
case job_mvdump:
rc = check_job_mvdump_data(&job->data.mvdump, job->name);
}
+ if (!rc)
+ rc = check_secure_boot(job);
return rc;
}
@@ -1594,6 +1612,7 @@ get_menu_job(struct scan_token* scan, ch
sizeof(struct job_menu_entry) * job->data.menu.num);
/* Fill in data */
current = 0;
+ job->data.menu.entry->is_secure = SECURE_BOOT_UNDEFINED;
for (i=index+1; (scan[i].id != scan_id_empty) &&
(scan[i].id != scan_id_section_heading) &&
(scan[i].id != scan_id_menu_heading); i++) {
@@ -1625,6 +1644,7 @@ get_menu_job(struct scan_token* scan, ch
if (temp_job == NULL)
return -1;
memset((void *) temp_job, 0, sizeof(struct job_data));
+ temp_job->is_secure = SECURE_BOOT_UNDEFINED;
rc = get_job_from_section_data(data, temp_job,
job->data.menu.entry[current].name);
if (rc) {
@@ -1637,6 +1657,8 @@ get_menu_job(struct scan_token* scan, ch
job->data.menu.entry[current].id = job_ipl;
job->data.menu.entry[current].data.ipl =
temp_job->data.ipl;
+ job->data.menu.entry[current].is_secure =
+ temp_job->is_secure;
memset((void *) &temp_job->data.ipl, 0,
sizeof(struct job_ipl_data));
break;
@@ -1874,6 +1896,7 @@ job_get(int argc, char* argv[], struct j
job->add_files = cmdline.add_files;
job->data.mvdump.force = cmdline.force;
job->dry_run = cmdline.dry_run;
+ job->is_secure = SECURE_BOOT_UNDEFINED;
/* Get job data from user input */
if (cmdline.help) {
job->command_line = 1;
@@ -1892,10 +1915,10 @@ job_get(int argc, char* argv[], struct j
job_free(job);
return rc;
}
- if (cmdline.is_secure)
+ if (cmdline.is_secure != SECURE_BOOT_UNDEFINED)
job->is_secure = cmdline.is_secure;
- else
- job->is_secure = job->is_secure ? : SECURE_BOOT_AUTO;
+ else if (job->id != job_menu && job->is_secure == SECURE_BOOT_UNDEFINED)
+ job->is_secure = SECURE_BOOT_AUTO;
/* Check job data for validity */
rc = check_job_data(job);

View File

@ -0,0 +1,143 @@
Subject: [PATCH] [FEAT VS1804] zipl: remove some useless __packed___ attributes
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 2227bb8330aea1368ba234ae6f24fe0b5779d67d
Problem-ID: VS1804
Upstream-Description:
zipl: remove some useless __packed___ attributes
The __packed__ attribute is not needed for these structures as they
don't need any padding to meet the size and alignment constraints
defined in the Linux for zSeries ABI.
Reported by GCC 9.2.1 when building with '-Waddress-of-packed-member'.
stage3.c: In function 'is_verified_address':
stage3.c:241:26: warning: taking address of packed member of 'struct ipl_rb_components' may result in an unaligned pointer value [-Waddress-of-packed-member]
241 | for_each_rb_entry(comp, comps) {
| ^~~~~
stage3.c:18:15: note: in definition of macro 'for_each_rb_entry'
18 | for (entry = rb->entries; \
| ^~
CC zipl/boot/kdump3.o
CC zipl/boot/sclp_stage3.o
sclp_stage3.c: In function '__sclp_hsa_copy':
sclp_stage3.c:75:34: warning: converting a packed 'struct sdias_sccb' pointer (alignment 1) to a 'struct read_sccb' pointer (alignment 4096) may result in an unaligned pointer value [-Waddress-of-packed-member]
75 | if (sclp_hsa_copy_wait((struct read_sccb *)sccb))
| ^~~~~~~~~
In file included from sclp_stage3.c:13:
sclp_stage3.h:43:8: note: defined here
43 | struct sdias_sccb {
| ^~~~~~~~~~
In file included from sclp_stage3.c:12:
sclp.h:149:8: note: defined here
149 | struct read_sccb {
| ^~~~~~~~~
sclp_stage3.c: In function 'sclp_hsa_get_size':
sclp_stage3.c:126:34: warning: converting a packed 'struct sdias_sccb' pointer (alignment 1) to a 'struct read_sccb' pointer (alignment 4096) may result in an unaligned pointer value [-Waddress-of-packed-member]
126 | if (sclp_hsa_copy_wait((struct read_sccb *)sccb))
| ^~~~~~~~~
In file included from sclp_stage3.c:13:
sclp_stage3.h:43:8: note: defined here
43 | struct sdias_sccb {
| ^~~~~~~~~~
In file included from sclp_stage3.c:12:
sclp.h:149:8: note: defined here
149 | struct read_sccb {
| ^~~~~~~~~
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/sclp.h | 6 ++++--
zipl/boot/sclp_stage3.h | 3 ++-
zipl/boot/stage3.h | 6 ++++--
3 files changed, 10 insertions(+), 5 deletions(-)
--- a/zipl/boot/sclp.h
+++ b/zipl/boot/sclp.h
@@ -53,19 +53,21 @@ struct gds_subvector {
uint8_t key;
} __packed;
+/* Structure must not have any padding */
struct sccb_header {
uint16_t length;
uint8_t function_code;
uint8_t control_mask[3];
uint16_t response_code;
-} __packed;
+};
+/* Structure must not have any padding */
struct evbuf_header {
uint16_t length;
uint8_t type;
uint8_t flags;
uint16_t _reserved;
-} __packed;
+};
struct mto {
uint16_t length;
--- a/zipl/boot/sclp_stage3.h
+++ b/zipl/boot/sclp_stage3.h
@@ -40,10 +40,11 @@ struct sdias_evbuf {
uint16_t dbs;
} __packed;
+/* Structure must not have any padding */
struct sdias_sccb {
struct sccb_header header;
struct sdias_evbuf evbuf;
-} __packed;
+};
int sclp_hsa_copy(void *, unsigned long, unsigned long);
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -124,11 +124,12 @@ struct ipl_rl_hdr {
} __packed;
/* IPL Report Block header */
+/* Structure must not have any padding */
struct ipl_rb_hdr {
uint32_t len;
uint8_t rbt;
uint8_t reserved1[11];
-} __packed;
+};
/* IPL Report Block types */
enum ipl_rbt {
@@ -162,12 +163,13 @@ struct ipl_rb_component_entry {
#define IPL_RB_COMPONENT_FLAG_SIGNED 0x80
#define IPL_RB_COMPONENT_FLAG_VERIFIED 0x40
+/* Structure must not have any padding */
struct ipl_rb_components {
uint32_t len;
uint8_t rbt;
uint8_t reserved1[11];
struct ipl_rb_component_entry entries[];
-} __packed;
+};
extern unsigned long long _parm_addr; /* address of parmline */
extern unsigned long long _initrd_addr; /* address of initrd */

View File

@ -0,0 +1,95 @@
Subject: [PATCH] [FEAT VS1804] zipl: Fix entry point for stand-alone kdump
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: abe0ba7412f4398973235497754b05a199aec818
Problem-ID: VS1804
Upstream-Description:
zipl: Fix entry point for stand-alone kdump
Currently zipl doesn't differentiate between the load address and the
entry point of an image, causing stage3 to strip away the entry point at
0x10000 for stand-alone kdump. This breaks the kdump kernel as it jumps
to 0x10000 after the special handling needed for kdump has been
performed.
Fix this by differentiating between the load address and the entry point
of an image.
Fixes: d142fbd5 ("zipl: Do not strip kernel image IPL header")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/include/boot.h | 4 ++--
zipl/src/boot.c | 10 +++++-----
zipl/src/bootmap.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
--- a/zipl/include/boot.h
+++ b/zipl/include/boot.h
@@ -310,8 +310,8 @@ int boot_init_fba_stage1b(struct boot_fb
int boot_get_eckd_stage2(void** data, size_t* size, struct job_data* job);
int boot_get_stage3_parms(void **buffer, size_t *bytecount, address_t parm_addr,
address_t initrd_addr, size_t initrd_len,
- address_t load_addr, int extra_parm, uint16_t flags,
- size_t image_len);
+ address_t entry, int extra_parm, uint16_t flags,
+ address_t image_addr, size_t image_len);
int boot_get_tape_ipl(void** data, size_t* size, address_t parm_addr,
address_t initrd_addr, address_t image_addr);
int boot_get_tape_dump(void** data, size_t* size, uint64_t mem);
--- a/zipl/src/boot.c
+++ b/zipl/src/boot.c
@@ -79,14 +79,14 @@ boot_check_data(void)
int
boot_get_stage3_parms(void **buffer, size_t *bytecount, address_t parm_addr,
address_t initrd_addr, size_t initrd_len,
- address_t image_addr, int extra_parm, uint16_t flags,
- size_t image_len)
+ address_t entry, int extra_parm, uint16_t flags,
+ address_t image_addr, size_t image_len)
{
struct boot_stage3_params params;
void* data;
- if (image_addr != (image_addr & PSW_ADDRESS_MASK)) {
- error_reason("Kernel image load address to high (31 bit "
+ if (entry != (entry & PSW_ADDRESS_MASK)) {
+ error_reason("Kernel image entry point to high (31 bit "
"addressing mode)");
return -1;
}
@@ -99,7 +99,7 @@ boot_get_stage3_parms(void **buffer, siz
params.parm_addr = (uint64_t) parm_addr;
params.initrd_addr = (uint64_t) initrd_addr;
params.initrd_len = (uint64_t) initrd_len;
- params.load_psw = (uint64_t)(image_addr | PSW_LOAD);
+ params.load_psw = (uint64_t)(entry | PSW_LOAD);
params.extra_parm = (uint64_t) extra_parm;
params.flags = flags;
params.image_len = (uint64_t) image_len;
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -646,7 +646,7 @@ add_ipl_program(int fd, struct job_ipl_d
ipl->is_kdump ? ipl->image_addr + 0x10 :
ipl->image_addr,
(info->type == disk_type_scsi) ? 0 : 1,
- flags, image_size);
+ flags, ipl->image_addr, image_size);
if (rc) {
free(table);
return rc;

View File

@ -0,0 +1,70 @@
Subject: [PATCH] [BZ 184396] zipl: fix zipl.conf man page example for secure boot
From: Stefan Haberland <sth@linux.ibm.com>
Description: zipl: fix secure boot config handling
Symptom: The config file parsing for secure boot worked not as
it was expected to be. For example a config section
setting was not evaluated properly.
It is not possible to specify command line option -S
without other options.
Additionally the man page showed an invalid example.
Problem: The config file parsing was not implemented properly.
Solution: The hierarchy of the secure boot settings in the config
file is:
defaultboot > menu > section
Allow that --secure or -S is specified on command line
without the need to allow all options on the command
line. Also ensure that the command line option
overrules the config option and correctly ensure that
secure boot is only set for SCSI devices.
Fix man page example.
Reproduction: Run zipl with a secure= setting in a configuration
section or specify -S on command line.
Upstream-ID: 299fd2b7729f35c6fe3be18964f7e5e6a365f94d
Problem-ID: 184396
Upstream-Description:
zipl: fix zipl.conf man page example for secure boot
The secure= option is not supported in the defaultboot section when a
menu is used. It should be placed in the menu section in this case.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
zipl/man/zipl.conf.5 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/zipl/man/zipl.conf.5
+++ b/zipl/man/zipl.conf.5
@@ -82,8 +82,6 @@ below).
.br
defaultmenu = menu1
.br
-secure = auto
-.br
[linux]
.br
@@ -117,6 +115,8 @@ prompt = 1
.br
timeout = 0
.br
+secure = auto
+.br
.PP
.B BootLoaderSpec configuration files
@@ -522,7 +522,7 @@ non-default memory location.
.B secure
=
.IR auto / 1 / 0
-(configuration only)
+(configuration and menu)
.IP
.B Configuration section:
.br

View File

@ -0,0 +1,76 @@
Subject: [PATCH] [FEAT VS1804] zipl: Fix dependency generation in zipl/boot
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 121d5d80137f270e4828f457f717e9ab365f303b
Problem-ID: VS1804
Upstream-Description:
zipl: Fix dependency generation in zipl/boot
When adding new header from zipl/include to a .c file within zipl/boot
a compiler error appears
stage3.c:16:10: fatal error: zipl.h: No such file or directory
#include "zipl.h"
^~~~~~~~
compilation terminated.
CC zipl/boot/stage3.o
This is because the rule to generate dependencies (*.o.d) does not use
the CFLAGS_BOOT. Thus it cannot find the header and fails. Note this
only applies to the dependency generation, the actual build succeeds.
To fix this rename the CFLAGS_BOOT to ALL_CFLAGS. Using ALL_CFLAGS
instead of e.g. ALL_CPPFLAGS is important to also overwrite flags given
on the commandline via OPT_FLAGS, e.g.
make V=1 OPT_FLAGS="-D__FOO__"
While at it also remove the unused and wrong '-D__ASSEMBLY__'.
Fixes: 5a6605fe ("zipl: Ensure that boot loader CFLAGS are not overwritten")
Fixes: aa913b1e ("build process: Add automatic dependency generation")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/zipl/boot/Makefile
+++ b/zipl/boot/Makefile
@@ -1,7 +1,7 @@
# Common definitions
include ../../common.mak
-CFLAGS_BOOT = $(NO_PIE_CFLAGS) -Os -g -I../include -D__ASSEMBLY__ \
+ALL_CFLAGS = $(NO_PIE_CFLAGS) -Os -g -I $(rootdir)/zipl/include \
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
@@ -21,10 +21,10 @@ all: data.o data.h tape0.bin stage3.bin
%: %.S
%.o: %.S
- $(CC) $(CFLAGS_BOOT) -c -o $@ $<
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
%.o: %.c
- $(CC) $(CFLAGS_BOOT) -c -o $@ $<
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
eckd2dump_sv.exec: \
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_sv.o \

View File

@ -0,0 +1,349 @@
Subject: [PATCH] [FEAT VS1804] zipl: Make use of __packed macro
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 0f7ed7d4fc86041a8646ce7abb615849e1298cca
Problem-ID: VS1804
Upstream-Description:
zipl: Make use of __packed macro
Make use of the pre-defined __packed macro throughout zipl. This
requires adding the global include dir to ALL_CFLAGS.
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/Makefile | 2 -
zipl/boot/s390.h | 2 -
zipl/include/boot.h | 52 +++++++++++++++++++++++++------------------------
zipl/include/bootmap.h | 4 ++-
zipl/src/bootmap.c | 5 ++--
zipl/src/install.c | 3 +-
6 files changed, 37 insertions(+), 31 deletions(-)
--- a/zipl/boot/Makefile
+++ b/zipl/boot/Makefile
@@ -2,7 +2,7 @@
include ../../common.mak
ALL_CFLAGS = $(NO_PIE_CFLAGS) -Os -g -I $(rootdir)/zipl/include \
- -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
+ -I $(rootdir)/include -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
-fexec-charset=IBM1047 -m64 -mpacked-stack \
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -11,7 +11,7 @@
#ifndef S390_H
#define S390_H
-#include "../../include/lib/zt_common.h"
+#include "lib/zt_common.h"
#include "libc.h"
#define __pa32(x) ((uint32_t)(unsigned long)(x))
--- a/zipl/include/boot.h
+++ b/zipl/include/boot.h
@@ -14,6 +14,8 @@
#include <sys/types.h>
+#include "lib/zt_common.h"
+
#include "disk.h"
#include "job.h"
#include "zipl.h"
@@ -51,7 +53,7 @@ struct scsi_dump_sb {
uint64_t csum_offset;
uint64_t csum_size;
uint64_t csum;
-} __attribute((packed));
+} __packed;
#define SCSI_DUMP_SB_MAGIC 0x5a46435044554d50ULL; /* ZFCPDUMP */
/* To avoid a csum entry of 0 a seed is used */
@@ -63,7 +65,7 @@ struct scsi_dump_sb {
struct scsi_dump_param {
uint64_t block;
uint64_t reserved;
-} __attribute((packed));
+} __packed;
/* ECKD dump parameter */
struct eckd_dump_param {
@@ -73,14 +75,14 @@ struct eckd_dump_param {
uint8_t num_heads;
uint8_t bpt;
char reserved[4];
-} __attribute((packed, may_alias));
+} __packed __may_alias;
/* FBA dump parameter */
struct fba_dump_param {
uint64_t start_blk;
uint64_t blockct;
-} __attribute((packed));
+} __packed;
struct boot_info_bp_dump {
union {
@@ -89,7 +91,7 @@ struct boot_info_bp_dump {
struct scsi_dump_param scsi;
} param;
uint8_t unused[16];
-} __attribute__ ((packed));
+} __packed;
/*
* Layout of block pointer for linear devices
@@ -101,7 +103,7 @@ struct linear_blockptr {
uint16_t size;
uint16_t blockct;
uint8_t reserved[4];
-} __attribute((packed));
+} __packed;
/*
* Layout of block pointer for cylinder/head/sector devices
@@ -115,7 +117,7 @@ struct eckd_blockptr {
uint16_t size;
uint8_t blockct;
uint8_t reserved[8];
-} __attribute((packed));
+} __packed;
struct boot_info_bp_ipl {
union {
@@ -123,7 +125,7 @@ struct boot_info_bp_ipl {
struct linear_blockptr lin;
} bm_ptr;
uint8_t unused[16];
-} __attribute__ ((packed));
+} __packed;
struct boot_info {
char magic[4];
@@ -135,7 +137,7 @@ struct boot_info {
struct boot_info_bp_dump dump;
struct boot_info_bp_ipl ipl;
} bp;
-} __attribute__ ((packed));
+} __packed;
struct boot_ccw0 {
uint8_t cmd;
@@ -144,21 +146,21 @@ struct boot_ccw0 {
uint8_t flags;
uint8_t pad;
uint16_t count;
-} __attribute__ ((packed));
+} __packed;
/* Boot data structures for FBA disks */
struct boot_fba_locread {
struct boot_ccw0 locate;
struct boot_ccw0 read;
-} __attribute__ ((packed));
+} __packed;
struct boot_fba_locdata {
uint8_t command;
uint8_t dummy;
uint16_t blockct;
uint32_t blocknr;
-} __attribute__ ((packed));
+} __packed;
struct boot_fba_stage0 {
uint64_t psw;
@@ -169,13 +171,13 @@ struct boot_fba_stage0 {
struct boot_fba_locdata locdata[2];
uint64_t reserved[4];
struct boot_info boot_info;
-} __attribute__ ((packed));
+} __packed;
struct boot_fba_stage1b {
struct boot_fba_locread locread[STAGE2_BLK_CNT_MAX];
struct boot_fba_locdata locdata[STAGE2_BLK_CNT_MAX];
uint8_t unused[448];
-} __attribute__ ((packed));
+} __packed;
/* Boot data structures for ECKD disks */
@@ -184,14 +186,14 @@ struct boot_eckd_ccw1 {
uint8_t flags;
uint16_t count;
uint32_t address;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_ssrt {
struct boot_ccw0 seek;
struct boot_ccw0 search;
struct boot_ccw0 tic;
struct boot_ccw0 read;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_seekarg {
uint16_t pad;
@@ -199,32 +201,32 @@ struct boot_eckd_seekarg {
uint16_t head;
uint8_t sec;
uint8_t pad2;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_cdl_stage0 {
uint64_t psw;
struct boot_ccw0 read;
struct boot_ccw0 tic;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_ldl_stage0 {
uint64_t psw;
struct boot_ccw0 read_r0;
struct boot_ccw0 read_r1;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_stage1 {
struct boot_eckd_ssrt ssrt[2];
struct boot_ccw0 tic1b;
struct boot_eckd_seekarg seek[2];
struct boot_info boot_info;
-} __attribute__ ((packed));
+} __packed;
struct boot_eckd_stage1b {
struct boot_eckd_ssrt ssrt[STAGE2_BLK_CNT_MAX];
struct boot_eckd_seekarg seek[STAGE2_BLK_CNT_MAX];
uint8_t unused[64];
-} __attribute__ ((packed));
+} __packed;
/* Stage 2 boot menu parameter structure */
@@ -236,7 +238,7 @@ struct boot_stage2_params {
uint16_t banner;
uint16_t config[BOOT_MENU_ENTRIES + 1];
uint64_t config_kdump;
-} __attribute__ ((packed));
+} __packed;
/* Stage 3 bootloader parameter structure */
@@ -251,7 +253,7 @@ struct boot_stage3_params {
uint16_t reserved[3];
uint64_t image_len;
uint64_t image_addr;
-} __attribute__ ((packed));
+} __packed;
#define STAGE3_FLAG_SCSI 0x0001
#define STAGE3_FLAG_KDUMP 0x0002
@@ -275,7 +277,7 @@ struct mvdump_param {
uint8_t blocksize;
uint8_t bpt;
uint8_t num_heads;
-} __attribute__ ((packed));
+} __packed;
struct mvdump_parm_table {
uint64_t timestamp;
@@ -284,7 +286,7 @@ struct mvdump_parm_table {
uint8_t ssid[MAX_DUMP_VOLUMES];
unsigned char reserved[512 - sizeof(uint64_t) - sizeof(uint16_t) -
(MAX_DUMP_VOLUMES * (sizeof(struct mvdump_param) + 1))];
-} __attribute__ ((packed));
+} __packed;
void boot_get_dump_info(struct boot_info *boot_info, uint8_t dev_type,
void *param);
--- a/zipl/include/bootmap.h
+++ b/zipl/include/bootmap.h
@@ -12,6 +12,8 @@
#ifndef BOOTMAP_H
#define BOOTMAP_H
+#include "lib/zt_common.h"
+
#include "disk.h"
#include "job.h"
#include "zipl.h"
@@ -23,7 +25,7 @@ struct signature_header {
uint8_t format;
uint8_t reserved[3];
uint32_t length;
-} __attribute((packed));
+} __packed;
typedef union {
uint64_t load_address;
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -18,6 +18,7 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include "lib/zt_common.h"
#include "lib/util_part.h"
#include "lib/util_path.h"
@@ -223,7 +224,7 @@ struct component_entry {
uint8_t data[23];
uint8_t type;
component_data compdat;
-} __attribute((packed));
+} __packed;
typedef enum {
component_execute = 0x01,
@@ -263,7 +264,7 @@ struct component_header {
uint8_t magic[4];
uint8_t type;
uint8_t reserved[27];
-} __attribute((packed));
+} __packed;
typedef enum {
component_header_ipl = 0x00,
--- a/zipl/src/install.c
+++ b/zipl/src/install.c
@@ -23,6 +23,7 @@
#include <syslog.h>
#include <unistd.h>
+#include "lib/zt_common.h"
#include "lib/util_sys.h"
#include "boot.h"
@@ -89,7 +90,7 @@ update_scsi_mbr(void* bootblock, disk_bl
uint8_t program_table_pointer[16];
uint8_t reserved2[0x50];
struct boot_info boot_info;
- } __attribute__ ((packed))* mbr;
+ } __packed* mbr;
struct scsi_dump_param param;
void* buffer;

View File

@ -0,0 +1,188 @@
Subject: [PATCH] [FEAT VS1804] zipl: define __section macro and make use of it
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 154734efc7ffeb1e51dd2be62561a364fdc6117c
Problem-ID: VS1804
Upstream-Description:
zipl: define __section macro and make use of it
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/zt_common.h | 1 +
zipl/boot/eckd2dump_mv.c | 8 ++++----
zipl/boot/eckd2dump_sv.c | 5 +++--
zipl/boot/fba2dump.c | 4 ++--
zipl/boot/stage2.c | 4 +++-
zipl/boot/stage2dump.c | 5 +++--
zipl/boot/stage2dump.h | 3 +--
zipl/boot/tape2dump.c | 4 +++-
8 files changed, 20 insertions(+), 14 deletions(-)
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -31,6 +31,7 @@
#define __packed __attribute__((packed))
#define __aligned(x) __attribute__((aligned(x)))
#define __may_alias __attribute__((may_alias))
+#define __section(x) __attribute__((__section__(#x)))
typedef unsigned long long u64;
typedef signed long long s64;
--- a/zipl/boot/eckd2dump_mv.c
+++ b/zipl/boot/eckd2dump_mv.c
@@ -9,6 +9,8 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "lib/zt_common.h"
+
#include "eckd2dump.h"
#include "error.h"
#include "stage2dump.h"
@@ -19,8 +21,7 @@
/*
* Magic number at start of dump record
*/
-uint64_t magic __attribute__((section(".stage2.head")))
- = 0x584d554c54363401ULL; /* XMULT64, version 1 */
+uint64_t __section(.stage2.head) magic = 0x584d554c54363401ULL; /* XMULT64, version 1 */
/*
* Parameter format for ECKD MV dumper (13 bytes):
@@ -59,8 +60,7 @@ struct mvdump_parm_table {
(MAX_DUMP_VOLUMES * (sizeof(struct mvdump_param) + 1))];
} __packed;
-static struct mvdump_parm_table mvdump_table
- __attribute__((section(".eckd2dump_mv.tail")));
+static struct mvdump_parm_table __section(.eckd2dump_mv.tail) mvdump_table;
static int volnr_current;
--- a/zipl/boot/eckd2dump_sv.c
+++ b/zipl/boot/eckd2dump_sv.c
@@ -9,6 +9,8 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "lib/zt_common.h"
+
#include "eckd2dump.h"
#include "error.h"
#include "stage2dump.h"
@@ -16,8 +18,7 @@
/*
* Magic number at start of dump record
*/
-uint64_t magic __attribute__((section(".stage2.head"))) =
- 0x5845434b44363401ULL; /* "XECKD64", version 1 */
+uint64_t __section(.stage2.head) magic = 0x5845434b44363401ULL; /* "XECKD64", version 1 */
/*
* ECKD parameter block passed by zipl
--- a/zipl/boot/fba2dump.c
+++ b/zipl/boot/fba2dump.c
@@ -9,6 +9,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "lib/zt_common.h"
#include "error.h"
#include "fba.h"
#include "stage2dump.h"
@@ -20,8 +21,7 @@
/*
* Magic number at start of dump record
*/
-uint64_t magic __attribute__((section(".stage2.head")))
- = 0x5844464241363401ULL; /* XDFBA64, version 1 */
+uint64_t __section(.stage2.head) magic = 0x5844464241363401ULL; /* XDFBA64, version 1 */
/*
* FBA dump device partition specification
--- a/zipl/boot/stage2.c
+++ b/zipl/boot/stage2.c
@@ -9,6 +9,8 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "lib/zt_common.h"
+
#include "error.h"
#include "libc.h"
#include "menu.h"
@@ -141,4 +143,4 @@ void panic_notify(unsigned long UNUSED(r
{
}
-uint64_t stage2_head __attribute__((section(".stage2.head")));
+uint64_t __section(.stage2.head) stage2_head;
--- a/zipl/boot/stage2dump.c
+++ b/zipl/boot/stage2dump.c
@@ -11,6 +11,8 @@
#include <stdarg.h>
+#include "lib/zt_common.h"
+
#include "error.h"
#include "sclp.h"
#include "stage2dump.h"
@@ -34,8 +36,7 @@ struct ipib_info {
/*
* Tail parameters
*/
-struct stage2dump_parm_tail parm_tail
- __attribute__ ((section(".stage2dump.tail"))) = {
+struct stage2dump_parm_tail parm_tail = {
.mem_upper_limit = 0xffffffffffffffffULL,
};
--- a/zipl/boot/stage2dump.h
+++ b/zipl/boot/stage2dump.h
@@ -28,8 +28,7 @@ struct stage2dump_parm_tail {
uint64_t mem_upper_limit;
} __packed;
-extern struct stage2dump_parm_tail parm_tail
- __attribute__ ((section(".stage2dump.tail")));
+extern struct stage2dump_parm_tail __section(.stage2dump.tail) parm_tail;
/*
* S390 dump format defines
--- a/zipl/boot/tape2dump.c
+++ b/zipl/boot/tape2dump.c
@@ -9,6 +9,8 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "lib/zt_common.h"
+
#include "cio.h"
#include "error.h"
#include "libc.h"
@@ -33,7 +35,7 @@ struct tape_head {
uint64_t ccw2;
} __packed;
-struct tape_head tape_head __attribute__((section(".stage2.head"))) = {
+struct tape_head __section(.stage2.head) tape_head = {
.psw = 0x0008000080002018ULL, /* Start code at 0x2018 */
.ccw1 = 0x0700000060000001ULL, /* Rewind ccw */
.ccw2 = 0x0200200020003000ULL, /* CCW to load dump tool to 0x2000 */

View File

@ -0,0 +1,61 @@
Subject: [PATCH] [FEAT VS1804] zipl: Make use of __noreturn macro
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 86856f98dbe3f68e34b91b58e9fc92f7cdc8a0d4
Problem-ID: VS1804
Upstream-Description:
zipl: Make use of __noreturn macro
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/libc.c | 4 +++-
zipl/boot/libc.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
--- a/zipl/boot/libc.c
+++ b/zipl/boot/libc.c
@@ -11,6 +11,8 @@
#include <stdarg.h>
+#include "lib/zt_common.h"
+
#include "error.h"
#include "libc.h"
#include "sclp.h"
@@ -511,7 +513,7 @@ void initialize(void)
/*
* Load disabled wait PSW with reason code in address field
*/
-void libc_stop(unsigned long reason)
+void __noreturn libc_stop(unsigned long reason)
{
struct psw_t psw;
--- a/zipl/boot/libc.h
+++ b/zipl/boot/libc.h
@@ -60,7 +60,7 @@ char *strcpy(char *, const char *);
unsigned long get_zeroed_page(void);
void free_page(unsigned long);
void initialize(void);
-void libc_stop(unsigned long) __attribute__((noreturn));
+void libc_stop(unsigned long);
void start(void);
void pgm_check_handler(void);
void pgm_check_handler_fn(void);

View File

@ -0,0 +1,66 @@
Subject: [PATCH] [FEAT VS1804] zipl: Define __noinline macro and make use of it
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 5eace91ee7bd76b8ab44291299ac313c87c9ecb8
Problem-ID: VS1804
Upstream-Description:
zipl: Define __noinline macro and make use of it
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/zt_common.h | 1 +
libutil/util_panic_example.c | 2 +-
zipl/boot/libc.c | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -32,6 +32,7 @@
#define __aligned(x) __attribute__((aligned(x)))
#define __may_alias __attribute__((may_alias))
#define __section(x) __attribute__((__section__(#x)))
+#define __noinline __attribute__((__noinline__))
typedef unsigned long long u64;
typedef signed long long s64;
--- a/libutil/util_panic_example.c
+++ b/libutil/util_panic_example.c
@@ -15,10 +15,10 @@
#include <sys/resource.h>
#include <sys/time.h>
+#include "lib/zt_common.h"
#include "lib/util_panic.h"
/* Make functions noinline to have a nice backtrace */
-#define __noinline __attribute__((noinline))
/*
* Test util_panic()
--- a/zipl/boot/libc.c
+++ b/zipl/boot/libc.c
@@ -473,7 +473,7 @@ void pgm_check_handler_fn(void)
libc_stop(psw_old->addr);
}
-__attribute__ ((noinline)) void load_wait_psw(uint64_t psw_mask, struct psw_t *psw)
+void __noinline load_wait_psw(uint64_t psw_mask, struct psw_t *psw)
{
struct psw_t wait_psw = { .mask = psw_mask, .addr = 0 };
struct psw_t old_psw, *wait_psw_ptr = &wait_psw;

View File

@ -0,0 +1,49 @@
Subject: [PATCH] [FEAT VS1804] zipl/stage3: Mark start_kernel __noreturn
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: edfb6a03d862e332223eda02be46109be12c0a4e
Problem-ID: VS1804
Upstream-Description:
zipl/stage3: Mark start_kernel __noreturn
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/stage3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/zipl/boot/stage3.c
+++ b/zipl/boot/stage3.c
@@ -175,8 +175,7 @@ static void ebcdic_to_ascii(unsigned cha
target[i] = ebc[source[i]];
}
-static void
-start_kernel(void)
+static inline void __noreturn start_kernel(void)
{
struct psw_t *psw = &S390_lowcore.program_new_psw;
unsigned long addr, code;
@@ -199,6 +198,7 @@ start_kernel(void)
: [addr] "=&d" (addr),
[code] "+&d" (code)
: [psw] "a" (psw) );
+ while (1);
}
unsigned int

View File

@ -0,0 +1,41 @@
Subject: [PATCH] [FEAT VS1804] zipl/sclp: Remove duplicate macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: b2ae5a91ac16c5facb892dedc2dcb268eff07edf
Problem-ID: VS1804
Upstream-Description:
zipl/sclp: Remove duplicate macros
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/sclp_stage3.h | 3 ---
1 file changed, 3 deletions(-)
--- a/zipl/boot/sclp_stage3.h
+++ b/zipl/boot/sclp_stage3.h
@@ -17,9 +17,6 @@
#define SDIAS_EVSTATE_ALL_STORED 0x00
#define SDIAS_EVSTATE_PART_STORED 0x10
-#define SDIAS_EVSTATE_ALL_STORED 0x00
-#define SDIAS_EVSTATE_PART_STORED 0x10
-
struct sdias_evbuf {
struct evbuf_header header;
uint8_t event_qual;

View File

@ -0,0 +1,116 @@
Subject: [PATCH] [FEAT VS1804] zipl: Make address/size/mask macros UL
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: ea14f5471c6fbc9a8a407aa33324db39082b4689
Problem-ID: VS1804
Upstream-Description:
zipl: Make address/size/mask macros UL
While at it also fix some white space damages.
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/stage3.h | 18 +++++++++---------
zipl/include/zipl.h | 36 ++++++++++++++++++------------------
2 files changed, 27 insertions(+), 27 deletions(-)
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -15,12 +15,12 @@
#include "libc.h"
#include "s390.h"
-#define IPL_DEVICE 0x10404
-#define INITRD_START 0x10408
-#define INITRD_SIZE 0x10410
-#define OLDMEM_BASE 0x10418
-#define OLDMEM_SIZE 0x10420
-#define COMMAND_LINE 0x10480
+#define IPL_DEVICE 0x10404UL
+#define INITRD_START 0x10408UL
+#define INITRD_SIZE 0x10410UL
+#define OLDMEM_BASE 0x10418UL
+#define OLDMEM_SIZE 0x10420UL
+#define COMMAND_LINE 0x10480UL
#define COMMAND_LINE_SIZE 896
#define COMMAND_LINE_EXTRA 0xE000
@@ -30,11 +30,11 @@
#define IPL_FLAG_SECURE 0x40
#define DEFAULT_IMAGE_ADDR 0x10000
-#define DEFAULT_PSW_LOAD 0x0008000080010000L
-#define PSW_ADDR_MASK 0x000000007FFFFFFFL
+#define DEFAULT_PSW_LOAD 0x0008000080010000UL
+#define PSW_ADDR_MASK 0x000000007FFFFFFFUL
#define KERNEL_HEADER_SIZE 65536
-#define UNSPECIFIED_ADDRESS -1ULL
+#define UNSPECIFIED_ADDRESS -1UL
/* IPL Parameter List header */
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -19,27 +19,27 @@
#define ZIPL_MAGIC_SIZE 4
#define DISK_LAYOUT_ID 0x00000001
-#define ZIPL_STAGE2_LOAD_ADDRESS 0x2000
-#define ZIPL_STAGE3_ENTRY_ADDRESS 0xa000LL
-#define DEFAULT_IMAGE_ADDRESS 0x10000LL
-#define KDUMP_IMAGE_ADDRESS 0x10010LL
-#define DEFAULT_STAGE3_ADDRESS 0xa000LL
-#define DEFAULT_STAGE3_PARAMS_ADDRESS 0x9000LL
-#define MINIMUM_ADDRESS 0x10000LL
-#define ADDRESS_LIMIT 0x80000000LL
+#define ZIPL_STAGE2_LOAD_ADDRESS 0x2000UL
+#define ZIPL_STAGE3_ENTRY_ADDRESS 0xa000UL
+#define DEFAULT_IMAGE_ADDRESS 0x10000UL
+#define KDUMP_IMAGE_ADDRESS 0x10010UL
+#define DEFAULT_STAGE3_ADDRESS 0xa000UL
+#define DEFAULT_STAGE3_PARAMS_ADDRESS 0x9000UL
+#define MINIMUM_ADDRESS 0x10000UL
+#define ADDRESS_LIMIT 0x80000000UL
#define ADDRESS_LIMIT_KDUMP 0x2000000UL /* HSA size: 32 MiB */
-#define UNSPECIFIED_ADDRESS -1ULL
-#define MAXIMUM_PARMLINE_SIZE 0x380
-#define MAXIMUM_PHYSICAL_BLOCKSIZE 0x1000
+#define UNSPECIFIED_ADDRESS -1UL
+#define MAXIMUM_PARMLINE_SIZE 0x380UL
+#define MAXIMUM_PHYSICAL_BLOCKSIZE 0x1000UL
-#define STAGE3_HEAP_SIZE 0x4000
-#define STAGE3_HEAP_ADDRESS 0x2000
-#define STAGE3_STACK_SIZE 0x1000
-#define STAGE3_STACK_ADDRESS 0xF000
+#define STAGE3_HEAP_SIZE 0x4000UL
+#define STAGE3_HEAP_ADDRESS 0x2000UL
+#define STAGE3_STACK_SIZE 0x1000UL
+#define STAGE3_STACK_ADDRESS 0xF000UL
-#define PSW_ADDRESS_MASK 0x000000007fffffffLL
-#define PSW_LOAD 0x0008000080000000LL
-#define PSW_DISABLED_WAIT 0x000a000000000000LL
+#define PSW_ADDRESS_MASK 0x000000007fffffffUL
+#define PSW_LOAD 0x0008000080000000UL
+#define PSW_DISABLED_WAIT 0x000a000000000000UL
#define BOOTMAP_FILENAME "bootmap"
#define BOOTMAP_TEMPLATE_FILENAME "bootmap_temp.XXXXXX"

View File

@ -0,0 +1,52 @@
Subject: [PATCH] [FEAT VS1804] zipl/libc: Use stdint.h instead of self defined macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 8face3e63ed88443392bcbcd93cc0b5e29b40069
Problem-ID: VS1804
Upstream-Description:
zipl/libc: Use stdint.h instead of self defined macros
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/libc.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--- a/zipl/boot/libc.h
+++ b/zipl/boot/libc.h
@@ -11,6 +11,8 @@
#ifndef LIBC_H
#define LIBC_H
+#include <stdint.h>
+
#define NULL ((void *) 0)
#define EPERM 1 /* Operation not permitted */
@@ -42,11 +44,6 @@
#define MIB (1024ULL * 1024)
#define LINE_LENGTH 80 /* max line length printed by printf */
-typedef unsigned long long uint64_t;
-typedef unsigned int uint32_t;
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-
void printf(const char *, ...);
void snprintf(char *buf, unsigned long size, const char *fmt, ...);
void *memcpy(void *, const void *, unsigned long);

View File

@ -0,0 +1,199 @@
Subject: [PATCH] [FEAT VS1804] zipl: Consolidate IMAGE macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: cb614ed1ee61f05fb521a7e3ac0d27eb2eb45672
Problem-ID: VS1804
Upstream-Description:
zipl: Consolidate IMAGE macros
Combine the different macros for 0x10000 and use a consistent naming
schema.
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/stage3.c | 7 ++++---
zipl/boot/stage3.h | 2 --
zipl/include/zipl.h | 8 +++++---
zipl/src/bootmap.c | 8 ++++----
zipl/src/job.c | 17 +++++++++--------
5 files changed, 22 insertions(+), 20 deletions(-)
--- a/zipl/boot/stage3.c
+++ b/zipl/boot/stage3.c
@@ -13,6 +13,7 @@
#include "s390.h"
#include "stage3.h"
#include "error.h"
+#include "zipl.h"
#define for_each_rb_entry(entry, rb) \
for (entry = rb->entries; \
@@ -272,7 +273,7 @@ void start(void)
* verified component. If it is not IPL is aborted.
*/
if (secure_boot_enabled()) {
- if (_image_addr != DEFAULT_IMAGE_ADDR ||
+ if (_image_addr != IMAGE_LOAD_ADDRESS ||
_load_psw != DEFAULT_PSW_LOAD)
panic(ESECUREBOOT, "%s", msg_sipl_inval);
@@ -283,8 +284,8 @@ void start(void)
* cut the kernel header
*/
memmove((void *)_image_addr,
- (void *)_image_addr + KERNEL_HEADER_SIZE,
- _image_len - KERNEL_HEADER_SIZE);
+ (void *)_image_addr + IMAGE_LOAD_ADDRESS,
+ _image_len - IMAGE_LOAD_ADDRESS);
/* store subchannel ID into low core and into new kernel space */
subchannel_id = S390_lowcore.subchannel_id;
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -29,10 +29,8 @@
#define IPL_FLAG_SECURE 0x40
-#define DEFAULT_IMAGE_ADDR 0x10000
#define DEFAULT_PSW_LOAD 0x0008000080010000UL
#define PSW_ADDR_MASK 0x000000007FFFFFFFUL
-#define KERNEL_HEADER_SIZE 65536
#define UNSPECIFIED_ADDRESS -1UL
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -19,13 +19,15 @@
#define ZIPL_MAGIC_SIZE 4
#define DISK_LAYOUT_ID 0x00000001
+#define IMAGE_ENTRY 0x10000UL
+#define IMAGE_ENTRY_KDUMP 0x10010UL
+
#define ZIPL_STAGE2_LOAD_ADDRESS 0x2000UL
#define ZIPL_STAGE3_ENTRY_ADDRESS 0xa000UL
-#define DEFAULT_IMAGE_ADDRESS 0x10000UL
-#define KDUMP_IMAGE_ADDRESS 0x10010UL
#define DEFAULT_STAGE3_ADDRESS 0xa000UL
#define DEFAULT_STAGE3_PARAMS_ADDRESS 0x9000UL
-#define MINIMUM_ADDRESS 0x10000UL
+#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
+
#define ADDRESS_LIMIT 0x80000000UL
#define ADDRESS_LIMIT_KDUMP 0x2000000UL /* HSA size: 32 MiB */
#define UNSPECIFIED_ADDRESS -1UL
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -644,8 +644,8 @@ add_ipl_program(int fd, struct job_ipl_d
rc = boot_get_stage3_parms(&stage3_params, &stage3_params_size,
ipl->parm_addr, ipl->ramdisk_addr,
ramdisk_size,
- ipl->is_kdump ? ipl->image_addr + 0x10 :
- ipl->image_addr,
+ ipl->is_kdump ? IMAGE_ENTRY_KDUMP :
+ IMAGE_ENTRY,
(info->type == disk_type_scsi) ? 0 : 1,
flags, ipl->image_addr, image_size);
if (rc) {
@@ -1187,7 +1187,7 @@ bootmap_create(struct job_data *job, dis
ulong unused_size;
/* Use approximated stage 3 size as starting point */
- size = MINIMUM_ADDRESS;
+ size = IMAGE_LOAD_ADDRESS;
/* Ramdisk */
if (job->data.dump.ramdisk != NULL) {
@@ -1199,7 +1199,7 @@ bootmap_create(struct job_data *job, dis
/* Kernel */
if (stat(job->data.dump.image, &st))
goto out_misc_free_temp_dev;
- size += DIV_ROUND_UP(st.st_size - 0x10000,
+ size += DIV_ROUND_UP(st.st_size - IMAGE_LOAD_ADDRESS,
info->phy_block_size);
/* Parmfile */
size += DIV_ROUND_UP(DUMP_PARAM_MAX_LEN, info->phy_block_size);
--- a/zipl/src/job.c
+++ b/zipl/src/job.c
@@ -23,6 +23,7 @@
#include "job.h"
#include "misc.h"
#include "scan.h"
+#include "zipl.h"
/* Command line options */
static struct option options[] = {
@@ -663,12 +664,12 @@ check_component_address_data(struct comp
address_limit);
return -1;
}
- if (*cl[i].addrp < MINIMUM_ADDRESS) {
+ if (*cl[i].addrp < IMAGE_LOAD_ADDRESS) {
if (name != NULL)
error_text("Section '%s'", name);
error_reason("Component '%s' falls below available "
"address space (limit is 0x%08x)",
- cl[i].name, MINIMUM_ADDRESS);
+ cl[i].name, IMAGE_LOAD_ADDRESS);
return -1;
}
}
@@ -706,12 +707,12 @@ finalize_component_address_data(struct c
for (j = -1; j < i; j++) {
if (j < 0) {
/* Try address before first component */
- addr = MINIMUM_ADDRESS;
+ addr = IMAGE_LOAD_ADDRESS;
} else {
/* Try address after component j */
addr = *cl[j].addrp + cl[j].size;
- if (addr < MINIMUM_ADDRESS)
- addr = MINIMUM_ADDRESS;
+ if (addr < IMAGE_LOAD_ADDRESS)
+ addr = IMAGE_LOAD_ADDRESS;
}
addr = ALIGN(addr, cl[i].align);
if (addr + cl[i].size > address_limit) {
@@ -905,7 +906,7 @@ check_job_dump_images(struct job_dump_da
dump->image = misc_strdup(ZFCPDUMP_IMAGE);
if (dump->image == NULL)
return -1;
- dump->image_addr = DEFAULT_IMAGE_ADDRESS;
+ dump->image_addr = IMAGE_LOAD_ADDRESS;
/* Ramdisk is no longer required with new initramfs dump system */
if (misc_check_readable_file(ZFCPDUMP_INITRD))
@@ -1351,7 +1352,7 @@ get_job_from_section_data(char* data[],
return -1;
if (extract_address(job->data.ipl.image,
&job->data.ipl.image_addr)) {
- job->data.ipl.image_addr = DEFAULT_IMAGE_ADDRESS;
+ job->data.ipl.image_addr = IMAGE_LOAD_ADDRESS;
}
/* Fill in parmline */
rc = get_parmline(data[(int) scan_keyword_parmfile],
@@ -1406,7 +1407,7 @@ get_job_from_section_data(char* data[],
return -1;
if (extract_address(job->data.ipl_tape.image,
&job->data.ipl_tape.image_addr)) {
- job->data.ipl_tape.image_addr = DEFAULT_IMAGE_ADDRESS;
+ job->data.ipl_tape.image_addr = IMAGE_LOAD_ADDRESS;
}
/* Fill in parmline */
rc = get_parmline(data[(int) scan_keyword_parmfile],

View File

@ -0,0 +1,110 @@
Subject: [PATCH] [FEAT VS1804] zipl: Consolidate STAGE{2,3} macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 4762e65acbc4efe7142ccb5fd2ef86073737ebd8
Problem-ID: VS1804
Upstream-Description:
zipl: Consolidate STAGE{2,3} macros
Increase consistency with the other macros by moving and renaming
the STAGE{2,3} macros in zipl.h.
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/include/zipl.h | 8 ++++----
zipl/src/boot.c | 4 ++--
zipl/src/bootmap.c | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -19,13 +19,12 @@
#define ZIPL_MAGIC_SIZE 4
#define DISK_LAYOUT_ID 0x00000001
+#define STAGE3_ENTRY 0xa000UL
#define IMAGE_ENTRY 0x10000UL
#define IMAGE_ENTRY_KDUMP 0x10010UL
-#define ZIPL_STAGE2_LOAD_ADDRESS 0x2000UL
-#define ZIPL_STAGE3_ENTRY_ADDRESS 0xa000UL
-#define DEFAULT_STAGE3_ADDRESS 0xa000UL
-#define DEFAULT_STAGE3_PARAMS_ADDRESS 0x9000UL
+#define STAGE2_LOAD_ADDRESS 0x2000UL
+#define STAGE3_LOAD_ADDRESS 0xa000UL
#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
#define ADDRESS_LIMIT 0x80000000UL
@@ -38,6 +37,7 @@
#define STAGE3_HEAP_ADDRESS 0x2000UL
#define STAGE3_STACK_SIZE 0x1000UL
#define STAGE3_STACK_ADDRESS 0xF000UL
+#define STAGE3_PARAMS_ADDRESS 0x9000UL
#define PSW_ADDRESS_MASK 0x000000007fffffffUL
#define PSW_LOAD 0x0008000080000000UL
--- a/zipl/src/boot.c
+++ b/zipl/src/boot.c
@@ -195,7 +195,7 @@ boot_init_fba_stage1b(struct boot_fba_st
stage1b->locdata[i].blocknr =
(uint32_t) stage2_list[i].linear.block;
stage1b->locread[i].read.address_lo =
- ZIPL_STAGE2_LOAD_ADDRESS + i * FBA_BLK_SIZE;
+ STAGE2_LOAD_ADDRESS + i * FBA_BLK_SIZE;
}
/* Terminate CCW chain */
stage1b->locread[i - 1].read.flags &= ~CCW_FLAG_CC;
@@ -220,7 +220,7 @@ boot_init_eckd_stage1b(struct boot_eckd_
stage1b->seek[i].head = stage2_list[i].chs.head |
((stage2_list[i].chs.cyl >> 12) & 0xfff0);
stage1b->seek[i].sec = stage2_list[i].chs.sec;
- stage1b->ssrt[i].read.address_lo = ZIPL_STAGE2_LOAD_ADDRESS +
+ stage1b->ssrt[i].read.address_lo = STAGE2_LOAD_ADDRESS +
i * stage2_list[i].chs.size;
stage1b->ssrt[i].read.flags = CCW_FLAG_CC | CCW_FLAG_SLI;
}
--- a/zipl/src/bootmap.c
+++ b/zipl/src/bootmap.c
@@ -627,7 +627,7 @@ add_ipl_program(int fd, struct job_ipl_d
}
/* Add stage 3 loader to bootmap */
- rc = add_component_file(fd, ZIPL_STAGE3_PATH, DEFAULT_STAGE3_ADDRESS,
+ rc = add_component_file(fd, ZIPL_STAGE3_PATH, STAGE3_LOAD_ADDRESS,
signature_size, VOID_ADD(table, offset), 1,
info, target, &comp_loc[comp_nr]);
if (rc) {
@@ -654,7 +654,7 @@ add_ipl_program(int fd, struct job_ipl_d
}
rc = add_component_buffer(fd, stage3_params, stage3_params_size,
(component_data) (uint64_t)
- DEFAULT_STAGE3_PARAMS_ADDRESS,
+ STAGE3_PARAMS_ADDRESS,
VOID_ADD(table, offset), info,
&comp_loc[comp_nr], component_load);
free(stage3_params);
@@ -792,7 +792,7 @@ add_ipl_program(int fd, struct job_ipl_d
create_component_entry(VOID_ADD(table, offset), NULL,
component_execute,
(component_data) (uint64_t)
- (ZIPL_STAGE3_ENTRY_ADDRESS | PSW_LOAD),
+ (STAGE3_ENTRY | PSW_LOAD),
info);
/* Write component table */
rc = disk_write_block_aligned(fd, table, info->phy_block_size,

View File

@ -0,0 +1,53 @@
Subject: [PATCH] [FEAT VS1804] zipl: stfle: use uint64_t instead of u64
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 9d1baaa594d796ca9fe6bdf1282c78e4b2ff5234
Problem-ID: VS1804
Upstream-Description:
zipl: stfle: use uint64_t instead of u64
As the definition of `stfle_fac_list` in the lowcore uses uint64_t, we
should also use uint64_t for the `stfle_fac_list` parameter of the
`stfle/__stfle_asm` function.
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/s390.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -452,7 +452,7 @@ static inline int test_facility(unsigned
return __test_facility(nr, &S390_lowcore.stfle_fac_list);
}
-static inline unsigned long __stfle_asm(u64 *stfle_fac_list, int size)
+static inline unsigned long __stfle_asm(uint64_t *stfle_fac_list, int size)
{
register unsigned long reg0 asm("0") = size - 1;
@@ -469,7 +469,7 @@ static inline unsigned long __stfle_asm(
* @stfle_fac_list: array where facility list can be stored
* @size: size of passed in array in double words
*/
-static inline void stfle(u64 *stfle_fac_list, int size)
+static inline void stfle(uint64_t *stfle_fac_list, int size)
{
unsigned long nr;

View File

@ -0,0 +1,42 @@
Subject: [PATCH] [FEAT VS1804] zipl/boot: fix comment in stage3.lds
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 971970989bbb1de8887d11b0ab8e4f19adbd484f
Problem-ID: VS1804
Upstream-Description:
zipl/boot: fix comment in stage3.lds
See STAGE3_STACK_ADDRESS macro.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/stage3.lds | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/zipl/boot/stage3.lds
+++ b/zipl/boot/stage3.lds
@@ -10,7 +10,7 @@
* 0x6000-0x8fff free
* 0x9000-0x9fff Stage3 parameter
* 0xa000-0xdfff Stage3 code + data
- * 0xe000-0xffff Stack
+ * 0xf000-0xffff Stack
*/
SECTIONS

View File

@ -0,0 +1,50 @@
Subject: [PATCH] [FEAT VS1804] lib/zt_common: add STATIC_ASSERT macro
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: bac3f93772bdf8618c2c9677c59569d70e4a39c0
Problem-ID: VS1804
Upstream-Description:
lib/zt_common: add STATIC_ASSERT macro
Add `STATIC_ASSERT` macro that uses `_Static_assert` if available (was
introduced with gcc 4.6, see https://gcc.gnu.org/wiki/C11Status). For
example, this could be used for the verification of structure sizes at
compile time.
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/zt_common.h | 7 +++++++
1 file changed, 7 insertions(+)
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -22,6 +22,13 @@
# define UNUSED(x) x
#endif
+#ifdef STATIC_ASSERT
+#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ >= 5)
+# define STATIC_ASSERT(test) _Static_assert((test), "(" #test ") failed");
+#else
+# define STATIC_ASSERT(test)
+#endif
+
#define RELEASE_STRING STRINGIFY (S390_TOOLS_RELEASE)
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)

View File

@ -0,0 +1,91 @@
Subject: [PATCH] [FEAT VS1804] zipl: use STATIC_ASSERT macro for no padding verification
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: cc16e41595d6dcb942f84443f27a1b52d06d17da
Problem-ID: VS1804
Upstream-Description:
zipl: use STATIC_ASSERT macro for no padding verification
A simple comment above the struct declaration to indicate that the
structure must not have any padding is prone to error. Therefore let's
add a check for the structure size at compile time.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/sclp.h | 2 ++
zipl/boot/sclp_stage3.h | 2 ++
zipl/boot/stage3.h | 4 ++++
3 files changed, 8 insertions(+)
--- a/zipl/boot/sclp.h
+++ b/zipl/boot/sclp.h
@@ -60,6 +60,7 @@ struct sccb_header {
uint8_t control_mask[3];
uint16_t response_code;
};
+STATIC_ASSERT(sizeof(struct sccb_header) == 2 + 1 + 3 + 2)
/* Structure must not have any padding */
struct evbuf_header {
@@ -68,6 +69,7 @@ struct evbuf_header {
uint8_t flags;
uint16_t _reserved;
};
+STATIC_ASSERT(sizeof(struct evbuf_header) == 2 + 1 + 1 + 2)
struct mto {
uint16_t length;
--- a/zipl/boot/sclp_stage3.h
+++ b/zipl/boot/sclp_stage3.h
@@ -42,6 +42,8 @@ struct sdias_sccb {
struct sccb_header header;
struct sdias_evbuf evbuf;
};
+STATIC_ASSERT(sizeof(struct sdias_sccb) ==
+ sizeof(struct sccb_header) + sizeof(struct sdias_evbuf))
int sclp_hsa_copy(void *, unsigned long, unsigned long);
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -15,6 +15,8 @@
#include "libc.h"
#include "s390.h"
+#include "lib/zt_common.h"
+
#define IPL_DEVICE 0x10404UL
#define INITRD_START 0x10408UL
#define INITRD_SIZE 0x10410UL
@@ -128,6 +130,7 @@ struct ipl_rb_hdr {
uint8_t rbt;
uint8_t reserved1[11];
};
+STATIC_ASSERT(sizeof(struct ipl_rb_hdr) == 4 + 1 + 11)
/* IPL Report Block types */
enum ipl_rbt {
@@ -168,6 +171,7 @@ struct ipl_rb_components {
uint8_t reserved1[11];
struct ipl_rb_component_entry entries[];
};
+STATIC_ASSERT(sizeof(struct ipl_rb_components) == 4 + 1 + 11)
extern unsigned long long _parm_addr; /* address of parmline */
extern unsigned long long _initrd_addr; /* address of initrd */

View File

@ -0,0 +1,65 @@
Subject: [PATCH] [FEAT VS1804] Support `lib/zt_common.h` to be used in assembler and add `_AC` macro
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 400167f5128a14ba48b0d05b7b777b42c450c73f
Problem-ID: VS1804
Upstream-Description:
Support `lib/zt_common.h` to be used in assembler and add `_AC` macro
Support `lib/zt_common.h` to be used in assembler files. In addition,
add the macro `_AC` that can be used to make constant macros usable in
both assembler and C code.
Suggested-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/zt_common.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -15,6 +15,21 @@
#define STRINGIFY_1(x) #x
#define STRINGIFY(x) STRINGIFY_1(x)
+/* Use this macro to make constant macros usable in both assembler and
+ * C code.
+ *
+ * Usage example:
+ * #define IMAGE_ENTRY _AC(0x10000, UL)
+ */
+#ifdef __ASSEMBLER__
+#define _AC(X, TYPE) X
+#else
+#define _AC(X, TYPE) X##TYPE
+#endif
+
+
+#ifndef __ASSEMBLER__
+
#ifdef UNUSED
#elif defined(__GNUC__)
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
@@ -50,4 +65,5 @@ typedef signed short int s16;
typedef unsigned char u8;
typedef signed char s8;
+#endif /* __ASSEMBLER__ */
#endif /* LIB_ZT_COMMON_H */

View File

@ -0,0 +1,359 @@
Subject: [PATCH] [FEAT VS1804] zipl: move IPL related definitions into separate header
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 9d39a4bd47008b15bbf4ebe672b91d6d63888536
Problem-ID: VS1804
Upstream-Description:
zipl: move IPL related definitions into separate header
Move the IPL related definitions into `include/boot/ipl.h`. This
allows the reuse of the definitions, e.g. in the boot loader for
protected guests.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/ipl.h | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++
zipl/boot/stage3.h | 140 ----------------------------------------------
2 files changed, 160 insertions(+), 139 deletions(-)
--- /dev/null
+++ b/include/boot/ipl.h
@@ -0,0 +1,159 @@
+/*
+ * IPL related definitions
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 IPL_H
+#define IPL_H
+
+#include "lib/zt_common.h"
+
+#define IPL_FLAG_SECURE 0x40
+
+#define IPL_RB_COMPONENT_FLAG_SIGNED 0x80
+#define IPL_RB_COMPONENT_FLAG_VERIFIED 0x40
+
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+/* IPL Parameter List header */
+struct ipl_pl_hdr {
+ uint32_t len;
+ uint8_t flags;
+ uint8_t reserved1[2];
+ uint8_t version;
+} __packed;
+
+/* IPL Parameter Block header */
+struct ipl_pb_hdr {
+ uint32_t len;
+ uint8_t pbt;
+} __packed;
+
+/* IPL Parameter Block 0 with common fields */
+struct ipl_pb0_common {
+ uint32_t len;
+ uint8_t pbt;
+ uint8_t flags;
+ uint8_t reserved1[2];
+ uint8_t loadparm[8];
+ uint8_t reserved2[84];
+} __packed;
+
+/* IPL Parameter Block 0 for FCP */
+struct ipl_pb0_fcp {
+ uint32_t len;
+ uint8_t pbt;
+ uint8_t reserved1[3];
+ uint8_t loadparm[8];
+ uint8_t reserved2[304];
+ uint8_t opt;
+ uint8_t reserved3[3];
+ uint8_t cssid;
+ uint8_t reserved4[1];
+ uint8_t devno;
+ uint8_t reserved5[4];
+ uint64_t wwpn;
+ uint64_t lun;
+ uint32_t bootprog;
+ uint8_t reserved6[12];
+ uint64_t br_lba;
+ uint32_t scp_data_len;
+ uint8_t reserved7[260];
+ uint8_t scp_data[];
+} __packed;
+
+/* IPL Parameter Block 0 for CCW */
+struct ipl_pb0_ccw {
+ uint32_t len;
+ uint8_t pbt;
+ uint8_t flags;
+ uint8_t reserved1[2];
+ uint8_t loadparm[8];
+ uint8_t reserved2[84];
+ uint16_t reserved3 : 13;
+ uint8_t ssid : 3;
+ uint16_t devno;
+ uint8_t vm_flags;
+ uint8_t reserved4[3];
+ uint32_t vm_parm_len;
+ uint8_t nss_name[8];
+ uint8_t vm_parm[64];
+ uint8_t reserved5[8];
+} __packed;
+
+struct ipl_parameter_block {
+ struct ipl_pl_hdr hdr;
+ union {
+ struct ipl_pb_hdr pb0_hdr;
+ struct ipl_pb0_common common;
+ struct ipl_pb0_fcp fcp;
+ struct ipl_pb0_ccw ccw;
+ char raw[PAGE_SIZE - sizeof(struct ipl_pl_hdr)];
+ };
+} __packed __aligned(PAGE_SIZE);
+
+/* IPL Report List header */
+struct ipl_rl_hdr {
+ uint32_t len;
+ uint8_t flags;
+ uint8_t reserved1[2];
+ uint8_t version;
+ uint8_t reserved2[8];
+} __packed;
+
+/* IPL Report Block header */
+/* Structure must not have any padding */
+struct ipl_rb_hdr {
+ uint32_t len;
+ uint8_t rbt;
+ uint8_t reserved1[11];
+};
+STATIC_ASSERT(sizeof(struct ipl_rb_hdr) == 4 + 1 + 11)
+
+/* IPL Report Block types */
+enum ipl_rbt {
+ IPL_RBT_CERTIFICATES = 1,
+ IPL_RBT_COMPONENTS = 2,
+};
+
+/* IPL Report Block for the certificate list */
+struct ipl_rb_certificate_entry {
+ uint64_t addr;
+ uint64_t len;
+} __packed;
+
+struct ipl_rb_certificates {
+ uint32_t len;
+ uint8_t rbt;
+ uint8_t reserved1[11];
+ struct ipl_rb_certificate_entry entries[];
+} __packed;
+
+/* IPL Report Block for the component list */
+struct ipl_rb_component_entry {
+ uint64_t addr;
+ uint64_t len;
+ uint8_t flags;
+ uint8_t reserved1[5];
+ uint16_t certificate_index;
+ uint8_t reserved2[8];
+};
+
+/* Structure must not have any padding */
+struct ipl_rb_components {
+ uint32_t len;
+ uint8_t rbt;
+ uint8_t reserved1[11];
+ struct ipl_rb_component_entry entries[];
+};
+STATIC_ASSERT(sizeof(struct ipl_rb_components) == 4 + 1 + 11)
+
+#endif /* __ASSEMBLER__ */
+#endif /* IPL_H */
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -15,7 +15,7 @@
#include "libc.h"
#include "s390.h"
-#include "lib/zt_common.h"
+#include "boot/ipl.h"
#define IPL_DEVICE 0x10404UL
#define INITRD_START 0x10408UL
@@ -29,150 +29,12 @@
#define STAGE3_FLAG_SCSI 0x0001000000000000ULL
#define STAGE3_FLAG_KDUMP 0x0002000000000000ULL
-#define IPL_FLAG_SECURE 0x40
-
#define DEFAULT_PSW_LOAD 0x0008000080010000UL
#define PSW_ADDR_MASK 0x000000007FFFFFFFUL
#define UNSPECIFIED_ADDRESS -1UL
-/* IPL Parameter List header */
-struct ipl_pl_hdr {
- uint32_t len;
- uint8_t flags;
- uint8_t reserved1[2];
- uint8_t version;
-} __packed;
-
-/* IPL Parameter Block header */
-struct ipl_pb_hdr {
- uint32_t len;
- uint8_t pbt;
-} __packed;
-
-/* IPL Parameter Block 0 with common fields */
-struct ipl_pb0_common {
- uint32_t len;
- uint8_t pbt;
- uint8_t flags;
- uint8_t reserved1[2];
- uint8_t loadparm[8];
- uint8_t reserved2[84];
-} __packed;
-
-/* IPL Parameter Block 0 for FCP */
-struct ipl_pb0_fcp {
- uint32_t len;
- uint8_t pbt;
- uint8_t reserved1[3];
- uint8_t loadparm[8];
- uint8_t reserved2[304];
- uint8_t opt;
- uint8_t reserved3[3];
- uint8_t cssid;
- uint8_t reserved4[1];
- uint8_t devno;
- uint8_t reserved5[4];
- uint64_t wwpn;
- uint64_t lun;
- uint32_t bootprog;
- uint8_t reserved6[12];
- uint64_t br_lba;
- uint32_t scp_data_len;
- uint8_t reserved7[260];
- uint8_t scp_data[];
-} __packed;
-
-/* IPL Parameter Block 0 for CCW */
-struct ipl_pb0_ccw {
- uint32_t len;
- uint8_t pbt;
- uint8_t flags;
- uint8_t reserved1[2];
- uint8_t loadparm[8];
- uint8_t reserved2[84];
- uint16_t reserved3 : 13;
- uint8_t ssid : 3;
- uint16_t devno;
- uint8_t vm_flags;
- uint8_t reserved4[3];
- uint32_t vm_parm_len;
- uint8_t nss_name[8];
- uint8_t vm_parm[64];
- uint8_t reserved5[8];
-} __packed;
-
-struct ipl_parameter_block {
- struct ipl_pl_hdr hdr;
- union {
- struct ipl_pb_hdr pb0_hdr;
- struct ipl_pb0_common common;
- struct ipl_pb0_fcp fcp;
- struct ipl_pb0_ccw ccw;
- char raw[PAGE_SIZE - sizeof(struct ipl_pl_hdr)];
- };
-} __packed __aligned(PAGE_SIZE);
-
-/* IPL Report List header */
-struct ipl_rl_hdr {
- uint32_t len;
- uint8_t flags;
- uint8_t reserved1[2];
- uint8_t version;
- uint8_t reserved2[8];
-} __packed;
-
-/* IPL Report Block header */
-/* Structure must not have any padding */
-struct ipl_rb_hdr {
- uint32_t len;
- uint8_t rbt;
- uint8_t reserved1[11];
-};
-STATIC_ASSERT(sizeof(struct ipl_rb_hdr) == 4 + 1 + 11)
-
-/* IPL Report Block types */
-enum ipl_rbt {
- IPL_RBT_CERTIFICATES = 1,
- IPL_RBT_COMPONENTS = 2,
-};
-
-/* IPL Report Block for the certificate list */
-struct ipl_rb_certificate_entry {
- uint64_t addr;
- uint64_t len;
-} __packed;
-
-struct ipl_rb_certificates {
- uint32_t len;
- uint8_t rbt;
- uint8_t reserved1[11];
- struct ipl_rb_certificate_entry entries[];
-} __packed;
-
-/* IPL Report Block for the component list */
-struct ipl_rb_component_entry {
- uint64_t addr;
- uint64_t len;
- uint8_t flags;
- uint8_t reserved1[5];
- uint16_t certificate_index;
- uint8_t reserved2[8];
-};
-
-#define IPL_RB_COMPONENT_FLAG_SIGNED 0x80
-#define IPL_RB_COMPONENT_FLAG_VERIFIED 0x40
-
-/* Structure must not have any padding */
-struct ipl_rb_components {
- uint32_t len;
- uint8_t rbt;
- uint8_t reserved1[11];
- struct ipl_rb_component_entry entries[];
-};
-STATIC_ASSERT(sizeof(struct ipl_rb_components) == 4 + 1 + 11)
-
extern unsigned long long _parm_addr; /* address of parmline */
extern unsigned long long _initrd_addr; /* address of initrd */
extern unsigned long long _initrd_len; /* length of initrd */

View File

@ -0,0 +1,148 @@
Subject: [PATCH] [FEAT VS1804] zipl: move SIGP related functions and definitions into separate header
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 675c854fa3239882c59a9419c776eb13bc70cf76
Problem-ID: VS1804
Upstream-Description:
zipl: move SIGP related functions and definitions into separate header
Move SIGP related functions and definitions to
`include/boot/sigp.h`. This allows the reuse of the definitions in
assembler files.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/sigp.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
zipl/boot/s390.h | 38 -----------------------------------
2 files changed, 56 insertions(+), 37 deletions(-)
--- /dev/null
+++ b/include/boot/sigp.h
@@ -0,0 +1,55 @@
+/*
+ * SIGP related definitions and functions.
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 S390_SIGP_H
+#define S390_SIGP_H
+
+/* Signal Processor Order Codes */
+#define SIGP_STOP_AND_STORE_STATUS 9
+#define SIGP_SET_MULTI_THREADING 22
+#define SIGP_STORE_ASTATUS_AT_ADDRESS 23
+
+/* Signal Processor Condition Codes */
+#define SIGP_CC_ORDER_CODE_ACCEPTED 0
+#define SIGP_CC_BUSY 2
+
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+static inline int sigp(uint16_t addr, uint8_t order, uint32_t parm,
+ uint32_t *status)
+{
+ register unsigned int reg1 asm ("1") = parm;
+ int cc;
+
+ asm volatile(
+ " sigp %1,%2,0(%3)\n"
+ " ipm %0\n"
+ " srl %0,28\n"
+ : "=d" (cc), "+d" (reg1) : "d" (addr), "a" (order) : "cc");
+ if (status && cc == 1)
+ *status = reg1;
+ return cc;
+}
+
+static inline int sigp_busy(uint16_t addr, uint8_t order, uint32_t parm,
+ uint32_t *status)
+{
+ int cc;
+
+ do {
+ cc = sigp(addr, order, parm, status);
+ } while (cc == SIGP_CC_BUSY);
+ return cc;
+}
+
+#endif /* __ASSEMBLER__ */
+#endif /* S390_SIGP_H */
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -13,6 +13,7 @@
#include "lib/zt_common.h"
#include "libc.h"
+#include "boot/sigp.h"
#define __pa32(x) ((uint32_t)(unsigned long)(x))
#define __pa(x) ((unsigned long)(x))
@@ -295,43 +296,6 @@ static inline int diag308(unsigned long
}
/*
- * Signal Processor
- */
-#define SIGP_STOP_AND_STORE_STATUS 9
-#define SIGP_SET_MULTI_THREADING 22
-#define SIGP_STORE_ASTATUS_AT_ADDRESS 23
-
-#define SIGP_CC_ORDER_CODE_ACCEPTED 0
-#define SIGP_CC_BUSY 2
-
-static inline int sigp(uint16_t addr, uint8_t order, uint32_t parm,
- uint32_t *status)
-{
- register unsigned int reg1 asm ("1") = parm;
- int cc;
-
- asm volatile(
- " sigp %1,%2,0(%3)\n"
- " ipm %0\n"
- " srl %0,28\n"
- : "=d" (cc), "+d" (reg1) : "d" (addr), "a" (order) : "cc");
- if (status && cc == 1)
- *status = reg1;
- return cc;
-}
-
-static inline int sigp_busy(uint16_t addr, uint8_t order, uint32_t parm,
- uint32_t *status)
-{
- int cc;
-
- do {
- cc = sigp(addr, order, parm, status);
- } while (cc == SIGP_CC_BUSY);
- return cc;
-}
-
-/*
* Store CPU address
*/
static inline unsigned short stap(void)

View File

@ -0,0 +1,117 @@
Subject: [PATCH] [FEAT VS1804] zipl: add SIGP_SET_ARCHITECTURE to sigp.h and use it
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 0e385a81caf7c266c0784613e0264c03271eb99a
Problem-ID: VS1804
Upstream-Description:
zipl: add SIGP_SET_ARCHITECTURE to sigp.h and use it
This makes the code easier to read.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/sigp.h | 1 +
zipl/boot/head.S | 6 ++++--
zipl/boot/stage3.c | 6 ++++--
zipl/boot/tape0.S | 6 ++++--
4 files changed, 13 insertions(+), 6 deletions(-)
--- a/include/boot/sigp.h
+++ b/include/boot/sigp.h
@@ -12,6 +12,7 @@
/* Signal Processor Order Codes */
#define SIGP_STOP_AND_STORE_STATUS 9
+#define SIGP_SET_ARCHITECTURE 18
#define SIGP_SET_MULTI_THREADING 22
#define SIGP_STORE_ASTATUS_AT_ADDRESS 23
--- a/zipl/boot/head.S
+++ b/zipl/boot/head.S
@@ -9,16 +9,18 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "boot/sigp.h"
+
.section .text.start
.globl _start
_start:
basr %r13,0
0: la %r7,2 /* First try code 2: */
la %r6,0 /* 64 bit psws are restored */
- sigp %r7,%r6,0x12 /* Switch to 64 bit */
+ sigp %r7,%r6,SIGP_SET_ARCHITECTURE /* Switch to 64 bit */
bc 8,.Lswitched_64-0b(%r13) /* Accepted ? */
la %r7,1 /* Failed - try code 1 */
- sigp %r7,%r6,0x12 /* Switch to 64 bit */
+ sigp %r7,%r6,SIGP_SET_ARCHITECTURE /* Switch to 64 bit */
.Lswitched_64:
sam64 /* Switch to 64 bit addr mode */
basr %r13,0
--- a/zipl/boot/stage3.c
+++ b/zipl/boot/stage3.c
@@ -10,6 +10,7 @@
*/
#include "libc.h"
+#include "boot/sigp.h"
#include "s390.h"
#include "stage3.h"
#include "error.h"
@@ -194,11 +195,12 @@ static inline void __noreturn start_kern
" sam31\n"
" sr %r1,%r1\n"
" sr %r2,%r2\n"
- " sigp %r1,%r2,0x12\n"
+ " sigp %r1,%r2,%[order]\n"
" lpsw 0\n"
: [addr] "=&d" (addr),
[code] "+&d" (code)
- : [psw] "a" (psw) );
+ : [psw] "a" (psw),
+ [order] "L" (SIGP_SET_ARCHITECTURE));
while (1);
}
--- a/zipl/boot/tape0.S
+++ b/zipl/boot/tape0.S
@@ -7,6 +7,8 @@
# it under the terms of the MIT license. See LICENSE for details.
#
+#include "boot/sigp.h"
+
IPL_BS = 1024 # block size for tape access
IPL_OFF = 0x4000 # temporary kernel load addr
COMMAND_LINE_SIZE = 896 # max command line length
@@ -184,10 +186,10 @@ iplstart:
0:
la %r7,2 #/* First try code 2: */
la %r6,0 #/* 64 bit psws are restored */
- sigp %r7,%r6,0x12 #/* Switch to 64 bit */
+ sigp %r7,%r6,SIGP_SET_ARCHITECTURE #/* Switch to 64 bit */
bc 8,.Lswitched_64-0b(%r13) #/* Accepted ? */
la %r7,1 #/* Failed - try code 1 */
- sigp %r7,%r6,0x12 #/* Switch to 64 bit */
+ sigp %r7,%r6,SIGP_SET_ARCHITECTURE #/* Switch to 64 bit */
.Lswitched_64:
sam64 #/* Switch to 64 bit addr mode */
basr %r13,0

View File

@ -0,0 +1,56 @@
Subject: [PATCH] [FEAT VS1804] zipl/stage3: make IPL_DEVICE definition consistent with tape0.S
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: d884fb8db4c4f383780d6fc8087abd8f80e1c8b8
Problem-ID: VS1804
Upstream-Description:
zipl/stage3: make IPL_DEVICE definition consistent with tape0.S
Make `IPL_DEVICE` definition consistent with the kernel definition and
the definition in tape0.S. This allows us to refactor the code later.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/stage3.c | 2 +-
zipl/boot/stage3.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/zipl/boot/stage3.c
+++ b/zipl/boot/stage3.c
@@ -292,7 +292,7 @@ void start(void)
/* store subchannel ID into low core and into new kernel space */
subchannel_id = S390_lowcore.subchannel_id;
*(unsigned int *)__LC_IPLDEV = subchannel_id;
- *(unsigned int *)IPL_DEVICE = subchannel_id;
+ *(unsigned long long *)IPL_DEVICE = subchannel_id;
/* if valid command line is given, copy it into new kernel space */
if (_parm_addr != UNSPECIFIED_ADDRESS) {
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -17,7 +17,7 @@
#include "boot/ipl.h"
-#define IPL_DEVICE 0x10404UL
+#define IPL_DEVICE 0x10400UL
#define INITRD_START 0x10408UL
#define INITRD_SIZE 0x10410UL
#define OLDMEM_BASE 0x10418UL

View File

@ -0,0 +1,109 @@
Subject: [PATCH] [FEAT VS1804] zipl: move Linux layout definitions into separate header
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 7e37a1d4e0605ea120db18f82d039c055fd5d737
Problem-ID: VS1804
Upstream-Description:
zipl: move Linux layout definitions into separate header
Move the Linux layout values to `include/boot/linux_layout.h`. This
allows the reuse of the definitions, e.g. in assembler files, and
later for the creation of linker scripts.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/linux_layout.h | 33 +++++++++++++++++++++++++++++++++
zipl/boot/stage3.h | 9 ++-------
zipl/include/zipl.h | 3 +--
3 files changed, 36 insertions(+), 9 deletions(-)
--- /dev/null
+++ b/include/boot/linux_layout.h
@@ -0,0 +1,33 @@
+/*
+ * s390 Linux layout definitions
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 LINUX_LAYOUT_H
+#define LINUX_LAYOUT_H
+
+#include "lib/zt_common.h"
+
+/* Entry address offsets */
+#define IMAGE_ENTRY _AC(0x10000, UL)
+#define IMAGE_ENTRY_KDUMP _AC(0x10010, UL)
+
+/* Parameter address offsets */
+#define IPL_DEVICE _AC(0x10400, UL)
+#define INITRD_START _AC(0x10408, UL)
+#define INITRD_SIZE _AC(0x10410, UL)
+#define OLDMEM_BASE _AC(0x10418, UL)
+#define OLDMEM_SIZE _AC(0x10420, UL)
+#define COMMAND_LINE _AC(0x10480, UL)
+
+/* Parameter sizes */
+#define COMMAND_LINE_SIZE 896
+
+
+#ifndef __ASSEMBLER__
+#endif /* __ASSEMBLER__ */
+#endif /* LINUX_LAYOUT_H */
--- a/zipl/boot/stage3.h
+++ b/zipl/boot/stage3.h
@@ -16,14 +16,9 @@
#include "s390.h"
#include "boot/ipl.h"
+#include "boot/linux_layout.h"
+
-#define IPL_DEVICE 0x10400UL
-#define INITRD_START 0x10408UL
-#define INITRD_SIZE 0x10410UL
-#define OLDMEM_BASE 0x10418UL
-#define OLDMEM_SIZE 0x10420UL
-#define COMMAND_LINE 0x10480UL
-#define COMMAND_LINE_SIZE 896
#define COMMAND_LINE_EXTRA 0xE000
#define STAGE3_FLAG_SCSI 0x0001000000000000ULL
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -14,14 +14,13 @@
#include <stdint.h>
#include "lib/zt_common.h"
+#include "boot/linux_layout.h"
#define ZIPL_MAGIC "zIPL"
#define ZIPL_MAGIC_SIZE 4
#define DISK_LAYOUT_ID 0x00000001
#define STAGE3_ENTRY 0xa000UL
-#define IMAGE_ENTRY 0x10000UL
-#define IMAGE_ENTRY_KDUMP 0x10010UL
#define STAGE2_LOAD_ADDRESS 0x2000UL
#define STAGE3_LOAD_ADDRESS 0xa000UL

View File

@ -0,0 +1,79 @@
Subject: [PATCH] [FEAT VS1804] zipl: tape0: use constants defined in linux_layout.h
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: c871050097ecb2ec83cf3018ea36e01cd22cbe7d
Problem-ID: VS1804
Upstream-Description:
zipl: tape0: use constants defined in linux_layout.h
Use the constants defined in `linux_layout.h`. Therefore move the
`PARMAREA` address offset to `linux_layout.h` and include the header.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/linux_layout.h | 1 +
zipl/boot/tape0.S | 14 +++-----------
2 files changed, 4 insertions(+), 11 deletions(-)
--- a/include/boot/linux_layout.h
+++ b/include/boot/linux_layout.h
@@ -17,6 +17,7 @@
#define IMAGE_ENTRY_KDUMP _AC(0x10010, UL)
/* Parameter address offsets */
+#define PARMAREA _AC(0x10400, UL)
#define IPL_DEVICE _AC(0x10400, UL)
#define INITRD_START _AC(0x10408, UL)
#define INITRD_SIZE _AC(0x10410, UL)
--- a/zipl/boot/tape0.S
+++ b/zipl/boot/tape0.S
@@ -8,29 +8,21 @@
#
#include "boot/sigp.h"
+#include "boot/linux_layout.h"
IPL_BS = 1024 # block size for tape access
IPL_OFF = 0x4000 # temporary kernel load addr
-COMMAND_LINE_SIZE = 896 # max command line length
-KERNEL_OFF = 0x10000 # kernel start code offset
+KERNEL_OFF = IMAGE_ENTRY # kernel start code offset
# relative to image start
__LC_IO_NEW_PSW = 0x1f0 # IO New PSW addr
-# Parameter address offsets
-
-PARMAREA = 0x10400 # Parameter area offset
-IPL_DEVICE = 0x10400 # IPL device offset
-INITRD_START = 0x10408 # ramdisk addr offset
-INITRD_SIZE = 0x10410 # ramdisk size offset
-COMMAND_LINE = 0x10480 # command line offset
-
# Default IPL parameter - will be overwritten by zIPL
RAMDISK_ORIGIN = 0x800000 # default ramdisk load addr
RAMDISK_SIZE = 0x800000 # default ramdisk size
PARMFILE_ADDR = 0x1000 # default parmfile load addr
-KERNEL_ADDR = 0x10000 # default kernel load addr
+KERNEL_ADDR = IMAGE_ENTRY # default kernel load addr
.org 0x0

View File

@ -0,0 +1,45 @@
Subject: [PATCH] [FEAT VS1804] zipl: use STAGE3_ENTRY for STAGE3_LOAD_ADDRESS
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: c07104dbc734ec6e55accf1bd2091b251f312ed8
Problem-ID: VS1804
Upstream-Description:
zipl: use STAGE3_ENTRY for STAGE3_LOAD_ADDRESS
Use STAGE3_ENTRY for STAGE3_LOAD_ADDRESS as they have the same value
and this makes it more clear that the load address of stage3 is also
its entry point.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/include/zipl.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -23,7 +23,7 @@
#define STAGE3_ENTRY 0xa000UL
#define STAGE2_LOAD_ADDRESS 0x2000UL
-#define STAGE3_LOAD_ADDRESS 0xa000UL
+#define STAGE3_LOAD_ADDRESS STAGE3_ENTRY
#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
#define ADDRESS_LIMIT 0x80000000UL

View File

@ -0,0 +1,105 @@
Subject: [PATCH] [FEAT VS1804] zipl: move loaders layout definitions into separate header
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 97ab8fb4e98c84a89d421c08b392db665125a3c0
Problem-ID: VS1804
Upstream-Description:
zipl: move loaders layout definitions into separate header
Move the loaders (stage2/stage3) layout values to
`include/boot/loaders_layout.h` and use the `_AC` macro for the
constants. This allows the reuse of the definitions, e.g. in assembler
files, and later for the creation of linker scripts.
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/loaders_layout.h | 32 ++++++++++++++++++++++++++++++++
zipl/include/zipl.h | 14 +-------------
2 files changed, 33 insertions(+), 13 deletions(-)
--- /dev/null
+++ b/include/boot/loaders_layout.h
@@ -0,0 +1,32 @@
+/*
+ * zipl stage2/stage3 layout definitions
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 LOADERS_LAYOUT_H
+#define LOADERS_LAYOUT_H
+
+#include "lib/zt_common.h"
+#include "linux_layout.h"
+
+#define STAGE3_ENTRY _AC(0xa000, UL)
+
+#define STAGE2_LOAD_ADDRESS _AC(0x2000, UL)
+#define STAGE3_LOAD_ADDRESS STAGE3_ENTRY
+#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
+
+#define STAGE3_HEAP_SIZE _AC(0x4000, UL)
+#define STAGE3_HEAP_ADDRESS _AC(0x2000, UL)
+#define STAGE3_STACK_SIZE _AC(0x1000, UL)
+#define STAGE3_STACK_ADDRESS _AC(0xF000, UL)
+#define STAGE3_PARAMS_ADDRESS _AC(0x9000, UL)
+
+
+#ifndef __ASSEMBLER__
+#endif /* __ASSEMBLER__ */
+#endif /* LOADERS_LAYOUT_H */
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -14,30 +14,18 @@
#include <stdint.h>
#include "lib/zt_common.h"
-#include "boot/linux_layout.h"
+#include "boot/loaders_layout.h"
#define ZIPL_MAGIC "zIPL"
#define ZIPL_MAGIC_SIZE 4
#define DISK_LAYOUT_ID 0x00000001
-#define STAGE3_ENTRY 0xa000UL
-
-#define STAGE2_LOAD_ADDRESS 0x2000UL
-#define STAGE3_LOAD_ADDRESS STAGE3_ENTRY
-#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
-
#define ADDRESS_LIMIT 0x80000000UL
#define ADDRESS_LIMIT_KDUMP 0x2000000UL /* HSA size: 32 MiB */
#define UNSPECIFIED_ADDRESS -1UL
#define MAXIMUM_PARMLINE_SIZE 0x380UL
#define MAXIMUM_PHYSICAL_BLOCKSIZE 0x1000UL
-#define STAGE3_HEAP_SIZE 0x4000UL
-#define STAGE3_HEAP_ADDRESS 0x2000UL
-#define STAGE3_STACK_SIZE 0x1000UL
-#define STAGE3_STACK_ADDRESS 0xF000UL
-#define STAGE3_PARAMS_ADDRESS 0x9000UL
-
#define PSW_ADDRESS_MASK 0x000000007fffffffUL
#define PSW_LOAD 0x0008000080000000UL
#define PSW_DISABLED_WAIT 0x000a000000000000UL

View File

@ -0,0 +1,192 @@
Subject: [PATCH] [FEAT VS1804] zipl/s390.h: rename `inline` macro into `__always_inline`
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 67e76b8ebd8acb4aef1d22309287776892b7267e
Problem-ID: VS1804
Upstream-Description:
zipl/s390.h: rename `inline` macro into `__always_inline`
Rename `inline` macro into `__always_inline` so one can differentiate
between the macro and the C keyword. While at it, undefine the
previous `__always_inline` macro so s390.h can be used in combination
with glibc.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/s390.h | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -19,7 +19,12 @@
#define __pa(x) ((unsigned long)(x))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define barrier() __asm__ __volatile__("": : :"memory")
-#define inline inline __attribute__((always_inline))
+/* The Linux kernel (in stddef.h) and glibc (sys/cdefs.h) define
+ * __always_inline. Therefore undefine it first to allow the headers
+ * to be included first.
+ */
+#undef __always_inline
+#define __always_inline inline __attribute__((always_inline))
/*
* Helper macro for exception table entries
@@ -214,7 +219,7 @@ do { \
libc_stop(reason); \
} while (0)
-static inline int page_is_valid(unsigned long addr)
+static __always_inline int page_is_valid(unsigned long addr)
{
unsigned long tmp;
int rc;
@@ -234,7 +239,7 @@ static inline int page_is_valid(unsigned
return rc;
}
-static inline uint32_t csum_partial(const void *buf, int len, uint32_t sum)
+static __always_inline uint32_t csum_partial(const void *buf, int len, uint32_t sum)
{
register unsigned long reg2 asm("2") = (unsigned long) buf;
register unsigned long reg3 asm("3") = (unsigned long) len;
@@ -262,7 +267,7 @@ static inline uint32_t csum_partial(cons
"i" (low), "i" (high)); \
})
-static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
+static __always_inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
{
unsigned long reg;
@@ -282,7 +287,7 @@ enum diag308_subcode {
DIAG308_STORE = 6,
};
-static inline int diag308(unsigned long subcode, void *addr)
+static __always_inline int diag308(unsigned long subcode, void *addr)
{
register unsigned long _addr asm("0") = (unsigned long) addr;
register unsigned long _rc asm("1") = 0;
@@ -298,7 +303,7 @@ static inline int diag308(unsigned long
/*
* Store CPU address
*/
-static inline unsigned short stap(void)
+static __always_inline unsigned short stap(void)
{
unsigned short cpu_address;
@@ -309,7 +314,7 @@ static inline unsigned short stap(void)
/*
* Program the clock comparator
*/
-static inline void set_clock_comparator(uint64_t time)
+static __always_inline void set_clock_comparator(uint64_t time)
{
asm volatile("sckc %0" : : "Q" (time));
}
@@ -317,7 +322,7 @@ static inline void set_clock_comparator(
/*
* Program the CPU timer
*/
-static inline void set_cpu_timer(uint64_t timer)
+static __always_inline void set_cpu_timer(uint64_t timer)
{
asm volatile("spt %0" : : "Q" (timer));
}
@@ -325,7 +330,7 @@ static inline void set_cpu_timer(uint64_
/*
* Get current time (store clock)
*/
-static inline unsigned long long get_tod_clock(void)
+static __always_inline unsigned long long get_tod_clock(void)
{
unsigned long long clk;
@@ -343,7 +348,7 @@ struct cpuid {
unsigned int unused:16;
} __packed __aligned(8);
-static inline void get_cpu_id(struct cpuid *ptr)
+static __always_inline void get_cpu_id(struct cpuid *ptr)
{
asm volatile("stidp %0" : "=Q" (*ptr));
}
@@ -351,7 +356,7 @@ static inline void get_cpu_id(struct cpu
/*
* Check if we run under z/VM
*/
-static inline int is_zvm(void)
+static __always_inline int is_zvm(void)
{
struct cpuid cpuid;
@@ -369,7 +374,7 @@ typedef struct {
/*
* Save vector registers
*/
-static inline void save_vx_regs(__vector128 *vxrs)
+static __always_inline void save_vx_regs(__vector128 *vxrs)
{
typedef struct { __vector128 _[32]; } addrtype;
@@ -383,7 +388,7 @@ static inline void save_vx_regs(__vector
/*
* Save vector registers safe
*/
-static inline void save_vx_regs_safe(__vector128 *vxrs)
+static __always_inline void save_vx_regs_safe(__vector128 *vxrs)
{
unsigned long cr0;
@@ -396,7 +401,7 @@ static inline void save_vx_regs_safe(__v
#define MAX_FACILITY_BIT (256*8) /* stfle_fac_list has 256 bytes */
-static inline int __test_facility(unsigned long nr, void *facilities)
+static __always_inline int __test_facility(unsigned long nr, void *facilities)
{
unsigned char *ptr;
@@ -411,12 +416,12 @@ static inline int __test_facility(unsign
* That makes it easier to query facility bits with the bit number as
* documented in the Principles of Operation.
*/
-static inline int test_facility(unsigned long nr)
+static __always_inline int test_facility(unsigned long nr)
{
return __test_facility(nr, &S390_lowcore.stfle_fac_list);
}
-static inline unsigned long __stfle_asm(uint64_t *stfle_fac_list, int size)
+static __always_inline unsigned long __stfle_asm(uint64_t *stfle_fac_list, int size)
{
register unsigned long reg0 asm("0") = size - 1;
@@ -433,7 +438,7 @@ static inline unsigned long __stfle_asm(
* @stfle_fac_list: array where facility list can be stored
* @size: size of passed in array in double words
*/
-static inline void stfle(uint64_t *stfle_fac_list, int size)
+static __always_inline void stfle(uint64_t *stfle_fac_list, int size)
{
unsigned long nr;

View File

@ -0,0 +1,74 @@
Subject: [PATCH] [FEAT VS1804] zipl: move __always_inline/barrier/__pa32/pa to zt_common.h
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 24fe8c1d1b75185f341ec2d0efc6c34f0b9263f1
Problem-ID: VS1804
Upstream-Description:
zipl: move __always_inline/barrier/__pa32/pa to zt_common.h
Move `__always_inline/barrier/__pa32/pa` to `lib/zt_common.h` as this
is non-architecture dependent code.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/zt_common.h | 12 ++++++++++++
zipl/boot/s390.h | 9 ---------
2 files changed, 12 insertions(+), 9 deletions(-)
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -55,6 +55,18 @@
#define __may_alias __attribute__((may_alias))
#define __section(x) __attribute__((__section__(#x)))
#define __noinline __attribute__((__noinline__))
+/* The Linux kernel (in stddef.h) and glibc (sys/cdefs.h) define
+ * __always_inline. Therefore undefine it first to allow the headers
+ * to be included first.
+ */
+#undef __always_inline
+#define __always_inline inline __attribute__((always_inline))
+
+#define __pa32(x) ((uint32_t)(unsigned long)(x))
+#define __pa(x) ((unsigned long)(x))
+
+#define barrier() __asm__ __volatile__("": : :"memory")
+
typedef unsigned long long u64;
typedef signed long long s64;
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -15,16 +15,7 @@
#include "libc.h"
#include "boot/sigp.h"
-#define __pa32(x) ((uint32_t)(unsigned long)(x))
-#define __pa(x) ((unsigned long)(x))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#define barrier() __asm__ __volatile__("": : :"memory")
-/* The Linux kernel (in stddef.h) and glibc (sys/cdefs.h) define
- * __always_inline. Therefore undefine it first to allow the headers
- * to be included first.
- */
-#undef __always_inline
-#define __always_inline inline __attribute__((always_inline))
/*
* Helper macro for exception table entries

View File

@ -0,0 +1,44 @@
Subject: [PATCH] [FEAT VS1804] zipl: make BLK_PWRT unsigned int
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 2e28291c75d73b92921f7769eaa803fe3222f383
Problem-ID: VS1804
Upstream-Description:
zipl: make BLK_PWRT unsigned int
Otherwise there might be a compiler warning when using 'MIN(bl_count,
BLK_PWRT)'.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/fba2dump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/zipl/boot/fba2dump.c
+++ b/zipl/boot/fba2dump.c
@@ -14,7 +14,7 @@
#include "fba.h"
#include "stage2dump.h"
-#define BLK_PWRT 64 /* Blocks per write */
+#define BLK_PWRT 64U /* Blocks per write */
#define BLK_SIZE 0x200 /* FBA block size */
#define BLK_PER_PAGE (PAGE_SIZE / BLK_SIZE) /* FBA blocks per page */

View File

@ -0,0 +1,105 @@
Subject: [PATCH] [FEAT VS1804] Consolidate MIN and MAX macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: c55ceabc6726a7806922d288149003661f673a2f
Problem-ID: VS1804
Upstream-Description:
Consolidate MIN and MAX macros
Consolidate MIN and MAX macros and make sure it can be used in
combination with glib.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/lib/util_base.h | 17 +----------------
include/lib/zt_common.h | 17 +++++++++++++++++
zipl/boot/s390.h | 1 -
3 files changed, 18 insertions(+), 17 deletions(-)
--- a/include/lib/util_base.h
+++ b/include/lib/util_base.h
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "zt_common.h"
void util_hexdump(FILE *fh, const char *tag, const void *data, int cnt);
void util_hexdump_grp(FILE *fh, const char *tag, const void *data, int group,
@@ -22,22 +23,6 @@ void util_print_indented(const char *str
#define UTIL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
-#define MIN(x, y) \
-({ \
- __typeof__(x) _x = (x); \
- __typeof__(y) _y = (y); \
- \
- _x < _y ? _x : _y; \
-})
-
-#define MAX(x, y) \
-({ \
- __typeof__(x) _x = (x); \
- __typeof__(y) _y = (y); \
- \
- _x > _y ? _x : _y; \
-})
-
static inline void util_ptr_vec_free(void **ptr_vec, int count)
{
int i;
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -67,6 +67,23 @@
#define barrier() __asm__ __volatile__("": : :"memory")
+#undef MIN
+#define MIN(x, y) \
+ ({ \
+ __typeof__(x) _x = (x); \
+ __typeof__(y) _y = (y); \
+ \
+ _x < _y ? _x : _y; \
+ })
+
+#undef MAX
+#define MAX(x, y) \
+ ({ \
+ __typeof__(x) _x = (x); \
+ __typeof__(y) _y = (y); \
+ \
+ _x > _y ? _x : _y; \
+ })
typedef unsigned long long u64;
typedef signed long long s64;
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -15,7 +15,6 @@
#include "libc.h"
#include "boot/sigp.h"
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
/*
* Helper macro for exception table entries

View File

@ -0,0 +1,76 @@
Subject: [PATCH] [FEAT VS1804] zipl: remove libc.h include in s390.h
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: f454c6825f5087cf671d0dfbe96f7f3d148569d6
Problem-ID: VS1804
Upstream-Description:
zipl: remove libc.h include in s390.h
This allows the use of s390.h in combination with other libc
implementations than our minimal libc, e.g. with glibc.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/s390.h | 1 -
zipl/boot/sclp.c | 1 +
zipl/boot/sclp_stage3.c | 1 +
zipl/boot/stage2dump.c | 1 +
4 files changed, 3 insertions(+), 1 deletion(-)
--- a/zipl/boot/s390.h
+++ b/zipl/boot/s390.h
@@ -12,7 +12,6 @@
#define S390_H
#include "lib/zt_common.h"
-#include "libc.h"
#include "boot/sigp.h"
--- a/zipl/boot/sclp.c
+++ b/zipl/boot/sclp.c
@@ -9,6 +9,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "libc.h"
#include "error.h"
#include "s390.h"
#include "sclp.h"
--- a/zipl/boot/sclp_stage3.c
+++ b/zipl/boot/sclp_stage3.c
@@ -9,6 +9,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "libc.h"
#include "sclp.h"
#include "sclp_stage3.h"
--- a/zipl/boot/stage2dump.c
+++ b/zipl/boot/stage2dump.c
@@ -13,6 +13,7 @@
#include "lib/zt_common.h"
+#include "libc.h"
#include "error.h"
#include "sclp.h"
#include "stage2dump.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
Subject: [PATCH] [FEAT VS1804] zipl/libc: include 's390.h'
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: b0f82d22f9f60a0a8db1976751aa5a875e7c5f80
Problem-ID: VS1804
Upstream-Description:
zipl/libc: include 's390.h'
Include 'boot/s390.h' in 'libc.c' as `PAGE_SIZE` is used there and
move the 'libc.h' include directive to the top.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/libc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/zipl/boot/libc.c
+++ b/zipl/boot/libc.c
@@ -9,12 +9,14 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
+#include "libc.h"
+
#include <stdarg.h>
#include "lib/zt_common.h"
+#include "boot/s390.h"
#include "error.h"
-#include "libc.h"
#include "sclp.h"
extern char __heap_start[];

View File

@ -0,0 +1,69 @@
Subject: [PATCH] [FEAT VS1804] include/boot/s390.h: move panic and panic_notify to libc.h
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 2568863f581cff9bf3b1e27c2d2917b5ae3b5177
Problem-ID: VS1804
Upstream-Description:
include/boot/s390.h: move panic and panic_notify to libc.h
... as this code is not s390 specific and not every user of s390.h
wants to implement `panic_notify`.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/s390.h | 9 ---------
zipl/boot/libc.h | 8 ++++++++
2 files changed, 8 insertions(+), 9 deletions(-)
--- a/include/boot/s390.h
+++ b/include/boot/s390.h
@@ -201,15 +201,6 @@ struct _lowcore {
#define S390_lowcore (*((struct _lowcore *) 0))
-void panic_notify(unsigned long reason);
-
-#define panic(reason, x...) \
-do { \
- printf(x); \
- panic_notify(reason); \
- libc_stop(reason); \
-} while (0)
-
static __always_inline int page_is_valid(unsigned long addr)
{
unsigned long tmp;
--- a/zipl/boot/libc.h
+++ b/zipl/boot/libc.h
@@ -61,6 +61,14 @@ void libc_stop(unsigned long);
void start(void);
void pgm_check_handler(void);
void pgm_check_handler_fn(void);
+void panic_notify(unsigned long reason);
+
+#define panic(reason, ...) \
+ do { \
+ printf(__VA_ARGS__); \
+ panic_notify(reason); \
+ libc_stop(reason); \
+ } while (0)
static inline int isdigit(int c)
{

View File

@ -0,0 +1,73 @@
Subject: [PATCH] [FEAT VS1804] include/boot/s390.h: fixes for -Werror=sign-conversion
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 305235a7bce814f71ec113a612b6117c96894e23
Problem-ID: VS1804
Upstream-Description:
include/boot/s390.h: fixes for -Werror=sign-conversion
Errors fixed:
../../include/boot/s390.h: In function '__stfle_asm':
../../include/boot/s390.h:424:41: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
register unsigned long reg0 asm("0") = size - 1;
../../include/boot/s390.h: In function 'stfle':
../../include/boot/s390.h:453:31: error: conversion to 'long unsigned int' from 'int' may change the sign of the result [-Werror=sign-conversion]
nr = MIN((nr + 1) * 8, size * 8UL);
../../include/boot/s390.h: In function 'diag308':
../../include/boot/s390.h:296:9: error: conversion from 'long unsigned int' to 'int' may change value [-Werror=conversion]
return _rc;
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/s390.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/include/boot/s390.h
+++ b/include/boot/s390.h
@@ -269,7 +269,7 @@ enum diag308_subcode {
DIAG308_STORE = 6,
};
-static __always_inline int diag308(unsigned long subcode, void *addr)
+static __always_inline unsigned long diag308(unsigned long subcode, void *addr)
{
register unsigned long _addr asm("0") = (unsigned long) addr;
register unsigned long _rc asm("1") = 0;
@@ -403,7 +403,7 @@ static __always_inline int test_facility
return __test_facility(nr, &S390_lowcore.stfle_fac_list);
}
-static __always_inline unsigned long __stfle_asm(uint64_t *stfle_fac_list, int size)
+static __always_inline unsigned long __stfle_asm(uint64_t *stfle_fac_list, unsigned int size)
{
register unsigned long reg0 asm("0") = size - 1;
@@ -420,7 +420,7 @@ static __always_inline unsigned long __s
* @stfle_fac_list: array where facility list can be stored
* @size: size of passed in array in double words
*/
-static __always_inline void stfle(uint64_t *stfle_fac_list, int size)
+static __always_inline void stfle(uint64_t *stfle_fac_list, unsigned int size)
{
unsigned long nr;

View File

@ -0,0 +1,640 @@
Subject: [PATCH] [FEAT VS1804] zipl: refactor all EBCDIC code into separate files
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: a37170b8bec07a0ffc3270a4c78124e1117f0337
Problem-ID: VS1804
Upstream-Description:
zipl: refactor all EBCDIC code into separate files
This allows the reuse of the code later in sclp.c. While at it, also
declare @source parameter of `ebcdic_to_ascii` function as `const` and
rename all `ebc_` function name prefixes into `ebcdic_`. Move
conversion tables to separate file so it only gets linked into loaders
that need it.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/Makefile | 16 ++--
zipl/boot/ebcdic.c | 30 ++++++++
zipl/boot/ebcdic.h | 45 ++++++++++++
zipl/boot/ebcdic_conv.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++
zipl/boot/ebcdic_conv.h | 21 ++++++
zipl/boot/libc.c | 19 -----
zipl/boot/libc.h | 25 -------
zipl/boot/menu.c | 9 +-
zipl/boot/stage3.c | 156 --------------------------------------------
9 files changed, 280 insertions(+), 208 deletions(-)
--- a/zipl/boot/Makefile
+++ b/zipl/boot/Makefile
@@ -28,22 +28,22 @@ all: data.o data.h tape0.bin stage3.bin
eckd2dump_sv.exec: \
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_sv.o \
- libc.o sclp.o entry.o
+ libc.o ebcdic.o sclp.o entry.o
eckd2dump_mv.exec: \
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_mv.o \
- libc.o sclp.o entry.o
+ libc.o ebcdic.o sclp.o entry.o
fba2dump.exec: \
head.o stage2dump.o cio.o fba2dump.o \
- libc.o sclp.o entry.o
+ libc.o ebcdic.o sclp.o entry.o
tape2dump.exec: \
head.o stage2dump.o cio.o tape2dump.o \
- libc.o sclp.o entry.o
-eckd2.exec: head.o stage2.o cio.o eckd2.o libc.o menu.o sclp.o \
+ libc.o ebcdic.o sclp.o entry.o
+eckd2.exec: head.o stage2.o cio.o eckd2.o libc.o ebcdic.o menu.o sclp.o \
kdump2.o kdump.o entry.o
-fba2.exec: head.o stage2.o cio.o fba2.o libc.o menu.o sclp.o \
+fba2.exec: head.o stage2.o cio.o fba2.o libc.o ebcdic.o menu.o sclp.o \
kdump2.o kdump.o entry.o
-stage3.exec: head.o stage3.o kdump3.o libc.o sclp.o sclp_stage3.o \
- kdump.o entry.o stage3.lds
+stage3.exec: head.o stage3.o kdump3.o libc.o ebcdic.o ebcdic_conv.o sclp.o \
+ sclp_stage3.o kdump.o entry.o stage3.lds
%.exec: %.o
STAGE=$$( \
--- /dev/null
+++ b/zipl/boot/ebcdic.c
@@ -0,0 +1,30 @@
+/*
+ * EBCDIC specific functions
+ *
+ * Copyright IBM Corp. 2013, 2020
+ *
+ * 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 "ebcdic.h"
+
+
+/*
+ * Convert ebcdic string to number with given base
+ */
+unsigned long ebcdic_strtoul(char *nptr, char **endptr, int base)
+{
+ unsigned long val = 0;
+
+ while (ebcdic_isdigit(*nptr)) {
+ if (val != 0)
+ val *= base;
+ val += *nptr - 0xf0;
+ nptr++;
+ }
+ if (endptr)
+ *endptr = (char *)nptr;
+ return val;
+}
--- /dev/null
+++ b/zipl/boot/ebcdic.h
@@ -0,0 +1,45 @@
+/*
+ * EBCDIC specific functions
+ *
+ * Copyright IBM Corp. 2013, 2020
+ *
+ * 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 EBCDIC_H
+#define EBCDIC_H
+
+#include "lib/zt_common.h"
+
+
+#ifndef __ASSEMBLER__
+
+unsigned long ebcdic_strtoul(char *, char **, int);
+
+static __always_inline int ecbdic_isspace(char c)
+{
+ return (c == 0x40) || (c == 0x05) || (c == 0x15) || (c == 0x25) ||
+ (c == 0x0b) || (c == 0x0c) || (c == 0x0d);
+}
+
+static __always_inline int ebcdic_isdigit(char c)
+{
+ return (c >= 0xf0) && (c <= 0xf9);
+}
+
+static __always_inline int ebcdic_isupper(char c)
+{
+ return (c >= 0xC1 && c <= 0xC9) || (c >= 0xD1 && c <= 0xD9) ||
+ (c >= 0xE2 && c <= 0xE9);
+}
+
+static __always_inline char ebcdic_tolower(char c)
+{
+ if (ebcdic_isupper(c))
+ c -= 0x40;
+ return c;
+}
+#endif /* __ASSEMBLER__ */
+#endif /* EBCDIC_H */
--- /dev/null
+++ b/zipl/boot/ebcdic_conv.c
@@ -0,0 +1,167 @@
+/*
+ * EBCDIC conversion functions
+ *
+ * Copyright IBM Corp. 2013, 2020
+ *
+ * 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 "ebcdic_conv.h"
+#include "libc.h"
+#include "boot/s390.h"
+
+
+static unsigned char ebcdic_037[256] = {
+/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
+ 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
+/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
+ 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+/* 0x10 DLE DC1 DC2 DC3 -RES -NL BS -POC
+ -ENP ->LF */
+ 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
+/* 0x18 CAN EM -UBS -CU1 -IFS -IGS -IRS -ITB
+ -IUS */
+ 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+/* 0x20 -DS -SOS FS -WUS -BYP LF ETB ESC
+ -INP */
+ 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
+/* 0x28 -SA -SFE -SM -CSP -MFA ENQ ACK BEL
+ -SW */
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
+/* 0x30 ---- ---- SYN -IR -PP -TRN -NBS EOT */
+ 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
+/* 0x38 -SBS -IT -RFF -CU3 DC4 NAK ---- SUB */
+ 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
+/* 0x40 SP RSP ä ---- */
+ 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
+/* 0x48 . < ( + | */
+ 0x87, 0xA4, 0x9B, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
+/* 0x50 & ---- */
+ 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
+/* 0x58 ß ! $ * ) ; */
+ 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAA,
+/* 0x60 - / ---- Ä ---- ---- ---- */
+ 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
+/* 0x68 ---- , % _ > ? */
+ 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
+/* 0x70 --- ---- ---- ---- ---- ---- ---- */
+ 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+/* 0x78 * ` : # @ ' = " */
+ 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
+/* 0x80 * a b c d e f g */
+ 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+/* 0x88 h i ---- ---- ---- */
+ 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
+/* 0x90 ° j k l m n o p */
+ 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+/* 0x98 q r ---- ---- */
+ 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
+/* 0xA0 ~ s t u v w x */
+ 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+/* 0xA8 y z ---- ---- ---- ---- */
+ 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
+/* 0xB0 ^ ---- § ---- */
+ 0x5E, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
+/* 0xB8 ---- [ ] ---- ---- ---- ---- */
+ 0xAB, 0x07, 0x5B, 0x5D, 0x07, 0x07, 0x07, 0x07,
+/* 0xC0 { A B C D E F G */
+ 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+/* 0xC8 H I ---- ö ---- */
+ 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
+/* 0xD0 } J K L M N O P */
+ 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
+/* 0xD8 Q R ---- ü */
+ 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
+/* 0xE0 \ S T U V W X */
+ 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+/* 0xE8 Y Z ---- Ö ---- ---- ---- */
+ 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
+/* 0xF0 0 1 2 3 4 5 6 7 */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+/* 0xF8 8 9 ---- ---- Ü ---- ---- ---- */
+ 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
+};
+
+static unsigned char ebcdic_500[256] = {
+/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
+ 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
+/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
+ 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+/* 0x10 DLE DC1 DC2 DC3 -RES -NL BS -POC
+ -ENP ->LF */
+ 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
+/* 0x18 CAN EM -UBS -CU1 -IFS -IGS -IRS -ITB
+ -IUS */
+ 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+/* 0x20 -DS -SOS FS -WUS -BYP LF ETB ESC
+ -INP */
+ 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
+/* 0x28 -SA -SFE -SM -CSP -MFA ENQ ACK BEL
+ -SW */
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
+/* 0x30 ---- ---- SYN -IR -PP -TRN -NBS EOT */
+ 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
+/* 0x38 -SBS -IT -RFF -CU3 DC4 NAK ---- SUB */
+ 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
+/* 0x40 SP RSP ä ---- */
+ 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
+/* 0x48 . < ( + | */
+ 0x87, 0xA4, 0x9B, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
+/* 0x50 & ---- */
+ 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
+/* 0x58 ß ! $ * ) ; */
+ 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAA,
+/* 0x60 - / ---- Ä ---- ---- ---- */
+ 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
+/* 0x68 ---- , % _ > ? */
+ 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
+/* 0x70 --- ---- ---- ---- ---- ---- ---- */
+ 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+/* 0x78 * ` : # @ ' = " */
+ 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
+/* 0x80 * a b c d e f g */
+ 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+/* 0x88 h i ---- ---- ---- */
+ 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
+/* 0x90 ° j k l m n o p */
+ 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+/* 0x98 q r ---- ---- */
+ 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
+/* 0xA0 ~ s t u v w x */
+ 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+/* 0xA8 y z ---- ---- ---- ---- */
+ 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
+/* 0xB0 ^ ---- § ---- */
+ 0x5E, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
+/* 0xB8 ---- [ ] ---- ---- ---- ---- */
+ 0xAB, 0x07, 0x5B, 0x5D, 0x07, 0x07, 0x07, 0x07,
+/* 0xC0 { A B C D E F G */
+ 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+/* 0xC8 H I ---- ö ---- */
+ 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
+/* 0xD0 } J K L M N O P */
+ 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
+/* 0xD8 Q R ---- ü */
+ 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
+/* 0xE0 \ S T U V W X */
+ 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+/* 0xE8 Y Z ---- Ö ---- ---- ---- */
+ 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
+/* 0xF0 0 1 2 3 4 5 6 7 */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+/* 0xF8 8 9 ---- ---- Ü ---- ---- ---- */
+ 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
+};
+
+void ebcdic_to_ascii(unsigned char *target, const unsigned char *source,
+ unsigned int l)
+{
+ unsigned char *ebc;
+ unsigned int i;
+
+ ebc = is_zvm() ? ebcdic_037 : ebcdic_500;
+ for (i = 0; i < l; i++)
+ target[i] = ebc[source[i]];
+}
--- /dev/null
+++ b/zipl/boot/ebcdic_conv.h
@@ -0,0 +1,21 @@
+/*
+ * EBCDIC conversion functions
+ *
+ * Copyright IBM Corp. 2013, 2020
+ *
+ * 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 EBCDIC_CONV_H
+#define EBCDIC_CONV_H
+
+
+#ifndef __ASSEMBLER__
+
+void ebcdic_to_ascii(unsigned char *target, const unsigned char *source,
+ unsigned int l);
+
+#endif /* __ASSEMBLER__ */
+#endif /* EBCDIC_CONV_H */
--- a/zipl/boot/libc.c
+++ b/zipl/boot/libc.c
@@ -18,6 +18,7 @@
#include "error.h"
#include "sclp.h"
+#include "ebcdic.h"
extern char __heap_start[];
extern char __heap_stop[];
@@ -129,24 +130,6 @@ int strncmp(const char *s1, const char *
return 0;
}
-/*
- * Convert ebcdic string to number with given base
- */
-unsigned long ebcstrtoul(char *nptr, char **endptr, int base)
-{
- unsigned long val = 0;
-
- while (ebc_isdigit(*nptr)) {
- if (val != 0)
- val *= base;
- val += *nptr - 0xf0;
- nptr++;
- }
- if (endptr)
- *endptr = (char *) nptr;
- return val;
-}
-
static int skip_atoi(const char **c)
{
int i = 0;
--- a/zipl/boot/libc.h
+++ b/zipl/boot/libc.h
@@ -51,7 +51,6 @@ void *memmove(void *, const void *, unsi
void *memset(void *, int c, unsigned long);
char *strcat(char *, const char *);
int strncmp(const char *, const char *, unsigned long);
-unsigned long ebcstrtoul(char *, char **, int);
int strlen(const char *);
char *strcpy(char *, const char *);
unsigned long get_zeroed_page(void);
@@ -80,28 +79,4 @@ static inline int isspace(char c)
return (c == 32) || (c >= 9 && c <= 13);
}
-static inline int ebc_isspace(char c)
-{
- return (c == 0x40) || (c == 0x05) || (c == 0x15) || (c == 0x25) ||
- (c == 0x0b) || (c == 0x0c) || (c == 0x0d);
-}
-
-static inline int ebc_isdigit(char c)
-{
- return (c >= 0xf0) && (c <= 0xf9);
-}
-
-static inline int ebc_isupper(char c)
-{
- return (c >= 0xC1 && c <= 0xC9) || (c >= 0xD1 && c <= 0xD9) ||
- (c >= 0xE2 && c <= 0xE9);
-}
-
-static inline char ebc_tolower(char c)
-{
- if (ebc_isupper(c))
- c -= 0x40;
- return c;
-}
-
#endif /* LIBC_H */
--- a/zipl/boot/menu.c
+++ b/zipl/boot/menu.c
@@ -12,6 +12,7 @@
#include "libc.h"
#include "menu.h"
#include "sclp.h"
+#include "ebcdic.h"
static const char *msg_econfig = "Error: undefined configuration\n";
@@ -55,8 +56,8 @@ static int menu_read(void)
/* input under zVM needs to be converted to lower case */
if (is_zvm())
for (i = 0; i < count; i++)
- temp_area[i] = ebc_tolower(temp_area[i]);
- value = ebcstrtoul((char *)temp_area, &endptr, 10);
+ temp_area[i] = ebcdic_tolower(temp_area[i]);
+ value = ebcdic_strtoul((char *)temp_area, &endptr, 10);
if ((endptr != temp_area) && (value < BOOT_MENU_ENTRIES - 1) &&
(__stage2_params.config[value] != 0)) {
@@ -112,7 +113,7 @@ static int menu_param(unsigned long *val
int i;
if (!sclp_param(loadparm))
- *value = ebcstrtoul(loadparm, &endptr, 10);
+ *value = ebcdic_strtoul(loadparm, &endptr, 10);
/* got number, done */
if (endptr != loadparm)
@@ -121,7 +122,7 @@ static int menu_param(unsigned long *val
/* no number, check for keyword */
i = 0;
/* skip leading whitespaces */
- while ((i < PARAM_SIZE) && ebc_isspace(loadparm[i]))
+ while ((i < PARAM_SIZE) && ecbdic_isspace(loadparm[i]))
i++;
if (!strncmp(&loadparm[i], "PROMPT", 6)) {
--- a/zipl/boot/stage3.c
+++ b/zipl/boot/stage3.c
@@ -12,9 +12,12 @@
#include "libc.h"
#include "boot/sigp.h"
#include "boot/s390.h"
+#include "boot/sigp.h"
#include "stage3.h"
#include "error.h"
#include "zipl.h"
+#include "ebcdic.h"
+#include "ebcdic_conv.h"
#define for_each_rb_entry(entry, rb) \
for (entry = rb->entries; \
@@ -24,159 +27,6 @@
static const char *msg_sipl_inval = "Secure boot failure: invalid load address";
static const char *msg_sipl_unverified = "Secure boot failure: unverified load address";
-static unsigned char ebc_037[256] = {
-/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
- 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
-/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
- 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-/* 0x10 DLE DC1 DC2 DC3 -RES -NL BS -POC
- -ENP ->LF */
- 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
-/* 0x18 CAN EM -UBS -CU1 -IFS -IGS -IRS -ITB
- -IUS */
- 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
-/* 0x20 -DS -SOS FS -WUS -BYP LF ETB ESC
- -INP */
- 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
-/* 0x28 -SA -SFE -SM -CSP -MFA ENQ ACK BEL
- -SW */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
-/* 0x30 ---- ---- SYN -IR -PP -TRN -NBS EOT */
- 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
-/* 0x38 -SBS -IT -RFF -CU3 DC4 NAK ---- SUB */
- 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
-/* 0x40 SP RSP ä ---- */
- 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
-/* 0x48 . < ( + | */
- 0x87, 0xA4, 0x9B, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
-/* 0x50 & ---- */
- 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
-/* 0x58 ß ! $ * ) ; */
- 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAA,
-/* 0x60 - / ---- Ä ---- ---- ---- */
- 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
-/* 0x68 ---- , % _ > ? */
- 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
-/* 0x70 --- ---- ---- ---- ---- ---- ---- */
- 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
-/* 0x78 * ` : # @ ' = " */
- 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
-/* 0x80 * a b c d e f g */
- 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-/* 0x88 h i ---- ---- ---- */
- 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
-/* 0x90 ° j k l m n o p */
- 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
-/* 0x98 q r ---- ---- */
- 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
-/* 0xA0 ~ s t u v w x */
- 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-/* 0xA8 y z ---- ---- ---- ---- */
- 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
-/* 0xB0 ^ ---- § ---- */
- 0x5E, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
-/* 0xB8 ---- [ ] ---- ---- ---- ---- */
- 0xAB, 0x07, 0x5B, 0x5D, 0x07, 0x07, 0x07, 0x07,
-/* 0xC0 { A B C D E F G */
- 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-/* 0xC8 H I ---- ö ---- */
- 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
-/* 0xD0 } J K L M N O P */
- 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
-/* 0xD8 Q R ---- ü */
- 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
-/* 0xE0 \ S T U V W X */
- 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-/* 0xE8 Y Z ---- Ö ---- ---- ---- */
- 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
-/* 0xF0 0 1 2 3 4 5 6 7 */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-/* 0xF8 8 9 ---- ---- Ü ---- ---- ---- */
- 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
-};
-
-static unsigned char ebc_500[256] = {
-/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
- 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
-/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
- 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-/* 0x10 DLE DC1 DC2 DC3 -RES -NL BS -POC
- -ENP ->LF */
- 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
-/* 0x18 CAN EM -UBS -CU1 -IFS -IGS -IRS -ITB
- -IUS */
- 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
-/* 0x20 -DS -SOS FS -WUS -BYP LF ETB ESC
- -INP */
- 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
-/* 0x28 -SA -SFE -SM -CSP -MFA ENQ ACK BEL
- -SW */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
-/* 0x30 ---- ---- SYN -IR -PP -TRN -NBS EOT */
- 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
-/* 0x38 -SBS -IT -RFF -CU3 DC4 NAK ---- SUB */
- 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
-/* 0x40 SP RSP ä ---- */
- 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
-/* 0x48 . < ( + | */
- 0x87, 0xA4, 0x9B, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
-/* 0x50 & ---- */
- 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
-/* 0x58 ß ! $ * ) ; */
- 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0xAA,
-/* 0x60 - / ---- Ä ---- ---- ---- */
- 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
-/* 0x68 ---- , % _ > ? */
- 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
-/* 0x70 --- ---- ---- ---- ---- ---- ---- */
- 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
-/* 0x78 * ` : # @ ' = " */
- 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
-/* 0x80 * a b c d e f g */
- 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-/* 0x88 h i ---- ---- ---- */
- 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
-/* 0x90 ° j k l m n o p */
- 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
-/* 0x98 q r ---- ---- */
- 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
-/* 0xA0 ~ s t u v w x */
- 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-/* 0xA8 y z ---- ---- ---- ---- */
- 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
-/* 0xB0 ^ ---- § ---- */
- 0x5E, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
-/* 0xB8 ---- [ ] ---- ---- ---- ---- */
- 0xAB, 0x07, 0x5B, 0x5D, 0x07, 0x07, 0x07, 0x07,
-/* 0xC0 { A B C D E F G */
- 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-/* 0xC8 H I ---- ö ---- */
- 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
-/* 0xD0 } J K L M N O P */
- 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
-/* 0xD8 Q R ---- ü */
- 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
-/* 0xE0 \ S T U V W X */
- 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-/* 0xE8 Y Z ---- Ö ---- ---- ---- */
- 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
-/* 0xF0 0 1 2 3 4 5 6 7 */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-/* 0xF8 8 9 ---- ---- Ü ---- ---- ---- */
- 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
-};
-
-static void ebcdic_to_ascii(unsigned char *target, unsigned char *source,
- unsigned int l)
-{
- unsigned char *ebc;
- unsigned int i;
-
- ebc = is_zvm() ? ebc_037 : ebc_500;
- for (i = 0; i < l; i++)
- target[i] = ebc[source[i]];
-}
-
static inline void __noreturn start_kernel(void)
{
struct psw_t *psw = &S390_lowcore.program_new_psw;

View File

@ -0,0 +1,79 @@
Subject: [PATCH] [FEAT VS1804] zipl/sclp: add macros for the control-program masks
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 303a3707e2e59e0ad581876db426a52fffa606b0
Problem-ID: VS1804
Upstream-Description:
zipl/sclp: add macros for the control-program masks
Add macros for the control-program masks and use them.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/sclp.c | 16 ++++++++--------
zipl/boot/sclp.h | 6 ++++++
2 files changed, 14 insertions(+), 8 deletions(-)
--- a/zipl/boot/sclp.c
+++ b/zipl/boot/sclp.c
@@ -126,20 +126,20 @@ int sclp_setup(int initialise)
switch (initialise) {
case SCLP_INIT:
- sccb->receive_mask = 0x80000000;
- sccb->send_mask = 0x40000000;
+ sccb->receive_mask = SCLP_EVENT_MASK_OPCMD;
+ sccb->send_mask = SCLP_EVENT_MASK_MSG;
break;
case SCLP_DISABLE:
- sccb->receive_mask = 0x0;
- sccb->send_mask = 0x0;
+ sccb->receive_mask = SCLP_EVENT_MASK_DISABLE;
+ sccb->send_mask = SCLP_EVENT_MASK_DISABLE;
break;
case SCLP_HSA_INIT:
- sccb->receive_mask = 0x0;
- sccb->send_mask = 0x40000010;
+ sccb->receive_mask = SCLP_EVENT_MASK_DISABLE;
+ sccb->send_mask = SCLP_EVENT_MASK_MSG | SCLP_EVENT_MASK_SDIAS;
break;
case SCLP_HSA_INIT_ASYNC:
- sccb->receive_mask = 0x00000010;
- sccb->send_mask = 0x40000010;
+ sccb->receive_mask = SCLP_EVENT_MASK_SDIAS;
+ sccb->send_mask = SCLP_EVENT_MASK_MSG | SCLP_EVENT_MASK_SDIAS;
break;
}
--- a/zipl/boot/sclp.h
+++ b/zipl/boot/sclp.h
@@ -28,6 +28,12 @@
#define SCLP_CMD_READ_INFO2 0x00020001
#define SCLP_CMD_READ_DATA 0x00770005
+/* SCLP event masks */
+#define SCLP_EVENT_MASK_DISABLE 0x00000000
+#define SCLP_EVENT_MASK_SDIAS 0x00000010
+#define SCLP_EVENT_MASK_MSG 0x40000000
+#define SCLP_EVENT_MASK_OPCMD 0x80000000
+
#define PSW_EXT_MASK 0x00080000ULL
#define PSW_EXT_ADDR 0x80000000ULL
#define PSW_WAIT_MASK 0x010a0000ULL

View File

@ -0,0 +1,163 @@
Subject: [PATCH] [FEAT VS1804] zipl/sclp: add `sclp_print_ascii`
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: f99560f734e8101a0e8195d73e3350d9211335b8
Problem-ID: VS1804
Upstream-Description:
zipl/sclp: add `sclp_print_ascii`
Add `sclp_print_ascii` function that can be used to print output on
the SCLP ASCII console. This would increase the size of the
loaders (e.g. eckd2.bin and fba2.bin) and therefore might break the
compilation. In order to avoid that add a macro 'ENABLE_SCLP_ASCII'
which must be defined by the users of the `sclp_print_ascii` function.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/sclp.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
zipl/boot/sclp.h | 20 +++++++++++++++++++-
2 files changed, 69 insertions(+), 1 deletion(-)
--- a/zipl/boot/sclp.c
+++ b/zipl/boot/sclp.c
@@ -13,6 +13,10 @@
#include "error.h"
#include "boot/s390.h"
#include "sclp.h"
+#include "ebcdic.h"
+#ifdef ENABLE_SCLP_ASCII
+# include "ebcdic_conv.h"
+#endif /* ENABLE_SCLP_ASCII */
/* Perform service call. Return 0 on success, non-zero otherwise. */
static int sclp_service_call(unsigned int command, void *sccb)
@@ -133,6 +137,10 @@ int sclp_setup(int initialise)
sccb->receive_mask = SCLP_EVENT_MASK_DISABLE;
sccb->send_mask = SCLP_EVENT_MASK_DISABLE;
break;
+ case SCLP_LINE_ASCII_INIT:
+ sccb->receive_mask = SCLP_EVENT_MASK_DISABLE;
+ sccb->send_mask = SCLP_EVENT_MASK_MSG | SCLP_EVENT_MASK_ASCII;
+ break;
case SCLP_HSA_INIT:
sccb->receive_mask = SCLP_EVENT_MASK_DISABLE;
sccb->send_mask = SCLP_EVENT_MASK_MSG | SCLP_EVENT_MASK_SDIAS;
@@ -161,6 +169,48 @@ out_free_page:
return rc;
}
+#ifdef ENABLE_SCLP_ASCII
+/* Content of @buffer must be EBCDIC encoded. The function used for
+ * the conversion `ebcdic_to_ascii` differentiates whether the code
+ * runs on z/VM or not and then selects the appropriate EBCDIC
+ * coding.
+ */
+int sclp_print_ascii(const char *buffer)
+{
+ struct write_sccb *sccb = NULL;
+ int rc, str_len = strlen(buffer);
+ unsigned long data_len = str_len + 1;
+
+ /* don't overflow the sccb buffer */
+ if (data_len > SCCB_MAX_DATA_LEN)
+ data_len = SCCB_MAX_DATA_LEN;
+
+ sccb = (void *)get_zeroed_page();
+ sccb->header.length = sizeof(struct write_sccb) - sizeof(struct mdb)
+ + data_len;
+ sccb->header.function_code = SCLP_FC_NORMAL_WRITE;
+ sccb->msg_buf.header.length = sizeof(struct msg_buf) - sizeof(struct mdb)
+ + data_len;
+ sccb->msg_buf.header.type = SCLP_EVENT_DATA_ASCII;
+ sccb->msg_buf.header.flags = 0;
+ ebcdic_to_ascii(sccb->msg_buf.data,
+ (const unsigned char *)buffer,
+ data_len - 1);
+ sccb->msg_buf.data[data_len - 1] = '\0';
+
+ /* SCLP command for write data */
+ rc = start_sclp(SCLP_CMD_WRITE_DATA, sccb);
+ if (rc || sccb->header.response_code != 0x20) {
+ rc = 1;
+ goto out_free_page;
+ }
+ rc = 0;
+out_free_page:
+ free_page((unsigned long) sccb);
+ return rc;
+}
+#endif /* ENABLE_SCLP_ASCII */
+
int sclp_print(char *buffer)
{
struct write_sccb *sccb;
--- a/zipl/boot/sclp.h
+++ b/zipl/boot/sclp.h
@@ -28,9 +28,16 @@
#define SCLP_CMD_READ_INFO2 0x00020001
#define SCLP_CMD_READ_DATA 0x00770005
+/* SCLP function codes */
+#define SCLP_FC_NORMAL_WRITE 0
+
+/* SCLP event data types */
+#define SCLP_EVENT_DATA_ASCII 0x1a
+
/* SCLP event masks */
#define SCLP_EVENT_MASK_DISABLE 0x00000000
#define SCLP_EVENT_MASK_SDIAS 0x00000010
+#define SCLP_EVENT_MASK_ASCII 0x00000040
#define SCLP_EVENT_MASK_MSG 0x40000000
#define SCLP_EVENT_MASK_OPCMD 0x80000000
@@ -46,6 +53,11 @@
#define SCLP_DISABLE 0x1
#define SCLP_HSA_INIT 0x2
#define SCLP_HSA_INIT_ASYNC 0x3
+#define SCLP_LINE_ASCII_INIT 0x4
+
+#define SCCB_SIZE PAGE_SIZE
+#define SCCB_MAX_DATA_LEN (SCCB_SIZE - sizeof(struct sccb_header) \
+ - sizeof(struct evbuf_header))
typedef uint32_t sccb_mask_t;
@@ -114,7 +126,10 @@ struct mdb {
struct msg_buf {
struct evbuf_header header;
- struct mdb mdb;
+ union {
+ struct mdb mdb;
+ uint8_t data[0];
+ };
} __packed;
struct write_sccb {
@@ -164,6 +179,9 @@ struct read_sccb {
int start_sclp(unsigned int, void *);
int sclp_setup(int);
int sclp_print(char *);
+# ifdef ENABLE_SCLP_ASCII
+int sclp_print_ascii(const char *);
+# endif /* ENABLE_SCLP_ASCII */
int sclp_param(char *);
int sclp_read(unsigned long, void *, int *);
int sclp_read_info(struct read_info_sccb *sccb);

View File

@ -0,0 +1,47 @@
Subject: [PATCH] [FEAT VS1804] zipl/libc: printf: print on linemode and ASCII console
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: e51663bbca8770c1f7986dac47a59193dbf96010
Problem-ID: VS1804
Upstream-Description:
zipl/libc: printf: print on linemode and ASCII console
... if the `ENABLE_SCLP_ASCII` macro is defined.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
zipl/boot/libc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/zipl/boot/libc.c
+++ b/zipl/boot/libc.c
@@ -406,8 +406,11 @@ void printf(const char *fmt, ...)
buf[LINE_LENGTH - 2] = '.';
buf[LINE_LENGTH - 3] = '.';
}
- sclp_print(buf);
va_end(va);
+ sclp_print(buf);
+#ifdef ENABLE_SCLP_ASCII
+ sclp_print_ascii(buf);
+#endif /* ENABLE_SCLP_ASCII */
}
/*

View File

@ -0,0 +1,134 @@
Subject: [PATCH] [FEAT VS1804] Consolidate `ALIGN, __ALIGN_MASK, ARRAY_SIZE` macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 67aef9bbf3b5d18c70e8c4a45734bcb6d6744a8c
Problem-ID: VS1804
Upstream-Description:
Consolidate `ALIGN, __ALIGN_MASK, ARRAY_SIZE` macros
Consolidate `ALIGN, __ALIGN_MASK, ARRAY_SIZE` macros and add them to
lib/zt_common.h. While at it, adapt coding style.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
cmsfs-fuse/dasd.c | 1 +
cmsfs-fuse/helper.h | 2 --
include/lib/zt_common.h | 4 ++++
zconf/qeth/misc.h | 2 --
zdev/include/misc.h | 2 +-
zdump/zg.c | 2 +-
zdump/zg.h | 3 ---
zipl/include/zipl.h | 4 ----
8 files changed, 7 insertions(+), 13 deletions(-)
--- a/cmsfs-fuse/dasd.c
+++ b/cmsfs-fuse/dasd.c
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "lib/zt_common.h"
#include "cmsfs-fuse.h"
#include "edf.h"
#include "helper.h"
--- a/cmsfs-fuse/helper.h
+++ b/cmsfs-fuse/helper.h
@@ -49,6 +49,4 @@ extern FILE *logfile;
fprintf(stderr, COMP "Warning, " __VA_ARGS__); \
} while (0)
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
#endif
--- a/include/lib/zt_common.h
+++ b/include/lib/zt_common.h
@@ -44,6 +44,10 @@
# define STATIC_ASSERT(test)
#endif
+#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
#define RELEASE_STRING STRINGIFY (S390_TOOLS_RELEASE)
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)
--- a/zconf/qeth/misc.h
+++ b/zconf/qeth/misc.h
@@ -12,8 +12,6 @@
#include <stdbool.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
char *misc_link_target(const char *fmt, ...);
bool misc_str_in_list(const char *str, const char *strings[], int array_size);
int misc_argz_add_from_file(char **argz, size_t *argz_len,
--- a/zdev/include/misc.h
+++ b/zdev/include/misc.h
@@ -15,10 +15,10 @@
#include <stdio.h>
#include <stdlib.h>
+#include "lib/zt_common.h"
#include "lib/util_list.h"
#include "exit_code.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define SCOPE_ACTIVE(x) ((x) & config_active ? 1 : 0)
#define SCOPE_PERSISTENT(x) ((x) & config_persistent ? 1 : 0)
#define SCOPE_AUTOCONF(x) ((x) & config_autoconf ? 1 : 0)
--- a/zdump/zg.c
+++ b/zdump/zg.c
@@ -432,7 +432,7 @@ char *zg_devnode_create(dev_t dev)
char *file_path;
unsigned int i;
- for (i = 0; i < ARRAY_ELEMENT_CNT(dir_vec); i++) {
+ for (i = 0; i < ARRAY_SIZE(dir_vec); i++) {
if (dir_vec[i] == NULL)
continue;
file_path = devnode_create_dir(dir_vec[i], dev);
--- a/zdump/zg.h
+++ b/zdump/zg.h
@@ -122,10 +122,7 @@ do { \
* Misc
*/
#define PAGE_SIZE 4096UL
-#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
-#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
-#define ARRAY_ELEMENT_CNT(x) (sizeof(x) / sizeof(x[0]))
#define ROUNDUP(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
static inline u32 zg_csum_partial(const void *buf, int len, u32 sum)
--- a/zipl/include/zipl.h
+++ b/zipl/include/zipl.h
@@ -62,10 +62,6 @@ typedef uint64_t address_t;
* resulting return code or 0. */
#define DRY_RUN_FUNC(x) (dry_run ? 0 : (x))
-#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
-#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-
extern int verbose;
extern int interactive;
extern int dry_run;

View File

@ -0,0 +1,803 @@
Subject: [PATCH] [FEAT VS1804] genprotimg: boot: initial bootloader support
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 3356d6f4facd748f8f5cf24ffc5056db3e915f2c
Problem-ID: VS1804
Upstream-Description:
genprotimg: boot: initial bootloader support
Add a boot loader for protected virtualization (PV) that can be
combined with a kernel/initrd/parmfile to form a single bootable file.
This file must be constructed in a way that it can be used (1) for a
QEMU direct kernel boot and (2) it can be zipl'ed by the normal,
unmodified zipl program.
This new boot loader consists of two parts:
1. stage3a boot loader (cleartext), this loader is responsible for
the transition into the protected mode by doing diag308 subcode 8
and 10 calls.
2. stage3b boot loader (encrypted), this loader is very similar to the
normal zipl stage3 boot loader. It will be loaded by the Ultravisor
after the successful transition into protected mode. Like the zipl
stage3 boot loader it moves the kernel and patches in the values
for initrd and parmline.
The requirements for (1) and (2) result in the following constraints:
1. It must be possible to place stage3a and stage3b at a location >=
0x10000 because the zipl stage3 loader zeroes out everything at
addresses lower than 0x10000 of the image.
2. As the stage3 loader of zipl assumes that the passed kernel image
looks like a normal kernel image, the zipl stage3 loader modifies the
content at the memory area 0x10400 - 0x10800, therefore we leave this
area unused in our stage3a loader.
3. The default entry address used by the zipl stage3 loader is 0x10000
so we add a simple branch to 0x11000 at 0x10000 so the zipl stage3
loader can modify the area 0x10400 - 0x10800 without affecting the
stage3a loader.
The stage3b loader is linked at address 0x9000, therefore it will not
work at another address. The relocation support for the stage3b
loader, so that it can be placed at addresses != 0x9000, is added in
the next patch. This loader with relocation support has the name
'stage3b_reloc'.
The memory layout of the single bootable file looks like:
+-----------------------+-----------+------------------------+
|Start |End |Use |
+=======================+===========+========================+
|0 |0x7 |Short PSW, starting |
| | |instruction at 0x11000 |
+-----------------------+-----------+------------------------+
|0x10000 |0x10012 |Branch to 0x11000 |
+-----------------------+-----------+------------------------+
|0x10013 |0x10fff |Left intentionally |
| | |unused |
+-----------------------+-----------+------------------------+
|0x11000 |0x12fff |Stage3a |
+-----------------------+-----------+------------------------+
|0x13000 |0x13fff |IPIB used as argument |
| | |for the diag308 call |
+-----------------------+-----------+------------------------+
|0x14000 |0x1[45]fff |UV header used for the |
| | |diag308 call (size can |
| | |be either 1 or 2 pages) |
+-----------------------+-----------+------------------------+
|NEXT_PAGE_ALIGNED_ADDR | |Encrypted Kernel |
+-----------------------+-----------+------------------------+
|NEXT_PAGE_ALIGNED_ADDR | |Encrypted Cmdline |
+-----------------------+-----------+------------------------+
|NEXT_PAGE_ALIGNED_ADDR | |Encrypted Initrd |
+-----------------------+-----------+------------------------+
|NEXT_PAGE_ALIGNED_ADDR | |Encrypted Stage3b_reloc |
+-----------------------+-----------+------------------------+
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
genprotimg/boot/.gitignore | 3
genprotimg/boot/Makefile | 83 +++++++++++++++++++++++++++
genprotimg/boot/common_memory_layout.h | 25 ++++++++
genprotimg/boot/head.S | 29 +++++++++
genprotimg/boot/stage3a.c | 62 ++++++++++++++++++++
genprotimg/boot/stage3a.h | 34 +++++++++++
genprotimg/boot/stage3a.lds | 101 +++++++++++++++++++++++++++++++++
genprotimg/boot/stage3a_init.S | 26 ++++++++
genprotimg/boot/stage3b.c | 77 +++++++++++++++++++++++++
genprotimg/boot/stage3b.h | 38 ++++++++++++
genprotimg/boot/stage3b.lds | 87 ++++++++++++++++++++++++++++
include/boot/ipl.h | 25 ++++++++
include/boot/s390.h | 22 +++++--
zipl/boot/error.h | 6 +
14 files changed, 613 insertions(+), 5 deletions(-)
--- /dev/null
+++ b/genprotimg/boot/.gitignore
@@ -0,0 +1,3 @@
+*.elf
+*.bin
+*.d
--- /dev/null
+++ b/genprotimg/boot/Makefile
@@ -0,0 +1,83 @@
+# Common definitions
+include ../../common.mak
+
+ZIPL_DIR := $(rootdir)/zipl
+ZIPL_BOOT_DIR := $(ZIPL_DIR)/boot
+
+INCLUDE_PATHS := $(ZIPL_BOOT_DIR) $(ZIPL_DIR)/include $(rootdir)/include
+INCLUDE_PARMS := $(addprefix -I,$(INCLUDE_PATHS))
+
+ALL_CFLAGS := $(NO_PIE_CFLAGS) -Os -g \
+ $(INCLUDE_PARMS) \
+ -DENABLE_SCLP_ASCII=1 \
+ -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
+ -fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
+ -fno-delete-null-pointer-checks \
+ -fexec-charset=IBM1047 -m64 -mpacked-stack \
+ -mstack-size=4096 -mstack-guard=128 -msoft-float \
+ -Wall -Wformat-security -Wextra -Werror
+
+FILES := stage3a.bin stage3b.bin
+
+ZIPL_SRCS_C := libc.c ebcdic.c ebcdic_conv.c sclp.c
+ZIPL_SRCS_ASM := entry.S
+
+ZIPL_OBJS_C := $(ZIPL_SRCS_C:%.c=%.o)
+ZIPL_OBJS_ASM := $(ZIPL_SRCS_ASM:%.S=%.o)
+ZIPL_OBJS := $(ZIPL_OBJS_C) $(ZIPL_OBJS_ASM)
+
+
+all: $(FILES)
+
+# Prevent make from using some default rules...
+%: %.S
+
+%.o: %.S Makefile
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
+
+%.o: %.c Makefile
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
+
+
+# Special rules for zipl object files
+$(ZIPL_OBJS_C): %.o : $(ZIPL_BOOT_DIR)/%.c
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
+
+$(ZIPL_OBJS_ASM): %.o : $(ZIPL_BOOT_DIR)/%.S
+ $(CC) $(ALL_CFLAGS) -c -o $@ $<
+
+dependencies_zipl_c := $(ZIPL_SRCS_C:%.c=.%.o.d)
+
+$(dependencies_zipl_c): .%.o.d : $(ZIPL_BOOT_DIR)/%.c
+ $(CC_SILENT) -MM $(ALL_CPPFLAGS) $(ALL_CFLAGS) $< > $@
+
+ifneq ($(MAKECMDGOALS),clean)
+-include $(dependencies_zipl_c)
+endif
+
+
+stage3a.elf: head.o stage3a_init.o stage3a.o stage3a.lds $(ZIPL_OBJS)
+stage3b.elf: head.o stage3b.o stage3b.lds $(ZIPL_OBJS)
+
+%.elf: %.o
+ case $* in \
+ stage3a) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3a.lds";; \
+ stage3b) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3b.lds";; \
+ esac; \
+ $(LINK) $$SFLAGS -m64 $(filter %.o, $^) -o $@
+ @chmod a-x $@
+
+%.bin: %.elf
+ $(OBJCOPY) -O binary \
+ --only-section=.text* \
+ --only-section=.ex_table* \
+ --only-section=.fixup* \
+ --only-section=.data* \
+ --only-section=.rodata* \
+ $< $@
+ @chmod a-x $@
+
+clean:
+ rm -f *.o *.elf *.bin *.map .*.d
+
+.PHONY: all clean
--- /dev/null
+++ b/genprotimg/boot/common_memory_layout.h
@@ -0,0 +1,25 @@
+/*
+ * Common memory layout for stage3a and stage3b bootloader.
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 COMMON_MEMORY_LAYOUT_H
+#define COMMON_MEMORY_LAYOUT_H
+
+#include "boot/loaders_layout.h"
+
+#define STACK_ADDRESS STAGE3_STACK_ADDRESS
+#define STACK_SIZE STAGE3_STACK_SIZE
+
+#define HEAP_ADDRESS STAGE3_HEAP_ADDRESS
+#define HEAP_SIZE STAGE3_HEAP_SIZE
+
+
+#ifndef __ASSEMBLER__
+
+#endif /* __ASSEMBLER__ */
+#endif /* COMMON_MEMORY_LAYOUT_H */
--- /dev/null
+++ b/genprotimg/boot/head.S
@@ -0,0 +1,29 @@
+/*
+ * Entry code for stage 3a boot loader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 "common_memory_layout.h"
+
+#include "boot/s390.h"
+#include "boot/sigp.h"
+
+.section .text.start
+.globl _start
+_start:
+ /* Might be called after a diag308 so better set
+ * architecture and addressing mode
+ */
+ lhi %r1, 1
+ sigp %r1, %r0, SIGP_SET_ARCHITECTURE
+ sam64
+
+ /* Initialize stack */
+ lgfi %r15, STACK_ADDRESS + STACK_SIZE - STACK_FRAME_OVERHEAD
+ brasl %r14, initialize
+.previous
--- /dev/null
+++ b/genprotimg/boot/stage3a.c
@@ -0,0 +1,62 @@
+/*
+ * Main program for stage3a bootloader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 "libc.h"
+#include "stage3a.h"
+
+#include "lib/zt_common.h"
+#include "boot/s390.h"
+#include "boot/ipl.h"
+#include "sclp.h"
+#include "error.h"
+
+
+static volatile struct stage3a_args __section(".loader_parms") loader_parms;
+
+void __noreturn start(void)
+{
+ int rc;
+ volatile struct stage3a_args *args = &loader_parms;
+ /* calculate the IPIB memory address */
+ struct ipl_parameter_block *ipib = (void *)((uint64_t)args + args->ipib_offs);
+
+ /* Calculate the PV header memory address and set it and its
+ * size in the IPIB. This allows the PV header to be position
+ * independent.
+ */
+ ipib->pv.pv_hdr_addr = (uint64_t)args + args->hdr_offs;
+ ipib->pv.pv_hdr_size = args->hdr_size;
+
+ /* set up ASCII and line-mode */
+ sclp_setup(SCLP_LINE_ASCII_INIT);
+
+ /* test if Secure Execution Unpack facility is available */
+ stfle(S390_lowcore.stfle_fac_list,
+ ARRAY_SIZE(S390_lowcore.stfle_fac_list));
+ rc = test_facility(UNPACK_FACILITY);
+ if (rc == 0)
+ panic(ENOPV, "Secure unpack facility is not available\n");
+
+ rc = diag308(DIAG308_SET_PV, ipib);
+ if (rc != DIAG308_RC_OK)
+ panic(EPV, "Protected boot setup has failed: 0x%x\n", rc);
+
+ rc = diag308(DIAG308_UNPACK_PV, 0x0);
+ if (rc != DIAG308_RC_OK) {
+ sclp_setup(SCLP_LINE_ASCII_INIT);
+ panic(EPV, "Protected boot has failed: 0x%x\n", rc);
+ }
+
+ while (1)
+ ;
+}
+
+void panic_notify(unsigned long UNUSED(rc))
+{
+}
--- /dev/null
+++ b/genprotimg/boot/stage3a.h
@@ -0,0 +1,34 @@
+/*
+ * Main program for stage3a bootloader.
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 STAGE3A_H
+#define STAGE3A_H
+
+#include "lib/zt_common.h"
+#include "boot/loaders_layout.h"
+
+#define STAGE3A_INIT_ENTRY IMAGE_ENTRY
+#define STAGE3A_ENTRY (STAGE3A_INIT_ENTRY + _AC(0x1000, UL))
+#define STAGE3A_LOAD_ADDRESS IMAGE_LOAD_ADDRESS
+
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+/* Must not have any padding */
+struct stage3a_args {
+ uint64_t hdr_offs;
+ uint64_t hdr_size;
+ uint64_t ipib_offs;
+};
+STATIC_ASSERT(sizeof(struct stage3a_args) == 3 * 8)
+
+#endif /* __ASSEMBLER__ */
+#endif /* STAGE3A_H */
--- /dev/null
+++ b/genprotimg/boot/stage3a.lds
@@ -0,0 +1,101 @@
+/*
+ * Memory layout for stage 3a
+ * ==========================
+ *
+ * General memory layout
+ * ---------------------
+ *
+ * 0x00000 - 0x01fff Lowcore
+ * 0x02000 - 0x05fff Memory allocation (heap)
+ * 0x0f000 - 0x0ffff Stack
+ * 0x10000 - 0x10012 Jump to the "actual" stage3a code
+ * 0x11000 - 0x12fff Stage3a code + arguments (offsets and lengths to the
+ * actual data: IPIB and UV header)
+ */
+
+OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
+OUTPUT_ARCH(s390:64-bit)
+
+ENTRY(_init)
+
+__heap_size__ = 0x4000;
+__stack_size__ = 0x1000;
+
+SECTIONS
+{
+ . = 0x0;
+
+ . = 0x2000;
+ __heap_start = .;
+ .heap : {
+ . = . + __heap_size__;
+ ASSERT(__heap_stop - __heap_start == __heap_size__,
+ "Heap section doesn't conform to the described memory layout");
+ }
+ __heap_stop = .;
+
+ . = 0xf000;
+ __stack_start = .;
+ .stack : {
+ . = . + __stack_size__;
+ ASSERT(__stack_end - __stack_start == __stack_size__,
+ "Stack section doesn't conform to the described memory layout");
+ }
+ __stack_end = .;
+
+ . = 0x10000;
+ __text_init_start = .;
+ .text : {
+ stage3a_init.o(.text.init)
+ __text_init_stop = ABSOLUTE(.);
+ /* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY',
+ * otherwise the text data could be overwritten by the original zipl stage3
+ * boot loader */
+ ASSERT(__text_init_stop - __text_init_start < 0x400,
+ "Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'");
+ . = 0x1000;
+ head.o(.text.start)
+ *(.text)
+ }
+
+ .ex_table ALIGN(16) : {
+ __ex_table_start = .;
+ *(.ex_table)
+ __ex_table_stop = .;
+ }
+
+ .bss ALIGN(16) : {
+ __bss_start = .;
+ *(.bss)
+ __bss_stop = .;
+ }
+
+ .rodata ALIGN(16) : {
+ *(.rodata)
+ *(.rodata.*)
+ }
+
+ .data ALIGN(16) : {
+ *(.data)
+ . = ALIGN(16);
+ /* The IPIB offset and the UV header offset and size will be
+ * saved in 'loader_parms' */
+ __loader_parms_start = .;
+ KEEP(*(.loader_parms));
+ __loader_parms_stop = .;
+ ASSERT(__loader_parms_stop - __loader_parms_start == 3 * 8,
+ "Data size must be equal to 'sizeof(struct stage3a_args)'");
+ ASSERT(ABSOLUTE(.) < 0x13000, "Data section doesn't conform to the described memory layout");
+ }
+
+ /* List this explicitly as otherwise .note.gnu.build-id will be
+ * put at 0x0 */
+ .notes : {
+ *(.note.*)
+ }
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.eh_frame)
+ }
+}
--- /dev/null
+++ b/genprotimg/boot/stage3a_init.S
@@ -0,0 +1,26 @@
+/*
+ * Entry code for stage 3a boot loader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 "stage3a.h"
+#include "boot/sigp.h"
+
+.section .text.init
+.globl _init
+_init:
+ /* set architecture and switch to 64bit */
+ lhi %r1, 1
+ sigp %r1, %r0, SIGP_SET_ARCHITECTURE
+ sam64
+ /* The original stage3 boot loader will try to store the
+ * kernel command line and the address and size of the
+ * ramdisk. Simply ignore this by starting at 0x11000.
+ */
+ lgfi %r1, STAGE3A_ENTRY
+ br %r1
+.previous
--- /dev/null
+++ b/genprotimg/boot/stage3b.c
@@ -0,0 +1,77 @@
+/*
+ * Main program for stage3b bootloader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 "libc.h"
+#include "stage3b.h"
+
+#include "lib/zt_common.h"
+#include "boot/s390.h"
+#include "boot/linux_layout.h"
+#include "boot/loaders_layout.h"
+#include "sclp.h"
+#include "error.h"
+
+
+static volatile struct stage3b_args __section(".loader_parms") loader_parms;
+
+static inline void __noreturn load_psw(struct psw_t psw)
+{
+ asm volatile("lpswe %0" : : "Q"(psw) : "cc");
+
+ while (1)
+ ;
+}
+
+void __noreturn start(void)
+{
+ volatile struct stage3b_args *args = &loader_parms;
+ volatile struct memblob *kernel = &args->kernel;
+ volatile struct memblob *cmdline = &args->cmdline;
+ volatile struct memblob *initrd = &args->initrd;
+ volatile struct psw_t psw = args->psw;
+
+ /* set up ASCII and line-mode */
+ sclp_setup(SCLP_LINE_ASCII_INIT);
+
+ if (kernel->size < IMAGE_LOAD_ADDRESS)
+ panic(EINTERNAL, "Invalid kernel\n");
+
+ if (cmdline->size > COMMAND_LINE_SIZE)
+ panic(EINTERNAL, "Command line is too large\n");
+
+ /* move the kernel and cut the kernel header */
+ memmove((void *)IMAGE_LOAD_ADDRESS,
+ (void *)(kernel->src + IMAGE_LOAD_ADDRESS),
+ kernel->size - IMAGE_LOAD_ADDRESS);
+
+ /* move the kernel cmdline */
+ memmove((void *)COMMAND_LINE,
+ (void *)cmdline->src,
+ cmdline->size);
+ /* the initrd does not need to be moved */
+
+ if (initrd->size != 0) {
+ /* copy initrd start address and size into new kernel space */
+ *(unsigned long long *)INITRD_START = initrd->src;
+ *(unsigned long long *)INITRD_SIZE = initrd->size;
+ }
+
+ /* disable ASCII and line-mode */
+ sclp_setup(SCLP_DISABLE);
+
+ /* use lpswe instead of diag308 as a I/O subsystem reset is not
+ * needed as this was already done by the diag308 subcode 10 call
+ * in stage3a
+ */
+ load_psw(psw);
+}
+
+void panic_notify(unsigned long UNUSED(rc))
+{
+}
--- /dev/null
+++ b/genprotimg/boot/stage3b.h
@@ -0,0 +1,38 @@
+/*
+ * Main program for stage3b bootloader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 STAGE3B_H
+#define STAGE3B_H
+
+#include "lib/zt_common.h"
+
+
+#ifndef __ASSEMBLER__
+
+#include <stdint.h>
+
+#include "boot/s390.h"
+
+/* Must not have any padding included */
+struct memblob {
+ uint64_t src;
+ uint64_t size;
+};
+STATIC_ASSERT(sizeof(struct memblob) == 2 * 8)
+
+/* Must not have any padding included */
+struct stage3b_args {
+ struct memblob kernel;
+ struct memblob cmdline;
+ struct memblob initrd;
+ struct psw_t psw;
+};
+STATIC_ASSERT(sizeof(struct stage3b_args) == 3 * sizeof(struct memblob) + 16)
+#endif /* __ASSEMBLER__ */
+#endif /* STAGE3B_H */
--- /dev/null
+++ b/genprotimg/boot/stage3b.lds
@@ -0,0 +1,87 @@
+/*
+ * Memory layout for stage 3b
+ * ==========================
+ *
+ * General memory layout
+ * ---------------------
+ *
+ * 0x00000 - 0x01fff Lowcore
+ * 0x02000 - 0x05fff Memory allocation (heap)
+ * 0x0a000 - 0x0efff Stage3b code
+ * 0x0f000 - 0x0ffff Stack
+ */
+
+OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
+OUTPUT_ARCH(s390:64-bit)
+
+ENTRY(_start)
+
+__heap_size__ = 0x4000;
+__stack_size__ = 0x1000;
+
+SECTIONS
+{
+ . = 0x0;
+
+ . = 0x2000;
+ __heap_start = .;
+ .heap : {
+ . = . + __heap_size__;
+ ASSERT(__heap_stop - __heap_start == __heap_size__,
+ "Heap section doesn't conform to the described memory layout");
+ }
+ __heap_stop = .;
+
+ . = 0xa000;
+ .text : {
+ head.o(.text.start)
+ *(.text)
+ }
+
+ .ex_table ALIGN(16) : {
+ __ex_table_start = .;
+ *(.ex_table)
+ __ex_table_stop = .;
+ }
+
+ .bss ALIGN(16) : {
+ __bss_start = .;
+ *(.bss)
+ __bss_stop = .;
+ }
+
+ .rodata ALIGN(16) : {
+ *(.rodata)
+ *(.rodata.*)
+ }
+
+ .data ALIGN(16) : {
+ *(.data)
+ . = ALIGN(16);
+ __loader_parms_start = .;
+ KEEP(*(.loader_parms));
+ __loader_parms_end = .;
+ ASSERT(__loader_parms_end - __loader_parms_start == 3 * 16 + 16,
+ "Data size must be equal to 'sizeof(struct stage3b_args)'");
+ }
+
+ . = 0xf000;
+ __stack_start = .;
+ .stack : {
+ . = . + __stack_size__;
+ ASSERT(__stack_end - __stack_start == __stack_size__,
+ "Stack section doesn't conform to the described memory layout");
+ }
+ __stack_end = .;
+
+ /* List this explicitly as otherwise .note.gnu.build-id will be
+ * put at 0x0 */
+ .notes : {
+ *(.note.*)
+ }
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.eh_frame)
+ }
+}
--- a/include/boot/ipl.h
+++ b/include/boot/ipl.h
@@ -89,6 +89,30 @@ struct ipl_pb0_ccw {
uint8_t reserved5[8];
} __packed;
+/* Structure must not have any padding */
+struct ipl_pb0_pv_comp {
+ uint64_t tweak_pref;
+ uint64_t addr;
+ uint64_t len;
+};
+STATIC_ASSERT(sizeof(struct ipl_pb0_pv_comp) == 3 * 8)
+
+/* IPL Parameter Block 0 for PV */
+struct ipl_pb0_pv {
+ uint32_t len;
+ uint8_t pbt;
+ uint8_t reserved1[3];
+ uint8_t loadparm[8];
+ uint8_t reserved2[84];
+ uint8_t reserved3[3];
+ uint8_t version;
+ uint8_t reserved4[4];
+ uint32_t num_comp;
+ uint64_t pv_hdr_addr;
+ uint64_t pv_hdr_size;
+ struct ipl_pb0_pv_comp components[];
+} __packed;
+
struct ipl_parameter_block {
struct ipl_pl_hdr hdr;
union {
@@ -96,6 +120,7 @@ struct ipl_parameter_block {
struct ipl_pb0_common common;
struct ipl_pb0_fcp fcp;
struct ipl_pb0_ccw ccw;
+ struct ipl_pb0_pv pv;
char raw[PAGE_SIZE - sizeof(struct ipl_pl_hdr)];
};
} __packed __aligned(PAGE_SIZE);
--- a/include/boot/s390.h
+++ b/include/boot/s390.h
@@ -18,6 +18,12 @@
#define PAGE_SIZE _AC(4096, UL)
+/* Minimum size of a stack frame in bytes */
+#define STACK_FRAME_OVERHEAD _AC(160, U)
+
+/* Facilities */
+#define UNPACK_FACILITY _AC(161, U)
+
#ifndef __ASSEMBLER__
@@ -262,11 +268,17 @@ static __always_inline void __ctl_set_bi
* DIAG 308 support
*/
enum diag308_subcode {
- DIAG308_REL_HSA = 2,
- DIAG308_IPL = 3,
- DIAG308_DUMP = 4,
- DIAG308_SET = 5,
- DIAG308_STORE = 6,
+ DIAG308_REL_HSA = 2,
+ DIAG308_IPL = 3,
+ DIAG308_DUMP = 4,
+ DIAG308_SET = 5,
+ DIAG308_STORE = 6,
+ DIAG308_SET_PV = 8,
+ DIAG308_UNPACK_PV = 10,
+};
+
+enum diag308_rc {
+ DIAG308_RC_OK = 0x0001,
};
static __always_inline unsigned long diag308(unsigned long subcode, void *addr)
--- a/zipl/boot/error.h
+++ b/zipl/boot/error.h
@@ -71,4 +71,10 @@
#define ENOTIME 0x00004605 /* The zipl time stamps do not match */
#define ENOMSS 0x00004606 /* Could not enable MSS */
+/*
+ * PV error codes
+ */
+#define ENOPV 0x00004607 /* No support for PV */
+#define EPV 0x00004608 /* PV error */
+
#endif /* ERROR_H */

View File

@ -0,0 +1,479 @@
Subject: [PATCH] [FEAT VS1804] genprotimg: boot: use C pre-processor for linker script generation
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 2d600570df98a1d26a6f3947ae8c39bcde00b464
Problem-ID: VS1804
Upstream-Description:
genprotimg: boot: use C pre-processor for linker script generation
Use C pre-processor for linker script generation. This allows the
usage of constants in our "linker scripts" `*.lds.S` (actually, these
are assembler files, so we can make us of the C pre-processor and its
capabilities).
Suggested-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
genprotimg/boot/.gitignore | 1
genprotimg/boot/Makefile | 13 ++++-
genprotimg/boot/stage3a.lds | 101 -----------------------------------------
genprotimg/boot/stage3a.lds.S | 103 ++++++++++++++++++++++++++++++++++++++++++
genprotimg/boot/stage3b.h | 4 +
genprotimg/boot/stage3b.lds | 87 -----------------------------------
genprotimg/boot/stage3b.lds.S | 87 +++++++++++++++++++++++++++++++++++
7 files changed, 207 insertions(+), 189 deletions(-)
--- a/genprotimg/boot/.gitignore
+++ b/genprotimg/boot/.gitignore
@@ -1,3 +1,4 @@
*.elf
+*.lds
*.bin
*.d
--- a/genprotimg/boot/Makefile
+++ b/genprotimg/boot/Makefile
@@ -39,6 +39,17 @@ all: $(FILES)
$(CC) $(ALL_CFLAGS) -c -o $@ $<
+# Dependencies for the .lds generation
+sources_lds_S = $(wildcard *.lds.S)
+dependencies_lds_S = $(sources_lds_s:%.lds.S=.%.lds.d)
+# Include all ".lds.d" dependency files for all make targets except for "clean"
+ifneq ($(MAKECMDGOALS),clean)
+-include $(dependencies_lds_S)
+endif
+
+%.lds: %.lds.S Makefile
+ $(CPP) -Wp,-MD,.$@.d,-MT,$@ $(INCLUDE_PARMS) -P -C -o $@ $<
+
# Special rules for zipl object files
$(ZIPL_OBJS_C): %.o : $(ZIPL_BOOT_DIR)/%.c
$(CC) $(ALL_CFLAGS) -c -o $@ $<
@@ -78,6 +89,6 @@ stage3b.elf: head.o stage3b.o stage3b.ld
@chmod a-x $@
clean:
- rm -f *.o *.elf *.bin *.map .*.d
+ rm -f *.o *.elf *.bin *.map .*.d *.lds
.PHONY: all clean
--- a/genprotimg/boot/stage3a.lds
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Memory layout for stage 3a
- * ==========================
- *
- * General memory layout
- * ---------------------
- *
- * 0x00000 - 0x01fff Lowcore
- * 0x02000 - 0x05fff Memory allocation (heap)
- * 0x0f000 - 0x0ffff Stack
- * 0x10000 - 0x10012 Jump to the "actual" stage3a code
- * 0x11000 - 0x12fff Stage3a code + arguments (offsets and lengths to the
- * actual data: IPIB and UV header)
- */
-
-OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
-OUTPUT_ARCH(s390:64-bit)
-
-ENTRY(_init)
-
-__heap_size__ = 0x4000;
-__stack_size__ = 0x1000;
-
-SECTIONS
-{
- . = 0x0;
-
- . = 0x2000;
- __heap_start = .;
- .heap : {
- . = . + __heap_size__;
- ASSERT(__heap_stop - __heap_start == __heap_size__,
- "Heap section doesn't conform to the described memory layout");
- }
- __heap_stop = .;
-
- . = 0xf000;
- __stack_start = .;
- .stack : {
- . = . + __stack_size__;
- ASSERT(__stack_end - __stack_start == __stack_size__,
- "Stack section doesn't conform to the described memory layout");
- }
- __stack_end = .;
-
- . = 0x10000;
- __text_init_start = .;
- .text : {
- stage3a_init.o(.text.init)
- __text_init_stop = ABSOLUTE(.);
- /* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY',
- * otherwise the text data could be overwritten by the original zipl stage3
- * boot loader */
- ASSERT(__text_init_stop - __text_init_start < 0x400,
- "Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'");
- . = 0x1000;
- head.o(.text.start)
- *(.text)
- }
-
- .ex_table ALIGN(16) : {
- __ex_table_start = .;
- *(.ex_table)
- __ex_table_stop = .;
- }
-
- .bss ALIGN(16) : {
- __bss_start = .;
- *(.bss)
- __bss_stop = .;
- }
-
- .rodata ALIGN(16) : {
- *(.rodata)
- *(.rodata.*)
- }
-
- .data ALIGN(16) : {
- *(.data)
- . = ALIGN(16);
- /* The IPIB offset and the UV header offset and size will be
- * saved in 'loader_parms' */
- __loader_parms_start = .;
- KEEP(*(.loader_parms));
- __loader_parms_stop = .;
- ASSERT(__loader_parms_stop - __loader_parms_start == 3 * 8,
- "Data size must be equal to 'sizeof(struct stage3a_args)'");
- ASSERT(ABSOLUTE(.) < 0x13000, "Data section doesn't conform to the described memory layout");
- }
-
- /* List this explicitly as otherwise .note.gnu.build-id will be
- * put at 0x0 */
- .notes : {
- *(.note.*)
- }
-
- /* Sections to be discarded */
- /DISCARD/ : {
- *(.eh_frame)
- }
-}
--- /dev/null
+++ b/genprotimg/boot/stage3a.lds.S
@@ -0,0 +1,103 @@
+/*
+ * Memory layout for stage 3a
+ * ==========================
+ *
+ * General memory layout
+ * ---------------------
+ *
+ * 0x00000 - 0x01fff Lowcore
+ * 0x02000 - 0x05fff Memory allocation (heap)
+ * 0x0f000 - 0x0ffff Stack
+ * 0x10000 - 0x10012 Jump to the "actual" stage3a code
+ * 0x11000 - 0x12fff Stage3a code + arguments (offsets and lengths to the
+ * actual data: IPIB and UV header)
+ */
+
+#include "stage3a.h"
+#include "common_memory_layout.h"
+
+OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
+OUTPUT_ARCH(s390:64-bit)
+
+ENTRY(_init)
+
+SECTIONS
+{
+ . = 0x0;
+
+ . = HEAP_ADDRESS;
+ __heap_start = .;
+ .heap : {
+ . = . + HEAP_SIZE;
+ ASSERT(__heap_stop - __heap_start == HEAP_SIZE,
+ "Heap section doesn't conform to the described memory layout");
+ }
+ __heap_stop = .;
+
+ . = STACK_ADDRESS;
+ __stack_start = .;
+ .stack : {
+ . = . + STACK_SIZE;
+ ASSERT(__stack_end - __stack_start == STACK_SIZE,
+ "Stack section doesn't conform to the described memory layout");
+ }
+ __stack_end = .;
+
+ . = STAGE3A_INIT_ENTRY;
+ __text_init_start = .;
+ .text : {
+ stage3a_init.o(.text.init)
+ __text_init_stop = ABSOLUTE(.);
+ /* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY',
+ * otherwise the text data could be overwritten by the original zipl stage3
+ * boot loader */
+ ASSERT(__text_init_stop - __text_init_start < PARMAREA - IMAGE_ENTRY,
+ "Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'");
+ . = 0x1000;
+ ASSERT(ABSOLUTE(.) == STAGE3A_ENTRY,
+ "Text section doesn't conform to the described memory layout");
+ head.o(.text.start)
+ *(.text)
+ }
+
+ .ex_table ALIGN(16) : {
+ __ex_table_start = .;
+ *(.ex_table)
+ __ex_table_stop = .;
+ }
+
+ .bss ALIGN(16) : {
+ __bss_start = .;
+ *(.bss)
+ __bss_stop = .;
+ }
+
+ .rodata ALIGN(16) : {
+ *(.rodata)
+ *(.rodata.*)
+ }
+
+ .data ALIGN(16) : {
+ *(.data)
+ . = ALIGN(16);
+ /* The IPIB offset and the UV header offset and size will be
+ * saved in 'loader_parms' */
+ __loader_parms_start = .;
+ KEEP(*(.loader_parms));
+ __loader_parms_stop = .;
+ ASSERT(__loader_parms_stop - __loader_parms_start == 3 * 8,
+ "Data size must be equal to 'sizeof(struct stage3a_args)'");
+ ASSERT(ABSOLUTE(.) < 0x13000, "Data section doesn't conform to the described memory layout");
+ }
+
+ /* List this explicitly as otherwise .note.gnu.build-id will be
+ * put at 0x0 */
+ .notes : {
+ *(.note.*)
+ }
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.eh_frame)
+ }
+}
--- a/genprotimg/boot/stage3b.h
+++ b/genprotimg/boot/stage3b.h
@@ -11,6 +11,10 @@
#define STAGE3B_H
#include "lib/zt_common.h"
+#include "boot/loaders_layout.h"
+
+#define STAGE3B_ENTRY STAGE3_ENTRY
+#define STAGE3B_LOAD_ADDRESS STAGE3B_ENTRY
#ifndef __ASSEMBLER__
--- a/genprotimg/boot/stage3b.lds
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Memory layout for stage 3b
- * ==========================
- *
- * General memory layout
- * ---------------------
- *
- * 0x00000 - 0x01fff Lowcore
- * 0x02000 - 0x05fff Memory allocation (heap)
- * 0x0a000 - 0x0efff Stage3b code
- * 0x0f000 - 0x0ffff Stack
- */
-
-OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
-OUTPUT_ARCH(s390:64-bit)
-
-ENTRY(_start)
-
-__heap_size__ = 0x4000;
-__stack_size__ = 0x1000;
-
-SECTIONS
-{
- . = 0x0;
-
- . = 0x2000;
- __heap_start = .;
- .heap : {
- . = . + __heap_size__;
- ASSERT(__heap_stop - __heap_start == __heap_size__,
- "Heap section doesn't conform to the described memory layout");
- }
- __heap_stop = .;
-
- . = 0xa000;
- .text : {
- head.o(.text.start)
- *(.text)
- }
-
- .ex_table ALIGN(16) : {
- __ex_table_start = .;
- *(.ex_table)
- __ex_table_stop = .;
- }
-
- .bss ALIGN(16) : {
- __bss_start = .;
- *(.bss)
- __bss_stop = .;
- }
-
- .rodata ALIGN(16) : {
- *(.rodata)
- *(.rodata.*)
- }
-
- .data ALIGN(16) : {
- *(.data)
- . = ALIGN(16);
- __loader_parms_start = .;
- KEEP(*(.loader_parms));
- __loader_parms_end = .;
- ASSERT(__loader_parms_end - __loader_parms_start == 3 * 16 + 16,
- "Data size must be equal to 'sizeof(struct stage3b_args)'");
- }
-
- . = 0xf000;
- __stack_start = .;
- .stack : {
- . = . + __stack_size__;
- ASSERT(__stack_end - __stack_start == __stack_size__,
- "Stack section doesn't conform to the described memory layout");
- }
- __stack_end = .;
-
- /* List this explicitly as otherwise .note.gnu.build-id will be
- * put at 0x0 */
- .notes : {
- *(.note.*)
- }
-
- /* Sections to be discarded */
- /DISCARD/ : {
- *(.eh_frame)
- }
-}
--- /dev/null
+++ b/genprotimg/boot/stage3b.lds.S
@@ -0,0 +1,87 @@
+/*
+ * Memory layout for stage 3b
+ * ==========================
+ *
+ * General memory layout
+ * ---------------------
+ *
+ * 0x00000 - 0x01fff Lowcore
+ * 0x02000 - 0x05fff Memory allocation (heap)
+ * 0x0a000 - 0x0efff Stage3b code
+ * 0x0f000 - 0x0ffff Stack
+ */
+
+#include "stage3b.h"
+#include "common_memory_layout.h"
+
+OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
+OUTPUT_ARCH(s390:64-bit)
+
+ENTRY(_start)
+
+SECTIONS
+{
+ . = 0x0;
+
+ . = HEAP_ADDRESS;
+ __heap_start = .;
+ .heap : {
+ . = . + HEAP_SIZE;
+ ASSERT(__heap_stop - __heap_start == HEAP_SIZE,
+ "Heap section doesn't conform to the described memory layout");
+ }
+ __heap_stop = .;
+
+ . = STAGE3B_ENTRY;
+ .text : {
+ head.o(.text.start)
+ *(.text)
+ }
+
+ .ex_table ALIGN(16) : {
+ __ex_table_start = .;
+ *(.ex_table)
+ __ex_table_stop = .;
+ }
+
+ .bss ALIGN(16) : {
+ __bss_start = .;
+ *(.bss)
+ __bss_stop = .;
+ }
+
+ .rodata ALIGN(16) : {
+ *(.rodata)
+ *(.rodata.*)
+ }
+
+ .data ALIGN(16) : {
+ *(.data)
+ . = ALIGN(16);
+ __loader_parms_start = .;
+ KEEP(*(.loader_parms));
+ __loader_parms_end = .;
+ ASSERT(__loader_parms_end - __loader_parms_start == 3 * 16 + 16,
+ "Data size must be equal to 'sizeof(struct stage3b_args)'");
+ }
+
+ . = STACK_ADDRESS;
+ __stack_start = .;
+ .stack : {
+ . = . + STACK_SIZE;
+ ASSERT(__stack_end - __stack_start == STACK_SIZE,
+ "Stack section doesn't conform to the described memory layout");
+ }
+ __stack_end = .;
+
+ /* List this explicitly as otherwise .note.gnu.build-id will be
+ * put at 0x0 */
+ .notes : {
+ *(.note.*)
+ }
+
+ /* Sections to be discarded */
+ /DISCARD/ : {
+ *(.eh_frame)
+ }
+}

View File

@ -0,0 +1,120 @@
Subject: [PATCH] [FEAT VS1804] genprotimg: add relocator for stage3b
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: d2f8f972cff7aacbef8e72577af70dbf59ba3ead
Problem-ID: VS1804
Upstream-Description:
genprotimg: add relocator for stage3b
Add support for the placement of the stage3b loader at other addresses
than 0xa000. For this add a position independent relocator that first
copies the original stage3b code to the memory location 0xa000 and
then starts it.
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
genprotimg/boot/Makefile | 5 +++
genprotimg/boot/stage3b_reloc.S | 53 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletion(-)
--- a/genprotimg/boot/Makefile
+++ b/genprotimg/boot/Makefile
@@ -17,7 +17,7 @@ ALL_CFLAGS := $(NO_PIE_CFLAGS) -Os -g \
-mstack-size=4096 -mstack-guard=128 -msoft-float \
-Wall -Wformat-security -Wextra -Werror
-FILES := stage3a.bin stage3b.bin
+FILES := stage3a.bin stage3b.bin stage3b_reloc.bin
ZIPL_SRCS_C := libc.c ebcdic.c ebcdic_conv.c sclp.c
ZIPL_SRCS_ASM := entry.S
@@ -66,14 +66,17 @@ ifneq ($(MAKECMDGOALS),clean)
-include $(dependencies_zipl_c)
endif
+stage3b_reloc.o: stage3b.bin
stage3a.elf: head.o stage3a_init.o stage3a.o stage3a.lds $(ZIPL_OBJS)
stage3b.elf: head.o stage3b.o stage3b.lds $(ZIPL_OBJS)
+stage3b_reloc.elf:
%.elf: %.o
case $* in \
stage3a) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3a.lds";; \
stage3b) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3b.lds";; \
+ stage3b_reloc) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-estage3b_reloc_start,-Ttext,0";; \
esac; \
$(LINK) $$SFLAGS -m64 $(filter %.o, $^) -o $@
@chmod a-x $@
--- /dev/null
+++ b/genprotimg/boot/stage3b_reloc.S
@@ -0,0 +1,53 @@
+/*
+ * Relocator code for stage 3b boot loader
+ *
+ * Copyright IBM Corp. 2020
+ *
+ * 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 "stage3b.h"
+#include "boot/sigp.h"
+
+.macro MEMCPY dst,src,len
+ lgr %r0, \dst
+ lgr %r1, \len
+ lgr %r2, \src
+ lgr %r3, \len
+
+20: mvcle %r0, %r2, 0
+ jo 20b
+.endm
+
+.org 0x0
+.section .text.start
+.globl stage3b_reloc_start
+stage3b_reloc_start:
+ /* Might be called after a diag308 so better set
+ * architecture and addressing mode
+ */
+ lhi %r1, 1
+ sigp %r1, %r0, SIGP_SET_ARCHITECTURE
+ sam64
+
+.copy_stage3b:
+ /* Location of stage3b in memory */
+ larl %r8, stage3b_start
+
+ /* Destination for stage3b */
+ lgfi %r9, STAGE3B_LOAD_ADDRESS
+
+ /* Size of stage3b */
+ lghi %r11, stage3b_end - stage3b_start
+
+ /* Copy the stage3b loader to address STAGE3B_LOAD_ADDRESS */
+ MEMCPY %r9, %r8, %r11
+
+ /* Branch to STAGE3B_ENTRY */
+ lgfi %r9, STAGE3B_ENTRY
+ br %r9
+stage3b_start:
+ .incbin "stage3b.bin"
+stage3b_end:
+.previous

View File

@ -0,0 +1,38 @@
Subject: [PATCH] [FEAT VS1804] README.md: remove useless empty line
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: b06af6026f08d67339a109ba7457373ab82d3248
Problem-ID: VS1804
Upstream-Description:
README.md: remove useless empty line
Remove useless empty line.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
README.md | 1 -
1 file changed, 1 deletion(-)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,3 @@
-
s390-tools
==========

View File

@ -0,0 +1,54 @@
Subject: [PATCH] [FEAT VS1804] include/boot/s390.h: add guard for `struct __vector128`
From: Marc Hartmayer <mhartmay@linux.ibm.com>
Summary: genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
initrd, optionally a file with the kernel command line, and it
generates a single, loadable image file. The image consists of a
concatenation of a plain text boot loader, the encrypted
components for kernel, initrd, and cmdline, and the
integrity-protected PV header, containing metadata necessary for
running the guest in PV mode. It's possible to use this image file
as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: 11bdab26297e508fdab29f9457094eedf681de53
Problem-ID: VS1804
Upstream-Description:
include/boot/s390.h: add guard for `struct __vector128`
`linux/asm/types.h` also defines the struct `__vector128` so in order
to avoid definition conflicts add the macro guard _S390_TYPES_H, which
is defined in `linux/asm/types`. `linux/asm/types.h` is included by
glib2, which is used by the PV tooling.
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
include/boot/s390.h | 5 +++++
1 file changed, 5 insertions(+)
--- a/include/boot/s390.h
+++ b/include/boot/s390.h
@@ -358,12 +358,17 @@ static __always_inline int is_zvm(void)
return cpuid.version == 0xff;
}
+/* To avoid conflicts add a macro guard since __vector128 is also
+ * defined in 'linux/asm/types.h'.
+ */
+#ifndef _S390_TYPES_H
/*
* Vector register definition
*/
typedef struct {
uint32_t u[4];
} __vector128;
+#endif
/*
* Save vector registers

View File

@ -1,3 +1,73 @@
-------------------------------------------------------------------
Thu Mar 19 19:22:19 UTC 2020 - Mark Post <mpost@suse.com>
- Added the following patches for bsc#1166850
zipl: fix secure boot config handling:
* s390-tools-sles15sp2-01-zipl-Add-missing-options-to-help-output.patch
* s390-tools-sles15sp2-02-zipl-allow-stand-alone-secure-option-on-command-l.patch
* s390-tools-sles15sp2-03-zipl-correct-secure-boot-config-handling.patch
* s390-tools-sles15sp2-04-zipl-fix-zipl.conf-man-page-example-for-secure-boot.patch
- Modified the spec file so that the kernel used for the SCSI dump
tool is named zfcpdump-image instead of zfcpdump_part.image. This
is to match the new version of zipl that expects this new file name.
(bsc#1166851)
-------------------------------------------------------------------
Wed Mar 18 17:58:57 UTC 2020 - Mark Post <mpost@suse.com>
- Added the following patches to implement jsc#SLE-7471, Enhanced
tooling for kvm guest images (bsc#1165549):
* s390-tools-sles15sp2-01-zipl-fix-Wdiscarded-qualifiers.patch
* s390-tools-sles15sp2-02-zipl-fix-Waddress-of-packed-member.patch
* s390-tools-sles15sp2-03-zipl-remove-some-useless-__packed___-attributes.patch
* s390-tools-sles15sp2-04-zipl-Fix-entry-point-for-stand-alone-kdump.patch
* s390-tools-sles15sp2-05-zipl-Fix-dependency-generation-in-zipl-boot.patch
* s390-tools-sles15sp2-06-zipl-Make-use-of-__packed-macro.patch
* s390-tools-sles15sp2-07-zipl-define-__section-macro-and-make-use-of-it.patch
* s390-tools-sles15sp2-08-zipl-Make-use-of-__noreturn-macro.patch
* s390-tools-sles15sp2-09-zipl-Define-__noinline-macro-and-make-use-of-it.patch
* s390-tools-sles15sp2-10-zipl-stage3-Mark-start_kernel-__noreturn.patch
* s390-tools-sles15sp2-11-zipl-sclp-Remove-duplicate-macros.patch
* s390-tools-sles15sp2-12-zipl-Make-address-size-mask-macros-UL.patch
* s390-tools-sles15sp2-13-zipl-libc-Use-stdint.h-instead-of-self-defined-macro.patch
* s390-tools-sles15sp2-14-zipl-Consolidate-IMAGE-macros.patch
* s390-tools-sles15sp2-15-zipl-Consolidate-STAGE-2-3-macros.patch
* s390-tools-sles15sp2-16-zipl-stfle-use-uint64_t-instead-of-u64.patch
* s390-tools-sles15sp2-17-zipl-boot-fix-comment-in-stage3.lds.patch
* s390-tools-sles15sp2-18-lib-zt_common-add-STATIC_ASSERT-macro.patch
* s390-tools-sles15sp2-19-zipl-use-STATIC_ASSERT-macro-for-no-padding-verifica.patch
* s390-tools-sles15sp2-20-Support-lib-zt_common.h-to-be-used-in-assembler-and-.patch
* s390-tools-sles15sp2-21-zipl-move-IPL-related-definitions-into-separate-head.patch
* s390-tools-sles15sp2-22-zipl-move-SIGP-related-functions-and-definitions-int.patch
* s390-tools-sles15sp2-23-zipl-add-SIGP_SET_ARCHITECTURE-to-sigp.h-and-use-it.patch
* s390-tools-sles15sp2-24-zipl-stage3-make-IPL_DEVICE-definition-consistent-wi.patch
* s390-tools-sles15sp2-25-zipl-move-Linux-layout-definitions-into-separate-hea.patch
* s390-tools-sles15sp2-26-zipl-tape0-use-constants-defined-in-linux_layout.h.patch
* s390-tools-sles15sp2-27-zipl-use-STAGE3_ENTRY-for-STAGE3_LOAD_ADDRESS.patch
* s390-tools-sles15sp2-28-zipl-move-loaders-layout-definitions-into-separate-h.patch
* s390-tools-sles15sp2-29-zipl-s390.h-rename-inline-macro-into-__always_inline.patch
* s390-tools-sles15sp2-30-zipl-move-__always_inline-barrier-__pa32-pa-to-zt_co.patch
* s390-tools-sles15sp2-31-zipl-make-BLK_PWRT-unsigned-int.patch
* s390-tools-sles15sp2-32-Consolidate-MIN-and-MAX-macros.patch
* s390-tools-sles15sp2-33-zipl-remove-libc.h-include-in-s390.h.patch
* s390-tools-sles15sp2-34-zipl-move-s390.h-to-include-boot-s390.h.patch
* s390-tools-sles15sp2-35-zipl-libc-include-s390.h.patch
* s390-tools-sles15sp2-36-include-boot-s390.h-move-panic-and-panic_notify-to-l.patch
* s390-tools-sles15sp2-37-include-boot-s390.h-fixes-for-Werror-sign-conversion.patch
* s390-tools-sles15sp2-38-zipl-refactor-all-EBCDIC-code-into-separate-files.patch
* s390-tools-sles15sp2-39-zipl-sclp-add-macros-for-the-control-program-masks.patch
* s390-tools-sles15sp2-40-zipl-sclp-add-sclp_print_ascii.patch
* s390-tools-sles15sp2-41-zipl-libc-printf-print-on-linemode-and-ASCII-console.patch
* s390-tools-sles15sp2-42-Consolidate-ALIGN-__ALIGN_MASK-ARRAY_SIZE-macros.patch
* s390-tools-sles15sp2-43-genprotimg-boot-initial-bootloader-support.patch
* s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch
* s390-tools-sles15sp2-45-genprotimg-add-relocator-for-stage3b.patch
* s390-tools-sles15sp2-46-README.md-remove-useless-empty-line.patch
* s390-tools-sles15sp2-47-include-boot-s390.h-add-guard-for-struct-__vector128.patch
* s390-tools-sles15sp2-48-genprotimg-introduce-new-tool-for-the-creation-of-PV.patch
- Added a BuildRequires for glib2-devel to support the new feature.
- Added a %dir entry for /usr/share/s390-tools/genprotimg
-------------------------------------------------------------------
Tue Mar 10 18:25:51 UTC 2020 - Mark Post <mpost@suse.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package s390-tools
#
# Copyright (c) 2001-2020 SUSE LLC, Nuernberg, Germany.
# Copyright (c) 2001-2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -135,6 +135,58 @@ Patch45: s390-tools-sles15sp2-04-zipl-libc-Indicate-truncated-lines-in-pr
Patch46: s390-tools-sles15sp2-01-zpcictl-Initiate-recover-after-reset.patch
Patch47: s390-tools-sles15sp2-02-zpcictl-Rename-misleading-sysfs_write_data.patch
Patch48: s390-tools-sles15sp2-03-zpcitctl-Exit-on-error-in-sysfs_report_error.patch
Patch49: s390-tools-sles15sp2-01-zipl-fix-Wdiscarded-qualifiers.patch
Patch50: s390-tools-sles15sp2-02-zipl-fix-Waddress-of-packed-member.patch
Patch51: s390-tools-sles15sp2-03-zipl-remove-some-useless-__packed___-attributes.patch
Patch52: s390-tools-sles15sp2-04-zipl-Fix-entry-point-for-stand-alone-kdump.patch
Patch53: s390-tools-sles15sp2-05-zipl-Fix-dependency-generation-in-zipl-boot.patch
Patch54: s390-tools-sles15sp2-06-zipl-Make-use-of-__packed-macro.patch
Patch55: s390-tools-sles15sp2-07-zipl-define-__section-macro-and-make-use-of-it.patch
Patch56: s390-tools-sles15sp2-08-zipl-Make-use-of-__noreturn-macro.patch
Patch57: s390-tools-sles15sp2-09-zipl-Define-__noinline-macro-and-make-use-of-it.patch
Patch58: s390-tools-sles15sp2-10-zipl-stage3-Mark-start_kernel-__noreturn.patch
Patch59: s390-tools-sles15sp2-11-zipl-sclp-Remove-duplicate-macros.patch
Patch60: s390-tools-sles15sp2-12-zipl-Make-address-size-mask-macros-UL.patch
Patch61: s390-tools-sles15sp2-13-zipl-libc-Use-stdint.h-instead-of-self-defined-macro.patch
Patch62: s390-tools-sles15sp2-14-zipl-Consolidate-IMAGE-macros.patch
Patch63: s390-tools-sles15sp2-15-zipl-Consolidate-STAGE-2-3-macros.patch
Patch64: s390-tools-sles15sp2-16-zipl-stfle-use-uint64_t-instead-of-u64.patch
Patch65: s390-tools-sles15sp2-17-zipl-boot-fix-comment-in-stage3.lds.patch
Patch66: s390-tools-sles15sp2-18-lib-zt_common-add-STATIC_ASSERT-macro.patch
Patch67: s390-tools-sles15sp2-19-zipl-use-STATIC_ASSERT-macro-for-no-padding-verifica.patch
Patch68: s390-tools-sles15sp2-20-Support-lib-zt_common.h-to-be-used-in-assembler-and-.patch
Patch69: s390-tools-sles15sp2-21-zipl-move-IPL-related-definitions-into-separate-head.patch
Patch70: s390-tools-sles15sp2-22-zipl-move-SIGP-related-functions-and-definitions-int.patch
Patch71: s390-tools-sles15sp2-23-zipl-add-SIGP_SET_ARCHITECTURE-to-sigp.h-and-use-it.patch
Patch72: s390-tools-sles15sp2-24-zipl-stage3-make-IPL_DEVICE-definition-consistent-wi.patch
Patch73: s390-tools-sles15sp2-25-zipl-move-Linux-layout-definitions-into-separate-hea.patch
Patch74: s390-tools-sles15sp2-26-zipl-tape0-use-constants-defined-in-linux_layout.h.patch
Patch75: s390-tools-sles15sp2-27-zipl-use-STAGE3_ENTRY-for-STAGE3_LOAD_ADDRESS.patch
Patch76: s390-tools-sles15sp2-28-zipl-move-loaders-layout-definitions-into-separate-h.patch
Patch77: s390-tools-sles15sp2-29-zipl-s390.h-rename-inline-macro-into-__always_inline.patch
Patch78: s390-tools-sles15sp2-30-zipl-move-__always_inline-barrier-__pa32-pa-to-zt_co.patch
Patch79: s390-tools-sles15sp2-31-zipl-make-BLK_PWRT-unsigned-int.patch
Patch80: s390-tools-sles15sp2-32-Consolidate-MIN-and-MAX-macros.patch
Patch81: s390-tools-sles15sp2-33-zipl-remove-libc.h-include-in-s390.h.patch
Patch82: s390-tools-sles15sp2-34-zipl-move-s390.h-to-include-boot-s390.h.patch
Patch83: s390-tools-sles15sp2-35-zipl-libc-include-s390.h.patch
Patch84: s390-tools-sles15sp2-36-include-boot-s390.h-move-panic-and-panic_notify-to-l.patch
Patch85: s390-tools-sles15sp2-37-include-boot-s390.h-fixes-for-Werror-sign-conversion.patch
Patch86: s390-tools-sles15sp2-38-zipl-refactor-all-EBCDIC-code-into-separate-files.patch
Patch87: s390-tools-sles15sp2-39-zipl-sclp-add-macros-for-the-control-program-masks.patch
Patch88: s390-tools-sles15sp2-40-zipl-sclp-add-sclp_print_ascii.patch
Patch89: s390-tools-sles15sp2-41-zipl-libc-printf-print-on-linemode-and-ASCII-console.patch
Patch90: s390-tools-sles15sp2-42-Consolidate-ALIGN-__ALIGN_MASK-ARRAY_SIZE-macros.patch
Patch91: s390-tools-sles15sp2-43-genprotimg-boot-initial-bootloader-support.patch
Patch92: s390-tools-sles15sp2-44-genprotimg-boot-use-C-pre-processor-for-linker-scrip.patch
Patch93: s390-tools-sles15sp2-45-genprotimg-add-relocator-for-stage3b.patch
Patch94: s390-tools-sles15sp2-46-README.md-remove-useless-empty-line.patch
Patch95: s390-tools-sles15sp2-47-include-boot-s390.h-add-guard-for-struct-__vector128.patch
Patch96: s390-tools-sles15sp2-48-genprotimg-introduce-new-tool-for-the-creation-of-PV.patch
Patch97: s390-tools-sles15sp2-01-zipl-Add-missing-options-to-help-output.patch
Patch98: s390-tools-sles15sp2-02-zipl-allow-stand-alone-secure-option-on-command-l.patch
Patch99: s390-tools-sles15sp2-03-zipl-correct-secure-boot-config-handling.patch
Patch100: s390-tools-sles15sp2-04-zipl-fix-zipl.conf-man-page-example-for-secure-boot.patch
# SUSE patches
Patch900: s390-tools-sles12-zipl_boot_msg.patch
@ -156,6 +208,7 @@ BuildRequires: dracut
BuildRequires: fuse-devel
BuildRequires: gcc-c++
BuildRequires: gettext-tools
BuildRequires: glib2-devel
BuildRequires: glibc-devel-static
BuildRequires: kernel-zfcpdump
BuildRequires: libcryptsetup-devel > 2.0.3
@ -270,7 +323,7 @@ install -m 755 read_values %{buildroot}/%{_bindir}/
install -m644 -t %{buildroot}/%{_mandir}/man8 %{SOURCE87}
export ROOT_BUILD_DIR="%{_builddir}/%{name}-%{version}/zfcpdump/kernel"
install -D -m600 /boot/image-*-zfcpdump %{buildroot}%{_prefix}/lib/s390-tools/zfcpdump/zfcpdump_part.image
install -D -m600 /boot/image-*-zfcpdump %{buildroot}%{_prefix}/lib/s390-tools/zfcpdump/zfcpdump-image
install -D -m644 etc/cpuplugd.conf %{buildroot}%{_sysconfdir}/cpuplugd.conf
install -D -m644 etc/udev/rules.d/40-z90crypt.rules %{buildroot}%{_prefix}/lib/udev/rules.d/40-z90crypt.rules
@ -528,6 +581,7 @@ fi
%dir %{_datadir}/s390-tools
%dir %{_datadir}/s390-tools/cpumf
%dir %{_datadir}/s390-tools/netboot
%dir %{_datadir}/s390-tools/genprotimg
%dir %{_prefix}/lib/dracut/modules.d/95zdev
%dir /boot/zipl
%dir /lib/s390-tools/