2018-03-15 02:13:07 +03:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2013-06-08 04:59:02 +04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: tbprint - Table output utilities
|
|
|
|
*
|
2021-01-15 21:48:25 +03:00
|
|
|
* Copyright (C) 2000 - 2021, Intel Corp.
|
2013-06-08 04:59:02 +04:00
|
|
|
*
|
2018-03-15 02:13:07 +03:00
|
|
|
*****************************************************************************/
|
2013-06-08 04:59:02 +04:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
|
|
|
#include "accommon.h"
|
|
|
|
#include "actables.h"
|
|
|
|
|
|
|
|
#define _COMPONENT ACPI_TABLES
|
|
|
|
ACPI_MODULE_NAME("tbprint")
|
|
|
|
|
|
|
|
/* Local prototypes */
|
|
|
|
static void acpi_tb_fix_string(char *string, acpi_size length);
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
|
|
|
|
struct acpi_table_header *header);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_fix_string
|
|
|
|
*
|
|
|
|
* PARAMETERS: string - String to be repaired
|
|
|
|
* length - Maximum length
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Replace every non-printable or non-ascii byte in the string
|
|
|
|
* with a question mark '?'.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static void acpi_tb_fix_string(char *string, acpi_size length)
|
|
|
|
{
|
|
|
|
|
|
|
|
while (length && *string) {
|
2015-07-01 09:45:11 +03:00
|
|
|
if (!isprint((int)*string)) {
|
2013-06-08 04:59:02 +04:00
|
|
|
*string = '?';
|
|
|
|
}
|
2015-12-29 08:54:36 +03:00
|
|
|
|
2013-06-08 04:59:02 +04:00
|
|
|
string++;
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_cleanup_table_header
|
|
|
|
*
|
|
|
|
* PARAMETERS: out_header - Where the cleaned header is returned
|
|
|
|
* header - Input ACPI table header
|
|
|
|
*
|
|
|
|
* RETURN: Returns the cleaned header in out_header
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Copy the table header and ensure that all "string" fields in
|
|
|
|
* the header consist of printable characters.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_tb_cleanup_table_header(struct acpi_table_header *out_header,
|
|
|
|
struct acpi_table_header *header)
|
|
|
|
{
|
|
|
|
|
2015-07-01 09:45:11 +03:00
|
|
|
memcpy(out_header, header, sizeof(struct acpi_table_header));
|
2013-06-08 04:59:02 +04:00
|
|
|
|
2019-04-08 23:42:25 +03:00
|
|
|
acpi_tb_fix_string(out_header->signature, ACPI_NAMESEG_SIZE);
|
2013-06-08 04:59:02 +04:00
|
|
|
acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE);
|
|
|
|
acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
|
2019-04-08 23:42:25 +03:00
|
|
|
acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAMESEG_SIZE);
|
2013-06-08 04:59:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_print_table_header
|
|
|
|
*
|
|
|
|
* PARAMETERS: address - Table physical address
|
|
|
|
* header - Table header
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
acpi_tb_print_table_header(acpi_physical_address address,
|
|
|
|
struct acpi_table_header *header)
|
|
|
|
{
|
|
|
|
struct acpi_table_header local_header;
|
|
|
|
|
2019-04-08 23:42:24 +03:00
|
|
|
if (ACPI_COMPARE_NAMESEG(header->signature, ACPI_SIG_FACS)) {
|
2013-06-08 04:59:02 +04:00
|
|
|
|
|
|
|
/* FACS only has signature and length fields */
|
|
|
|
|
2016-02-19 09:16:42 +03:00
|
|
|
ACPI_INFO(("%-4.4s 0x%8.8X%8.8X %06X",
|
2015-04-13 06:48:52 +03:00
|
|
|
header->signature, ACPI_FORMAT_UINT64(address),
|
2013-06-08 04:59:02 +04:00
|
|
|
header->length));
|
ACPICA: Avoid subobject buffer overflow when validating RSDP signature
ACPICA commit 6bb72909c1e3d415aee214104a01bc9834b2d4ce
Since the Signature member is accessed through an struct acpi_table_header, the
pointer to it is only to a 4-char array, and so trying to read past the
4th character, as will be done when it is an RSDP, reads beyond the
bounds of the accessed member. On CHERI, and thus Arm's experimental
Morello prototype architecture, pointers are represented as
capabilities, which are unforgeable bounded pointers, providing
always-on fine-grained spatial memory safety. By default, subobject
bounds enforcement is not enabled, only bounds on allocations, but it is
enabled in the cheri_BSD (a port of free_BSD) kernel as intra-object
overflow attacks are common on operating system kernels, and so this
overflow is detected there and traps.
Link: https://github.com/acpica/acpica/commit/6bb72909
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-12-22 19:24:44 +03:00
|
|
|
} else if (ACPI_VALIDATE_RSDP_SIG(ACPI_CAST_PTR(struct acpi_table_rsdp,
|
|
|
|
header)->signature)) {
|
2013-06-08 04:59:02 +04:00
|
|
|
|
|
|
|
/* RSDP has no common fields */
|
|
|
|
|
2015-07-01 09:45:11 +03:00
|
|
|
memcpy(local_header.oem_id,
|
|
|
|
ACPI_CAST_PTR(struct acpi_table_rsdp, header)->oem_id,
|
|
|
|
ACPI_OEM_ID_SIZE);
|
2013-06-08 04:59:02 +04:00
|
|
|
acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE);
|
|
|
|
|
2016-02-19 09:16:42 +03:00
|
|
|
ACPI_INFO(("RSDP 0x%8.8X%8.8X %06X (v%.2d %-6.6s)",
|
2015-04-13 06:48:52 +03:00
|
|
|
ACPI_FORMAT_UINT64(address),
|
2013-06-08 04:59:02 +04:00
|
|
|
(ACPI_CAST_PTR(struct acpi_table_rsdp, header)->
|
|
|
|
revision >
|
|
|
|
0) ? ACPI_CAST_PTR(struct acpi_table_rsdp,
|
|
|
|
header)->length : 20,
|
|
|
|
ACPI_CAST_PTR(struct acpi_table_rsdp,
|
|
|
|
header)->revision,
|
|
|
|
local_header.oem_id));
|
|
|
|
} else {
|
|
|
|
/* Standard ACPI table with full common header */
|
|
|
|
|
|
|
|
acpi_tb_cleanup_table_header(&local_header, header);
|
|
|
|
|
2016-02-19 09:16:42 +03:00
|
|
|
ACPI_INFO(("%-4.4s 0x%8.8X%8.8X"
|
2014-02-08 05:42:01 +04:00
|
|
|
" %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
|
2015-04-13 06:48:52 +03:00
|
|
|
local_header.signature, ACPI_FORMAT_UINT64(address),
|
2013-06-08 04:59:02 +04:00
|
|
|
local_header.length, local_header.revision,
|
|
|
|
local_header.oem_id, local_header.oem_table_id,
|
|
|
|
local_header.oem_revision,
|
|
|
|
local_header.asl_compiler_id,
|
|
|
|
local_header.asl_compiler_revision));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_validate_checksum
|
|
|
|
*
|
|
|
|
* PARAMETERS: table - ACPI table to verify
|
|
|
|
* length - Length of entire table
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
|
|
|
|
* exception on bad checksum.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
|
|
|
|
{
|
|
|
|
u8 checksum;
|
|
|
|
|
2013-09-23 05:52:29 +04:00
|
|
|
/*
|
|
|
|
* FACS/S3PT:
|
|
|
|
* They are the odd tables, have no standard ACPI header and no checksum
|
|
|
|
*/
|
|
|
|
|
2019-04-08 23:42:24 +03:00
|
|
|
if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_S3PT) ||
|
|
|
|
ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
|
2013-09-23 05:52:29 +04:00
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
2013-06-08 04:59:02 +04:00
|
|
|
/* Compute the checksum on the table */
|
|
|
|
|
|
|
|
checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
|
|
|
|
|
|
|
|
/* Checksum ok? (should be zero) */
|
|
|
|
|
|
|
|
if (checksum) {
|
|
|
|
ACPI_BIOS_WARNING((AE_INFO,
|
|
|
|
"Incorrect checksum in table [%4.4s] - 0x%2.2X, "
|
|
|
|
"should be 0x%2.2X",
|
|
|
|
table->signature, table->checksum,
|
|
|
|
(u8)(table->checksum - checksum)));
|
|
|
|
|
|
|
|
#if (ACPI_CHECKSUM_ABORT)
|
|
|
|
return (AE_BAD_CHECKSUM);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_tb_checksum
|
|
|
|
*
|
|
|
|
* PARAMETERS: buffer - Pointer to memory region to be checked
|
|
|
|
* length - Length of this memory region
|
|
|
|
*
|
|
|
|
* RETURN: Checksum (u8)
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Calculates circular checksum of memory region.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
u8 acpi_tb_checksum(u8 *buffer, u32 length)
|
|
|
|
{
|
|
|
|
u8 sum = 0;
|
|
|
|
u8 *end = buffer + length;
|
|
|
|
|
|
|
|
while (buffer < end) {
|
|
|
|
sum = (u8)(sum + *(buffer++));
|
|
|
|
}
|
|
|
|
|
|
|
|
return (sum);
|
|
|
|
}
|