G.2 (v2.0.0): unified rng_get_bytes() entropy entry point; virtio-rng sole backend

The QEMU-verifiable slice of the real-hardware RNG driver (per FABRIC-3.md
§G.2). New include/starkernel/rng.h + src/starkernel/rng/rng.c provide the
single entropy entry point: rng_init() probes the backend set (v2.0.0:
virtio-rng only) and, on no backend, prints a loud boot-time warning while
rng_get_bytes() returns RNG_ERR_NO_BACKEND - never silently degrading to a
deterministic seed. The backend-selection switch in rng.c is the exact seam
v2.5.0's per-arch drivers (amd64 RDRAND, riscv64 Zkr, aarch64 peripheral) plug
into without touching the call path.

Consumers route through the unified layer instead of virtio-rng directly:
capsule_mint.c (identity seed + drive_uuid) and kernel_main.c phase 8
(rng_init()). virtio_rng.c stays as the sole backend. Built clean on
amd64/aarch64/riscv64. QEMU amd64 boot: POST 1012/0/0 + ok>, "rng: backend =
virtio-rng" + "entropy: ready", Zuse identity confirmed from thumbdrive -
mint/cert behavior unchanged.

FABRIC-3.md §G.2 v2.0.0 slice marked BUILT+VERIFIED.
This commit is contained in:
Robert Allan James
2026-08-29 09:57:17 -04:00
parent aee1ecaa8f
commit 09857b7228
8 changed files with 157 additions and 17 deletions
+12 -12
View File
@@ -65,7 +65,7 @@ EFI_RUNTIME_SERVICES *g_sk_runtime_services = NULL;
#include "starkernel/repl.h"
#include "starkernel/pci.h"
#include "starkernel/virtio_blk.h"
#include "starkernel/virtio_rng.h"
#include "starkernel/rng.h"
#include "starkernel/virtio_input.h"
#include "starkernel/xhci_driver.h"
#include "block_subsystem.h"
@@ -590,20 +590,20 @@ static void kernel_main_deep(BootInfo *boot_info) {
}
}
/* Phase 8: virtio-rng entropy source. Real per-arch RNG doesn't cover
* all three architectures (amd64 RDRAND, riscv64 Zkr, but aarch64 has
* neither in QEMU's CPU models -- see vm_uuid.h's identical finding),
* so signing/keygen entropy comes from this paravirtualized device
* instead. Unconditional call site, same graceful-noop precedent as
* virtio_blk_find_artemis() above -- boot proceeds either way, the
* device is only required once something actually calls
* virtio_rng_get_bytes(). */
/* Phase 8: entropy. Real per-arch RNG doesn't cover all three
* architectures (amd64 RDRAND, riscv64 Zkr, but aarch64 has neither in
* QEMU's CPU models -- see vm_uuid.h's identical finding), so signing/
* keygen entropy comes from the unified rng_get_bytes() layer, whose
* v2.0.0 backend is the paravirtualized virtio-rng device. Unconditional
* call site, same graceful-noop precedent as virtio_blk_find_artemis()
* above -- boot proceeds either way, the device is only required once
* something actually calls rng_get_bytes(). */
{
int rrc = virtio_rng_init();
int rrc = rng_init();
if (rrc == 0) {
console_println("virtio-rng: ready");
console_println("entropy: ready");
} else {
console_println("virtio-rng: not available (continuing without)");
console_println("entropy: not available (continuing without)");
}
}