diff options
Diffstat (limited to 'usr.sbin/bhyve/acpi.c')
-rw-r--r-- | usr.sbin/bhyve/acpi.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index f9504f8..ed0c545 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -680,29 +680,26 @@ basl_end(struct basl_fio *in, struct basl_fio *out) } static int -basl_load(int fd, uint64_t off) +basl_load(struct vmctx *ctx, int fd, uint64_t off) { - struct stat sb; + struct stat sb; void *gaddr; - int err; - err = 0; - if (fstat(fd, &sb) < 0) { - err = errno; - } else { - gaddr = paddr_guest2host(basl_acpi_base + off, sb.st_size); - if (gaddr != NULL) { - if (read(fd, gaddr, sb.st_size) < 0) - err = errno; - } else - err = EFAULT; - } + if (fstat(fd, &sb) < 0) + return (errno); + + gaddr = paddr_guest2host(ctx, basl_acpi_base + off, sb.st_size); + if (gaddr == NULL) + return (EFAULT); - return (err); + if (read(fd, gaddr, sb.st_size) < 0) + return (errno); + + return (0); } static int -basl_compile(int (*fwrite_section)(FILE *fp), uint64_t offset) +basl_compile(struct vmctx *ctx, int (*fwrite_section)(FILE *), uint64_t offset) { struct basl_fio io[2]; static char iaslbuf[3*MAXPATHLEN + 10]; @@ -736,7 +733,7 @@ basl_compile(int (*fwrite_section)(FILE *fp), uint64_t offset) * Copy the aml output file into guest * memory at the specified location */ - err = basl_load(io[1].fd, offset); + err = basl_load(ctx, io[1].fd, offset); } } basl_end(&io[0], &io[1]); @@ -842,7 +839,7 @@ acpi_build(struct vmctx *ctx, int ncpu, int ioapic) * copying them into guest memory */ while (!err && basl_ftables[i].wsect != NULL) { - err = basl_compile(basl_ftables[i].wsect, + err = basl_compile(ctx, basl_ftables[i].wsect, basl_ftables[i].offset); i++; } |