diff --git a/devicemodel/hw/pci/passthrough.c b/devicemodel/hw/pci/passthrough.c index 5507f32ec..4d3243283 100644 --- a/devicemodel/hw/pci/passthrough.c +++ b/devicemodel/hw/pci/passthrough.c @@ -69,6 +69,8 @@ */ #define AUDIO_NHLT_HACK 1 +extern uint64_t audio_nhlt_len; + /* TODO: Add support for IO BAR of PTDev */ static int iofd = -1; @@ -1555,9 +1557,10 @@ write_dsdt_hdas(struct pci_vdev *dev) " MaxNotFixed, NonCacheable, ReadOnly,"); dsdt_line(" 0x0000000000000000, // Granularity"); dsdt_line(" 0x00000000000F2800, // Range Minimum"); - dsdt_line(" 0x00000000000F2FDE, // Range Maximum"); + dsdt_line(" 0x%08X, // Range Maximum", + 0xF2800 + audio_nhlt_len -1); dsdt_line(" 0x0000000000000000, // Translation Offset"); - dsdt_line(" 0x00000000000007DF, // Length"); + dsdt_line(" 0x%08X, // Length", audio_nhlt_len); dsdt_line(" ,, _Y06, AddressRangeACPI, TypeStatic)"); dsdt_line(" })"); dsdt_line(" Name (_S0W, 0x03) // _S0W: S0 Device Wake State"); diff --git a/devicemodel/hw/platform/acpi/acpi.c b/devicemodel/hw/platform/acpi/acpi.c index b2669665d..460c0e56e 100644 --- a/devicemodel/hw/platform/acpi/acpi.c +++ b/devicemodel/hw/platform/acpi/acpi.c @@ -86,6 +86,8 @@ #define ASL_SUFFIX ".aml" #define ASL_COMPILER "/usr/sbin/iasl" +uint64_t audio_nhlt_len = 0; + static int basl_keep_temps; static int basl_verbose_iasl; static int basl_ncpu; @@ -595,8 +597,10 @@ basl_fwrite_nhlt(FILE *fp, struct vmctx *ctx) return -1; } + + audio_nhlt_len = lseek(fd, 0, SEEK_END); /* check if file size exceeds reserved room */ - if (lseek(fd, 0, SEEK_END) > DSDT_OFFSET - NHLT_OFFSET) { + if (audio_nhlt_len > DSDT_OFFSET - NHLT_OFFSET) { fprintf(stderr, "Host NHLT exceeds reserved room!\n"); close(fd); return -1;