On Wed, Jan 04, 2017 at 07:16:54PM +0100, Stefan Sperling wrote:
> So the problem seems to be that boot uses too much stack memory.
> 
> The diff below fixes the problem for me. As far as I can tell this
> should work on both 512 and 4k disks. But I cannot test with a 4k disk.

Alternatively, this diff also works for me and avoids alloc() / free().
I prefer the alloc() / free() version, though.

Index: softraid_amd64.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/softraid_amd64.c,v
retrieving revision 1.3
diff -u -p -r1.3 softraid_amd64.c
--- softraid_amd64.c    24 Dec 2016 22:49:38 -0000      1.3
+++ softraid_amd64.c    4 Jan 2017 18:17:43 -0000
@@ -33,7 +33,8 @@
 #include "softraid_amd64.h"
 
 static int gpt_chk_mbr(struct dos_partition *, u_int64_t);
-static uint64_t findopenbsd_gpt(struct sr_boot_volume *, const char **);
+static uint64_t findopenbsd_gpt(struct sr_boot_volume *, u_char *,
+    const char **);
 
 void
 srprobe_meta_opt_load(struct sr_metadata *sm, struct sr_meta_opt_head *som)
@@ -424,7 +425,7 @@ gpt_chk_mbr(struct dos_partition *dp, u_
 }
 
 static uint64_t
-findopenbsd_gpt(struct sr_boot_volume *bv, const char **err)
+findopenbsd_gpt(struct sr_boot_volume *bv, u_char * buf, const char **err)
 {
        struct                   gpt_header gh;
        int                      i, part, found;
@@ -435,7 +436,6 @@ findopenbsd_gpt(struct sr_boot_volume *b
        const char               openbsd_uuid_code[] = GPT_UUID_OPENBSD;
        struct gpt_partition     gp;
        static struct uuid      *openbsd_uuid = NULL, openbsd_uuid_space;
-       static u_char            buf[4096];
 
        /* Prepare OpenBSD UUID */
        if (openbsd_uuid == NULL) {
@@ -531,7 +531,7 @@ sr_getdisklabel(struct sr_boot_volume *b
        struct dos_mbr mbr;
        const char *err = NULL;
        u_int start = 0;
-       char buf[DEV_BSIZE];
+       char buf[4096];
        int i;
 
        /* Check for MBR to determine partition offset. */
@@ -539,7 +539,7 @@ sr_getdisklabel(struct sr_boot_volume *b
        sr_strategy(bv, F_READ, DOSBBSECTOR, sizeof(mbr), &mbr, NULL);
        if (gpt_chk_mbr(mbr.dmbr_parts, bv->sbv_size /
                    (bv->sbv_secsize / DEV_BSIZE)) == 0) {
-               start = findopenbsd_gpt(bv, &err);
+               start = findopenbsd_gpt(bv, buf, &err);
                if (start == (u_int)-1) {
                        if (err != NULL)
                                return (err);

Reply via email to