ACPICA: Finish support for the CDAT table
authorBob Moore <robert.moore@intel.com>
Thu, 27 Oct 2022 17:58:36 +0000 (19:58 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Oct 2022 15:28:23 +0000 (17:28 +0200)
ACPICA commit 8ac4e5116f59d6f9ba2fbeb9ce22ab58237a278f

Finish support for the CDAT table, in both the data table compiler and
the disassembler.

Link: https://github.com/acpica/acpica/commit/8ac4e511
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
13 files changed:
drivers/acpi/acpica/Makefile
drivers/acpi/acpica/acglobal.h
drivers/acpi/acpica/actables.h
drivers/acpi/acpica/acutils.h
drivers/acpi/acpica/tbdata.c
drivers/acpi/acpica/tbfadt.c
drivers/acpi/acpica/tbprint.c
drivers/acpi/acpica/tbutils.c
drivers/acpi/acpica/tbxfroot.c
drivers/acpi/acpica/utcksum.c [new file with mode: 0644]
include/acpi/actbl1.h
include/acpi/actbl2.h
tools/power/acpi/tools/acpidump/apdump.c

index 59700433a96e51599adf6306068b03bcb3dceec7..9e0d95d76fff79b5c28a18f790080b1247b5862d 100644 (file)
@@ -155,6 +155,7 @@ acpi-y +=           \
        utalloc.o       \
        utascii.o       \
        utbuffer.o      \
+       utcksum.o       \
        utcopy.o        \
        utexcep.o       \
        utdebug.o       \
index 088d6a7d052cd8925bd6bafb167fb134c2869c9e..777457a5834008764f6e0d3d9640b27261a282df 100644 (file)
@@ -24,6 +24,7 @@ ACPI_GLOBAL(struct acpi_table_list, acpi_gbl_root_table_list);
 
 ACPI_GLOBAL(struct acpi_table_header *, acpi_gbl_DSDT);
 ACPI_GLOBAL(struct acpi_table_header, acpi_gbl_original_dsdt_header);
+ACPI_INIT_GLOBAL(char *, acpi_gbl_CDAT, NULL);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_dsdt_index, ACPI_INVALID_TABLE_INDEX);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_facs_index, ACPI_INVALID_TABLE_INDEX);
 ACPI_INIT_GLOBAL(u32, acpi_gbl_xfacs_index, ACPI_INVALID_TABLE_INDEX);
index f8d7bfd737df27b8ad73050b605ac3a218d57e40..1c29325e4c7f7484578f84e2fec9ae12d0e93fbf 100644 (file)
@@ -124,11 +124,6 @@ void
 acpi_tb_print_table_header(acpi_physical_address address,
                           struct acpi_table_header *header);
 
-u8 acpi_tb_checksum(u8 *buffer, u32 length);
-
-acpi_status
-acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
-
 void acpi_tb_check_dsdt_header(void);
 
 struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
index 6e6270f96bfb9ffe8a944229e97d2fc9c4647b7e..71175b664f49e21dcdeaffd7da7fb783a72e5108 100644 (file)
@@ -158,6 +158,19 @@ u8 acpi_ut_valid_name_char(char character, u32 position);
 
 void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count);
 
+/*
+ * utcksum - Checksum utilities
+ */
+u8 acpi_ut_generate_checksum(void *table, u32 length, u8 original_checksum);
+
+u8 acpi_ut_checksum(u8 *buffer, u32 length);
+
+acpi_status
+acpi_ut_verify_cdat_checksum(struct acpi_table_cdat *cdat_table, u32 length);
+
+acpi_status
+acpi_ut_verify_checksum(struct acpi_table_header *table, u32 length);
+
 /*
  * utnonansi - Non-ANSI C library functions
  */
index a7642b34ce48fafaf88a65e76d9bbbafb6ef6aa8..1f7677e0dbbe58092191476ec338d1c7142d88b2 100644 (file)
@@ -522,7 +522,7 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc,
                /* Verify the checksum */
 
                status =
