pc-bios/s390-ccw: Add DASD IPL support
cover pc-bios/s390-ccw: Add DASD IPL support
Conny, Alex, Christian,
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
Eugene (jno) Dvurechenski (9):
pc-bios/s390-ccw: make checkpatch happy pc-bios/s390-ccw: cleanup and enhance bootmap defintions pc-bios/s390-ccw: handle different sector sizes pc-bios/s390-ccw: add some utility code pc-bios/s390-ccw: Unify error handling pc-bios/s390-ccw: Add fill_hex_val func to provide better msgs pc-bios/s390-ccw: factor out ipl code pc-bios/s390-ccw: IPL from CDL-formatted ECKD DASD pc-bios/s390-ccw: IPL from LDL/CMS-formatted ECKD DASD
Jens Freimann (1):
pc-bios/s390-ccw: update binary
pc-bios/s390-ccw.img | Bin 9432 -> 17624 bytes pc-bios/s390-ccw/bootmap.c | 443 +++++++++++++++++++++++++++++------------- pc-bios/s390-ccw/bootmap.h | 344 ++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/main.c | 13 +- pc-bios/s390-ccw/s390-ccw.h | 38 ++-- pc-bios/s390-ccw/sclp-ascii.c | 4 +- pc-bios/s390-ccw/virtio.c | 122 ++++++++++-- pc-bios/s390-ccw/virtio.h | 50 ++++- 8 files changed, 836 insertions(+), 178 deletions(-) create mode 100644 pc-bios/s390-ccw/bootmap.h
Signature · 1 line
1.8.5.5
PATCH 1/10 pc-bios/s390-ccw: make checkpatch happy
From: "Eugene (jno) Dvurechenski" <[email protected]>
Remove tabs, tweak whitespace and comments.
--- pc-bios/s390-ccw/bootmap.c | 37 ++++++++++++++++++++----------------- pc-bios/s390-ccw/s390-ccw.h | 20 ++++++++++---------- pc-bios/s390-ccw/sclp-ascii.c | 4 ++-- pc-bios/s390-ccw/virtio.c | 26 +++++++++++++------------- pc-bios/s390-ccw/virtio.h | 2 +- 5 files changed, 46 insertions(+), 43 deletions(-)
pc-bios/s390-ccw/bootmap.c +20 -17
@@ -10,7 +10,7 @@#include "s390-ccw.h" -// #define DEBUG_FALLBACK +/* #define DEBUG_FALLBACK */ #ifdef DEBUG_FALLBACK #define dputs (txt) \
@@ -47,13 +47,13 @@ struct mbr {struct scsi_blockptr blockptr; } __attribute__ ((packed)); -#define ZIPL_MAGIC "zIPL" +#define ZIPL_MAGIC "zIPL" -#define ZIPL_COMP_HEADER_IPL 0x00 -#define ZIPL_COMP_HEADER_DUMP 0x01 +#define ZIPL_COMP_HEADER_IPL 0x00 +#define ZIPL_COMP_HEADER_DUMP 0x01 -#define ZIPL_COMP_ENTRY_LOAD 0x02 -#define ZIPL_COMP_ENTRY_EXEC 0x01 +#define ZIPL_COMP_ENTRY_LOAD 0x02 +#define ZIPL_COMP_ENTRY_EXEC 0x01/* Scratch space */ static uint8_t sec[SECTOR_SIZE] __attribute__((__aligned__(SECTOR_SIZE)));
@@ -107,8 +107,8 @@ static void jump_to_IPL_code(uint64_t address)/* Check for ZIPL magic. Returns 0 if not matched. */ static int zipl_magic (uint8_t *ptr) { -uint32_t *p = (void *)ptr; -uint32_t *z = (void *)ZIPL_MAGIC ; +uint32_t *p = (void *)ptr; +uint32_t *z = (void *)ZIPL_MAGIC ;if (*p != *z) {debug_print_int ("invalid magic" , *p);
@@ -136,7 +136,7 @@ static inline bool unused_space(const void *p, unsigned int size)static int zipl_load_segment (struct component_entry *entry) {const int max_entries = (SECTOR_SIZE /sizeof (struct scsi_blockptr )); -struct scsi_blockptr *bprs = (void *)sec; +struct scsi_blockptr *bprs = (void *)sec;const int bprs_size =sizeof (sec);uint64_t blockno;long address;
@@ -156,16 +156,18 @@ static int zipl_load_segment(struct component_entry *entry) }for (i =0 ;; i++) { -u64 *cur_desc = (void *)&bprs[i]; +u64 *cur_desc = (void *)&bprs[i]; blockno = bprs[i].blockno; -if (!blockno) +if (!blockno) {break ; + }/* we need the updated blockno for the next indirect entry in the chain, but don't want to advance address */ -if (i == (max_entries -1 )) +if (i == (max_entries -1 )) {break ; + }if (bprs[i].blockct ==0 &&unused_space (&bprs[i +1 ],sizeof (struct scsi_blockptr ))) {
@@ -178,9 +180,10 @@ static int zipl_load_segment(struct component_entry *entry)break ; } address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ],0 , - (void *)address); -if (address ==-1 ) + (void *)address); +if (address ==-1 ) { goto fail; + } } }while (blockno);
@@ -220,7 +223,7 @@ static int zipl_run(struct scsi_blockptr *pte) entry++; -if ((uint8_t *)(&entry[1 ]) > (tmp_sec +SECTOR_SIZE )) { +if ((uint8_t *)(&entry[1 ]) > (tmp_sec +SECTOR_SIZE )) { goto fail; } }
@@ -241,7 +244,7 @@ fail:int zipl_load (void ) { -struct mbr *mbr = (void *)sec; +struct mbr *mbr = (void *)sec;uint8_t *ns, *ns_end;int program_table_entries =0 ;int pte_len =sizeof (struct scsi_blockptr );
@@ -249,7 +252,7 @@ int zipl_load(void)const char *error ="" ;/* Grab the MBR */ -virtio_read (0 , (void *)mbr); +virtio_read (0 , (void *)mbr);dputs ("checking magic\n" );
pc-bios/s390-ccw/s390-ccw.h +10 -10
@@ -34,10 +34,10 @@ typedef unsigned long long __u64;#define PAGE_SIZE 4096#ifndef EIO -#define EIO 1 +#define EIO 1#endif #ifndef EBUSY -#define EBUSY 2 +#define EBUSY 2#endif #ifndef NULL #define NULL 0
@@ -57,7 +57,7 @@ void sclp_setup(void);/* virtio.c */ unsigned long virtio_load_direct (ulong rec_list1,ulong rec_list2, -ulong subchan_id,void *load_addr); +ulong subchan_id,void *load_addr);bool virtio_is_blk (struct subchannel_id schid);void virtio_setup_block (struct subchannel_id schid);int virtio_read (ulong sector,void *load_addr);
@@ -88,7 +88,7 @@ static inline void fill_hex(char *out, unsigned char val)static inline void print_int (const char *desc,u64 addr) { -unsigned char *addr_c = (unsigned char *)&addr; +unsigned char *addr_c = (unsigned char *)&addr;char out[] =": 0xffffffffffffffff\n" ;unsigned int i;
@@ -118,16 +118,16 @@ static inline void debug_print_addr(const char *desc, void *p)* Hypercall functions * ***********************************************/ -#define KVM_S390_VIRTIO_NOTIFY 0 -#define KVM_S390_VIRTIO_RESET 1 -#define KVM_S390_VIRTIO_SET_STATUS 2 +#define KVM_S390_VIRTIO_NOTIFY 0 +#define KVM_S390_VIRTIO_RESET 1 +#define KVM_S390_VIRTIO_SET_STATUS 2#define KVM_S390_VIRTIO_CCW_NOTIFY 3static inline void yield (void ) { - asmvolatile ("diag 0,0,0x44" - : : - :"memory" ,"cc" ); + asmvolatile ("diag 0,0,0x44" + : : + :"memory" ,"cc" ); }#define SECTOR_SIZE 512
pc-bios/s390-ccw/sclp-ascii.c +2 -2
@@ -33,7 +33,7 @@ static int sclp_service_call(unsigned int command, void *sccb)static void sclp_set_write_mask (void ) { -WriteEventMask *sccb = (void *)_sccb; +WriteEventMask *sccb = (void *)_sccb; sccb->h.length =sizeof (WriteEventMask); sccb->mask_length =sizeof (unsigned int );
@@ -68,7 +68,7 @@ static void _memcpy(char *dest, const char *src, int len)void sclp_print (const char *str) {int len =_strlen (str); -WriteEventData *sccb = (void *)_sccb; +WriteEventData *sccb = (void *)_sccb; sccb->h.length =sizeof (WriteEventData) + len; sccb->h.function_code =SCLP_FC_NORMAL_WRITE ;
pc-bios/s390-ccw/virtio.c +13 -13
@@ -18,22 +18,22 @@ static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));static long kvm_hypercall (unsigned long nr,unsigned long param1,unsigned long param2) { - register ulong r_nr asm("1") = nr; - register ulong r_param1 asm("2") = param1; - register ulong r_param2 asm("3") = param2; - registerlong retval asm("2" ); + register ulong r_nr asm("1") = nr; + register ulong r_param1 asm("2") = param1; + register ulong r_param2 asm("3") = param2; + registerlong retval asm("2" ); - asmvolatile ("diag 2,4,0x500" - :"=d" (retval) - :"d" (r_nr),"0" (r_param1),"r" (r_param2) - :"memory" ,"cc" ); + asmvolatile ("diag 2,4,0x500" + :"=d" (retval) + :"d" (r_nr),"0" (r_param1),"r" (r_param2) + :"memory" ,"cc" ); -return retval; +return retval; }static void virtio_notify (struct subchannel_id schid) { -kvm_hypercall (KVM_S390_VIRTIO_CCW_NOTIFY , *(u32 *)&schid,0 ); +kvm_hypercall (KVM_S390_VIRTIO_CCW_NOTIFY , *(u32 *)&schid,0 ); }/***********************************************
@@ -236,7 +236,7 @@ static int virtio_read_many(ulong sector, void *load_addr, int sec_num) }unsigned long virtio_load_direct (ulong rec_list1,ulong rec_list2, -ulong subchan_id,void *load_addr) +ulong subchan_id,void *load_addr) {u8 status;int sec = rec_list1;
@@ -249,7 +249,7 @@ unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, }sclp_print ("." ); - status =virtio_read_many (sec, (void *)addr, sec_num); + status =virtio_read_many (sec, (void *)addr, sec_num);if (status) {virtio_panic ("I/O Error" ); }
@@ -274,7 +274,7 @@ void virtio_setup_block(struct subchannel_id schid)if (run_ccw (schid,CCW_CMD_READ_VQ_CONF , &config,sizeof (config))) {virtio_panic ("Could not get block device configuration\n" ); } -vring_init (&block, config.num, (void *)(100 *1024 *1024 ), +vring_init (&block, config.num, (void *)(100 *1024 *1024 ),KVM_S390_VIRTIO_RING_ALIGN ); info.queue = (100ULL *1024ULL *1024ULL );
pc-bios/s390-ccw/virtio.h +1 -1
@@ -66,7 +66,7 @@ struct virtio_dev {char *config; }; -#define KVM_S390_VIRTIO_RING_ALIGN 4096 +#define KVM_S390_VIRTIO_RING_ALIGN 4096#define VRING_USED_F_NO_NOTIFY 1
Signature · 1 line
1.8.5.5
PATCH 2/10 pc-bios/s390-ccw: cleanup and enhance bootmap defintions
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Add declarations to describe structure of different dasd IPL sources (eckd and fba). Move the structure definitions to a new header bootmap.h. While we are at it, change structs to typedefs.
--- pc-bios/s390-ccw/bootmap.c | 66 +++--------- pc-bios/s390-ccw/bootmap.h | 254 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+), 51 deletions(-) create mode 100644 pc-bios/s390-ccw/bootmap.h
pc-bios/s390-ccw/bootmap.c +15 -51
@@ -9,6 +9,7 @@*/ #include "s390-ccw.h" +#include "bootmap.h" /* #define DEBUG_FALLBACK */
@@ -20,41 +21,6 @@ do { } while (0)#endif -struct scsi_blockptr { -uint64_t blockno; -uint16_t size; -uint16_t blockct; -uint8_t reserved[4 ]; -} __attribute__ ((packed)); - -struct component_entry { -struct scsi_blockptr data; -uint8_t pad[7 ]; -uint8_t component_type; -uint64_t load_address; -} __attribute((packed)); - -struct component_header { -uint8_t magic[4 ]; -uint8_t type; -uint8_t reserved[27 ]; -} __attribute((packed)); - -struct mbr { -uint8_t magic[4 ]; -uint32_t version_id; -uint8_t reserved[8 ]; -struct scsi_blockptr blockptr; -} __attribute__ ((packed)); - -#define ZIPL_MAGIC "zIPL" - -#define ZIPL_COMP_HEADER_IPL 0x00 -#define ZIPL_COMP_HEADER_DUMP 0x01 - -#define ZIPL_COMP_ENTRY_LOAD 0x02 -#define ZIPL_COMP_ENTRY_EXEC 0x01 -/* Scratch space */ static uint8_t sec[SECTOR_SIZE] __attribute__((__aligned__(SECTOR_SIZE)));
@@ -118,8 +84,6 @@ static int zipl_magic(uint8_t *ptr)return 1 ; } -#define FREE_SPACE_FILLER '\xAA' -static inline bool unused_space (const void *p,unsigned int size) {int i;
@@ -133,10 +97,10 @@ static inline bool unused_space(const void *p, unsigned int size)return true; } -static int zipl_load_segment (struct component_entry *entry) +static int zipl_load_segment (ComponentEntry *entry) { -const int max_entries = (SECTOR_SIZE /sizeof (struct scsi_blockptr )); -struct scsi_blockptr *bprs = (void *)sec; +const int max_entries = (SECTOR_SIZE /sizeof (ScsiBlockPtr)); +ScsiBlockPtr *bprs = (void *)sec;const int bprs_size =sizeof (sec);uint64_t blockno;long address;
@@ -170,7 +134,7 @@ static int zipl_load_segment(struct component_entry *entry) }if (bprs[i].blockct ==0 &&unused_space (&bprs[i +1 ], -sizeof (struct scsi_blockptr ))) { +sizeof (ScsiBlockPtr))) {/* This is a "continue" pointer. * This ptr is the last one in the current script section. * I.e. the next ptr must point to the unused memory area.
@@ -195,14 +159,14 @@ fail: }/* Run a zipl program */ -static int zipl_run (struct scsi_blockptr *pte) +static int zipl_run (ScsiBlockPtr *pte) { -struct component_header *header; -struct component_entry *entry; +ComponentHeader *header; +ComponentEntry *entry;uint8_t tmp_sec[SECTOR_SIZE ];virtio_read (pte->blockno, tmp_sec); - header = (struct component_header *)tmp_sec; + header = (ComponentHeader *)tmp_sec;if (!zipl_magic (tmp_sec)) { goto fail;
@@ -215,7 +179,7 @@ static int zipl_run(struct scsi_blockptr *pte)dputs ("start loading images\n" );/* Load image(s) into RAM */ - entry = (struct component_entry *)(&header[1 ]); + entry = (ComponentEntry *)(&header[1 ]);while (entry->component_type ==ZIPL_COMP_ENTRY_LOAD ) {if (zipl_load_segment (entry) <0 ) { goto fail;
@@ -244,11 +208,11 @@ fail:int zipl_load (void ) { -struct mbr *mbr = (void *)sec; +ScsiMbr *mbr = (void *)sec;uint8_t *ns, *ns_end;int program_table_entries =0 ; -int pte_len =sizeof (struct scsi_blockptr ); -struct scsi_blockptr *prog_table_entry; +const int pte_len =sizeof (ScsiBlockPtr); +ScsiBlockPtr *prog_table_entry;const char *error ="" ;/* Grab the MBR */
@@ -276,7 +240,7 @@ int zipl_load(void) ns_end = sec +SECTOR_SIZE ;for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) { - prog_table_entry = (struct scsi_blockptr *)ns; + prog_table_entry = (ScsiBlockPtr *)ns;if (!prog_table_entry->blockno) {break ; }
@@ -292,7 +256,7 @@ int zipl_load(void)/* Run the default entry */ - prog_table_entry = (struct scsi_blockptr *)(sec + pte_len); + prog_table_entry = (ScsiBlockPtr *)(sec + pte_len);return zipl_run (prog_table_entry);
pc-bios/s390-ccw/bootmap.h new file +254 -0
254 lines not on this page · raw message
Signature · 1 line
1.8.5.5
PATCH 3/10 pc-bios/s390-ccw: handle different sector sizes
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Use the virtio device's configuration to figure out the disk geometry and use a sector size based upon the layout.
--- pc-bios/s390-ccw/bootmap.c | 3 +- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/virtio.c | 96 ++++++++++++++++++++++++++++++++++++++++++--- pc-bios/s390-ccw/virtio.h | 48 +++++++++++++++++++++++ 4 files changed, 142 insertions(+), 7 deletions(-)
pc-bios/s390-ccw/bootmap.c +2 -1
@@ -10,6 +10,7 @@#include "s390-ccw.h" #include "bootmap.h" +#include "virtio.h" /* #define DEBUG_FALLBACK */
@@ -238,7 +239,7 @@ int zipl_load(void) goto fail; } - ns_end = sec +SECTOR_SIZE ; + ns_end = sec +virtio_get_block_size ();for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) { prog_table_entry = (ScsiBlockPtr *)ns;if (!prog_table_entry->blockno) {
pc-bios/s390-ccw/s390-ccw.h +1 -1
@@ -130,6 +130,6 @@ static inline void yield(void) : "memory", "cc"); } -#define SECTOR_SIZE 512 +#define SECTOR_SIZE 4096#endif /* S390_CCW_H */
pc-bios/s390-ccw/virtio.c +91 -5
145 lines not on this page · raw message
pc-bios/s390-ccw/virtio.h +48 -0
52 lines not on this page · raw message
Signature · 1 line
1.8.5.5
Re: [Qemu-devel] [PATCH 03/10] pc-bios/s390-ccw: handle different sector sizes
Quoted 40 lines · Jens Freimann
From: "Eugene (jno) Dvurechenski" <[email protected]>
Use the virtio device's configuration to figure out the disk geometry and use a sector size based upon the layout.
Signed-off-by Eugene (jno) Dvurechenski <[email protected]>Signed-off-by Jens Freimann <[email protected]>--- pc-bios/s390-ccw/bootmap.c | 3 +- pc-bios/s390-ccw/s390-ccw.h | 2 +- pc-bios/s390-ccw/virtio.c | 96 ++++++++++++++++++++++++++++++++++++++++++--- pc-bios/s390-ccw/virtio.h | 48 +++++++++++++++++++++++ 4 files changed, 142 insertions(+), 7 deletions(-)pc-bios/s390-ccw/bootmap.c +2
-1@@ -10,6 +10,7 @@#include "s390-ccw.h" #include "bootmap.h" +#include "virtio.h" /* #define DEBUG_FALLBACK */ @@ -238,7 +239,7 @@ int zipl_load(void) goto fail; } - ns_end = sec +SECTOR_SIZE ; + ns_end = sec +virtio_get_block_size ();for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) { prog_table_entry = (ScsiBlockPtr *)ns;if (!prog_table_entry->blockno) {pc-bios/s390-ccw/s390-ccw.h +0
-0
pc-bios/s390-ccw/s390-ccw.h static inline void yield(void) · line 133
Quoted 5 lines
pc-bios/s390-ccw/s390-ccw.h +1
-1@@ -130,6 +130,6 @@ static inline void yield(void) : "memory", "cc"); } -#define SECTOR_SIZE 512 +#define SECTOR_SIZE 4096
Why keep the define at all?
Alex
Re: [Qemu-devel] [PATCH 03/10] pc-bios/s390-ccw: handle different sector sizes
Quoted 2 lines · Alexander Graf
Quoted 2 lines
-
ns_end= sec +SECTOR_SIZE;
+ns_end= sec +virtio_get_block_size();
...
Quoted 4 lines
Quoted 2 lines
-#define
SECTOR_SIZE512
+#defineSECTOR_SIZE4096Why keep the define at all?
Just to use as default value and in storage allocation (and similar static calculations) now.
Signature · 5 lines
Best Regards, Eugene "jno" Dvurechenski zLinux (KVM) Development - Software Engineer IBM Russia - Science & Technology Center phone: +7 (495) 660 8940 ext. 1021
begin:vcard
fn:Eugene Dvurechenski
n:Dvurechenski;Eugene
org:IBM Systems & Technology Group;IBM S&T Center, Russia adr:;;Obrucheva st., bld.30/1, E2V, floor 4;Moscow;;117485;Russia email;internet:[email protected]
title:Software Engineer
tel;work:+7 (495) 660 8940 ext. 1021
tel;cell:+7 (903) 790-07-49
x-mozilla-html:FALSE
url:http://fsw.su/
version:2.1
end:vcard
Re: [Qemu-devel] [PATCH 03/10] pc-bios/s390-ccw: handle different sector sizes
Quoted 10 lines · Eugene "jno" Dvurechenski
Quoted 2 lines · Alexander Graf
Quoted 2 lines
-
ns_end= sec +SECTOR_SIZE;
+ns_end= sec +virtio_get_block_size();...
Quoted 3 lines
Quoted 2 lines
-#define
SECTOR_SIZE512
+#defineSECTOR_SIZE4096Why keep the define at all?
Just to use as default value and in storage allocation (and similar static calculations) now.
Then either rename it MAX_SECTOR_SIZE and audit every single use of it or try to convert everything to be dynamically sized - gcc should be able to create arrays on the stack based on variables.
Alex
PATCH 4/10 pc-bios/s390-ccw: add some utility code
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
IPL_assert(term,message) is introduced to handle error conditions. ebcdic_to_ascii() to convert chars (mostly to print VOLSERs). read_block() provision for unified block-number handling.
--- pc-bios/s390-ccw/bootmap.c | 15 +-------- pc-bios/s390-ccw/bootmap.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 14 deletions(-)
pc-bios/s390-ccw/bootmap.c +1 -14
@@ -85,25 +85,12 @@ static int zipl_magic(uint8_t *ptr)return 1 ; } -static inline bool unused_space (const void *p,unsigned int size) -{ -int i; -const unsigned char *m = p; - -for (i =0 ; i < size; i++) { -if (m[i] !=FREE_SPACE_FILLER ) { -return false; - } - } -return true; -} -static int zipl_load_segment (ComponentEntry *entry) {const int max_entries = (SECTOR_SIZE /sizeof (ScsiBlockPtr));ScsiBlockPtr *bprs = (void *)sec;const int bprs_size =sizeof (sec); -uint64_t blockno; +block_number_t blockno;long address;int i;
pc-bios/s390-ccw/bootmap.h +83 -0
93 lines not on this page · raw message
Signature · 1 line
1.8.5.5
PATCH 5/10 pc-bios/s390-ccw: Unify error handling
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Convert to IPL_assert and friends
--- pc-bios/s390-ccw/bootmap.c | 82 ++++++++++++--------------------------------- pc-bios/s390-ccw/main.c | 13 ++++--- pc-bios/s390-ccw/s390-ccw.h | 2 +- 3 files changed, 31 insertions(+), 66 deletions(-)
pc-bios/s390-ccw/bootmap.c +21 -61
@@ -85,7 +85,7 @@ static int zipl_magic(uint8_t *ptr)return 1 ; } -static int zipl_load_segment (ComponentEntry *entry) +static void zipl_load_segment (ComponentEntry *entry) {const int max_entries = (SECTOR_SIZE /sizeof (ScsiBlockPtr));ScsiBlockPtr *bprs = (void *)sec;
@@ -102,10 +102,8 @@ static int zipl_load_segment(ComponentEntry *entry) do { memset(bprs, FREE_SPACE_FILLER, bprs_size); - if (virtio_read(blockno, (uint8_t *)bprs)) { - debug_print_int("failed reading bprs at", blockno); - goto fail; - } + debug_print_int("reading bprs at", blockno); + read_block(blockno, bprs, "zipl_load_segment: cannot read block"); for (i = 0;; i++) { u64 *cur_desc = (void *)&bprs[i];
@@ -133,21 +131,13 @@ static int zipl_load_segment(ComponentEntry *entry) } address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ],0 , (void *)address); -if (address ==-1 ) { - goto fail; - } +IPL_assert (address !=-1 ,"zipl_load_segment: wrong IPL address" ); } }while (blockno); - -return 0 ; - -fail: -sclp_print ("failed loading segment\n" ); -return -1 ; }/* Run a zipl program */ -static int zipl_run (ScsiBlockPtr *pte) +static void zipl_run (ScsiBlockPtr *pte) {ComponentHeader *header;ComponentEntry *entry;
@@ -156,75 +146,53 @@ static int zipl_run(ScsiBlockPtr *pte)virtio_read (pte->blockno, tmp_sec); header = (ComponentHeader *)tmp_sec; -if (!zipl_magic (tmp_sec)) { - goto fail; - } +IPL_assert (zipl_magic (tmp_sec),"zipl_run: zipl_magic" ); -if (header->type !=ZIPL_COMP_HEADER_IPL ) { - goto fail; - } +IPL_assert (header->type ==ZIPL_COMP_HEADER_IPL , +"zipl_run: wrong header type" );dputs ("start loading images\n" );/* Load image(s) into RAM */ entry = (ComponentEntry *)(&header[1 ]);while (entry->component_type ==ZIPL_COMP_ENTRY_LOAD ) { -if (zipl_load_segment (entry) <0 ) { - goto fail; - } +zipl_load_segment (entry); entry++; -if ((uint8_t *)(&entry[1 ]) > (tmp_sec +SECTOR_SIZE )) { - goto fail; - } +IPL_assert ((uint8_t *)(&entry[1 ]) <= (tmp_sec +SECTOR_SIZE ), +"zipl_run: wrong entry size" ); } -if (entry->component_type !=ZIPL_COMP_ENTRY_EXEC ) { - goto fail; - } +IPL_assert (entry->component_type ==ZIPL_COMP_ENTRY_EXEC , +"zipl_run: no EXEC entry" );/* should not return */ jump_to_IPL_code (entry->load_address); - -return 0 ; - -fail: -sclp_print ("failed running zipl\n" ); -return -1 ; } -int zipl_load (void ) +void zipl_load (void ) {ScsiMbr *mbr = (void *)sec;uint8_t *ns, *ns_end;int program_table_entries =0 ;const int pte_len =sizeof (ScsiBlockPtr);ScsiBlockPtr *prog_table_entry; -const char *error ="" ;/* Grab the MBR */ -virtio_read (0 , (void *)mbr); +read_block (0 , mbr,"zipl_load: cannot read block 0" );dputs ("checking magic\n" ); -if (!zipl_magic (mbr->magic)) { - error ="zipl_magic 1" ; - goto fail; - } +IPL_assert (zipl_magic (mbr->magic),"zipl_load: zipl_magic 1" );debug_print_int ("program table" , mbr->blockptr.blockno);/* Parse the program table */ -if (virtio_read (mbr->blockptr.blockno, sec)) { - error ="virtio_read" ; - goto fail; - } +read_block (mbr->blockptr.blockno, sec, +"zipl_load: cannot read program table" ); -if (!zipl_magic (sec)) { - error ="zipl_magic 2" ; - goto fail; - } +IPL_assert (zipl_magic (sec),"zipl_load: zipl_magic 2" ); ns_end = sec +virtio_get_block_size ();for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) {
@@ -238,19 +206,11 @@ int zipl_load(void)debug_print_int ("program table entries" , program_table_entries); -if (!program_table_entries) { - goto fail; - } +IPL_assert (program_table_entries,"zipl_load: no program table" );/* Run the default entry */ prog_table_entry = (ScsiBlockPtr *)(sec + pte_len); -return zipl_run (prog_table_entry); - -fail: -sclp_print ("failed loading zipl: " ); -sclp_print (error); -sclp_print ("\n" ); -return -1 ; +zipl_run (prog_table_entry);/* no return */ }
pc-bios/s390-ccw/main.c +9 -4
@@ -9,6 +9,7 @@*/ #include "s390-ccw.h" +#include "virtio.h" char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));uint64_t boot_value;
@@ -64,6 +65,10 @@ static void virtio_setup(uint64_t dev_info) }virtio_setup_block (blk_schid); + +if (!virtio_ipl_disk_is_valid ()) { +virtio_panic ("No valid hard disk detected.\n" ); + } }int main (void )
@@ -72,8 +77,8 @@ int main(void)debug_print_int ("boot reg[7] " , boot_value);virtio_setup (boot_value); -if (zipl_load () <0 ) -sclp_print ("Failed to load OS from hard disk\n" ); -disabled_wait (); -while (1 ) { } +zipl_load ();/* no return */ + +virtio_panic ("Failed to load OS from hard disk\n" ); +return 0 ;/* make compiler happy */ }
pc-bios/s390-ccw/s390-ccw.h +1 -1
@@ -64,7 +64,7 @@ int virtio_read(ulong sector, void *load_addr);int enable_mss_facility (void );/* bootmap.c */ -int zipl_load (void ); +void zipl_load (void );static inline void *memset (void *s,int c,size_t n) {
Signature · 1 line
1.8.5.5
PATCH 6/10 pc-bios/s390-ccw: Add fill_hex_val func to provide better msgs
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Factor out helper function for dumping a hex value into a buffer.
--- pc-bios/s390-ccw/s390-ccw.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/s390-ccw.h +11 -5
@@ -86,15 +86,21 @@ static inline void fill_hex(char *out, unsigned char val) out[1 ] = hex[val &0xf ]; } -static inline void print_int (const char *desc,u64 addr) +static inline void fill_hex_val (char *out,void *ptr,unsigned size) { -unsigned char *addr_c = (unsigned char *)&addr; -char out[] =": 0xffffffffffffffff\n" ; +unsigned char *value = ptr;unsigned int i; -for (i =0 ; i <sizeof (addr); i++) { -fill_hex (&out[4 + (i*2 )], addr_c[i]); +for (i =0 ; i < size; i++) { +fill_hex (&out[i*2 ], value[i]); } +} + +static inline void print_int (const char *desc,u64 addr) +{ +char out[] =": 0xffffffffffffffff\n" ; + +fill_hex_val (&out[4 ], &addr,sizeof (addr));sclp_print (desc);sclp_print (out);
Signature · 1 line
1.8.5.5
PATCH 7/10 pc-bios/s390-ccw: factor out ipl code
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Move the scsi-disk specific ipl code from zipl_load() into a new function ipl_scsi(). This makes it easier to add ipl routines for other disk types.
--- pc-bios/s390-ccw/bootmap.c | 82 +++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 37 deletions(-)
pc-bios/s390-ccw/bootmap.c +45 -37
@@ -12,7 +12,9 @@#include "bootmap.h" #include "virtio.h" +#ifdef DEBUG /* #define DEBUG_FALLBACK */ +#endif #ifdef DEBUG_FALLBACK #define dputs (txt) \
@@ -23,7 +25,7 @@#endif /* Scratch space */ -static uint8_t sec[SECTOR_SIZE] __attribute__((__aligned__(SECTOR_SIZE))); +static uint8_t sec[SECTOR_SIZE*4] __attribute__((__aligned__(PAGE_SIZE))); typedef struct ResetInfo { uint32_t ipl_mask;
@@ -71,19 +73,9 @@ static void jump_to_IPL_code(uint64_t address)virtio_panic ("\n! IPL returns !\n" ); } -/* Check for ZIPL magic. Returns 0 if not matched. */ -static int zipl_magic (uint8_t *ptr) -{ -uint32_t *p = (void *)ptr; -uint32_t *z = (void *)ZIPL_MAGIC ; - -if (*p != *z) { -debug_print_int ("invalid magic" , *p); -virtio_panic ("invalid magic" ); - } - -return 1 ; -} +/*********************************************************************** +* IPL a SCSI disk +*/ static void zipl_load_segment (ComponentEntry *entry) {
@@ -91,8 +83,10 @@ static void zipl_load_segment(ComponentEntry *entry)ScsiBlockPtr *bprs = (void *)sec;const int bprs_size =sizeof (sec);block_number_t blockno; -long address; +uint64_t address;int i; +char err_msg[] ="zIPL failed to read BPRS at 0xZZZZZZZZZZZZZZZZ" ; +char *blk_no = &err_msg[30 ];/* where to print blockno in (those ZZs) */ blockno = entry->data.blockno; address = entry->load_address;
@@ -102,11 +96,11 @@ static void zipl_load_segment(ComponentEntry *entry) do { memset(bprs, FREE_SPACE_FILLER, bprs_size); - debug_print_int("reading bprs at", blockno); - read_block(blockno, bprs, "zipl_load_segment: cannot read block"); + fill_hex_val(blk_no, &blockno, sizeof(blockno)); + read_block(blockno, bprs, err_msg); for (i = 0;; i++) { - u64 *cur_desc = (void *)&bprs[i]; + uint64_t *cur_desc = (void *)&bprs[i]; blockno = bprs[i].blockno; if (!blockno) {
@@ -131,7 +125,7 @@ static void zipl_load_segment(ComponentEntry *entry) } address =virtio_load_direct (cur_desc[0 ], cur_desc[1 ],0 , (void *)address); -IPL_assert (address !=-1 ,"zipl_load_segment: wrong IPL address" ); +IPL_assert (address !=-1 ,"zIPL load segment failed" ); } }while (blockno); }
@@ -143,13 +137,11 @@ static void zipl_run(ScsiBlockPtr *pte)ComponentEntry *entry;uint8_t tmp_sec[SECTOR_SIZE ]; -virtio_read (pte->blockno, tmp_sec); +read_block (pte->blockno, tmp_sec,"Cannot read header" ); header = (ComponentHeader *)tmp_sec; -IPL_assert (zipl_magic (tmp_sec),"zipl_run: zipl_magic" ); - -IPL_assert (header->type ==ZIPL_COMP_HEADER_IPL , -"zipl_run: wrong header type" ); +IPL_assert (magic_match (tmp_sec,ZIPL_MAGIC ),"No zIPL magic" ); +IPL_assert (header->type ==ZIPL_COMP_HEADER_IPL ,"Bad header type" );dputs ("start loading images\n" );
@@ -161,17 +153,16 @@ static void zipl_run(ScsiBlockPtr *pte) entry++;IPL_assert ((uint8_t *)(&entry[1 ]) <= (tmp_sec +SECTOR_SIZE ), -"zipl_run: wrong entry size" ); +"Wrong entry value" ); } -IPL_assert (entry->component_type ==ZIPL_COMP_ENTRY_EXEC , -"zipl_run: no EXEC entry" ); +IPL_assert (entry->component_type ==ZIPL_COMP_ENTRY_EXEC ,"No EXEC entry" );/* should not return */ jump_to_IPL_code (entry->load_address); } -void zipl_load (void ) +static void ipl_scsi (void ) {ScsiMbr *mbr = (void *)sec;uint8_t *ns, *ns_end;
@@ -179,20 +170,16 @@ void zipl_load(void)const int pte_len =sizeof (ScsiBlockPtr);ScsiBlockPtr *prog_table_entry; -/* Grab the MBR */ -read_block (0 , mbr,"zipl_load: cannot read block 0" ); - -dputs ("checking magic\n" ); - -IPL_assert (zipl_magic (mbr->magic),"zipl_load: zipl_magic 1" ); +/* The 0-th block (MBR) was already read into sec[] */ +sclp_print ("Using SCSI scheme.\n" );debug_print_int ("program table" , mbr->blockptr.blockno);/* Parse the program table */ read_block (mbr->blockptr.blockno, sec, -"zipl_load: cannot read program table" ); +"Error reading Program Table" ); -IPL_assert (zipl_magic (sec),"zipl_load: zipl_magic 2" ); +IPL_assert (magic_match (sec,ZIPL_MAGIC ),"No zIPL magic" ); ns_end = sec +virtio_get_block_size ();for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) {
@@ -206,7 +193,7 @@ void zipl_load(void)debug_print_int ("program table entries" , program_table_entries); -IPL_assert (program_table_entries,"zipl_load: no program table" ); +IPL_assert (program_table_entries !=0 ,"Empty Program Table" );/* Run the default entry */
@@ -214,3 +201,24 @@ void zipl_load(void)zipl_run (prog_table_entry);/* no return */ } + +/*********************************************************************** +* IPL starts here +*/ + +void zipl_load (void ) +{ +ScsiMbr *mbr = (void *)sec; + +/* Grab the MBR */ +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (0 , mbr,"Cannot read block 0" ); + +dputs ("checking magic\n" ); + +if (magic_match (mbr->magic,ZIPL_MAGIC )) { +ipl_scsi ();/* no return */ + } + +virtio_panic ("\n* invalid MBR magic *\n" ); +}
Signature · 1 line
1.8.5.5
PATCH 8/10 pc-bios/s390-ccw: IPL from CDL-formatted ECKD DASD
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Add code that allows us to start from ECKD DASD using the z/OS compatible disk layout (CDL), which is the most common format for ECKD DASD.
--- pc-bios/s390-ccw/bootmap.c | 168 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+)
pc-bios/s390-ccw/bootmap.c +168 -0
@@ -74,6 +74,171 @@ static void jump_to_IPL_code(uint64_t address) }/*********************************************************************** +* IPL an ECKD DASD (CDL or LDL/CMS format) +*/ + +static unsigned char _bprs[8 *1024 ];/* guessed "max" ECKD sector size */ +const int max_bprs_entries =sizeof (_bprs) /sizeof (ExtEckdBlockPtr); + +static bool eckd_valid_address (BootMapPointer *p) +{ +const uint64_t cylinder = p->eckd.cylinder + + ((p->eckd.head &0xfff0 ) <<12 ); +const uint64_t head = p->eckd.head &0x000f ; + +if (head >=virtio_get_heads () + || p->eckd.sector >virtio_get_sectors () + || p->eckd.sector <=0 ) { +return false; + } + +if (!virtio_guessed_disk_nature () && cylinder >=virtio_get_cylinders ()) { +return false; + } + +return true; +} + +static block_number_t eckd_block_num (BootMapPointer *p) +{ +const uint64_t sectors =virtio_get_sectors (); +const uint64_t heads =virtio_get_heads (); +const uint64_t cylinder = p->eckd.cylinder + + ((p->eckd.head &0xfff0 ) <<12 ); +const uint64_t head = p->eckd.head &0x000f ; +const block_number_t block = sectors * heads * cylinder + + sectors * head + + p->eckd.sector + -1 ;/* block nr starts with zero */ +return block; +} + +static block_number_t load_eckd_segments (block_number_t blk,uint64_t *address) +{ +block_number_t block_nr; +int j, rc; +BootMapPointer *bprs = (void *)_bprs; +bool more_data; + +memset (_bprs,FREE_SPACE_FILLER ,sizeof (_bprs)); +read_block (blk, bprs,"BPRS read failed" ); + +do { + more_data = false; +for (j =0 ;; j++) { + block_nr =eckd_block_num ((void *)&(bprs[j].xeckd)); +if (is_null_block_number (block_nr)) {/* end of chunk */ +break ; + } + +/* we need the updated blockno for the next indirect entry +* in the chain, but don't want to advance address +*/ +if (j == (max_bprs_entries -1 )) { +break ; + } + +IPL_assert (block_size_ok (bprs[j].xeckd.bptr.size), +"bad chunk block size" ); +IPL_assert (eckd_valid_address (&bprs[j]),"bad chunk ECKD addr" ); + +if ((bprs[j].xeckd.bptr.count ==0 ) &&unused_space (&(bprs[j+1 ]), +sizeof (EckdBlockPtr))) { +/* This is a "continue" pointer. +* This ptr should be the last one in the current +* script section. +* I.e. the next ptr must point to the unused memory area +*/ +memset (_bprs,FREE_SPACE_FILLER ,sizeof (_bprs)); +read_block (block_nr, bprs,"BPRS continuation read failed" ); + more_data = true; +break ; + } + +/* Load (count+1) blocks of code at (block_nr) +* to memory (address). +*/ + rc =virtio_read_many (block_nr, (void *)(*address), + bprs[j].xeckd.bptr.count+1 ); +IPL_assert (rc ==0 ,"code chunk read failed" ); + + *address += (bprs[j].xeckd.bptr.count+1 ) *virtio_get_block_size (); + } + }while (more_data); +return block_nr; +} + +static void run_eckd_boot_script (block_number_t mbr_block_nr) +{ +int i; +block_number_t block_nr; +uint64_t address; +ScsiMbr *scsi_mbr = (void *)sec; +BootMapScript *bms = (void *)sec; + +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (mbr_block_nr, sec,"Cannot read MBR" ); + + block_nr =eckd_block_num ((void *)&(scsi_mbr->blockptr)); + +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (block_nr, sec,"Cannot read Boot Map Script" ); + +for (i =0 ; bms->entry[i].type ==BOOT_SCRIPT_LOAD ; i++) { + address = bms->entry[i].address.load_address; + block_nr =eckd_block_num (&(bms->entry[i].blkptr)); + +do { + block_nr =load_eckd_segments (block_nr, &address); + }while (block_nr !=-1 ); + } + +IPL_assert (bms->entry[i].type ==BOOT_SCRIPT_EXEC , +"Unknown script entry type" ); +jump_to_IPL_code (bms->entry[i].address.load_address);/* no return */ +} + +static void ipl_eckd (void ) +{ +XEckdMbr *mbr; +Ipl2 *ipl2 = (void *)sec; +IplVolumeLabel *vlbl = (void *)sec; +block_number_t block_nr; + +sclp_print ("Using ECKD scheme.\n" ); +if (virtio_guessed_disk_nature ()) { +sclp_print ("Using guessed DASD geometry.\n" ); +virtio_assume_eckd (); + } +/* we have just read the block #0 and recognized it as "IPL1" */ + +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (1 , ipl2,"Cannot read IPL2 record at block 1" ); +IPL_assert (magic_match (ipl2,IPL2_MAGIC ),"No IPL2 record" ); + + mbr = &ipl2->u.x.mbr; +IPL_assert (magic_match (mbr,ZIPL_MAGIC ),"No zIPL section in IPL2 record." ); +IPL_assert (block_size_ok (mbr->blockptr.xeckd.bptr.size), +"Bad block size in zIPL section of IPL2 record." ); +IPL_assert (mbr->dev_type ==DEV_TYPE_ECKD , +"Non-ECKD device type in zIPL section of IPL2 record." ); + +/* save pointer to Boot Script */ + block_nr =eckd_block_num ((void *)&(mbr->blockptr)); + +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (2 , vlbl,"Cannot read Volume Label at block 2" ); +IPL_assert (magic_match (vlbl->key,VOL1_MAGIC ), +"Invalid magic of volume label block" ); +IPL_assert (magic_match (vlbl->f.key,VOL1_MAGIC ), +"Invalid magic of volser block" ); +print_volser (vlbl->f.volser); + +run_eckd_boot_script (block_nr); +/* no return */ +} + +/*********************************************************************** * IPL a SCSI disk */
@@ -219,6 +384,9 @@ void zipl_load(void)if (magic_match (mbr->magic,ZIPL_MAGIC )) {ipl_scsi ();/* no return */ } +if (magic_match (mbr->magic,IPL1_MAGIC )) { +ipl_eckd ();/* CDL ECKD; no return */ + }virtio_panic ("\n* invalid MBR magic *\n" ); }
Signature · 1 line
1.8.5.5
PATCH 9/10 pc-bios/s390-ccw: IPL from LDL/CMS-formatted ECKD DASD
In reply to Jens FreimannFrom: "Eugene (jno) Dvurechenski" <[email protected]>
Add code that allows us to start from two further ECKD DASD disk
layouts: LDL (Linux disk layout) and CMS (cms-formatted disk).
--- pc-bios/s390-ccw/bootmap.c | 92 ++++++++++++++++++++++++++++++++++++++++++---- pc-bios/s390-ccw/bootmap.h | 7 ++++ 2 files changed, 92 insertions(+), 7 deletions(-)
pc-bios/s390-ccw/bootmap.c +85 -7
@@ -80,6 +80,17 @@ static void jump_to_IPL_code(uint64_t address)static unsigned char _bprs[8 *1024 ];/* guessed "max" ECKD sector size */ const int max_bprs_entries =sizeof (_bprs) /sizeof (ExtEckdBlockPtr); +static inline void verify_boot_info (BootInfo *bip) +{ +IPL_assert (magic_match (bip->magic,ZIPL_MAGIC ),"No zIPL magic" ); +IPL_assert (bip->version ==BOOT_INFO_VERSION ,"Wrong zIPL version" ); +IPL_assert (bip->bp_type ==BOOT_INFO_BP_TYPE_IPL ,"DASD is not for IPL" ); +IPL_assert (bip->dev_type ==BOOT_INFO_DEV_TYPE_ECKD ,"DASD is not ECKD" ); +IPL_assert (bip->flags ==BOOT_INFO_FLAGS_ARCH ,"Not for this arch" ); +IPL_assert (block_size_ok (bip->bp.ipl.bm_ptr.eckd.bptr.size), +"Bad block size in zIPL section of the 1st record." ); +} +static bool eckd_valid_address (BootMapPointer *p) {const uint64_t cylinder = p->eckd.cylinder
@@ -198,19 +209,15 @@ static void run_eckd_boot_script(block_number_t mbr_block_nr)jump_to_IPL_code (bms->entry[i].address.load_address);/* no return */ } -static void ipl_eckd (void ) +static void ipl_eckd_cdl (void ) {XEckdMbr *mbr;Ipl2 *ipl2 = (void *)sec;IplVolumeLabel *vlbl = (void *)sec;block_number_t block_nr; -sclp_print ("Using ECKD scheme.\n" ); -if (virtio_guessed_disk_nature ()) { -sclp_print ("Using guessed DASD geometry.\n" ); -virtio_assume_eckd (); - }/* we have just read the block #0 and recognized it as "IPL1" */ +sclp_print ("CDL\n" );memset (sec,FREE_SPACE_FILLER ,sizeof (sec));read_block (1 , ipl2,"Cannot read IPL2 record at block 1" );
@@ -238,6 +245,57 @@ static void ipl_eckd(void)/* no return */ } +static void ipl_eckd_ldl (ECKD_IPL_mode_t mode) +{ +LDL_VTOC *vlbl = (void *)sec;/* already read, 3rd block */ +char msg[4 ] = {'?' ,'.' ,'\n' ,'\0' }; +block_number_t block_nr; +BootInfo *bip; + +sclp_print ((mode ==ECKD_CMS ) ?"CMS" :"LDL" ); +sclp_print (" version " ); +switch (vlbl->LDL_version) { +case LDL1_VERSION : + msg[0 ] ='1' ; +break ; +case LDL2_VERSION : + msg[0 ] ='2' ; +break ; +default : + msg[0 ] = vlbl->LDL_version; + msg[0 ] &=0x0f ;/* convert EBCDIC */ + msg[0 ] |=0x30 ;/* to ASCII (digit) */ + msg[1 ] ='?' ; +break ; + } +sclp_print (msg); +print_volser (vlbl->volser); + +/* DO NOT read BootMap pointer (only one, xECKD) at block #2 */ + +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (0 , sec,"Cannot read block 0" ); + bip = (void *)(sec +0x70 );/* "boot info" is "eckd mbr" for LDL */ +verify_boot_info (bip); + + block_nr =eckd_block_num ((void *)&(bip->bp.ipl.bm_ptr.eckd.bptr)); +run_eckd_boot_script (block_nr); +/* no return */ +} + +static void ipl_eckd (ECKD_IPL_mode_t mode) +{ +switch (mode) { +case ECKD_CDL : +ipl_eckd_cdl ();/* no return */ +case ECKD_CMS : +case ECKD_LDL : +ipl_eckd_ldl (mode);/* no return */ +default : +virtio_panic ("\n! Unknown ECKD IPL mode !\n" ); + } +} +/*********************************************************************** * IPL a SCSI disk */
@@ -374,6 +432,7 @@ static void ipl_scsi(void)void zipl_load (void ) {ScsiMbr *mbr = (void *)sec; +LDL_VTOC *vlbl = (void *)sec;/* Grab the MBR */ memset (sec,FREE_SPACE_FILLER ,sizeof (sec));
@@ -384,8 +443,27 @@ void zipl_load(void)if (magic_match (mbr->magic,ZIPL_MAGIC )) {ipl_scsi ();/* no return */ } + +/* We have failed to follow the SCSI scheme, so */ +sclp_print ("Using ECKD scheme.\n" ); +if (virtio_guessed_disk_nature ()) { +sclp_print ("Using guessed DASD geometry.\n" ); +virtio_assume_eckd (); + } +if (magic_match (mbr->magic,IPL1_MAGIC )) { -ipl_eckd ();/* CDL ECKD; no return */ +ipl_eckd (ECKD_CDL );/* no return */ + } + +/* LDL/CMS? */ +memset (sec,FREE_SPACE_FILLER ,sizeof (sec)); +read_block (2 , vlbl,"Cannot read block 2" ); + +if (magic_match (vlbl->magic,CMS1_MAGIC )) { +ipl_eckd (ECKD_CMS );/* no return */ + } +if (magic_match (vlbl->magic,LNX1_MAGIC )) { +ipl_eckd (ECKD_LDL );/* no return */ }virtio_panic ("\n* invalid MBR magic *\n" );
pc-bios/s390-ccw/bootmap.h +7 -0
@@ -255,6 +255,13 @@ typedef struct IplVolumeLabel { }; } __attribute__((packed)) IplVolumeLabel; +typedef enum { +ECKD_NO_IPL , +ECKD_CDL , +ECKD_CMS , +ECKD_LDL , +}ECKD_IPL_mode_t ; +/* utility code below */ static inline void IPL_assert (bool term,const char *message)
Signature · 1 line
1.8.5.5
PATCH 10/10 pc-bios/s390-ccw: update binary
In reply to Jens Freimann--- pc-bios/s390-ccw.img | Bin 9432 -> 17624 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
Signature · 1 line
1.8.5.5
Quoted 5 lines · Jens Freimann
Conny, Alex, Christian,
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
From a quick glimpse it looks quite clean and straight forward, but I'd like to make sure we get rid completely of the static sector size assumption.
Also, are we guaranteed that virtio always uses 512 byte block size? Or was that just an internal API thing?
Alex
Christian Borntraeger
Acked-byQuoted 9 lines · Alexander Graf
Quoted 5 lines · Jens Freimann
Conny, Alex, Christian,
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
From a quick glimpse it looks quite clean and straight forward, but I'd like to make sure we get rid completely of the static sector size assumption.
Should be. I guess s/SECTOR_SIZE/MAX_SECTOR_SIZE/g would be ok for you then?
Quoted 2 lines
Also, are we guaranteed that virtio always uses 512 byte block size? Or was that just an internal API thing?
The virtio-blk API always talks in 512 byte sectors, no matter the block size.
Overall this is a nice improvement of the boot code - if possible I would like to see that in 2.1.
Conny, can you carry that in your tree (with s/SECTOR_SIZE/MAX_SECTOR_SIZE/g)?
for the series.
Christian
Quoted 9 lines
Am 27.06.2014 um 09:53 schrieb Christian Borntraeger <[email protected]>:
Quoted 5 lines · Alexander Graf
Quoted 4 lines · Jens Freimann
Conny, Alex, Christian,
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
From a quick glimpse it looks quite clean and straight forward, but I'd like to make sure we get rid completely of the static sector size assumption.
Should be. I guess s/SECTOR_SIZE/MAX_SECTOR_SIZE/g would be ok for you then?
I'm not 100% convinced that we're safe on all users of SECTOR_SIZE. So please make sure to replace the occasions manually and audit every single one.
Alex
Quoted 16 lines
Quoted 2 lines
Also, are we guaranteed that virtio always uses 512 byte block size? Or was that just an internal API thing?
The virtio-blk API always talks in 512 byte sectors, no matter the block size.
Overall this is a nice improvement of the boot code - if possible I would like to see that in 2.1.
Conny, can you carry that in your tree (with s/SECTOR_SIZE/MAX_SECTOR_SIZE/g)?
for the series.
Christian
Quoted 13 lines · Alexander Graf
Quoted 13 lines
Am 27.06.2014 um 09:53 schrieb Christian Borntraeger <[email protected]>:
Quoted 9 lines · Alexander Graf
Quoted 7 lines · Jens Freimann
Conny, Alex, Christian,
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
From a quick glimpse it looks quite clean and straight forward, but I'd like to make sure we get rid completely of the static sector size assumption.
Should be. I guess s/SECTOR_SIZE/MAX_SECTOR_SIZE/g would be ok for you then?
I'm not 100% convinced that we're safe on all users of
SECTOR_SIZE. So please make sure to replace the occasions manually and audit every single one.
Yes, a mindless sed, would also replace VIRTIO_SECTOR_SIZE with VIRTIO_MAX_SECTOR_SIZE. Fortunately there are only 3 place in bootmap.c. Should be simple enough to review.
Quoted 20 lines
Alex
Quoted 16 lines
Quoted 2 lines
Also, are we guaranteed that virtio always uses 512 byte block size? Or was that just an internal API thing?
The virtio-blk API always talks in 512 byte sectors, no matter the block size.
Overall this is a nice improvement of the boot code - if possible I would like to see that in 2.1.
Conny, can you carry that in your tree (with s/SECTOR_SIZE/MAX_SECTOR_SIZE/g)?
for the series.
Christian
Quoted 14 lines · On Fri, 27 Jun 2014 11:27:12 +0200 Christian Borntraeger…
Quoted 13 lines · Alexander Graf
Quoted 13 lines
Am 27.06.2014 um 09:53 schrieb Christian Borntraeger <[email protected]>:
Quoted 9 lines · Alexander Graf
Quoted 7 lines · Jens Freimann
Conny, Alex, Christian,
here are some fixes for the s390-ccw bios. It's a mixture of additional features (DASD IPL support for different formats) and cleanups.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
From a quick glimpse it looks quite clean and straight forward, but I'd like to make sure we get rid completely of the static sector size assumption.
Should be. I guess s/SECTOR_SIZE/MAX_SECTOR_SIZE/g would be ok for you then?
I'm not 100% convinced that we're safe on all users of
SECTOR_SIZE. So please make sure to replace the occasions manually and audit every single one.Yes, a mindless sed, would also replace
VIRTIO_SECTOR_SIZEwithVIRTIO_MAX_SECTOR_SIZE. Fortunately there are only 3 place inbootmap.c. Should be simple enough to review.
Yes, all places that use it want a MAX_SECTOR_SIZE. All places using the actual sector size are now using the helper function.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Also, are we guaranteed that virtio always uses 512 byte block size? Or was that just an internal API thing?
The virtio-blk API always talks in 512 byte sectors, no matter the block size.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Overall this is a nice improvement of the boot code - if possible I would like to see that in 2.1.
Conny, can you carry that in your tree (with s/SECTOR_SIZE/MAX_SECTOR_SIZE/g)?
for the series.
Will push out shortly.
Unless there are objections, I'll send a pull request for this.