Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177863670
D61102.1795457609.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D61102.1795457609.diff
View Options
diff --git a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
--- a/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
+++ b/usr.sbin/bhyve/aarch64/bhyverun_machdep.c
@@ -27,6 +27,7 @@
*/
#include <sys/param.h>
+#include <sys/endian.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -73,10 +74,32 @@
nitems(config_options_machdep));
}
-/* Start of mem + 1M */
+/* Start of mem + 1M, or after a larger boot image */
#define FDT_BASE 0x100000
#define FDT_SIZE (64 * 1024)
+/*
+ * The header of a Linux arm64 Image, as booted by U-Boot's booti. The
+ * FreeBSD kernel.bin has one too. image_size is the size of the image in
+ * memory, including its bss.
+ */
+struct booti_header {
+ uint32_t code0;
+ uint32_t code1;
+ uint64_t text_offset;
+ uint64_t image_size;
+ uint64_t flags;
+ uint64_t res2;
+ uint64_t res3;
+ uint64_t res4;
+ uint32_t magic;
+ uint32_t res5;
+};
+#define BOOTI_MAGIC 0x644d5241 /* "ARM\x64" */
+
+/* The offset of the FDT from the start of high memory. */
+static vm_size_t fdt_offset = FDT_BASE;
+
/* Start of lowmem + 64K */
#define UART_MMIO_BASE 0x10000
#define UART_MMIO_SIZE 0x1000
@@ -246,6 +269,7 @@
void *data, *gptr;
vm_paddr_t loadaddr;
off_t size;
+ uint64_t memsize;
int fd;
fd = open(path, O_RDONLY);
@@ -265,6 +289,24 @@
(void)close(fd);
memcpy(gptr, data, size);
+ /*
+ * A kernel booted directly, such as a FreeBSD kernel.bin, is larger
+ * than the 1MB below the FDT. Put the FDT after the kernel and its
+ * bss instead.
+ */
+ memsize = size;
+ if ((size_t)size >= sizeof(struct booti_header)) {
+ const struct booti_header *hdr = data;
+
+ if (le32toh(hdr->magic) == BOOTI_MAGIC &&
+ le64toh(hdr->image_size) > memsize)
+ memsize = le64toh(hdr->image_size);
+ }
+ if (memsize > FDT_BASE)
+ fdt_offset = roundup2(memsize, 2 * 1024 * 1024);
+ if (fdt_offset + FDT_SIZE > vm_get_highmem_size(ctx))
+ errx(1, "%s does not fit in guest memory", path);
+
if (munmap(data, size) != 0)
err(1, "munmap(%s)", path);
@@ -394,7 +436,7 @@
static vm_paddr_t
fdt_gpa(struct vmctx *ctx)
{
- return (vm_get_highmem_base(ctx) + FDT_BASE);
+ return (vm_get_highmem_base(ctx) + fdt_offset);
}
int
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 24, 2026
+.Dd October 30, 2026
.Dt BHYVE 8
.Os
.Sh NAME
@@ -118,6 +118,14 @@
on arm64 the
.Pa u-boot-bhyve-arm64
package provides a U-Boot image that can be used to boot the guest.
+On arm64, the boot ROM can also be a kernel in the Linux arm64 Image format,
+such as the
+.Pa kernel.bin
+of a
+.Fx
+kernel build.
+That kernel boots without U-Boot or a loader.
+The kernel must have the drivers it needs compiled in.
.Pp
.Nm
runs until the guest operating system reboots (if
@@ -1301,6 +1309,16 @@
-o bootrom=/usr/local/share/u-boot/u-boot-bhyve-arm64/u-boot.bin -m 1G vm1
.Ed
.Pp
+To boot a
+.Fx
+kernel directly on arm64, with its root file system on the
+same image:
+.Bd -literal -offset indent
+bhyve -c 2 -s 0,hostbridge -s 1,virtio-blk,/my/image -s 2,virtio-rnd \\
+ -o console=stdio -o bootrom=/boot/kernel.bin \\
+ -o fdt.bootargs="FreeBSD:vfs.root.mountfrom=ufs:/dev/vtbd0p2" -m 1G vm1
+.Ed
+.Pp
Run a 24 GiB single-CPU virtual machine with three network ports, one of which
has a MAC address specified:
.Bd -literal -offset indent
diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5
--- a/usr.sbin/bhyve/bhyve_config.5
+++ b/usr.sbin/bhyve/bhyve_config.5
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 17, 2026
+.Dd October 30, 2026
.Dt BHYVE_CONFIG 5
.Os
.Sh NAME
@@ -317,6 +317,19 @@
The
.Ql tcp=ip:port
backend listens for TCP connections.
+.It Va fdt.bootargs Ta string Ta Ta
+Kernel command line, passed to the guest in the
+.Va bootargs
+property of the device tree's
+.Pa /chosen
+node.
+A
+.Fx
+kernel booted without a loader reads it when it starts with
+.Dq FreeBSD: .
+The kernel sets each
+.Ar name Ns = Ns Ar value
+word in it as a kernel environment variable.
.El
.Sh DEVICE SETTINGS
Device settings are stored under a device node.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 6:13 PM (9 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41937436
Default Alt Text
D61102.1795457609.diff (4 KB)
Attached To
Mode
D61102: bhyve: Allow an arm64 kernel as the boot ROM
Attached
Detach File
Event Timeline