On Thu, Aug 04, 2022 at 07:26:23PM +0200, Stefan Sperling wrote:
> This adds support for booting from RAID 1C volumes on amd64.
This is so cool and I can't wait to get a chance to try it out!
> Only boot-loader changes are needed. Both installboot(8) and
> the kernel already do what is required to make this work.
>
> I have tested with biosboot in vmm. The changes involved are trivial,
> and I am modifying copies of the same code across all bootloaders.
> So I would assume that all boot methods work with this patch.
> Additional testing to verify this would be welcome, of course.
>
> In my testing, a fresh install onto a RAID 1C volume succeeds and
> the resulting system can be booted as usual. I have tried this on
> a volume locked with a keydisk, and a volume locked with a passphrase.
>
> I have also tested booting with one of two disks missing and as
> expected the system came up with a degraded volume:
OpenBSD's RAID 1 implementation supports more than two disks. Would
there be a need to test such a setup as well?
Regards,
Erling
> softraid0: not all chunks were provided; attempting to bring volume 0 online
> softraid0: trying to bring up sd3 degraded
> sd2 at scsibus4 targ 1 lun 0: <OPENBSD, SR RAID 1C, 006>
> sd2: 8191MB, 512 bytes/sector, 16776624 sectors
> softraid0: volume sd2 is roaming, it used to be sd3, updating metadata
> softraid0: roaming device sd1a -> sd0a
> root on sd2a (3ee0bf348da5ea75.a) swap on sd2b dump on sd2b
>
> The volume could successfully be rebuilt with bioctl -R, once the
> missing disk was added back in.
>
> ok?
>
> diff 43cbe5bff6629c463463325cebb7e87b291b4a73
> 20d3307dd4ffcb7fd9baece3386a59b24bbcc8e0
> commit - 43cbe5bff6629c463463325cebb7e87b291b4a73
> commit + 20d3307dd4ffcb7fd9baece3386a59b24bbcc8e0
> blob - c00d17a6628822b649ad4391a3af7c69801631f0
> blob + e320f3d143c2d2023f83743be4ef31e82eabe2af
> --- share/man/man4/softraid.4
> +++ share/man/man4/softraid.4
> @@ -118,7 +118,8 @@ may be used to install
> in the boot storage area of the
> .Nm
> volume.
> -Boot support is currently limited to the CRYPTO and RAID 1 disciplines
> +Boot support is currently limited to the RAID 1C discipline on the
> +amd64 platform, and the CRYPTO and RAID 1 disciplines
> on amd64, arm64, i386, and sparc64 platforms.
> On sparc64, bootable chunks must be RAID partitions using the letter
> .Sq a .
> blob - 543d9b404ed39512ed693e96d60958d8d467c3e8
> blob + bda7e562558bc1cfad1800dac3f93e03439b48f7
> --- sys/arch/amd64/stand/boot/conf.c
> +++ sys/arch/amd64/stand/boot/conf.c
> @@ -41,7 +41,7 @@
> #include <biosdev.h>
> #include <dev/cons.h>
>
> -const char version[] = "3.54";
> +const char version[] = "3.55";
> int debug = 1;
>
>
> blob - 5b4e78c86c4ea1a1d3491ca2a8f973588a38e7ba
> blob + a53be08f763dd8a2069f5646bf266d747f3346a7
> --- sys/arch/amd64/stand/cdboot/conf.c
> +++ sys/arch/amd64/stand/cdboot/conf.c
> @@ -42,7 +42,7 @@
> #include <biosdev.h>
> #include <dev/cons.h>
>
> -const char version[] = "3.54";
> +const char version[] = "3.55";
> int debug = 1;
>
>
> blob - dcf19e147de5c7c2e8b2e75fc0c47bf97421dd97
> blob + ca83d39d7e22d24f86fc328e1a8703c4de8ce056
> --- sys/arch/amd64/stand/efi32/conf.c
> +++ sys/arch/amd64/stand/efi32/conf.c
> @@ -40,7 +40,7 @@
> #include "efidev.h"
> #include "efipxe.h"
>
> -const char version[] = "3.53";
> +const char version[] = "3.54";
>
> #ifdef EFI_DEBUG
> int debug = 0;
> blob - e55f63529858ee9b98014f1cb1e0105db8e5d7a9
> blob + 33b15ed229b1895c04047026193f36deb649866a
> --- sys/arch/amd64/stand/efi32/efidev.c
> +++ sys/arch/amd64/stand/efi32/efidev.c
> @@ -599,9 +599,11 @@ efiopen(struct open_file *f, ...)
> return EADAPT;
> }
>
> - 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;
> + }
>
> if (bv->sbv_diskinfo == NULL) {
> dip = alloc(sizeof(struct diskinfo));
> blob - 4eac75be43a98df370691f543dd172b8885dc0a4
> blob + 8ef9e04e890c237994cdcacc98b8d78de43d4e37
> --- sys/arch/amd64/stand/efi64/conf.c
> +++ sys/arch/amd64/stand/efi64/conf.c
> @@ -40,7 +40,7 @@
> #include "efidev.h"
> #include "efipxe.h"
>
> -const char version[] = "3.53";
> +const char version[] = "3.54";
>
> #ifdef EFI_DEBUG
> int debug = 0;
> blob - e55f63529858ee9b98014f1cb1e0105db8e5d7a9
> blob + 33b15ed229b1895c04047026193f36deb649866a
> --- sys/arch/amd64/stand/efi64/efidev.c
> +++ sys/arch/amd64/stand/efi64/efidev.c
> @@ -599,9 +599,11 @@ efiopen(struct open_file *f, ...)
> return EADAPT;
> }
>
> - 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;
> + }
>
> if (bv->sbv_diskinfo == NULL) {
> dip = alloc(sizeof(struct diskinfo));
> blob - 2096ee66f3d2908bf2b462211f8ba7aa5b6a83a0
> blob + b202cb05372802682f84d370c1e33dee21259938
> --- sys/arch/amd64/stand/efiboot/conf.c
> +++ sys/arch/amd64/stand/efiboot/conf.c
> @@ -40,7 +40,7 @@
> #include "efidev.h"
> #include "efipxe.h"
>
> -const char version[] = "3.61";
> +const char version[] = "3.62";
>
> #ifdef EFI_DEBUG
> int debug = 0;
> blob - 8fd81511be2a9308df7f65431007e1512f93530d
> blob + e35011973c13556a08b207e33bd95d617f50f57d
> --- sys/arch/amd64/stand/efiboot/efidev.c
> +++ sys/arch/amd64/stand/efiboot/efidev.c
> @@ -580,9 +580,11 @@ efiopen(struct open_file *f, ...)
> return EADAPT;
> }
>
> - 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;
> + }
>
> if (bv->sbv_diskinfo == NULL) {
> dip = alloc(sizeof(struct diskinfo));
> blob - b64714b20e05d1179b579707ab21693856c51320
> blob + d7420753924189713400ac47eb679694cdda5cd5
> --- sys/arch/amd64/stand/libsa/biosdev.c
> +++ sys/arch/amd64/stand/libsa/biosdev.c
> @@ -543,9 +543,11 @@ biosopen(struct open_file *f, ...)
> return EADAPT;
> }
>
> - 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;
> + }
>
> if (bv->sbv_diskinfo == NULL) {
> dip = alloc(sizeof(struct diskinfo));
> blob - 4c6099d83de61ff101f7dea8aadce815f2b4bba7
> blob + 294d307ea2da3d908e5cab75c63114a82e8ad346
> --- sys/arch/amd64/stand/libsa/softraid_amd64.c
> +++ sys/arch/amd64/stand/libsa/softraid_amd64.c
> @@ -291,6 +291,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)
> @@ -348,7 +349,7 @@ sr_strategy(struct sr_boot_volume *bv, int rw, daddr_t
> /* XXX - If I/O failed we should try another chunk... */
> return dip->strategy(dip, rw, blk, size, buf, rsize);
>
> - } else if (bv->sbv_level == 'C') {
> + } else if (bv->sbv_level == 'C' || bv->sbv_level == 0x1C) {
>
> /* Select first online chunk. */
> SLIST_FOREACH(bc, &bv->sbv_chunks, sbc_link)
> blob - f80304065d7843fb3d7ab61e904357c2d40a071b
> blob + 09212e51497c9e6ffacd755d9a2f1a6f37057532
> --- sys/arch/amd64/stand/pxeboot/conf.c
> +++ sys/arch/amd64/stand/pxeboot/conf.c
> @@ -44,7 +44,7 @@
> #include "pxeboot.h"
> #include "pxe_net.h"
>
> -const char version[] = "3.54";
> +const char version[] = "3.55";
> int debug = 0;
>
> void (*sa_cleanup)(void) = pxe_shutdown;
> blob - 41e964f879e42a663f46889219c3253cb2fbbfbb
> blob + b283b2a96dcd96f74eee4a9f36532f4e6e6684e6
> --- sys/lib/libsa/softraid.c
> +++ sys/lib/libsa/softraid.c
> @@ -66,7 +66,7 @@ sr_clear_keys(void)
> struct sr_boot_keydisk *kd;
>
> SLIST_FOREACH(bv, &sr_volumes, sbv_link) {
> - if (bv->sbv_level != 'C')
> + if (bv->sbv_level != 'C' && bv->sbv_level != 0x1C)
> continue;
> if (bv->sbv_keys != NULL) {
> explicit_bzero(bv->sbv_keys, SR_CRYPTO_KEYBLOCK_BYTES);
>
>