[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v1 11/20] acpi/hvmloader: Translate all addresses when assigning addresses in ACPI tables
Non-hvmloader users may be building tables in virtual address space and therefore we need to make sure that values that end up in tables are physical addresses. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> --- tools/firmware/hvmloader/acpi/build.c | 47 +++++++++++++++++---------------- 1 files changed, 24 insertions(+), 23 deletions(-) diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index 0adb3d6..4b0302c 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -126,7 +126,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, lapic = (struct acpi_20_madt_lapic *)(madt + 1); config->ainfo.nr_cpus =config-> hvminfo->nr_vcpus; - config->ainfo.madt_lapic0_addr = (uint32_t)lapic; + config->ainfo.madt_lapic0_addr = ctxt->mem_ops.v2p(ctxt, lapic); for ( i = 0; i < config->hvminfo->nr_vcpus; i++ ) { memset(lapic, 0, sizeof(*lapic)); @@ -143,7 +143,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, madt->header.length = (unsigned char *)lapic - (unsigned char *)madt; set_checksum(madt, offsetof(struct acpi_header, checksum), madt->header.length); - config->ainfo.madt_csum_addr = (uint32_t)&madt->header.checksum; + config->ainfo.madt_csum_addr = + ctxt->mem_ops.v2p(ctxt, &madt->header.checksum); return madt; } @@ -311,7 +312,7 @@ static int construct_passthrough_tables(struct acpi_ctxt *ctxt, break; memcpy(buffer, header, header->length); - table_ptrs[nr_tables++] = (unsigned long)buffer; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, buffer); total += header->length; acpi_pt_addr += header->length; } @@ -337,7 +338,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, { madt = construct_madt(ctxt, config); if (!madt) return -1; - table_ptrs[nr_tables++] = (unsigned long)madt; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, madt); } /* HPET. */ @@ -345,7 +346,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, { hpet = construct_hpet(ctxt, config); if (!hpet) return -1; - table_ptrs[nr_tables++] = (unsigned long)hpet; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, hpet); } /* WAET. */ @@ -353,7 +354,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, { waet = construct_waet(ctxt, config); if ( !waet ) return -1; - table_ptrs[nr_tables++] = (unsigned long)waet; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, waet); } if ( config->table_flags & ACPI_BUILD_SSDT_PM ) @@ -361,7 +362,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_pm), 16); if (!ssdt) return -1; memcpy(ssdt, ssdt_pm, sizeof(ssdt_pm)); - table_ptrs[nr_tables++] = (unsigned long)ssdt; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt); } if ( config->table_flags & ACPI_BUILD_SSDT_S3 ) @@ -369,7 +370,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s3), 16); if (!ssdt) return -1; memcpy(ssdt, ssdt_s3, sizeof(ssdt_s3)); - table_ptrs[nr_tables++] = (unsigned long)ssdt; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt); } else { printf("S3 disabled\n"); } @@ -379,7 +380,7 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_s4), 16); if (!ssdt) return -1; memcpy(ssdt, ssdt_s4, sizeof(ssdt_s4)); - table_ptrs[nr_tables++] = (unsigned long)ssdt; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt); } else { printf("S4 disabled\n"); } @@ -393,12 +394,12 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm), 16); if (!ssdt) return -1; memcpy(ssdt, ssdt_tpm, sizeof(ssdt_tpm)); - table_ptrs[nr_tables++] = (unsigned long)ssdt; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt); tcpa = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_tcpa), 16); if (!tcpa) return -1; memset(tcpa, 0, sizeof(*tcpa)); - table_ptrs[nr_tables++] = (unsigned long)tcpa; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, tcpa); tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE; tcpa->header.length = sizeof(*tcpa); @@ -426,11 +427,11 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, struct acpi_20_slit *slit = construct_slit(ctxt, config); if ( srat ) - table_ptrs[nr_tables++] = (unsigned long)srat; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, srat); else printf("Failed to build SRAT, skipping...\n"); if ( slit ) - table_ptrs[nr_tables++] = (unsigned long)slit; + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, slit); else printf("Failed to build SLIT, skipping...\n"); } @@ -527,8 +528,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) memcpy(fadt_10, &Fadt, sizeof(struct acpi_10_fadt)); fadt_10->header.length = sizeof(struct acpi_10_fadt); fadt_10->header.revision = ACPI_1_0_FADT_REVISION; - fadt_10->dsdt = (unsigned long)dsdt; - fadt_10->firmware_ctrl = (unsigned long)facs; + fadt_10->dsdt = ctxt->mem_ops.v2p(ctxt, dsdt); + fadt_10->firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs); set_checksum(fadt_10, offsetof(struct acpi_header, checksum), sizeof(struct acpi_10_fadt)); @@ -536,10 +537,10 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) fadt = ctxt->mem_ops.alloc(ctxt, sizeof(struct acpi_20_fadt), 16); if (!fadt) goto oom; memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt)); - fadt->dsdt = (unsigned long)dsdt; - fadt->x_dsdt = (unsigned long)dsdt; - fadt->firmware_ctrl = (unsigned long)facs; - fadt->x_firmware_ctrl = (unsigned long)facs; + fadt->dsdt = ctxt->mem_ops.v2p(ctxt, dsdt); + fadt->x_dsdt = ctxt->mem_ops.v2p(ctxt, dsdt); + fadt->firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs); + fadt->x_firmware_ctrl = ctxt->mem_ops.v2p(ctxt, facs); set_checksum(fadt, offsetof(struct acpi_header, checksum), sizeof(struct acpi_20_fadt)); @@ -553,7 +554,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) 16); if (!xsdt) goto oom; memcpy(xsdt, &Xsdt, sizeof(struct acpi_header)); - xsdt->entry[0] = (unsigned long)fadt; + xsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, fadt); for ( i = 0; secondary_tables[i]; i++ ) xsdt->entry[i+1] = secondary_tables[i]; xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t); @@ -566,7 +567,7 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) 16); if (!rsdt) goto oom; memcpy(rsdt, &Rsdt, sizeof(struct acpi_header)); - rsdt->entry[0] = (unsigned long)fadt_10; + rsdt->entry[0] = ctxt->mem_ops.v2p(ctxt, fadt_10); for ( i = 0; secondary_tables[i]; i++ ) rsdt->entry[i+1] = secondary_tables[i]; rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t); @@ -580,8 +581,8 @@ void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config) rsdp = (struct acpi_20_rsdp *)config->rsdp; memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp)); - rsdp->rsdt_address = (unsigned long)rsdt; - rsdp->xsdt_address = (unsigned long)xsdt; + rsdp->rsdt_address = ctxt->mem_ops.v2p(ctxt, rsdt); + rsdp->xsdt_address = ctxt->mem_ops.v2p(ctxt, xsdt); set_checksum(rsdp, offsetof(struct acpi_10_rsdp, checksum), sizeof(struct acpi_10_rsdp)); -- 1.7.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |