diff mbox

[2/2] lib: fwts_acpi_tables: Force fixup on XSDT and RSDT when loading from .dat files

Message ID 1342676948-21368-2-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King July 19, 2012, 5:49 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

When loading raw ACPI tables from .dat files we have no idea where the original
.dat tables were in memory, so this means that loading in the XSDT and RSDT is
problematic because these contain references to the original tables in memory
but we have no clue how these match up with the raw data.  Since fwts has to
fake the addresses of the loaded ACPI tables these don't match those in the
loaded XSDT and RSDT which leads to the ACPICA core getting confused.  The
best strategy is to therefore not load the XSDT and RSDT and rely on the fwts
table fix up stage to notice we haven't loaded the XSDT and RSDT and let this
create these tables based on the tables we have loaded from the raw .dat data,
leading us to having sane XSDT and RSDT that correctly reference the
loaded ACPI tables even if they are at faked addresses.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_acpi_tables.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

ivanhu July 20, 2012, 9:51 a.m. UTC | #1
On 07/19/2012 01:49 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> When loading raw ACPI tables from .dat files we have no idea where the original
> .dat tables were in memory, so this means that loading in the XSDT and RSDT is
> problematic because these contain references to the original tables in memory
> but we have no clue how these match up with the raw data.  Since fwts has to
> fake the addresses of the loaded ACPI tables these don't match those in the
> loaded XSDT and RSDT which leads to the ACPICA core getting confused.  The
> best strategy is to therefore not load the XSDT and RSDT and rely on the fwts
> table fix up stage to notice we haven't loaded the XSDT and RSDT and let this
> create these tables based on the tables we have loaded from the raw .dat data,
> leading us to having sane XSDT and RSDT that correctly reference the
> loaded ACPI tables even if they are at faked addresses.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_acpi_tables.c |   21 ++++++++++++++++++---
>   1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 4db5844..f388cdd 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -503,9 +503,24 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw)
>   						name[4] = '\0';
>   					}
>
> -					fwts_acpi_add_table(name, table,
> -						(uint64_t)fwts_fake_physical_addr(length), length,
> -						FWTS_ACPI_TABLE_FROM_FILE);
> +					if (!strncmp(name, "XSDT", 4) || !strncmp(name, "RSDT", 4)) {
> +						/*
> +						 * For XSDT and RSDT we don't bother loading at this point.
> +						 * These tables point to the other tables, however, we can't
> +						 * figure out which table each pointer references because
> +						 * we are loading in raw table data and we don't know where
> +						 * these were located in the original machine.  So the best
> +						 * way forward is to ignore these tables and instead leave
> +						 * the fix up stage fwts_acpi_load_tables_fixup() to magically
> +						 * create faked XSDT and RSDT entries based on the tables
> +						 * we've loaded from file.
> +						 */
> +						fwts_low_free(table);
> +					} else {
> +						fwts_acpi_add_table(name, table,
> +							(uint64_t)fwts_fake_physical_addr(length), length,
> +							FWTS_ACPI_TABLE_FROM_FILE);
> +					}
>   				}
>   				close(fd);
>   			} else
>
Acked-by: Ivan Hu<ivan.hu@canonical.com>
Keng-Yu Lin July 23, 2012, 5:26 a.m. UTC | #2
On Thu, Jul 19, 2012 at 1:49 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> When loading raw ACPI tables from .dat files we have no idea where the original
> .dat tables were in memory, so this means that loading in the XSDT and RSDT is
> problematic because these contain references to the original tables in memory
> but we have no clue how these match up with the raw data.  Since fwts has to
> fake the addresses of the loaded ACPI tables these don't match those in the
> loaded XSDT and RSDT which leads to the ACPICA core getting confused.  The
> best strategy is to therefore not load the XSDT and RSDT and rely on the fwts
> table fix up stage to notice we haven't loaded the XSDT and RSDT and let this
> create these tables based on the tables we have loaded from the raw .dat data,
> leading us to having sane XSDT and RSDT that correctly reference the
> loaded ACPI tables even if they are at faked addresses.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c |   21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 4db5844..f388cdd 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -503,9 +503,24 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw)
>                                                 name[4] = '\0';
>                                         }
>
> -                                       fwts_acpi_add_table(name, table,
> -                                               (uint64_t)fwts_fake_physical_addr(length), length,
> -                                               FWTS_ACPI_TABLE_FROM_FILE);
> +                                       if (!strncmp(name, "XSDT", 4) || !strncmp(name, "RSDT", 4)) {
> +                                               /*
> +                                                * For XSDT and RSDT we don't bother loading at this point.
> +                                                * These tables point to the other tables, however, we can't
> +                                                * figure out which table each pointer references because
> +                                                * we are loading in raw table data and we don't know where
> +                                                * these were located in the original machine.  So the best
> +                                                * way forward is to ignore these tables and instead leave
> +                                                * the fix up stage fwts_acpi_load_tables_fixup() to magically
> +                                                * create faked XSDT and RSDT entries based on the tables
> +                                                * we've loaded from file.
> +                                                */
> +                                               fwts_low_free(table);
> +                                       } else {
> +                                               fwts_acpi_add_table(name, table,
> +                                                       (uint64_t)fwts_fake_physical_addr(length), length,
> +                                                       FWTS_ACPI_TABLE_FROM_FILE);
> +                                       }
>                                 }
>                                 close(fd);
>                         } else
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 4db5844..f388cdd 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -503,9 +503,24 @@  static int fwts_acpi_load_tables_from_file(fwts_framework *fw)
 						name[4] = '\0';
 					}
 
-					fwts_acpi_add_table(name, table,
-						(uint64_t)fwts_fake_physical_addr(length), length,
-						FWTS_ACPI_TABLE_FROM_FILE);
+					if (!strncmp(name, "XSDT", 4) || !strncmp(name, "RSDT", 4)) {
+						/*
+						 * For XSDT and RSDT we don't bother loading at this point.
+						 * These tables point to the other tables, however, we can't
+						 * figure out which table each pointer references because
+						 * we are loading in raw table data and we don't know where
+						 * these were located in the original machine.  So the best
+						 * way forward is to ignore these tables and instead leave
+						 * the fix up stage fwts_acpi_load_tables_fixup() to magically
+						 * create faked XSDT and RSDT entries based on the tables
+						 * we've loaded from file.
+						 */
+						fwts_low_free(table);
+					} else {
+						fwts_acpi_add_table(name, table,
+							(uint64_t)fwts_fake_physical_addr(length), length,
+							FWTS_ACPI_TABLE_FROM_FILE);
+					}
 				}
 				close(fd);
 			} else