mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-28 01:59:49 +00:00
commands/acpi: Fix calculation of ACPI tables addresses when processing RSDT and XSDT
According to the ACPI specification the XSDT Entry field contains an array of 64-bit physical addresses which points to other DESCRIPTION_HEADERs. However, the entry_ptr iterator is defined as a 32-bit pointer. It means each 64-bit entry in the XSDT table is treated as two separate 32-bit entries then. Fix the issue by using correct addresses sizes when processing RSDT and XSDT tables. Signed-off-by: Qiumiao Zhang <zhangqiumiao1@huawei.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
f20123072a
commit
63fc253fc9
1 file changed
+22
-11
+22
-11
@@ -490,12 +490,12 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
|||||||
|
|
||||||
if (rsdp)
|
if (rsdp)
|
||||||
{
|
{
|
||||||
grub_uint32_t *entry_ptr;
|
grub_uint8_t *entry_ptr;
|
||||||
char *exclude = 0;
|
char *exclude = 0;
|
||||||
char *load_only = 0;
|
char *load_only = 0;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
/* RSDT consists of header and an array of 32-bit pointers. */
|
grub_size_t tbl_addr_size;
|
||||||
struct grub_acpi_table_header *rsdt;
|
struct grub_acpi_table_header *table_head;
|
||||||
|
|
||||||
exclude = state[0].set ? grub_strdup (state[0].arg) : 0;
|
exclude = state[0].set ? grub_strdup (state[0].arg) : 0;
|
||||||
if (exclude)
|
if (exclude)
|
||||||
@@ -515,20 +515,31 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
|
|||||||
rev1 = ! rsdp->revision;
|
rev1 = ! rsdp->revision;
|
||||||
rev2 = rsdp->revision;
|
rev2 = rsdp->revision;
|
||||||
if (rev2 && ((struct grub_acpi_table_header *) (grub_addr_t) ((struct grub_acpi_rsdp_v20 *) rsdp)->xsdt_addr) != NULL)
|
if (rev2 && ((struct grub_acpi_table_header *) (grub_addr_t) ((struct grub_acpi_rsdp_v20 *) rsdp)->xsdt_addr) != NULL)
|
||||||
rsdt = (struct grub_acpi_table_header *) (grub_addr_t) ((struct grub_acpi_rsdp_v20 *) rsdp)->xsdt_addr;
|
{
|
||||||
|
/* XSDT consists of header and an array of 64-bit pointers. */
|
||||||
|
table_head = (struct grub_acpi_table_header *) (grub_addr_t) ((struct grub_acpi_rsdp_v20 *) rsdp)->xsdt_addr;
|
||||||
|
tbl_addr_size = sizeof (((struct grub_acpi_rsdp_v20 *) rsdp)->xsdt_addr);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
rsdt = (struct grub_acpi_table_header *) (grub_addr_t) rsdp->rsdt_addr;
|
{
|
||||||
|
/* RSDT consists of header and an array of 32-bit pointers. */
|
||||||
|
table_head = (struct grub_acpi_table_header *) (grub_addr_t) rsdp->rsdt_addr;
|
||||||
|
tbl_addr_size = sizeof (rsdp->rsdt_addr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Load host tables. */
|
/* Load host tables. */
|
||||||
for (entry_ptr = (grub_uint32_t *) (rsdt + 1);
|
for (entry_ptr = (grub_uint8_t *) (table_head + 1);
|
||||||
entry_ptr < (grub_uint32_t *) (((grub_uint8_t *) rsdt)
|
entry_ptr < (grub_uint8_t *) (((grub_uint8_t *) table_head) + table_head->length);
|
||||||
+ rsdt->length);
|
entry_ptr += tbl_addr_size)
|
||||||
entry_ptr++)
|
|
||||||
{
|
{
|
||||||
char signature[5];
|
char signature[5];
|
||||||
struct efiemu_acpi_table *table;
|
struct efiemu_acpi_table *table;
|
||||||
struct grub_acpi_table_header *curtable
|
struct grub_acpi_table_header *curtable;
|
||||||
= (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
|
if (tbl_addr_size == sizeof (rsdp->rsdt_addr))
|
||||||
|
curtable = (struct grub_acpi_table_header *) (grub_addr_t) *((grub_uint32_t *) entry_ptr);
|
||||||
|
else
|
||||||
|
curtable = (struct grub_acpi_table_header *) (grub_addr_t) *((grub_uint64_t *) entry_ptr);
|
||||||
|
|
||||||
signature[4] = 0;
|
signature[4] = 0;
|
||||||
for (i = 0; i < 4;i++)
|
for (i = 0; i < 4;i++)
|
||||||
signature[i] = grub_tolower (curtable->signature[i]);
|
signature[i] = grub_tolower (curtable->signature[i]);
|
||||||
|
|||||||
Reference in new issue
Block a user