From 172b98bfeb4f750505efbdec60ed978a176fdaff Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 2 Sep 2022 08:13:03 +0000 Subject: [PATCH] Add softraid(4) RAID 1C boot support Equivalent of sys/arch/arm64/stand/efiboot/softraid_arm64.c r1.4: (commitid: Ka484R3swI5xSRWO) "Add softraid(4) RAID 1C boot support". Tell the boot loader to decrypt 1C like C volumes and check the number of disks in 1C like in 1C volumes -- no new code rquired. Tested on T4-2 guest domains "Looks reasonable" kettenis OK stsp NB: While kernel and boot loader support root on softraid on sparc64, installboot(8) still needs a pending fix for installations on multi-chunk softraid volumes. Until then, the usual installation process will fail on 1C volumes and requires manual fixup. --- sys/arch/sparc64/stand/ofwboot/boot.c | 5 +++-- sys/arch/sparc64/stand/ofwboot/softraid_sparc64.c | 8 +++++--- sys/arch/sparc64/stand/ofwboot/vers.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/arch/sparc64/stand/ofwboot/boot.c b/sys/arch/sparc64/stand/ofwboot/boot.c index 24036d9d4d3..0580f3e25f7 100644 --- a/sys/arch/sparc64/stand/ofwboot/boot.c +++ b/sys/arch/sparc64/stand/ofwboot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.39 2022/08/04 09:16:53 kn Exp $ */ +/* $OpenBSD: boot.c,v 1.40 2022/09/02 08:13:03 kn Exp $ */ /* $NetBSD: boot.c,v 1.3 2001/05/31 08:55:19 mrg Exp $ */ /* * Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved. @@ -366,7 +366,8 @@ srbootdev(const char *bootline) return ENODEV; } - if (bv->sbv_level == 'C' && bv->sbv_keys == NULL) + if ((bv->sbv_level == 'C' || bv->sbv_level == 0x1C) && + bv->sbv_keys == NULL) if (sr_crypto_unlock_volume(bv) != 0) return EPERM; diff --git a/sys/arch/sparc64/stand/ofwboot/softraid_sparc64.c b/sys/arch/sparc64/stand/ofwboot/softraid_sparc64.c index 3c279d5df92..6d90419387b 100644 --- a/sys/arch/sparc64/stand/ofwboot/softraid_sparc64.c +++ b/sys/arch/sparc64/stand/ofwboot/softraid_sparc64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_sparc64.c,v 1.5 2020/12/09 18:10:19 krw Exp $ */ +/* $OpenBSD: softraid_sparc64.c,v 1.6 2022/09/02 08:13:03 kn Exp $ */ /* * Copyright (c) 2012 Joel Sing @@ -290,6 +290,7 @@ srprobe(void) break; case 1: + case 0x1C: if (bv->sbv_chunk_no == bv->sbv_chunks_found) bv->sbv_state = BIOC_SVONLINE; else if (bv->sbv_chunks_found > 0) @@ -312,7 +313,8 @@ sr_vol_boot_chunk(struct sr_boot_volume *bv) { struct sr_boot_chunk *bc = NULL; - if (bv->sbv_level == 1 || bv->sbv_level == 'C' ) { /* RAID1 or CRYPTO */ + if (bv->sbv_level == 1 || bv->sbv_level == 'C' || + bv->sbv_level == 0x1C) { /* Select first online chunk. */ SLIST_FOREACH(bc, &bv->sbv_chunks, sbc_link) if (bc->sbc_state == BIOC_SDONLINE) @@ -368,7 +370,7 @@ sr_strategy(struct sr_boot_volume *bv, int sr_handle, int rw, daddr_t blk, err = strategy(&ofdev, rw, blk, size, buf, rsize); return err; - } else if (bv->sbv_level == 'C') { + } else if (bv->sbv_level == 'C' || bv->sbv_level == 0x1C) { /* XXX - select correct key. */ aes_xts_setkey(&ctx, (u_char *)bv->sbv_keys, 64); diff --git a/sys/arch/sparc64/stand/ofwboot/vers.c b/sys/arch/sparc64/stand/ofwboot/vers.c index c431a3be21d..7494fde8a78 100644 --- a/sys/arch/sparc64/stand/ofwboot/vers.c +++ b/sys/arch/sparc64/stand/ofwboot/vers.c @@ -1 +1 @@ -const char version[] = "1.23"; +const char version[] = "1.24"; -- 2.20.1