* [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
@ 2021-04-13 11:14 Igor Mammedov
2021-04-13 12:14 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Igor Mammedov @ 2021-04-13 11:14 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, drjones, mst, pbonzini, zhaoshenglong
Do the same as in commit
(4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
for remaining tables that happen to use saved at
the beginning pointer to build header to avoid assert
when table_data is relocated due to implicit re-size.
Reported-in: https://bugs.launchpad.net/bugs/1923497
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS:
I have build_header() refactoring patch that requires offset
instead of pointer, to make it harder to misuse but it's
a bit intrusive for last minute fixes. So here goes simplified
variant, and I'll post refactoring patch for 6.1. later.
---
hw/acpi/aml-build.c | 15 +++++++++------
hw/i386/acpi-build.c | 8 ++++++--
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d33ce8954a..f0035d2b4a 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
int i;
unsigned rsdt_entries_offset;
AcpiRsdtDescriptorRev1 *rsdt;
+ int rsdt_start = table_data->len;
const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
@@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
}
build_header(linker, table_data,
- (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
+ (void *)(table_data->data + rsdt_start),
+ "RSDT", rsdt_len, 1, oem_id, oem_table_id);
}
/* Build xsdt table */
@@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
int i;
unsigned xsdt_entries_offset;
AcpiXsdtDescriptorRev2 *xsdt;
+ int xsdt_start = table_data->len;
const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
@@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
}
build_header(linker, table_data,
- (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
+ (void *)(table_data->data + xsdt_start),
+ "XSDT", xsdt_len, 1, oem_id, oem_table_id);
}
void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
@@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
uint64_t control_area_start_address;
TPMIf *tpmif = tpm_find();
uint32_t start_method;
- void *tpm2_ptr;
tpm2_start = table_data->len;
- tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
+ acpi_data_push(table_data, sizeof(AcpiTableHeader));
/* Platform Class */
build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
@@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
log_addr_offset, 8,
ACPI_BUILD_TPMLOG_FILE, 0);
build_header(linker, table_data,
- tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
- oem_table_id);
+ (void *)(table_data->data + tpm2_start),
+ "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
}
Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index de98750aef..daaf8f473e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
const char *oem_table_id)
{
Acpi20Hpet *hpet;
+ int hpet_start = table_data->len;
hpet = acpi_data_push(table_data, sizeof(*hpet));
/* Note timer_block_id value must be kept in sync with value advertised by
@@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
hpet->timer_block_id = cpu_to_le32(0x8086a201);
hpet->addr.address = cpu_to_le64(HPET_BASE);
build_header(linker, table_data,
- (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
+ (void *)(table_data->data + hpet_start),
+ "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
}
static void
build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
const char *oem_id, const char *oem_table_id)
{
+ int tcpa_start = table_data->len;
Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
unsigned log_addr_offset =
@@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
ACPI_BUILD_TPMLOG_FILE, 0);
build_header(linker, table_data,
- (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
+ (void *)(table_data->data + tcpa_start),
+ "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
}
#define HOLE_640K_START (640 * KiB)
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
2021-04-13 11:14 [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header() Igor Mammedov
@ 2021-04-13 12:14 ` Michael S. Tsirkin
2021-04-13 13:18 ` Igor Mammedov
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-04-13 12:14 UTC (permalink / raw)
To: Igor Mammedov; +Cc: peter.maydell, drjones, pbonzini, qemu-devel, zhaoshenglong
On Tue, Apr 13, 2021 at 07:14:00AM -0400, Igor Mammedov wrote:
> Do the same as in commit
> (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
> for remaining tables that happen to use saved at
> the beginning pointer to build header to avoid assert
> when table_data is relocated due to implicit re-size.
>
> Reported-in: https://bugs.launchpad.net/bugs/1923497
Doesn't this fix the bug? If so -
Isn't this Fixes: ?
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> PS:
> I have build_header() refactoring patch that requires offset
> instead of pointer, to make it harder to misuse but it's
> a bit intrusive for last minute fixes. So here goes simplified
> variant, and I'll post refactoring patch for 6.1. later.
> ---
> hw/acpi/aml-build.c | 15 +++++++++------
> hw/i386/acpi-build.c | 8 ++++++--
> 2 files changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> index d33ce8954a..f0035d2b4a 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> int i;
> unsigned rsdt_entries_offset;
> AcpiRsdtDescriptorRev1 *rsdt;
> + int rsdt_start = table_data->len;
> const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
> const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
> const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
> @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> }
> build_header(linker, table_data,
> - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> + (void *)(table_data->data + rsdt_start),
> + "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> }
>
> /* Build xsdt table */
> @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> int i;
> unsigned xsdt_entries_offset;
> AcpiXsdtDescriptorRev2 *xsdt;
> + int xsdt_start = table_data->len;
> const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
> const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
> const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
> @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> }
> build_header(linker, table_data,
> - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> + (void *)(table_data->data + xsdt_start),
> + "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> }
>
> void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
> @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> uint64_t control_area_start_address;
> TPMIf *tpmif = tpm_find();
> uint32_t start_method;
> - void *tpm2_ptr;
>
> tpm2_start = table_data->len;
> - tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
> + acpi_data_push(table_data, sizeof(AcpiTableHeader));
>
> /* Platform Class */
> build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
> @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> log_addr_offset, 8,
> ACPI_BUILD_TPMLOG_FILE, 0);
> build_header(linker, table_data,
> - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
> - oem_table_id);
> + (void *)(table_data->data + tpm2_start),
> + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
> }
>
> Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index de98750aef..daaf8f473e 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> const char *oem_table_id)
> {
> Acpi20Hpet *hpet;
> + int hpet_start = table_data->len;
>
> hpet = acpi_data_push(table_data, sizeof(*hpet));
> /* Note timer_block_id value must be kept in sync with value advertised by
> @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> hpet->timer_block_id = cpu_to_le32(0x8086a201);
> hpet->addr.address = cpu_to_le64(HPET_BASE);
> build_header(linker, table_data,
> - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> + (void *)(table_data->data + hpet_start),
> + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> }
>
> static void
> build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> const char *oem_id, const char *oem_table_id)
> {
> + int tcpa_start = table_data->len;
> Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
> unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
> unsigned log_addr_offset =
> @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> ACPI_BUILD_TPMLOG_FILE, 0);
>
> build_header(linker, table_data,
> - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> + (void *)(table_data->data + tcpa_start),
> + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> }
>
> #define HOLE_640K_START (640 * KiB)
> --
> 2.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
2021-04-13 12:14 ` Michael S. Tsirkin
@ 2021-04-13 13:18 ` Igor Mammedov
2021-04-13 13:53 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Igor Mammedov @ 2021-04-13 13:18 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: peter.maydell, drjones, pbonzini, qemu-devel, zhaoshenglong
On Tue, 13 Apr 2021 08:14:56 -0400
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Tue, Apr 13, 2021 at 07:14:00AM -0400, Igor Mammedov wrote:
> > Do the same as in commit
> > (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
> > for remaining tables that happen to use saved at
> > the beginning pointer to build header to avoid assert
> > when table_data is relocated due to implicit re-size.
> >
> > Reported-in: https://bugs.launchpad.net/bugs/1923497
>
> Doesn't this fix the bug? If so -
> Isn't this Fixes: ?
that's buried in history
Fixes: 243bdb79fb0b2ed hw/arm/virt-acpi-build: Generate RSDT table
Fixes: cb51ac2ffe3649e hw/arm/virt: generate 64-bit addressable ACPI objects
Fixes: 4338416064303aa acpi: Move build_tpm2() in the generic part
Fixes: 72c194f7e75cb64 i386: ACPI table generation code from seabios
Fixes: 711b20b479aa96e Add ACPI tables for TPM
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > PS:
> > I have build_header() refactoring patch that requires offset
> > instead of pointer, to make it harder to misuse but it's
> > a bit intrusive for last minute fixes. So here goes simplified
> > variant, and I'll post refactoring patch for 6.1. later.
> > ---
> > hw/acpi/aml-build.c | 15 +++++++++------
> > hw/i386/acpi-build.c | 8 ++++++--
> > 2 files changed, 15 insertions(+), 8 deletions(-)
> >
> > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> > index d33ce8954a..f0035d2b4a 100644
> > --- a/hw/acpi/aml-build.c
> > +++ b/hw/acpi/aml-build.c
> > @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > int i;
> > unsigned rsdt_entries_offset;
> > AcpiRsdtDescriptorRev1 *rsdt;
> > + int rsdt_start = table_data->len;
> > const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
> > const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
> > const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
> > @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > }
> > build_header(linker, table_data,
> > - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > + (void *)(table_data->data + rsdt_start),
> > + "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > }
> >
> > /* Build xsdt table */
> > @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > int i;
> > unsigned xsdt_entries_offset;
> > AcpiXsdtDescriptorRev2 *xsdt;
> > + int xsdt_start = table_data->len;
> > const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
> > const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
> > const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
> > @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > }
> > build_header(linker, table_data,
> > - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > + (void *)(table_data->data + xsdt_start),
> > + "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > }
> >
> > void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
> > @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > uint64_t control_area_start_address;
> > TPMIf *tpmif = tpm_find();
> > uint32_t start_method;
> > - void *tpm2_ptr;
> >
> > tpm2_start = table_data->len;
> > - tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > + acpi_data_push(table_data, sizeof(AcpiTableHeader));
> >
> > /* Platform Class */
> > build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
> > @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > log_addr_offset, 8,
> > ACPI_BUILD_TPMLOG_FILE, 0);
> > build_header(linker, table_data,
> > - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
> > - oem_table_id);
> > + (void *)(table_data->data + tpm2_start),
> > + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
> > }
> >
> > Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index de98750aef..daaf8f473e 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > const char *oem_table_id)
> > {
> > Acpi20Hpet *hpet;
> > + int hpet_start = table_data->len;
> >
> > hpet = acpi_data_push(table_data, sizeof(*hpet));
> > /* Note timer_block_id value must be kept in sync with value advertised by
> > @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > hpet->timer_block_id = cpu_to_le32(0x8086a201);
> > hpet->addr.address = cpu_to_le64(HPET_BASE);
> > build_header(linker, table_data,
> > - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > + (void *)(table_data->data + hpet_start),
> > + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > }
> >
> > static void
> > build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > const char *oem_id, const char *oem_table_id)
> > {
> > + int tcpa_start = table_data->len;
> > Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
> > unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
> > unsigned log_addr_offset =
> > @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > ACPI_BUILD_TPMLOG_FILE, 0);
> >
> > build_header(linker, table_data,
> > - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > + (void *)(table_data->data + tcpa_start),
> > + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > }
> >
> > #define HOLE_640K_START (640 * KiB)
> > --
> > 2.27.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
2021-04-13 13:18 ` Igor Mammedov
@ 2021-04-13 13:53 ` Michael S. Tsirkin
2021-04-13 15:21 ` Igor Mammedov
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-04-13 13:53 UTC (permalink / raw)
To: Igor Mammedov; +Cc: peter.maydell, drjones, pbonzini, qemu-devel, zhaoshenglong
On Tue, Apr 13, 2021 at 03:18:16PM +0200, Igor Mammedov wrote:
> On Tue, 13 Apr 2021 08:14:56 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Tue, Apr 13, 2021 at 07:14:00AM -0400, Igor Mammedov wrote:
> > > Do the same as in commit
> > > (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
Format:
commit 4d027afeb3a97 ("Virt: ACPI: fix qemu assert due to re-assigned table data address")
> > > for remaining tables that happen to use saved at
> > > the beginning pointer to build header to avoid assert
> > > when table_data is relocated due to implicit re-size.
> > >
> > > Reported-in: https://bugs.launchpad.net/bugs/1923497
> >
> > Doesn't this fix the bug? If so -
> > Isn't this Fixes: ?
> that's buried in history
>
> Fixes: 243bdb79fb0b2ed hw/arm/virt-acpi-build: Generate RSDT table
> Fixes: cb51ac2ffe3649e hw/arm/virt: generate 64-bit addressable ACPI objects
> Fixes: 4338416064303aa acpi: Move build_tpm2() in the generic part
> Fixes: 72c194f7e75cb64 i386: ACPI table generation code from seabios
> Fixes: 711b20b479aa96e Add ACPI tables for TPM
I just mean:
Buglink: https://bugs.launchpad.net/qemu/+bug/1921138
as opposed to Reported.
Also do we CC stable for this?
>
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
patch itself ok:
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> > > ---
> > > PS:
> > > I have build_header() refactoring patch that requires offset
> > > instead of pointer, to make it harder to misuse but it's
> > > a bit intrusive for last minute fixes. So here goes simplified
> > > variant, and I'll post refactoring patch for 6.1. later.
> > > ---
> > > hw/acpi/aml-build.c | 15 +++++++++------
> > > hw/i386/acpi-build.c | 8 ++++++--
> > > 2 files changed, 15 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> > > index d33ce8954a..f0035d2b4a 100644
> > > --- a/hw/acpi/aml-build.c
> > > +++ b/hw/acpi/aml-build.c
> > > @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > int i;
> > > unsigned rsdt_entries_offset;
> > > AcpiRsdtDescriptorRev1 *rsdt;
> > > + int rsdt_start = table_data->len;
> > > const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
> > > const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
> > > const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
> > > @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > }
> > > build_header(linker, table_data,
> > > - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > + (void *)(table_data->data + rsdt_start),
> > > + "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > }
> > >
> > > /* Build xsdt table */
> > > @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > int i;
> > > unsigned xsdt_entries_offset;
> > > AcpiXsdtDescriptorRev2 *xsdt;
> > > + int xsdt_start = table_data->len;
> > > const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
> > > const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
> > > const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
> > > @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > }
> > > build_header(linker, table_data,
> > > - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > + (void *)(table_data->data + xsdt_start),
> > > + "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > }
> > >
> > > void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
> > > @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > uint64_t control_area_start_address;
> > > TPMIf *tpmif = tpm_find();
> > > uint32_t start_method;
> > > - void *tpm2_ptr;
> > >
> > > tpm2_start = table_data->len;
> > > - tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > > + acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > >
> > > /* Platform Class */
> > > build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
> > > @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > log_addr_offset, 8,
> > > ACPI_BUILD_TPMLOG_FILE, 0);
> > > build_header(linker, table_data,
> > > - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
> > > - oem_table_id);
> > > + (void *)(table_data->data + tpm2_start),
> > > + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
> > > }
> > >
> > > Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index de98750aef..daaf8f473e 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > const char *oem_table_id)
> > > {
> > > Acpi20Hpet *hpet;
> > > + int hpet_start = table_data->len;
> > >
> > > hpet = acpi_data_push(table_data, sizeof(*hpet));
> > > /* Note timer_block_id value must be kept in sync with value advertised by
> > > @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > hpet->timer_block_id = cpu_to_le32(0x8086a201);
> > > hpet->addr.address = cpu_to_le64(HPET_BASE);
> > > build_header(linker, table_data,
> > > - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > + (void *)(table_data->data + hpet_start),
> > > + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > }
> > >
> > > static void
> > > build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > const char *oem_id, const char *oem_table_id)
> > > {
> > > + int tcpa_start = table_data->len;
> > > Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
> > > unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
> > > unsigned log_addr_offset =
> > > @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > ACPI_BUILD_TPMLOG_FILE, 0);
> > >
> > > build_header(linker, table_data,
> > > - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > + (void *)(table_data->data + tcpa_start),
> > > + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > }
> > >
> > > #define HOLE_640K_START (640 * KiB)
> > > --
> > > 2.27.0
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
2021-04-13 13:53 ` Michael S. Tsirkin
@ 2021-04-13 15:21 ` Igor Mammedov
2021-04-13 20:09 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Igor Mammedov @ 2021-04-13 15:21 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: peter.maydell, drjones, pbonzini, qemu-devel, zhaoshenglong
On Tue, 13 Apr 2021 09:53:17 -0400
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Tue, Apr 13, 2021 at 03:18:16PM +0200, Igor Mammedov wrote:
> > On Tue, 13 Apr 2021 08:14:56 -0400
> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> >
> > > On Tue, Apr 13, 2021 at 07:14:00AM -0400, Igor Mammedov wrote:
> > > > Do the same as in commit
> > > > (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
>
> Format:
>
> commit 4d027afeb3a97 ("Virt: ACPI: fix qemu assert due to re-assigned table data address")
>
> > > > for remaining tables that happen to use saved at
> > > > the beginning pointer to build header to avoid assert
> > > > when table_data is relocated due to implicit re-size.
> > > >
> > > > Reported-in: https://bugs.launchpad.net/bugs/1923497
> > >
> > > Doesn't this fix the bug? If so -
> > > Isn't this Fixes: ?
> > that's buried in history
> >
> > Fixes: 243bdb79fb0b2ed hw/arm/virt-acpi-build: Generate RSDT table
> > Fixes: cb51ac2ffe3649e hw/arm/virt: generate 64-bit addressable ACPI objects
> > Fixes: 4338416064303aa acpi: Move build_tpm2() in the generic part
> > Fixes: 72c194f7e75cb64 i386: ACPI table generation code from seabios
> > Fixes: 711b20b479aa96e Add ACPI tables for TPM
>
>
> I just mean:
>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1921138
>
> as opposed to Reported.
>
> Also do we CC stable for this?
Given it's reported on 5.1, it is a good idea to cc stable.
Shall I repost with fixed: "Fixes:..."?
>
> >
> > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>
>
> patch itself ok:
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> > > > ---
> > > > PS:
> > > > I have build_header() refactoring patch that requires offset
> > > > instead of pointer, to make it harder to misuse but it's
> > > > a bit intrusive for last minute fixes. So here goes simplified
> > > > variant, and I'll post refactoring patch for 6.1. later.
> > > > ---
> > > > hw/acpi/aml-build.c | 15 +++++++++------
> > > > hw/i386/acpi-build.c | 8 ++++++--
> > > > 2 files changed, 15 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> > > > index d33ce8954a..f0035d2b4a 100644
> > > > --- a/hw/acpi/aml-build.c
> > > > +++ b/hw/acpi/aml-build.c
> > > > @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > int i;
> > > > unsigned rsdt_entries_offset;
> > > > AcpiRsdtDescriptorRev1 *rsdt;
> > > > + int rsdt_start = table_data->len;
> > > > const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
> > > > const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
> > > > const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
> > > > @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > > }
> > > > build_header(linker, table_data,
> > > > - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > > + (void *)(table_data->data + rsdt_start),
> > > > + "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > > }
> > > >
> > > > /* Build xsdt table */
> > > > @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > int i;
> > > > unsigned xsdt_entries_offset;
> > > > AcpiXsdtDescriptorRev2 *xsdt;
> > > > + int xsdt_start = table_data->len;
> > > > const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
> > > > const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
> > > > const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
> > > > @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > > }
> > > > build_header(linker, table_data,
> > > > - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > > + (void *)(table_data->data + xsdt_start),
> > > > + "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > > }
> > > >
> > > > void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
> > > > @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > uint64_t control_area_start_address;
> > > > TPMIf *tpmif = tpm_find();
> > > > uint32_t start_method;
> > > > - void *tpm2_ptr;
> > > >
> > > > tpm2_start = table_data->len;
> > > > - tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > > > + acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > > >
> > > > /* Platform Class */
> > > > build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
> > > > @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > log_addr_offset, 8,
> > > > ACPI_BUILD_TPMLOG_FILE, 0);
> > > > build_header(linker, table_data,
> > > > - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
> > > > - oem_table_id);
> > > > + (void *)(table_data->data + tpm2_start),
> > > > + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
> > > > }
> > > >
> > > > Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index de98750aef..daaf8f473e 100644
> > > > --- a/hw/i386/acpi-build.c
> > > > +++ b/hw/i386/acpi-build.c
> > > > @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > > const char *oem_table_id)
> > > > {
> > > > Acpi20Hpet *hpet;
> > > > + int hpet_start = table_data->len;
> > > >
> > > > hpet = acpi_data_push(table_data, sizeof(*hpet));
> > > > /* Note timer_block_id value must be kept in sync with value advertised by
> > > > @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > > hpet->timer_block_id = cpu_to_le32(0x8086a201);
> > > > hpet->addr.address = cpu_to_le64(HPET_BASE);
> > > > build_header(linker, table_data,
> > > > - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > > + (void *)(table_data->data + hpet_start),
> > > > + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > > }
> > > >
> > > > static void
> > > > build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > const char *oem_id, const char *oem_table_id)
> > > > {
> > > > + int tcpa_start = table_data->len;
> > > > Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
> > > > unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
> > > > unsigned log_addr_offset =
> > > > @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > ACPI_BUILD_TPMLOG_FILE, 0);
> > > >
> > > > build_header(linker, table_data,
> > > > - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > > + (void *)(table_data->data + tcpa_start),
> > > > + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > > }
> > > >
> > > > #define HOLE_640K_START (640 * KiB)
> > > > --
> > > > 2.27.0
> > >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header()
2021-04-13 15:21 ` Igor Mammedov
@ 2021-04-13 20:09 ` Michael S. Tsirkin
0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-04-13 20:09 UTC (permalink / raw)
To: Igor Mammedov; +Cc: peter.maydell, drjones, pbonzini, qemu-devel, zhaoshenglong
On Tue, Apr 13, 2021 at 05:21:10PM +0200, Igor Mammedov wrote:
> On Tue, 13 Apr 2021 09:53:17 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > On Tue, Apr 13, 2021 at 03:18:16PM +0200, Igor Mammedov wrote:
> > > On Tue, 13 Apr 2021 08:14:56 -0400
> > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > >
> > > > On Tue, Apr 13, 2021 at 07:14:00AM -0400, Igor Mammedov wrote:
> > > > > Do the same as in commit
> > > > > (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data address)
> >
> > Format:
> >
> > commit 4d027afeb3a97 ("Virt: ACPI: fix qemu assert due to re-assigned table data address")
> >
> > > > > for remaining tables that happen to use saved at
> > > > > the beginning pointer to build header to avoid assert
> > > > > when table_data is relocated due to implicit re-size.
> > > > >
> > > > > Reported-in: https://bugs.launchpad.net/bugs/1923497
> > > >
> > > > Doesn't this fix the bug? If so -
> > > > Isn't this Fixes: ?
> > > that's buried in history
> > >
> > > Fixes: 243bdb79fb0b2ed hw/arm/virt-acpi-build: Generate RSDT table
> > > Fixes: cb51ac2ffe3649e hw/arm/virt: generate 64-bit addressable ACPI objects
> > > Fixes: 4338416064303aa acpi: Move build_tpm2() in the generic part
> > > Fixes: 72c194f7e75cb64 i386: ACPI table generation code from seabios
> > > Fixes: 711b20b479aa96e Add ACPI tables for TPM
> >
> >
> > I just mean:
> >
> > Buglink: https://bugs.launchpad.net/qemu/+bug/1921138
> >
> > as opposed to Reported.
> >
> > Also do we CC stable for this?
> Given it's reported on 5.1, it is a good idea to cc stable.
>
> Shall I repost with fixed: "Fixes:..."?
Yes. If you can copy problem description from launchpad/ARM
commit into commit log, that's also a good idea.
> >
> > >
> > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> >
> >
> > patch itself ok:
> >
> > Acked-by: Michael S. Tsirkin <mst@redhat.com>
> >
> > > > > ---
> > > > > PS:
> > > > > I have build_header() refactoring patch that requires offset
> > > > > instead of pointer, to make it harder to misuse but it's
> > > > > a bit intrusive for last minute fixes. So here goes simplified
> > > > > variant, and I'll post refactoring patch for 6.1. later.
> > > > > ---
> > > > > hw/acpi/aml-build.c | 15 +++++++++------
> > > > > hw/i386/acpi-build.c | 8 ++++++--
> > > > > 2 files changed, 15 insertions(+), 8 deletions(-)
> > > > >
> > > > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> > > > > index d33ce8954a..f0035d2b4a 100644
> > > > > --- a/hw/acpi/aml-build.c
> > > > > +++ b/hw/acpi/aml-build.c
> > > > > @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > > int i;
> > > > > unsigned rsdt_entries_offset;
> > > > > AcpiRsdtDescriptorRev1 *rsdt;
> > > > > + int rsdt_start = table_data->len;
> > > > > const unsigned table_data_len = (sizeof(uint32_t) * table_offsets->len);
> > > > > const unsigned rsdt_entry_size = sizeof(rsdt->table_offset_entry[0]);
> > > > > const size_t rsdt_len = sizeof(*rsdt) + table_data_len;
> > > > > @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > > > }
> > > > > build_header(linker, table_data,
> > > > > - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > > > + (void *)(table_data->data + rsdt_start),
> > > > > + "RSDT", rsdt_len, 1, oem_id, oem_table_id);
> > > > > }
> > > > >
> > > > > /* Build xsdt table */
> > > > > @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > > int i;
> > > > > unsigned xsdt_entries_offset;
> > > > > AcpiXsdtDescriptorRev2 *xsdt;
> > > > > + int xsdt_start = table_data->len;
> > > > > const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len);
> > > > > const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]);
> > > > > const size_t xsdt_len = sizeof(*xsdt) + table_data_len;
> > > > > @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets,
> > > > > ACPI_BUILD_TABLE_FILE, ref_tbl_offset);
> > > > > }
> > > > > build_header(linker, table_data,
> > > > > - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > > > + (void *)(table_data->data + xsdt_start),
> > > > > + "XSDT", xsdt_len, 1, oem_id, oem_table_id);
> > > > > }
> > > > >
> > > > > void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
> > > > > @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > > uint64_t control_area_start_address;
> > > > > TPMIf *tpmif = tpm_find();
> > > > > uint32_t start_method;
> > > > > - void *tpm2_ptr;
> > > > >
> > > > > tpm2_start = table_data->len;
> > > > > - tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > > > > + acpi_data_push(table_data, sizeof(AcpiTableHeader));
> > > > >
> > > > > /* Platform Class */
> > > > > build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2);
> > > > > @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > > log_addr_offset, 8,
> > > > > ACPI_BUILD_TPMLOG_FILE, 0);
> > > > > build_header(linker, table_data,
> > > > > - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
> > > > > - oem_table_id);
> > > > > + (void *)(table_data->data + tpm2_start),
> > > > > + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_table_id);
> > > > > }
> > > > >
> > > > > Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
> > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > index de98750aef..daaf8f473e 100644
> > > > > --- a/hw/i386/acpi-build.c
> > > > > +++ b/hw/i386/acpi-build.c
> > > > > @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > > > const char *oem_table_id)
> > > > > {
> > > > > Acpi20Hpet *hpet;
> > > > > + int hpet_start = table_data->len;
> > > > >
> > > > > hpet = acpi_data_push(table_data, sizeof(*hpet));
> > > > > /* Note timer_block_id value must be kept in sync with value advertised by
> > > > > @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
> > > > > hpet->timer_block_id = cpu_to_le32(0x8086a201);
> > > > > hpet->addr.address = cpu_to_le64(HPET_BASE);
> > > > > build_header(linker, table_data,
> > > > > - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > > > + (void *)(table_data->data + hpet_start),
> > > > > + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id);
> > > > > }
> > > > >
> > > > > static void
> > > > > build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > > const char *oem_id, const char *oem_table_id)
> > > > > {
> > > > > + int tcpa_start = table_data->len;
> > > > > Acpi20Tcpa *tcpa = acpi_data_push(table_data, sizeof *tcpa);
> > > > > unsigned log_addr_size = sizeof(tcpa->log_area_start_address);
> > > > > unsigned log_addr_offset =
> > > > > @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> > > > > ACPI_BUILD_TPMLOG_FILE, 0);
> > > > >
> > > > > build_header(linker, table_data,
> > > > > - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > > > + (void *)(table_data->data + tcpa_start),
> > > > > + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id);
> > > > > }
> > > > >
> > > > > #define HOLE_640K_START (640 * KiB)
> > > > > --
> > > > > 2.27.0
> > > >
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-13 20:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 11:14 [PATCH for-6.0] x86: acpi: use offset instead of pointer when using build_header() Igor Mammedov
2021-04-13 12:14 ` Michael S. Tsirkin
2021-04-13 13:18 ` Igor Mammedov
2021-04-13 13:53 ` Michael S. Tsirkin
2021-04-13 15:21 ` Igor Mammedov
2021-04-13 20:09 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).