git: c43659fb1294 - stable/13 - bhyve: use basl to load ACPI tables
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Nov 2022 10:08:20 UTC
The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=c43659fb1294f5940fb3cd67c0dd0f5f961d360f commit c43659fb1294f5940fb3cd67c0dd0f5f961d360f Author: Corvin Köhne <corvink@FreeBSD.org> AuthorDate: 2022-11-04 11:30:37 +0000 Commit: Corvin Köhne <corvink@FreeBSD.org> CommitDate: 2022-11-30 07:03:47 +0000 bhyve: use basl to load ACPI tables Load the blobs compiled by iasl into a basl_table. The basl_table is a temporary buffer which copies the ACPI tables into guest memory for us. This allows us in the future to pass the blobs over the qemu fwcfg interface to the guest. Reviewed by: jhb, markj Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36986 (cherry picked from commit 22a2e94f3805195bf8195c81f7fda4157ebae372) --- usr.sbin/bhyve/acpi.c | 54 +++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index e22bfa0d4ef9..ac157505b7ba 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include <sys/errno.h> #include <sys/stat.h> +#include <err.h> #include <paths.h> #include <stdarg.h> #include <stdio.h> @@ -838,18 +839,26 @@ static int basl_load(struct vmctx *ctx, int fd, uint64_t off) { struct stat sb; - void *gaddr; + void *addr; if (fstat(fd, &sb) < 0) return (errno); - - gaddr = paddr_guest2host(ctx, basl_acpi_base + off, sb.st_size); - if (gaddr == NULL) + + addr = calloc(1, sb.st_size); + if (addr == NULL) return (EFAULT); - if (read(fd, gaddr, sb.st_size) < 0) + if (read(fd, addr, sb.st_size) < 0) return (errno); + struct basl_table *table; + + uint8_t name[ACPI_NAMESEG_SIZE + 1] = { 0 }; + memcpy(name, addr, sizeof(name) - 1 /* last char is '\0' */); + BASL_EXEC( + basl_table_create(&table, ctx, name, BASL_TABLE_ALIGNMENT, off)); + BASL_EXEC(basl_table_append_bytes(table, addr, sb.st_size)); + return (0); } @@ -968,30 +977,25 @@ acpi_build(struct vmctx *ctx, int ncpu) if (getenv("BHYVE_ACPI_KEEPTMPS")) basl_keep_temps = 1; - err = basl_make_templates(); + BASL_EXEC(basl_init()); + + BASL_EXEC(basl_make_templates()); /* * Run through all the ASL files, compiling them and * copying them into guest memory */ - if (err == 0) - err = basl_compile(ctx, basl_fwrite_rsdp, 0); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_facs, FACS_OFFSET); - if (err == 0) - err = basl_compile(ctx, basl_fwrite_dsdt, DSDT_OFFSET); + BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdp, 0)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_rsdt, RSDT_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_xsdt, XSDT_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_madt, MADT_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_fadt, FADT_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_hpet, HPET_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_mcfg, MCFG_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_facs, FACS_OFFSET)); + BASL_EXEC(basl_compile(ctx, basl_fwrite_dsdt, DSDT_OFFSET)); + + BASL_EXEC(basl_finish()); - return (err); + return (0); }