-                   acpi_tb_verify_checksum(table_desc->pointer,
+                   acpi_ut_verify_checksum(table_desc->pointer,
                                            table_desc->length);
                if (ACPI_FAILURE(status)) {
                        ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
index 31d7ea84a360f4a8df18aa86be9ba7d2b86a47a3..f04dc6051320eb834e1b2770864f2746ef6274a6 100644 (file)
@@ -298,7 +298,7 @@ void acpi_tb_parse_fadt(void)
         * Validate the FADT checksum before we copy the table. Ignore
         * checksum error as we want to try to get the DSDT and FACS.
         */
-       (void)acpi_tb_verify_checksum(table, length);
+       (void)acpi_ut_verify_checksum(table, length);
 
        /* Create a local copy of the FADT in common ACPI 2.0+ format */
 
index 595547db28c060e167b2661aa29fe409a2a51f5e..f07aa9b46f3f78d4232e0e23fefedc28b9f9268e 100644 (file)
@@ -10,6 +10,7 @@
 #include <acpi/acpi.h>
 #include "accommon.h"
 #include "actables.h"
+#include "acutils.h"
 
 #define _COMPONENT          ACPI_TABLES
 ACPI_MODULE_NAME("tbprint")
@@ -39,7 +40,7 @@ static void acpi_tb_fix_string(char *string, acpi_size length)
 {
 
        while (length && *string) {
-               if (!isprint((int)*string)) {
+               if (!isprint((int)(u8)*string)) {
                        *string = '?';
                }
 
@@ -135,77 +136,3 @@ acpi_tb_print_table_header(acpi_physical_address address,
                           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;
-
-       /*
-        * FACS/S3PT:
-        * They are the odd tables, have no standard ACPI header and no checksum
-        */
-
-       if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_S3PT) ||
-           ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
-               return (AE_OK);
-       }
-
-       /* 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);
-}
index 633a823be65fbd33ce889b724b36aa61b25d78e2..17ad9c227d42032b6ffcc2394884875a25d9eeb1 100644 (file)
@@ -299,7 +299,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 
        /* Validate the root table checksum */
 
-       status = acpi_tb_verify_checksum(table, length);
+       status = acpi_ut_verify_checksum(table, length);
        if (ACPI_FAILURE(status)) {
                acpi_os_unmap_memory(table, length);
                return_ACPI_STATUS(status);
index f1c2ab0a4561582a1c6d22bdfa5e994c8dabfc8b..53afd75bbc06b6ebe79ac29a761b0169ee802e28 100644 (file)
@@ -74,14 +74,14 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
 
        /* Check the standard checksum */
 
-       if (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
+       if (acpi_ut_checksum((u8 *)rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
                return (AE_BAD_CHECKSUM);
        }
 
        /* Check extended checksum if table version >= 2 */
 
        if ((rsdp->revision >= 2) &&
-           (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
+           (acpi_ut_checksum((u8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) {
                return (AE_BAD_CHECKSUM);
        }
 
diff --git a/drivers/acpi/acpica/utcksum.c b/drivers/acpi/acpica/utcksum.c
new file mode 100644 (file)
index 0000000..c166e4c
--- /dev/null
@@ -0,0 +1,170 @@
+// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
+/******************************************************************************
+ *
+ * Module Name: utcksum - Support generating table checksums
+ *
+ * Copyright (C) 2000 - 2022, Intel Corp.
+ *
+ *****************************************************************************/
+
+#include <acpi/acpi.h>
+#include "accommon.h"
+#include "acutils.h"
+
+/* This module used for application-level code only */
+
+#define _COMPONENT          ACPI_CA_DISASSEMBLER
+ACPI_MODULE_NAME("utcksum")
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_verify_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.
+ *              Note: We don't have to check for a CDAT here, since CDAT is
+ *              not in the RSDT/XSDT, and the CDAT table is never installed
+ *              via ACPICA.
+ *
+ ******************************************************************************/
+acpi_status acpi_ut_verify_checksum(struct acpi_table_header *table, u32 length)
+{
+       u8 checksum;
+
+       /*
+        * FACS/S3PT:
+        * They are the odd tables, have no standard ACPI header and no checksum
+        */
+       if (ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_S3PT) ||
+           ACPI_COMPARE_NAMESEG(table->signature, ACPI_SIG_FACS)) {
+               return (AE_OK);
+       }
+
+       /* Compute the checksum on the table */
+
+       length = table->length;
+       checksum =
+           acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, table), length,
+                                     table->checksum);
+
+       /* Computed checksum matches table? */
+
+       if (checksum != table->checksum) {
+               ACPI_BIOS_WARNING((AE_INFO,
+                                  "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
+                                  "should be 0x%2.2X",
+                                  table->signature, table->checksum,
+                                  table->checksum - checksum));
+
+#if (ACPI_CHECKSUM_ABORT)
+               return (AE_BAD_CHECKSUM);
+#endif
+       }
+
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_verify_cdat_checksum
+ *
+ * PARAMETERS:  table               - CDAT ACPI table to verify
+ *              length              - Length of entire table
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Verifies that the CDAT table checksums to zero. Optionally
+ *              returns an exception on bad checksum.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ut_verify_cdat_checksum(struct acpi_table_cdat *cdat_table, u32 length)
+{
+       u8 checksum;
+
+       /* Compute the checksum on the table */
+
+       checksum = acpi_ut_generate_checksum(ACPI_CAST_PTR(u8, cdat_table),
+                                            cdat_table->length,
+                                            cdat_table->checksum);
+
+       /* Computed checksum matches table? */
+
+       if (checksum != cdat_table->checksum) {
+               ACPI_BIOS_WARNING((AE_INFO,
+                                  "Incorrect checksum in table [%4.4s] - 0x%2.2X, "
+                                  "should be 0x%2.2X",
+                                  acpi_gbl_CDAT, cdat_table->checksum,
+                                  checksum));
+
+#if (ACPI_CHECKSUM_ABORT)
+               return (AE_BAD_CHECKSUM);
+#endif
+       }
+
+       cdat_table->checksum = checksum;
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_generate_checksum
+ *
+ * PARAMETERS:  table               - Pointer to table to be checksummed
+ *              length              - Length of the table
+ *              original_checksum   - Value of the checksum field
+ *
+ * RETURN:      8 bit checksum of buffer
+ *
+ * DESCRIPTION: Computes an 8 bit checksum of the table.
+ *
+ ******************************************************************************/
+
+u8 acpi_ut_generate_checksum(void *table, u32 length, u8 original_checksum)
+{
+       u8 checksum;
+
+       /* Sum the entire table as-is */
+
+       checksum = acpi_ut_checksum((u8 *)table, length);
+
+       /* Subtract off the existing checksum value in the table */
+
+       checksum = (u8)(checksum - original_checksum);
+
+       /* Compute and return the final checksum */
+
+       checksum = (u8)(0 - checksum);
+       return (checksum);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_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_ut_checksum(u8 *buffer, u32 length)
+{
+       u8 sum = 0;
+       u8 *end = buffer + length;
+
+       while (buffer < end) {
+               sum = (u8)(sum + *(buffer++));
+       }
+
+       return (sum);
+}
index 2aba6f516e70371c75f893418d957754f2be2065..4175dce3967c016783c483be89d3ec92a6711248 100644 (file)
@@ -45,6 +45,7 @@
 #define ACPI_SIG_HMAT           "HMAT" /* Heterogeneous Memory Attributes Table */
 #define ACPI_SIG_HPET           "HPET" /* High Precision Event Timer table */
 #define ACPI_SIG_IBFT           "IBFT" /* iSCSI Boot Firmware Table */
+#define ACPI_SIG_MSCT           "MSCT" /* Maximum System Characteristics Table */
 
 #define ACPI_SIG_S3PT           "S3PT" /* S3 Performance (sub)Table */
 #define ACPI_SIG_PCCS           "PCC"  /* PCC Shared Memory Region */
@@ -303,12 +304,125 @@ struct acpi_table_boot {
        u8 reserved[3];
 };
 
+/*******************************************************************************
+ *
+ * CDAT - Coherent Device Attribute Table
+ *        Version 1
+ *
+ * Conforms to the "Coherent Device Attribute Table (CDAT) Specification
+ " (Revision 1.01, October 2020.)
+ *
+ ******************************************************************************/
+
+struct acpi_table_cdat {
+       u32 length;             /* Length of table in bytes, including this header */
+       u8 revision;            /* ACPI Specification minor version number */
+       u8 checksum;            /* To make sum of entire table == 0 */
+       u8 reserved[6];
+       u32 sequence;           /* Used to detect runtime CDAT table changes */
+};
+
+/* CDAT common subtable header */
+
+struct acpi_cdat_header {
+       u8 type;
+       u8 reserved;
+       u16 length;
+};
+
+/* Values for Type field above */
+
+enum acpi_cdat_type {
+       ACPI_CDAT_TYPE_DSMAS = 0,
+       ACPI_CDAT_TYPE_DSLBIS = 1,
+       ACPI_CDAT_TYPE_DSMSCIS = 2,
+       ACPI_CDAT_TYPE_DSIS = 3,
+       ACPI_CDAT_TYPE_DSEMTS = 4,
+       ACPI_CDAT_TYPE_SSLBIS = 5,
+       ACPI_CDAT_TYPE_RESERVED = 6     /* 6 through 0xFF are reserved */
+};
+
+/* Subtable 0: Device Scoped Memory Affinity Structure (DSMAS) */
+
+struct acpi_cadt_dsmas {
+       u8 dsmad_handle;
+       u8 flags;
+       u16 reserved;
+       u64 dpa_base_address;
+       u64 dpa_length;
+};
+
+/* Flags for subtable above */
+
+#define ACPI_CEDT_DSMAS_NON_VOLATILE        (1 << 2)
+
+/* Subtable 1: Device scoped Latency and Bandwidth Information Structure (DSLBIS) */
+
+struct acpi_cdat_dslbis {
+       u8 handle;
+       u8 flags;               /* If Handle matches a DSMAS handle, the definition of this field matches
+                                * Flags field in HMAT System Locality Latency */
+       u8 data_type;
+       u8 reserved;
+       u64 entry_base_unit;
+       u16 entry[3];
+       u16 reserved2;
+};
+
+/* Subtable 2: Device Scoped Memory Side Cache Information Structure (DSMSCIS) */
+
+struct acpi_cdat_dsmscis {
+       u8 dsmas_handle;
+       u8 reserved[3];
+       u64 side_cache_size;
+       u32 cache_attributes;
+};
+
+/* Subtable 3: Device Scoped Initiator Structure (DSIS) */
+
+struct acpi_cdat_dsis {
+       u8 flags;
+       u8 handle;
+       u16 reserved;
+};
+
+/* Flags for above subtable */
+
+#define ACPI_CDAT_DSIS_MEM_ATTACHED         (1 << 0)
+
+/* Subtable 4: Device Scoped EFI Memory Type Structure (DSEMTS) */
+
+struct acpi_cdat_dsemts {
+       u8 dsmas_handle;
+       u8 memory_type;
+       u16 reserved;
+       u64 dpa_offset;
+       u64 range_length;
+};
+
+/* Subtable 5: Switch Scoped Latency and Bandwidth Information Structure (SSLBIS) */
+
+struct acpi_cdat_sslbis {
+       u8 data_type;
+       u8 reserved[3];
+       u64 entry_base_unit;
+};
+
+/* Sub-subtable for above, sslbe_entries field */
+
+struct acpi_cdat_sslbe {
+       u16 portx_id;
+       u16 porty_id;
+       u16 latency_or_bandwidth;
+       u16 reserved;
+};
+
 /*******************************************************************************
  *
  * CEDT - CXL Early Discovery Table
  *        Version 1
  *
- * Conforms to the "CXL Early Discovery Table" (CXL 2.0)
+ * Conforms to the "CXL Early Discovery Table" (CXL 2.0, October 2020)
  *
  ******************************************************************************/
 
index 05116f5c19a8c6c77bc3de0f9e9cef07fbd4c7ba..b2973dbe37ee96e450a05c26d6a204c711a958f8 100644 (file)
@@ -28,6 +28,7 @@
 #define ACPI_SIG_APMT           "APMT" /* Arm Performance Monitoring Unit table */
 #define ACPI_SIG_BDAT           "BDAT" /* BIOS Data ACPI Table */
 #define ACPI_SIG_CCEL           "CCEL" /* CC Event Log Table */
+#define ACPI_SIG_CDAT           "CDAT" /* Coherent Device Attribute Table */
 #define ACPI_SIG_IORT           "IORT" /* IO Remapping Table */
 #define ACPI_SIG_IVRS           "IVRS" /* I/O Virtualization Reporting Structure */
 #define ACPI_SIG_LPIT           "LPIT" /* Low Power Idle Table */
@@ -35,7 +36,6 @@
 #define ACPI_SIG_MCFG           "MCFG" /* PCI Memory Mapped Configuration table */
 #define ACPI_SIG_MCHI           "MCHI" /* Management Controller Host Interface table */
 #define ACPI_SIG_MPST           "MPST" /* Memory Power State Table */
-#define ACPI_SIG_MSCT           "MSCT" /* Maximum System Characteristics Table */
 #define ACPI_SIG_MSDM           "MSDM" /* Microsoft Data Management Table */
 #define ACPI_SIG_NFIT           "NFIT" /* NVDIMM Firmware Interface Table */
 #define ACPI_SIG_NHLT           "NHLT" /* Non HD Audio Link Table */
index d54dde02b87d750a76c8b52c8102d323b5d6b235..ea44b0ed5dcbbd05d3808ac6368cd19ca5c771c2 100644 (file)
@@ -78,7 +78,9 @@ u8 ap_is_valid_checksum(struct acpi_table_header *table)
                rsdp = ACPI_CAST_PTR(struct acpi_table_rsdp, table);
                status = acpi_tb_validate_rsdp(rsdp);
        } else {
-               status = acpi_tb_verify_checksum(table, table->length);
+               /* We don't have to check for a CDAT here, since CDAT is not in the RSDT/XSDT */
+
+               status = acpi_ut_verify_checksum(table, table->length);
        }
 
        if (ACPI_FAILURE(status)) {