From 855f8c0393a31efa1a61652932a7d72cbafe4cfa Mon Sep 17 00:00:00 2001 From: stsp Date: Fri, 12 Aug 2022 20:17:46 +0000 Subject: [PATCH] add support for booting from RAID 1C softraid(4) volumes on amd64 Only boot-loader changes are needed. Both installboot(8) and the kernel already do what is required to make this work. ok kn@ Tested: biosboot on vmm: kn, stsp biosboot and efiboot on server hardware: stsp --- share/man/man4/softraid.4 | 7 ++++--- sys/arch/amd64/stand/efi32/efidev.c | 6 ++++-- sys/arch/amd64/stand/efi64/efidev.c | 6 ++++-- sys/arch/amd64/stand/efiboot/efidev.c | 6 ++++-- sys/arch/amd64/stand/libsa/biosdev.c | 6 ++++-- sys/arch/amd64/stand/libsa/softraid_amd64.c | 5 +++-- sys/lib/libsa/softraid.c | 4 ++-- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/share/man/man4/softraid.4 b/share/man/man4/softraid.4 index c00d17a6628..e43219de1f6 100644 --- a/share/man/man4/softraid.4 +++ b/share/man/man4/softraid.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: softraid.4,v 1.46 2021/12/16 17:07:56 tj Exp $ +.\" $OpenBSD: softraid.4,v 1.47 2022/08/12 20:17:46 stsp Exp $ .\" .\" Copyright (c) 2007 Todd T. Fries .\" Copyright (c) 2007 Marco Peereboom @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 16 2021 $ +.Dd $Mdocdate: August 12 2022 $ .Dt SOFTRAID 4 .Os .Sh NAME @@ -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 . diff --git a/sys/arch/amd64/stand/efi32/efidev.c b/sys/arch/amd64/stand/efi32/efidev.c index e55f6352985..a841a08fcc1 100644 --- a/sys/arch/amd64/stand/efi32/efidev.c +++ b/sys/arch/amd64/stand/efi32/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.2 2020/12/09 18:10:18 krw Exp $ */ +/* $OpenBSD: efidev.c,v 1.3 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -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)); diff --git a/sys/arch/amd64/stand/efi64/efidev.c b/sys/arch/amd64/stand/efi64/efidev.c index e55f6352985..a841a08fcc1 100644 --- a/sys/arch/amd64/stand/efi64/efidev.c +++ b/sys/arch/amd64/stand/efi64/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.2 2020/12/09 18:10:18 krw Exp $ */ +/* $OpenBSD: efidev.c,v 1.3 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -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)); diff --git a/sys/arch/amd64/stand/efiboot/efidev.c b/sys/arch/amd64/stand/efiboot/efidev.c index 8fd81511be2..07c3a515a51 100644 --- a/sys/arch/amd64/stand/efiboot/efidev.c +++ b/sys/arch/amd64/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.38 2021/06/10 18:05:20 krw Exp $ */ +/* $OpenBSD: efidev.c,v 1.39 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -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)); diff --git a/sys/arch/amd64/stand/libsa/biosdev.c b/sys/arch/amd64/stand/libsa/biosdev.c index b64714b20e0..4e56de62c43 100644 --- a/sys/arch/amd64/stand/libsa/biosdev.c +++ b/sys/arch/amd64/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.34 2020/12/09 18:10:18 krw Exp $ */ +/* $OpenBSD: biosdev.c,v 1.35 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -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)); diff --git a/sys/arch/amd64/stand/libsa/softraid_amd64.c b/sys/arch/amd64/stand/libsa/softraid_amd64.c index 4c6099d83de..c4802372fda 100644 --- a/sys/arch/amd64/stand/libsa/softraid_amd64.c +++ b/sys/arch/amd64/stand/libsa/softraid_amd64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_amd64.c,v 1.7 2021/06/02 22:44:26 krw Exp $ */ +/* $OpenBSD: softraid_amd64.c,v 1.8 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 2012 Joel Sing @@ -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 blk, size_t size, /* 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) diff --git a/sys/lib/libsa/softraid.c b/sys/lib/libsa/softraid.c index 41e964f879e..76f1fece3bd 100644 --- a/sys/lib/libsa/softraid.c +++ b/sys/lib/libsa/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.4 2018/08/10 16:41:35 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.5 2022/08/12 20:17:46 stsp Exp $ */ /* * Copyright (c) 2012 Joel Sing @@ -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); -- 2.20.1