Skip to contentSkip to conversation

x86: acpi: Fix calculation of DSDT length

PATCH New Wolfgang Wallner 3 participants 7 messages Sep 16, 2020 – Sep 21, 2020 x86

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 x86: acpi: Fix calculation of DSDT length

Currently, the calculation for the length of the DSDT table includes any bytes that are added for alignment, but those bytes are not initialized.

This is because the DSDT length is calculated after a call to acpi_inc_align(). Split this up into the following sequence:

* acpi_inc()
* Calculate DSDT length
* acpi_align()

---

Changes in v2:
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/lib/acpi_table.c +3 -1
index 3a93fedfc3..6b827bfa3f 100644
@@ -427,7 +427,7 @@ ulong write_acpi_tables(ulong start_addr)
 	       (char *)&AmlCode + sizeof(struct acpi_table_header),
 	       dsdt->length - sizeof(struct acpi_table_header));
 
-	acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header));
+	acpi_inc(ctx, dsdt->length - sizeof(struct acpi_table_header));
 
 	/* Pack GNVS into the ACPI table area */
 	for (i = 0; i < dsdt->length; i++) {
@@ -450,6 +450,8 @@ ulong write_acpi_tables(ulong start_addr)
 	dsdt->checksum = 0;
 	dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
 
+	acpi_align(ctx);
+
 	/*
 	 * Fill in platform-specific global NVS variables. If this fails we
 	 * cannot return the error but this should only happen while debugging.
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 2/2 x86: acpi: Add memset to initialize SPCR table

Add a missing memset to acpi_create_spcr().

The other acpi_create_xxxx() functions perform a memset on their structures, acpi_create_spcr() does not and as a result the contents of this table are partly uninitialized (and thus random after every reset).

Fixes commit b288cd960072 ("x86: acpi: Generate SPCR table")

---

Changes in v2:
- Removed unrelated whitespace change
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +2 -0
index 6b827bfa3f..c445aa6870 100644
@@ -252,6 +252,8 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
 	int space_id;
 	int ret = -ENODEV;
 
+	memset((void *)spcr, 0, sizeof(struct acpi_spcr));
+
 	/* Fill out header fields */
 	acpi_fill_header(header, "SPCR");
 	header->length = sizeof(struct acpi_spcr);
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 2/2 x86: acpi: Add memset to initialize SPCR table

Quoted 9 lines · Wolfgang Wallner

Add a missing memset to acpi_create_spcr().

The other acpi_create_xxxx() functions perform a memset on their structures, acpi_create_spcr() does not and as a result the contents of this table are partly uninitialized (and thus random after every reset).

Fixes commit b288cd960072 ("x86: acpi: Generate SPCR table")

In tag block should not be any blank line, but I guess maintainer can fix this when applying (i.o.w. no need to resend).

Quoted 29 lines

---

Changes in v2:
- Removed unrelated whitespace change
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +2 -0
index 6b827bfa3f..c445aa6870 100644
@@ -252,6 +252,8 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
 	int space_id;
 	int ret = -ENODEV;
 
+	memset((void *)spcr, 0, sizeof(struct acpi_spcr));
+
 	/* Fill out header fields */
 	acpi_fill_header(header, "SPCR");
 	header->length = sizeof(struct acpi_spcr);
Signature · 1 line
2.28.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH v2 2/2 x86: acpi: Add memset to initialize SPCR table

Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Wolfgang Wallner

Add a missing memset to acpi_create_spcr().

The other acpi_create_xxxx() functions perform a memset on their structures, acpi_create_spcr() does not and as a result the contents of this table are partly uninitialized (and thus random after every reset).

Quoted 6 lines
Quoted 3 lines
Fixes commit b288cd960072 ("x86: acpi: Generate SPCR table")

In tag block should not be any blank line, but I guess maintainer can fix this when applying (i.o.w. no need to resend).

Yep, normally I will fix such kinds of issues when applying. Thanks for pointing it out.

Quoted 21 lines
Quoted 21 lines

---

Changes in v2:
- Removed unrelated whitespace change
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +0 -0
index 6b827bfa3f..c445aa6870 100644
@@ -252,6 +252,8 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
      int space_id;
      int ret = -ENODEV;
 
Quoted 6 lines

arch/x86/lib/acpi_table.c static void acpi_create_spcr(struct acpi_spcr *spcr)

Quoted 6 lines
arch/x86/lib/acpi_table.c +2 -1
+     memset((void *)spcr, 0, sizeof(struct acpi_spcr));
+
      /* Fill out header fields */
      acpi_fill_header(header, "SPCR");
      header->length = sizeof(struct acpi_spcr);
--
#4 lore raw

PATCH v2 2/2 x86: acpi: Add memset to initialize SPCR table

Quoted 13 lines · Bin Meng
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Wolfgang Wallner

Add a missing memset to acpi_create_spcr().

The other acpi_create_xxxx() functions perform a memset on their structures, acpi_create_spcr() does not and as a result the contents of this table are partly uninitialized (and thus random after every reset).

Fixes commit b288cd960072 ("x86: acpi: Generate SPCR table")
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

In tag block should not be any blank line, but I guess maintainer can fix this when applying (i.o.w. no need to resend).

Yep, normally I will fix such kinds of issues when applying. Thanks for pointing it out.

Fixed the tags format, and

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

---

Changes in v2:
- Removed unrelated whitespace change
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/lib/acpi_table.c +0 -0
index 6b827bfa3f..c445aa6870 100644
@@ -252,6 +252,8 @@ static void acpi_create_spcr(struct acpi_spcr *spcr)
      int space_id;
      int ret = -ENODEV;
 
Quoted 8 lines
Quoted 6 lines

arch/x86/lib/acpi_table.c static void acpi_create_spcr(struct acpi_spcr *spcr)

Quoted 6 lines
arch/x86/lib/acpi_table.c +2 -1
+     memset((void *)spcr, 0, sizeof(struct acpi_spcr));
+
      /* Fill out header fields */
      acpi_fill_header(header, "SPCR");
      header->length = sizeof(struct acpi_spcr);
--

applied to u-boot-x86, thanks!

#5 lore raw

PATCH v2 1/2 x86: acpi: Fix calculation of DSDT length

In reply to Wolfgang Wallner
Quoted 15 lines · Wolfgang Wallner

Currently, the calculation for the length of the DSDT table includes any bytes that are added for alignment, but those bytes are not initialized.

This is because the DSDT length is calculated after a call to acpi_inc_align(). Split this up into the following sequence:

* acpi_inc()
* Calculate DSDT length
* acpi_align()

Quoted 8 lines

---

Changes in v2:
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
#6 lore raw

PATCH v2 1/2 x86: acpi: Fix calculation of DSDT length

Quoted 20 lines · Bin Meng
Quoted 17 lines · Wolfgang Wallner

Currently, the calculation for the length of the DSDT table includes any bytes that are added for alignment, but those bytes are not initialized.

This is because the DSDT length is calculated after a call to acpi_inc_align(). Split this up into the following sequence:

* acpi_inc()
* Calculate DSDT length
* acpi_align()

---

Quoted 8 lines
Quoted 6 lines

Changes in v2:
- Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

applied to u-boot-x86, thanks!