Skip to content

h2: capture boot registers and forward a DTB address to the Linux guest - #72

Open
Brian Cain (androm3da) wants to merge 1 commit into
qualcomm:masterfrom
androm3da:bcain/qemu_boot-2
Open

h2: capture boot registers and forward a DTB address to the Linux guest#72
Brian Cain (androm3da) wants to merge 1 commit into
qualcomm:masterfrom
androm3da:bcain/qemu_boot-2

Conversation

@androm3da

Copy link
Copy Markdown
Member

Platform boot firmware may hand the kernel boot parameters in r1:0 at reset; a bootloader passes the generated device tree blob's physical address there. Those registers were clobbered during early init, so guests could never see them and fell back to built-in device trees.

Reserve a boot parameter block at a fixed offset in the entry page -- alongside the angel mailbox area, and patchable by external tooling -- and capture r1:0 into it on the boot thread before anything clobbers them. Expose the captured values through two new info-trap operations, INFO_BOOT_R00 and INFO_BOOT_R01, appended to the enum to preserve the existing ABI.

loadlinux reads them, validates the address (alignment plus FDT magic), and passes it as the vmboot argument, which lands in the guest's r1:0 per the existing thread-create convention. The Linux kernel's RISC-V style boot protocol picks the DTB address up from there and adopts the generated device tree.

}
r10 = add(PC,##h2_boot_params@PCREL)
memd(r10+#0) = r1:0
dccleana(r10) // reach memory before the cache kill below

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caches should be off at this point. Guess this can't hurt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but check failing tests.

Comment thread kernel/init/boot/boot.ref.S Outdated
* boot stub.
*/
.p2align 3
.globl h2_boot_params

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to H2K_boot_params.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

@androm3da
Brian Cain (androm3da) force-pushed the bcain/qemu_boot-2 branch 2 times, most recently from b42c7ac to 70bb60e Compare August 6, 2026 15:45
Platform boot firmware may hand the kernel boot parameters in r1:0 at
reset; a bootloader passes the generated device tree blob's physical
address there.  Those registers were clobbered during early init, so
guests could never see them and fell back to built-in device trees.

Reserve a boot parameter block at a fixed offset in the entry page --
alongside the angel mailbox area, and patchable by external tooling --
and capture r1:0 into it on the boot thread before anything clobbers
them.  Publish the captured words into kernel globals as boot_r0/boot_r1
once H2K_kg_init() has zeroed them, and expose those through two new
info-trap operations, INFO_BOOT_R00 and INFO_BOOT_R01, appended to the
enum to preserve the existing ABI.

Routing through globals rather than having info.ref.c read H2K_boot_params
directly keeps boot.ref.o out of the link.  Referencing it there would add
an archive edge that drags in globals.ref.o, create.ref.o, fatal.ref.o and
vmint, which collide with the local stubs in STANDALONE tests such as
kernel/vm/vmfuncs/test.

loadlinux reads them, validates the address (alignment plus FDT magic),
and passes it as the vmboot argument, which lands in the guest's r1:0
per the existing thread-create convention.  The Linux kernel's RISC-V
style boot protocol picks the DTB address up from there and adopts the
generated device tree.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
@androm3da

Copy link
Copy Markdown
Member Author

Ok, but check failing tests.

yeah, sorry about that - fixed now.

@bryanb-h2

Copy link
Copy Markdown
Contributor

Please move this PR to the internal repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untested Mark untested PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants