drivers/firmware/efi/libstub/zboot.c

Source file repositories/reference/linux-study-clean/drivers/firmware/efi/libstub/zboot.c

File Facts

System
Linux kernel
Corpus path
drivers/firmware/efi/libstub/zboot.c
Extension
.c
Size
2824 bytes
Lines
101
Domain
Driver Families
Bucket
drivers/firmware
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
			// Setting the random seed to 0x0 is the same as
			// allocating as low as possible
			seed = 0;
		} else if (efi_nokaslr) {
			efi_info("KASLR disabled on kernel command line\n");
		} else {
			status = efi_get_random_bytes(sizeof(seed), (u8 *)&seed);
			if (status == EFI_NOT_FOUND) {
				efi_info("EFI_RNG_PROTOCOL unavailable\n");
				efi_nokaslr = true;
			} else if (status != EFI_SUCCESS) {
				efi_err("efi_get_random_bytes() failed (0x%lx)\n",
					status);
				efi_nokaslr = true;
			}
		}

		status = efi_random_alloc(alloc_size, min_kimg_align, &image_base,
					  seed, EFI_LOADER_CODE, 0, EFI_ALLOC_LIMIT);
		if (status != EFI_SUCCESS) {
			efi_err("Failed to allocate memory\n");
			return status;
		}
	}

	// Decompress the payload into the newly allocated buffer
	status = efi_zboot_decompress((void *)image_base, alloc_size) ?:
	         efi_stub_common(handle, image, image_base, cmdline_ptr);

	efi_free(alloc_size, image_base);
	return status;
}

Annotation

Implementation Notes