diff options
Diffstat (limited to 'sys')
436 files changed, 5764 insertions, 804 deletions
diff --git a/sys/amd64/linux/linux_locore.asm b/sys/amd64/linux/linux_locore.asm index 19a6ac5d50d8..d4af90bda5fb 100644 --- a/sys/amd64/linux/linux_locore.asm +++ b/sys/amd64/linux/linux_locore.asm @@ -85,3 +85,5 @@ END(linux_rt_sigcode) .balign 4 .previous #endif + + .section .note.GNU-stack,"",%progbits diff --git a/sys/amd64/linux/linux_support.S b/sys/amd64/linux/linux_support.S index 7cc59b205a97..2ab46fe8c5ea 100644 --- a/sys/amd64/linux/linux_support.S +++ b/sys/amd64/linux/linux_support.S @@ -227,3 +227,5 @@ ENTRY(futex_xorl_smap) movq %rax,PCB_ONFAULT(%r8) ret END(futex_xorl_smap) + + .section .note.GNU-stack,"",%progbits diff --git a/sys/amd64/linux32/linux32_locore.asm b/sys/amd64/linux32/linux32_locore.asm index 4b77bd32600e..cc4b0488edb0 100644 --- a/sys/amd64/linux32/linux32_locore.asm +++ b/sys/amd64/linux32/linux32_locore.asm @@ -128,3 +128,5 @@ END(__kernel_vsyscall) .balign 4 .previous #endif + + .section .note.GNU-stack,"",%progbits diff --git a/sys/amd64/linux32/linux32_support.S b/sys/amd64/linux32/linux32_support.S index a316a9bf066d..1018b6ce579c 100644 --- a/sys/amd64/linux32/linux32_support.S +++ b/sys/amd64/linux32/linux32_support.S @@ -227,3 +227,5 @@ ENTRY(futex_xorl_smap) movq %rax,PCB_ONFAULT(%r8) ret END(futex_xorl_smap) + + .section .note.GNU-stack,"",%progbits diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h index 7319d950443b..9fde5fc5d7c9 100644 --- a/sys/arm/include/_types.h +++ b/sys/arm/include/_types.h @@ -57,6 +57,7 @@ typedef __int64_t __int_fast64_t; typedef __int32_t __register_t; typedef __int32_t __segsz_t; /* segment size (in pages) */ typedef __int64_t __time_t; /* time()... */ +#define __SIZEOF_TIME_T __SIZEOF_INT64_T typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; diff --git a/sys/arm64/include/_types.h b/sys/arm64/include/_types.h index 98f7dea67520..c46f64b2b252 100644 --- a/sys/arm64/include/_types.h +++ b/sys/arm64/include/_types.h @@ -55,6 +55,7 @@ typedef __int64_t __int_fast64_t; typedef __int64_t __register_t; typedef __int64_t __segsz_t; /* segment size (in pages) */ typedef __int64_t __time_t; /* time()... */ +#define __SIZEOF_TIME_T __SIZEOF_INT64_T typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; diff --git a/sys/arm64/linux/linux_locore.asm b/sys/arm64/linux/linux_locore.asm index c330546702f1..20846a324647 100644 --- a/sys/arm64/linux/linux_locore.asm +++ b/sys/arm64/linux/linux_locore.asm @@ -51,3 +51,5 @@ __user_rt_sigreturn: mov x8, #LINUX_SYS_linux_rt_sigreturn svc #0 EEND(__kernel_rt_sigreturn) + + .section .note.GNU-stack,"",%progbits diff --git a/sys/arm64/linux/linux_support.S b/sys/arm64/linux/linux_support.S index 3b16583e9d54..61a0604dd91b 100644 --- a/sys/arm64/linux/linux_support.S +++ b/sys/arm64/linux/linux_support.S @@ -176,3 +176,5 @@ ENTRY(futex_xorl) END(futex_xorl) GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) + + .section .note.GNU-stack,"",%progbits diff --git a/sys/compat/linux/linux_vdso_inc.S b/sys/compat/linux/linux_vdso_inc.S index 44cc357b4a4a..d2ac3e28aabe 100644 --- a/sys/compat/linux/linux_vdso_inc.S +++ b/sys/compat/linux/linux_vdso_inc.S @@ -37,3 +37,5 @@ _binary_linux_vdso_so_o_end: #include <machine/asm.h> GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) #endif + + .section .note.GNU-stack,"",%progbits diff --git a/sys/compat/linuxkpi/common/src/linux_acpi.c b/sys/compat/linuxkpi/common/src/linux_acpi.c index c7d62c745c7e..85a3afe5d01d 100644 --- a/sys/compat/linuxkpi/common/src/linux_acpi.c +++ b/sys/compat/linuxkpi/common/src/linux_acpi.c @@ -131,7 +131,7 @@ linux_handle_power_suspend_event(void *arg __unused, enum power_stype stype) linux_acpi_target_sleep_state = ACPI_STATE_S3; pm_suspend_target_state = PM_SUSPEND_TO_IDLE; break; - case POWER_STYPE_SUSPEND_TO_MEM: + case POWER_STYPE_FW_SUSPEND: linux_acpi_target_sleep_state = ACPI_STATE_S3; pm_suspend_target_state = PM_SUSPEND_MEM; break; diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index 90a74367a54f..58a31b5f326e 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -6,6 +6,7 @@ cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${ crypto/des/des_enc.c optional netsmb dev/cpufreq/cpufreq_dt.c optional cpufreq fdt dev/ofw/ofw_cpu.c optional fdt +dev/ofw/ofw_pci.c optional pci fdt dev/ofw/ofw_pcib.c optional pci fdt dev/pci/pci_dw.c optional pci fdt dev/pci/pci_dw_if.m optional pci fdt @@ -42,6 +43,14 @@ libkern/memset.c standard libkern/strcmp.c standard libkern/strlen.c standard libkern/strncmp.c standard +riscv/iommu/iommu_frontend.c standard +riscv/iommu/iommu_if.m standard +riscv/iommu/iommu.c standard +riscv/iommu/iommu_fdt.c optional fdt +riscv/iommu/iommu_pci.c optional pci +riscv/iommu/iommu_pmap.c optional iommu +dev/iommu/busdma_iommu.c optional iommu +dev/iommu/iommu_gas.c optional iommu riscv/riscv/aplic.c standard riscv/riscv/autoconf.c standard riscv/riscv/bus_machdep.c standard diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index 2c13c692d194..9c1952e49d50 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,4 +1,28 @@ ---------------------------------------- +8 April 2026. Summary of changes for version 20260804: + +Major changes: + +• ACPI Table Enhancements: +Updated IORT and MADT template compilations to add new IWB and GICv5 translator/router/ITS entries. Introduced full support for the new DTPR table, including compiler and disassembler handling, template fixes, and register structure refinements. — Jose Marinho and Michal Camacho Romero + +• Expanded IDs, GUIDs, and Methods: +Added Framework Computer Hardware IDs, modern standby _DSM GUIDs, and TPM2 start methods. Updated _DSM Arg3 formatting and _CPC handling to align with newer ACPI specifications and avoid Linux compatibility warnings. — Daniel Schaefer and Saket Dumbre + +• Compiler, Disassembler, and Tooling Improvements: +Enhanced the ASL compiler and disassembler with External() deduplication, alias node support, improved validation of malformed inputs, and comma-separated Package output. Updated acpisrc to recognize missing structures and improved parse tree walk termination logic. — ikaros and Pawel Chmielewski + +• Security and Stability Fixes: +Fixed multiple critical issues, including heap-buffer-overflows, use-after-free, NULL pointer dereferences, integer overflows, and out-of-bounds accesses across AML parsing, interpretation, and table handling code paths. — ikaros and Weiming Shi + +• Resource and Register Refactoring: +Corrected I2C LVR resource descriptor handling and refactored TPR Base/Limit registers to use compatible bitmask representations, with additional validation and cleanup across DTPR-related code. — Akhil R and Michal Camacho Romero + +• General Cleanup and Build Fixes: +Fixed a syntax error caused by a stray character, corrected spelling issues, improved comment alignment and formatting, updated dummy compiler metadata, and disabled excessive MSVC bitfield warnings (C4214) to improve build clarity. — Colin Ian King and Saket Dumbre + + +---------------------------------------- 12 December 2025. Summary of changes for version 20251212: Major changes: diff --git a/sys/contrib/dev/acpica/common/acfileio.c b/sys/contrib/dev/acpica/common/acfileio.c index 19274cb4bdd3..4ae0db12b09b 100644 --- a/sys/contrib/dev/acpica/common/acfileio.c +++ b/sys/contrib/dev/acpica/common/acfileio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -452,6 +452,15 @@ AcGetOneTableFromFile ( TableLength = TableHeader.Length; } + /* Table length must be at least large enough to hold the header */ + + if (TableLength < HeaderLength) + { + fprintf (stderr, "Table length too small for header: 0x%.2X\n", + TableLength); + return (AE_BAD_HEADER); + } + /* Allocate a buffer for the entire table */ Table = AcpiOsAllocate ((ACPI_SIZE) TableLength); diff --git a/sys/contrib/dev/acpica/common/acgetline.c b/sys/contrib/dev/acpica/common/acgetline.c index 2793f26077bb..8ad4f5174d41 100644 --- a/sys/contrib/dev/acpica/common/acgetline.c +++ b/sys/contrib/dev/acpica/common/acgetline.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/adfile.c b/sys/contrib/dev/acpica/common/adfile.c index f87b329d918d..dbf0eaeb2a2e 100644 --- a/sys/contrib/dev/acpica/common/adfile.c +++ b/sys/contrib/dev/acpica/common/adfile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index 83125098cbd1..7016d46dc849 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/adwalk.c b/sys/contrib/dev/acpica/common/adwalk.c index b7484315fe51..cd5c2b1d0911 100644 --- a/sys/contrib/dev/acpica/common/adwalk.c +++ b/sys/contrib/dev/acpica/common/adwalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/ahids.c b/sys/contrib/dev/acpica/common/ahids.c index 81b21253feef..7f011ec10201 100644 --- a/sys/contrib/dev/acpica/common/ahids.c +++ b/sys/contrib/dev/acpica/common/ahids.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -202,6 +202,14 @@ const AH_DEVICE_ID AslDeviceIds[] = {"CPLM3218", "Capella Micro CM3218x Ambient Light Sensor"}, {"DELLABCE", "Dell Airplane Mode Switch Driver"}, {"DLAC3002", "Qualcomm Atheros Bluetooth UART Transport"}, + {"FRMW0001", "Framework I2C HID from EC (Laptop 13 Intel 11-13th Gen)"}, + {"FRMW0002", "Framework PS2 Touchpad Emulation"}, + {"FRMW0003", "Framework I2C HID from EC (Laptop 16 AMD Ryzen 7040)"}, + {"FRMW0004", "Framework I2C HID from EC for keyboard media ikeys"}, + {"FRMW0005", "Framework I2C HID from EC for ALS Sensor"}, + {"FRMW0006", "Framework Desktop ARGB HID Interface (Chrome EC RGBKBD)"}, + {"FRMWC004", "Framework EC Controller"}, + {"FRMWC006", "Framework EC Sensor Hub"}, {"FTTH5506", "FocalTech 5506 Touch Controller"}, {"HAD0F28", "Intel HDMI Audio Driver"}, {"INBC0000", "GPIO Expander"}, diff --git a/sys/contrib/dev/acpica/common/ahpredef.c b/sys/contrib/dev/acpica/common/ahpredef.c index 3a94a24897ae..10a56aba7dc9 100644 --- a/sys/contrib/dev/acpica/common/ahpredef.c +++ b/sys/contrib/dev/acpica/common/ahpredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/ahtable.c b/sys/contrib/dev/acpica/common/ahtable.c index 109a723fd93d..7bde21e2264e 100644 --- a/sys/contrib/dev/acpica/common/ahtable.c +++ b/sys/contrib/dev/acpica/common/ahtable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -216,6 +216,7 @@ const AH_TABLE AcpiGbl_SupportedTables[] = {ACPI_SIG_DBGP, "Debug Port Table"}, {ACPI_SIG_DMAR, "DMA Remapping Table"}, {ACPI_SIG_DRTM, "Dynamic Root of Trust for Measurement Table"}, + {ACPI_SIG_DTPR, "DMA TXT Protection Ranges Table"}, {ACPI_SIG_DSDT, "Differentiated System Description Table (AML table)"}, {ACPI_SIG_ECDT, "Embedded Controller Boot Resources Table"}, {ACPI_SIG_EINJ, "Error Injection Table"}, diff --git a/sys/contrib/dev/acpica/common/ahuuids.c b/sys/contrib/dev/acpica/common/ahuuids.c index b87de1cdff82..40906109ae3e 100644 --- a/sys/contrib/dev/acpica/common/ahuuids.c +++ b/sys/contrib/dev/acpica/common/ahuuids.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -204,6 +204,11 @@ const AH_UUID Gbl_AcpiUuids[] = {"Cache Properties", UUID_CACHE_PROPERTIES}, {"Physical Package Property", UUID_PHYSICAL_PROPERTY}, + {"[Modern Standby]", NULL}, + {"Modern Standby Microsoft", UUID_LPS0_MICROSOFT}, + {"Modern Standby Intel", UUID_LPS0_INTEL}, + {"Modern Standby AMD", UUID_LPS0_AMD}, + {"[Miscellaneous]", NULL}, {"Platform-wide Capabilities", UUID_PLATFORM_CAPABILITIES}, {"Dynamic Enumeration", UUID_DYNAMIC_ENUMERATION}, diff --git a/sys/contrib/dev/acpica/common/cmfsize.c b/sys/contrib/dev/acpica/common/cmfsize.c index c6cedf9a0866..8e6bee607564 100644 --- a/sys/contrib/dev/acpica/common/cmfsize.c +++ b/sys/contrib/dev/acpica/common/cmfsize.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmextern.c b/sys/contrib/dev/acpica/common/dmextern.c index d2eeffdfe02e..405139beb815 100644 --- a/sys/contrib/dev/acpica/common/dmextern.c +++ b/sys/contrib/dev/acpica/common/dmextern.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmrestag.c b/sys/contrib/dev/acpica/common/dmrestag.c index 8c7cc4b9ef7c..95300444b9dc 100644 --- a/sys/contrib/dev/acpica/common/dmrestag.c +++ b/sys/contrib/dev/acpica/common/dmrestag.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmswitch.c b/sys/contrib/dev/acpica/common/dmswitch.c index 8d5ca2e016a7..9d7b48ccacd4 100644 --- a/sys/contrib/dev/acpica/common/dmswitch.c +++ b/sys/contrib/dev/acpica/common/dmswitch.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c index 140d279a486c..d7a42323c20c 100644 --- a/sys/contrib/dev/acpica/common/dmtable.c +++ b/sys/contrib/dev/acpica/common/dmtable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -568,6 +568,10 @@ static const char *AcpiDmTpm2Subnames[] = "Reserved", "Reserved", "Command Response Buffer with ARM SMC", + "FIFO over I2C", + "Command Response Buffer with AMD Mailbox", + "Reserved", + "Command Response Buffer with ARM Framework-A", "Unknown Subtable Type" /* Reserved */ }; @@ -700,6 +704,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] = {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp}, {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar}, {ACPI_SIG_DRTM, NULL, AcpiDmDumpDrtm, DtCompileDrtm, TemplateDrtm}, + {ACPI_SIG_DTPR, NULL, AcpiDmDumpDtpr, DtCompileDtpr, TemplateDtpr}, {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt}, {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj}, {ACPI_SIG_ERDT, NULL, AcpiDmDumpErdt, DtCompileErdt, TemplateErdt}, diff --git a/sys/contrib/dev/acpica/common/dmtables.c b/sys/contrib/dev/acpica/common/dmtables.c index c72f6451154c..8ec0077c3c38 100644 --- a/sys/contrib/dev/acpica/common/dmtables.c +++ b/sys/contrib/dev/acpica/common/dmtables.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c index aa8b5aa76892..bb4f75b70aeb 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump.c +++ b/sys/contrib/dev/acpica/common/dmtbdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtbdump1.c b/sys/contrib/dev/acpica/common/dmtbdump1.c index 3453ed479a22..5d2758c49acc 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump1.c +++ b/sys/contrib/dev/acpica/common/dmtbdump1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -1672,6 +1672,115 @@ AcpiDmDumpDrtm ( /******************************************************************************* * + * FUNCTION: AcpiDmDumpDtpr + * + * PARAMETERS: Table - A DTPR table + * + * RETURN: None + * + * DESCRIPTION: Format the contents of a DTPR. + * + ******************************************************************************/ + +void +AcpiDmDumpDtpr ( + ACPI_TABLE_HEADER *Table) +{ + ACPI_STATUS Status; + ACPI_TPR_ARRAY *TprArr; + ACPI_TPR_INSTANCE *TprInstance; + ACPI_TPR_AUX_SR *TprAuxSr; + ACPI_TPR_SERIALIZE_REQUEST *TprSerializeRequest; + UINT32 i = 0, j, InsCnt, TprRefCnt; + UINT32 Offset = sizeof(ACPI_TABLE_DTPR); + + /* Main table */ + + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoDtpr); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Subtables */ + + while (Offset < Table->Length) + { + InsCnt = ((ACPI_TABLE_DTPR*) Table)->InsCnt; + + for (i = 0; i < InsCnt; i++) + { + TprInstance = ACPI_ADD_PTR(ACPI_TPR_INSTANCE, Table, Offset); + Status = AcpiDmDumpTable(Table->Length, Offset, TprInstance, + sizeof(ACPI_TPR_INSTANCE), AcpiDmTableInfoDtprInstance); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Each of the TPR instances must have the same number of TPRs*/ + TprRefCnt = TprInstance->TprCnt; + + Offset += sizeof(ACPI_TPR_INSTANCE); + + if (TprInstance->TprCnt < 2) + { + AcpiOsPrintf("TPR Instance No.%d has invalid number of TPRs.\n" + "There should be at least 2 of them, but there is %d.", + i, TprInstance->TprCnt); + return; + } + else + { + if (TprInstance->TprCnt != TprRefCnt) + { + AcpiOsPrintf("Each of TPR instances should have equal\n" + "number of TPRs. TprInstance No.%d has %d TPRs" + ", while the reference TPR instance has %d.\n", + i, TprInstance->TprCnt, TprRefCnt); + return; + } + } + + for (j = 0; j < TprInstance->TprCnt; j++) + { + TprArr = ACPI_ADD_PTR(ACPI_TPR_ARRAY, Table, Offset); + Status = AcpiDmDumpTable(Table->Length, Offset, TprArr, + sizeof(ACPI_TPR_ARRAY), AcpiDmTableInfoDtprArr); + if (ACPI_FAILURE (Status)) + { + return; + } + + Offset += sizeof(ACPI_TPR_ARRAY); + } + } + + TprAuxSr = ACPI_ADD_PTR(ACPI_TPR_AUX_SR, Table, Offset); + Status = AcpiDmDumpTable(Table->Length, Offset, TprAuxSr, + sizeof(ACPI_TPR_AUX_SR), AcpiDmTableInfoDtprSerializeReq0); + + Offset += sizeof(ACPI_TPR_AUX_SR); + + for (i = 0; i < TprAuxSr->SrlCnt; i++) + { + TprSerializeRequest = ACPI_ADD_PTR(ACPI_TPR_SERIALIZE_REQUEST, + Table, Offset); + Status = AcpiDmDumpTable(Table->Length, Offset, TprSerializeRequest, + sizeof(ACPI_TPR_SERIALIZE_REQUEST), AcpiDmTableInfoDtprSerializeReq1); + if (ACPI_FAILURE (Status)) + { + return; + } + + Offset += sizeof(ACPI_TPR_SERIALIZE_REQUEST); + } + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmDumpEinj * * PARAMETERS: Table - A EINJ table diff --git a/sys/contrib/dev/acpica/common/dmtbdump2.c b/sys/contrib/dev/acpica/common/dmtbdump2.c index 957b3b00f216..21309e9c7869 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump2.c +++ b/sys/contrib/dev/acpica/common/dmtbdump2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtbdump3.c b/sys/contrib/dev/acpica/common/dmtbdump3.c index 458b94f6ee08..e827bf8e50cc 100644 --- a/sys/contrib/dev/acpica/common/dmtbdump3.c +++ b/sys/contrib/dev/acpica/common/dmtbdump3.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtbinfo.c b/sys/contrib/dev/acpica/common/dmtbinfo.c index 937ad013f079..afa3115fcbdc 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/dmtbinfo1.c b/sys/contrib/dev/acpica/common/dmtbinfo1.c index 49c0f6f2a31c..40d6dfc27a71 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo1.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -1155,6 +1155,44 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm2[] = /******************************************************************************* * + * DTPR - DMA TXT Protection Ranges Table + * + ******************************************************************************/ + +ACPI_DMTABLE_INFO AcpiDmTableInfoDtpr[] = +{ + {ACPI_DMT_UINT32, ACPI_DTPR_OFFSET (Flags), "Flags (reserved)", 0}, + {ACPI_DMT_UINT32, ACPI_DTPR_OFFSET (InsCnt), "Instance Count", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoDtprInstance[] = +{ + {ACPI_DMT_UINT32, ACPI_DTPR_INST_OFFSET (Flags), "Instance control flags (reserved)", 0}, + {ACPI_DMT_UINT32, ACPI_DTPR_INST_OFFSET (TprCnt), "Number of TPR ranges in instance", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoDtprArr[] = +{ + {ACPI_DMT_UINT64, ACPI_DTPR_ARR_OFFSET (Base), "TPR Base Address", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoDtprSerializeReq0[] = +{ + {ACPI_DMT_UINT32, ACPI_DTPR_AUX_SR_OFFSET (SrlCnt), "Number of serialization registers", 0}, + ACPI_DMT_TERMINATOR +}; + +ACPI_DMTABLE_INFO AcpiDmTableInfoDtprSerializeReq1[] = +{ + {ACPI_DMT_UINT64, ACPI_DTPR_SR_OFFSET (SrRegister), "Serialize Request register", 0}, + ACPI_DMT_TERMINATOR +}; + +/******************************************************************************* + * * ECDT - Embedded Controller Boot Resources Table * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/common/dmtbinfo2.c b/sys/contrib/dev/acpica/common/dmtbinfo2.c index d4ebc9f49074..fd6a11a7aa84 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo2.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -1243,7 +1243,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt30[] = { {ACPI_DMT_UINT16, ACPI_MADT30_OFFSET (Reserved), "Reserved", 0}, {ACPI_DMT_UINT32, ACPI_MADT30_OFFSET (LinkedTranslatorId), "Linked Its Id", 0}, - {ACPI_DMT_UINT32, ACPI_MADT30_OFFSET (TranslateFrameId), "Its Transalte Id", 0}, + {ACPI_DMT_UINT32, ACPI_MADT30_OFFSET (TranslateFrameId), "Its Translate Id", 0}, {ACPI_DMT_UINT32, ACPI_MADT30_OFFSET (Reserved2), "Reserved", 0}, {ACPI_DMT_UINT64, ACPI_MADT30_OFFSET (BaseAddress), "Its Translate Frame Physical Base Address", 0}, ACPI_DMT_TERMINATOR diff --git a/sys/contrib/dev/acpica/common/dmtbinfo3.c b/sys/contrib/dev/acpica/common/dmtbinfo3.c index d7cdc90cd993..88728e27a698 100644 --- a/sys/contrib/dev/acpica/common/dmtbinfo3.c +++ b/sys/contrib/dev/acpica/common/dmtbinfo3.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/common/getopt.c b/sys/contrib/dev/acpica/common/getopt.c index 535e7a00bc8f..3af472ffe13d 100644 --- a/sys/contrib/dev/acpica/common/getopt.c +++ b/sys/contrib/dev/acpica/common/getopt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslallocate.c b/sys/contrib/dev/acpica/compiler/aslallocate.c index 57e538b534e5..4d0aef2b4142 100644 --- a/sys/contrib/dev/acpica/compiler/aslallocate.c +++ b/sys/contrib/dev/acpica/compiler/aslallocate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index 625611a630de..015119ba4e78 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c index 1de3d763c765..700ad30045f2 100644 --- a/sys/contrib/dev/acpica/compiler/aslascii.c +++ b/sys/contrib/dev/acpica/compiler/aslascii.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslbtypes.c b/sys/contrib/dev/acpica/compiler/aslbtypes.c index 539cd7977b4e..a11b1f465d9e 100644 --- a/sys/contrib/dev/acpica/compiler/aslbtypes.c +++ b/sys/contrib/dev/acpica/compiler/aslbtypes.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslcache.c b/sys/contrib/dev/acpica/compiler/aslcache.c index 9f917ff32945..93309f90093f 100644 --- a/sys/contrib/dev/acpica/compiler/aslcache.c +++ b/sys/contrib/dev/acpica/compiler/aslcache.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index 684c59f802e9..f329f3738f8b 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -586,14 +586,16 @@ CgWriteTableHeader ( /* OEMID */ Child = Child->Asl.Next; - memcpy (AslGbl_TableHeader.OemId, Child->Asl.Value.String, - strlen (Child->Asl.Value.String)); + /* Bound copy to header field size to avoid overflow on malformed input */ + strncpy (AslGbl_TableHeader.OemId, Child->Asl.Value.String, + ACPI_OEM_ID_SIZE); /* OEM TableID */ Child = Child->Asl.Next; - memcpy (AslGbl_TableHeader.OemTableId, Child->Asl.Value.String, - strlen (Child->Asl.Value.String)); + /* Bound copy to header field size to avoid overflow on malformed input */ + strncpy (AslGbl_TableHeader.OemTableId, Child->Asl.Value.String, + ACPI_OEM_TABLE_ID_SIZE); /* OEM Revision */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 6e8ce6aae2c9..696da41ba46d 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index d131b949252a..d877357d4345 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index 5e94f9626018..bde40db4c00e 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslcstyle.y b/sys/contrib/dev/acpica/compiler/aslcstyle.y index 59a1abea1bee..6384a1e932d6 100644 --- a/sys/contrib/dev/acpica/compiler/aslcstyle.y +++ b/sys/contrib/dev/acpica/compiler/aslcstyle.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asldebug.c b/sys/contrib/dev/acpica/compiler/asldebug.c index 18b68dea6de0..bb5e0bbdb047 100644 --- a/sys/contrib/dev/acpica/compiler/asldebug.c +++ b/sys/contrib/dev/acpica/compiler/asldebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h index 89b6b8a69956..5f694efe40df 100644 --- a/sys/contrib/dev/acpica/compiler/asldefine.h +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index ff01bef7b4b7..6612af39fa94 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslexternal.c b/sys/contrib/dev/acpica/compiler/aslexternal.c index e2f082593c5d..83ba04f573f5 100644 --- a/sys/contrib/dev/acpica/compiler/aslexternal.c +++ b/sys/contrib/dev/acpica/compiler/aslexternal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -170,6 +170,10 @@ static void ExMoveExternals ( ACPI_PARSE_OBJECT *DefinitionBlockOp); +static void +ExRemoveOpFromTree ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -194,9 +198,14 @@ ExDoExternal ( ACPI_PARSE_OBJECT *ArgCountOp; ACPI_PARSE_OBJECT *TypeOp; ACPI_PARSE_OBJECT *ExternTypeOp = Op->Asl.Child->Asl.Next; + ACPI_PARSE_OBJECT *Existing; + ACPI_PARSE_OBJECT *NameOp = Op->Asl.Child; + ACPI_PARSE_OBJECT *ExistingNameOp; UINT32 ExternType; UINT8 ParamCount = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS; UINT32 ParamTypes[ACPI_METHOD_NUM_ARGS]; + char *NewPath = NULL; + char *ExistingPath; ExternType = AnMapObjTypeToBtype (ExternTypeOp); @@ -250,6 +259,53 @@ ExDoExternal ( ArgCountOp->Asl.Value.Integer = ParamCount; UtSetParseOpName (ArgCountOp); + /* + * Deduplicate identical External() declarations. The disassembler + * already collapses duplicates; mirror that behavior in the compiler + * so duplicate externals do not bloat emitted AML. + */ + + NewPath = NameOp->Asl.Namepath; + if (!NewPath && NameOp->Asl.Value.String) + { + (void) UtInternalizeName (NameOp->Asl.Value.String, &NewPath); + NameOp->Asl.Namepath = NewPath; + } + + Existing = AslGbl_ExternalsListHead; + while (Existing && NewPath) + { + ExistingNameOp = Existing->Asl.Child->Asl.Child; + ExistingPath = ExistingNameOp->Asl.Namepath; + if (!ExistingPath && ExistingNameOp->Asl.Value.String) + { + (void) UtInternalizeName (ExistingNameOp->Asl.Value.String, + &ExistingPath); + ExistingNameOp->Asl.Namepath = ExistingPath; + } + + if (ExistingPath && !strcmp (NewPath, ExistingPath)) + { + ACPI_PARSE_OBJECT *ExistingArgCount; + + /* Update arg count if this instance is more specific */ + + ExistingArgCount = Existing->Asl.Child->Asl.Child->Asl.Next->Asl.Next; + if ((ExternType == ACPI_BTYPE_METHOD) && + (ParamCount < ExistingArgCount->Asl.Value.Integer)) + { + ExistingArgCount->Asl.Value.Integer = ParamCount; + } + + /* Remove duplicate External node from the parse tree */ + + ExRemoveOpFromTree (Op); + return; + } + + Existing = Existing->Asl.Next; + } + /* Create new list node of arbitrary type */ ListOp = TrAllocateOp (PARSEOP_DEFAULT_ARG); @@ -282,6 +338,53 @@ ExDoExternal ( /******************************************************************************* * + * FUNCTION: ExRemoveOpFromTree + * + * PARAMETERS: Op - Parse op to remove from the tree + * + * RETURN: None + * + * DESCRIPTION: Unlink a parse op from its parent sibling list. Used to drop + * duplicate External() declarations before AML emission. + * + ******************************************************************************/ + +static void +ExRemoveOpFromTree ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Child; + + + if (!Op || !Op->Asl.Parent) + { + return; + } + + Parent = Op->Asl.Parent; + Child = Parent->Asl.Child; + + if (Child == Op) + { + Parent->Asl.Child = Op->Asl.Next; + return; + } + + while (Child && Child->Asl.Next != Op) + { + Child = Child->Asl.Next; + } + + if (Child) + { + Child->Asl.Next = Op->Asl.Next; + } +} + + +/******************************************************************************* + * * FUNCTION: ExInsertArgCount * * PARAMETERS: Op - Op for a method invocation diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c index 4bf18404b1f5..e3dfaa6ebf6e 100644 --- a/sys/contrib/dev/acpica/compiler/aslfileio.c +++ b/sys/contrib/dev/acpica/compiler/aslfileio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index 0cad8eff47e8..4528d17764f0 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 89107297588b..ecf4c683b78b 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index c79758919f6f..0f2d5931cec8 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -252,6 +252,7 @@ extern FILE *AslCompilerin; extern int DtParserdebug; extern int PrParserdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; +extern const UINT32 AslKeywordMappingCount; extern char *AslCompilertext; extern char *DtCompilerParsertext; diff --git a/sys/contrib/dev/acpica/compiler/aslhelp.c b/sys/contrib/dev/acpica/compiler/aslhelp.c index fcec07e67e70..0f6421ceba97 100644 --- a/sys/contrib/dev/acpica/compiler/aslhelp.c +++ b/sys/contrib/dev/acpica/compiler/aslhelp.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslhelpers.y b/sys/contrib/dev/acpica/compiler/aslhelpers.y index cb13d1ebcfe7..728ea9bd810c 100644 --- a/sys/contrib/dev/acpica/compiler/aslhelpers.y +++ b/sys/contrib/dev/acpica/compiler/aslhelpers.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslhex.c b/sys/contrib/dev/acpica/compiler/aslhex.c index 927e50f24c1d..e0d8831e2a4a 100644 --- a/sys/contrib/dev/acpica/compiler/aslhex.c +++ b/sys/contrib/dev/acpica/compiler/aslhex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslkeywords.y b/sys/contrib/dev/acpica/compiler/aslkeywords.y index 7cb670e61bfb..bdd42231cf55 100644 --- a/sys/contrib/dev/acpica/compiler/aslkeywords.y +++ b/sys/contrib/dev/acpica/compiler/aslkeywords.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index 136ca5823001..e2acc91755b9 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index 2a6341bb59e1..3c76672f0bef 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asllistsup.c b/sys/contrib/dev/acpica/compiler/asllistsup.c index 3458e28062de..f173d80de95d 100644 --- a/sys/contrib/dev/acpica/compiler/asllistsup.c +++ b/sys/contrib/dev/acpica/compiler/asllistsup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index c88fb13aba78..8aa3dce5b655 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -1406,6 +1406,8 @@ LdNamespace2Begin ( /* Save the target node within the alias node as well as type information */ + /* Mark as alias node and store target namespace node */ + Node->Flags |= ANOBJ_IS_ALIAS; Node->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); Node->Type = TargetNode->Type; if (Node->Type == ACPI_TYPE_METHOD) diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index 3dfdb1fce21e..c5885ea85786 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index ff22dec73369..21124cd1cabf 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index 4711b884a57c..08c1d5bdd36b 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -611,3 +611,5 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /*! [End] no source code translation !*/ }; + +const UINT32 AslKeywordMappingCount = ACPI_ARRAY_LENGTH (AslKeywordMapping); diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c index 81b57cb3f13d..032d953c596c 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapenter.c +++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c index a009f64bc98d..86299dd5b783 100644 --- a/sys/contrib/dev/acpica/compiler/aslmapoutput.c +++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslmaputils.c b/sys/contrib/dev/acpica/compiler/aslmaputils.c index f978e6a940b3..bafdca0322ce 100644 --- a/sys/contrib/dev/acpica/compiler/aslmaputils.c +++ b/sys/contrib/dev/acpica/compiler/aslmaputils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c index 1e363236a149..f7c121ca990d 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.c +++ b/sys/contrib/dev/acpica/compiler/aslmessages.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -412,7 +412,8 @@ const char *AslTableCompilerMsgs [] = /* ASL_MSG_UNKNOWN_FORMAT */ "Unknown format value", /* ASL_MSG_RESERVED_VALUE */ "Value for field is reserved or unknown", /* ASL_MSG_TWO_ZERO_VALUES */ "32-bit DSDT Address and 64-bit X_DSDT Address cannot both be zero", -/* ASL_MSG_BAD_PARSE_TREE */ "Parse tree appears to be ill-defined" +/* ASL_MSG_BAD_PARSE_TREE */ "Parse tree appears to be ill-defined", +/* ASL_MSG_MALFORMED_HEADER */ "Malformed ACPI table header detected" }; /* Preprocessor */ diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h index dc0bbe10bd0d..f8ef09bbe9d3 100644 --- a/sys/contrib/dev/acpica/compiler/aslmessages.h +++ b/sys/contrib/dev/acpica/compiler/aslmessages.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -414,6 +414,7 @@ typedef enum ASL_MSG_RESERVED_VALUE, ASL_MSG_TWO_ZERO_VALUES, ASL_MSG_BAD_PARSE_TREE, + ASL_MSG_MALFORMED_HEADER, /* These messages are used by the Preprocessor only */ diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c index 75096d38999e..6844890ce710 100644 --- a/sys/contrib/dev/acpica/compiler/aslmethod.c +++ b/sys/contrib/dev/acpica/compiler/aslmethod.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslnamesp.c b/sys/contrib/dev/acpica/compiler/aslnamesp.c index 9388d7428db6..e15421ec6df2 100644 --- a/sys/contrib/dev/acpica/compiler/aslnamesp.c +++ b/sys/contrib/dev/acpica/compiler/aslnamesp.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asloffset.c b/sys/contrib/dev/acpica/compiler/asloffset.c index d60c4c4ec367..097bedd495fd 100644 --- a/sys/contrib/dev/acpica/compiler/asloffset.c +++ b/sys/contrib/dev/acpica/compiler/asloffset.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index 8bef46b0d7ae..35f661331a9c 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -863,6 +863,14 @@ OpcGenerateAmlOpcode ( Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE); + if ((Op->Asl.ParseOpcode < ASL_PARSE_OPCODE_BASE) || + (Index >= AslKeywordMappingCount)) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "Invalid parse opcode in OpcGenerateAmlOpcode"); + return; + } + Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode; Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype; Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags; diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index 1978b38b1cff..6e77ae165f87 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -851,7 +851,9 @@ OpnDoPackage ( { ACPI_PARSE_OBJECT *InitializerOp; ACPI_PARSE_OBJECT *PackageLengthOp; + UINT64 DeclaredLength; UINT32 PackageLength = 0; + UINT32 MaxEncodedLength = 0x0FFFFFFF; /* Max AML package length encoding (28 bits) */ /* Opcode and package length first, followed by the initializer list */ @@ -875,9 +877,21 @@ OpnDoPackage ( /* If package length is a constant, compare to the initializer list */ if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || - (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)) + (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) || + (PackageLengthOp->Asl.ParseOpcode == PARSEOP_PACKAGE_LENGTH)) { - if (PackageLengthOp->Asl.Value.Integer > PackageLength) + DeclaredLength = PackageLengthOp->Asl.Value.Integer; + + /* Guard against values that cannot be encoded in AML package length format */ + + if (DeclaredLength > MaxEncodedLength) + { + AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, PackageLengthOp, NULL); + DeclaredLength = MaxEncodedLength; + PackageLengthOp->Asl.Value.Integer = DeclaredLength; + } + + if (DeclaredLength > PackageLength) { /* * Allow package length to be longer than the initializer @@ -891,9 +905,9 @@ OpnDoPackage ( PackageLengthOp, NULL); } - PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer; + PackageLength = (UINT32) DeclaredLength; } - else if (PackageLengthOp->Asl.Value.Integer < PackageLength) + else if (DeclaredLength < PackageLength) { /* * The package length is smaller than the length of the @@ -999,7 +1013,13 @@ OpnDoLoadTable ( /* Fourth child is the RootPath string */ Next = Next->Asl.Next; - if (Next->Asl.ParseOpcode == PARSEOP_ZERO) + if ((Next->Asl.ParseOpcode == PARSEOP_ZERO) || + ((Next->Asl.Value.Integer == 0) && + ((Next->Asl.ParseOpcode == PARSEOP_INTEGER) || + (Next->Asl.ParseOpcode == PARSEOP_BYTECONST) || + (Next->Asl.ParseOpcode == PARSEOP_WORDCONST) || + (Next->Asl.ParseOpcode == PARSEOP_DWORDCONST)|| + (Next->Asl.ParseOpcode == PARSEOP_QWORDCONST)))) { Next->Asl.ParseOpcode = PARSEOP_STRING_LITERAL; Next->Asl.Value.String = "\\"; diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 02d46458d6ac..afd11e06c2ac 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c index a46ce96f5dbd..7c5cb69cf705 100644 --- a/sys/contrib/dev/acpica/compiler/asloptions.c +++ b/sys/contrib/dev/acpica/compiler/asloptions.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslparseop.c b/sys/contrib/dev/acpica/compiler/aslparseop.c index 65e5b5b3ea59..c9ffb1d8d850 100644 --- a/sys/contrib/dev/acpica/compiler/aslparseop.c +++ b/sys/contrib/dev/acpica/compiler/aslparseop.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslparser.y b/sys/contrib/dev/acpica/compiler/aslparser.y index 65a75af9763c..b29eb2ad0374 100644 --- a/sys/contrib/dev/acpica/compiler/aslparser.y +++ b/sys/contrib/dev/acpica/compiler/aslparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslpld.c b/sys/contrib/dev/acpica/compiler/aslpld.c index b1d9a05a7bdc..cfd725a76854 100644 --- a/sys/contrib/dev/acpica/compiler/aslpld.c +++ b/sys/contrib/dev/acpica/compiler/aslpld.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslpredef.c b/sys/contrib/dev/acpica/compiler/aslpredef.c index 4125c51c6895..5e1eb160f666 100644 --- a/sys/contrib/dev/acpica/compiler/aslpredef.c +++ b/sys/contrib/dev/acpica/compiler/aslpredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c index 9d0e861a0ff9..116aa04976e0 100644 --- a/sys/contrib/dev/acpica/compiler/aslprepkg.c +++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslprimaries.y b/sys/contrib/dev/acpica/compiler/aslprimaries.y index 608009d30da3..ef5aa3a7a8b1 100644 --- a/sys/contrib/dev/acpica/compiler/aslprimaries.y +++ b/sys/contrib/dev/acpica/compiler/aslprimaries.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c index 819a498f2b7d..56faa95c6ba5 100644 --- a/sys/contrib/dev/acpica/compiler/aslprintf.c +++ b/sys/contrib/dev/acpica/compiler/aslprintf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslprune.c b/sys/contrib/dev/acpica/compiler/aslprune.c index 4fc3c063f1d6..a8b96f299b60 100644 --- a/sys/contrib/dev/acpica/compiler/aslprune.c +++ b/sys/contrib/dev/acpica/compiler/aslprune.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 8250e84fd783..6ac8c03089ab 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslresources.y b/sys/contrib/dev/acpica/compiler/aslresources.y index fd8a33d3c0d6..617a366411fd 100644 --- a/sys/contrib/dev/acpica/compiler/aslresources.y +++ b/sys/contrib/dev/acpica/compiler/aslresources.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 3f873da0e703..c1f5a6885a4f 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1i.c b/sys/contrib/dev/acpica/compiler/aslrestype1i.c index 02f4958d6d51..1ae5e3b0eef6 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1i.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1i.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index 6fb613370691..7296e2573858 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2d.c b/sys/contrib/dev/acpica/compiler/aslrestype2d.c index 3a7ca9189aff..f392eb6eed7a 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2d.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2d.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2e.c b/sys/contrib/dev/acpica/compiler/aslrestype2e.c index 4e6293617b94..d555fabb4114 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2e.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2e.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2q.c b/sys/contrib/dev/acpica/compiler/aslrestype2q.c index 6ebe149a3c14..489400417f8a 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2q.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2q.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2s.c b/sys/contrib/dev/acpica/compiler/aslrestype2s.c index f47402d4e025..8160114980ed 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2s.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2s.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2w.c b/sys/contrib/dev/acpica/compiler/aslrestype2w.c index cc8a31804977..97a9ad82b5ef 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2w.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2w.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslrules.y b/sys/contrib/dev/acpica/compiler/aslrules.y index c96d4cc75db6..00dede690168 100644 --- a/sys/contrib/dev/acpica/compiler/aslrules.y +++ b/sys/contrib/dev/acpica/compiler/aslrules.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c index 628a5c1ada2d..0da5eaa4d099 100644 --- a/sys/contrib/dev/acpica/compiler/aslstartup.c +++ b/sys/contrib/dev/acpica/compiler/aslstartup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index 50bda4b83fe1..f872b0f5f2e0 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l index 74ac78d8c4ef..d9e609faee46 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.l +++ b/sys/contrib/dev/acpica/compiler/aslsupport.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.y b/sys/contrib/dev/acpica/compiler/aslsupport.y index 3bd09a55e704..7595c1065df6 100644 --- a/sys/contrib/dev/acpica/compiler/aslsupport.y +++ b/sys/contrib/dev/acpica/compiler/aslsupport.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asltokens.y b/sys/contrib/dev/acpica/compiler/asltokens.y index 50d6031e5ed0..0497ba9535ec 100644 --- a/sys/contrib/dev/acpica/compiler/asltokens.y +++ b/sys/contrib/dev/acpica/compiler/asltokens.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index c58f771354f1..f239ff0b11fe 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index 9237176c94b5..d8021dbbb765 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 50234d71f0a7..36052302e9bf 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asltypes.y b/sys/contrib/dev/acpica/compiler/asltypes.y index 2c2669559585..3bfbae4f7b04 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.y +++ b/sys/contrib/dev/acpica/compiler/asltypes.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index 267ad8b77e13..69d0a2310a8d 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c index 712a06fda951..a7e08380c67b 100644 --- a/sys/contrib/dev/acpica/compiler/asluuid.c +++ b/sys/contrib/dev/acpica/compiler/asluuid.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslwalks.c b/sys/contrib/dev/acpica/compiler/aslwalks.c index db2c9daa455e..c28177603823 100644 --- a/sys/contrib/dev/acpica/compiler/aslwalks.c +++ b/sys/contrib/dev/acpica/compiler/aslwalks.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -197,6 +197,7 @@ AnMethodTypingWalkEnd ( void *Context) { UINT32 ThisOpBtype; + ACPI_PARSE_OBJECT *TargetMethodOp; switch (Op->Asl.ParseOpcode) @@ -227,12 +228,24 @@ AnMethodTypingWalkEnd ( if (Op->Asl.Child->Asl.Node && (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)) { + TargetMethodOp = Op->Asl.Child->Asl.Node->Op; + + /* Break mutual-recursion loops during typing */ + if (TargetMethodOp->Asl.CompileFlags & OP_VISITED) + { + break; + } + + TargetMethodOp->Asl.CompileFlags |= OP_VISITED; + /* We must type the method here */ - TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, + TrWalkParseTree (TargetMethodOp, ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); + TargetMethodOp->Asl.CompileFlags &= ~OP_VISITED; + ThisOpBtype = AnGetBtype (Op->Asl.Child); } } diff --git a/sys/contrib/dev/acpica/compiler/aslxref.c b/sys/contrib/dev/acpica/compiler/aslxref.c index eb61b1d461cd..0f8c62262a0c 100644 --- a/sys/contrib/dev/acpica/compiler/aslxref.c +++ b/sys/contrib/dev/acpica/compiler/aslxref.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -558,11 +558,23 @@ XfNamespaceLocateBegin ( Node = NextOp->Asl.Node; + /* Malformed tree: parent method has no namespace node */ + if (!Node) + { + return_ACPI_STATUS (AE_OK); + } + /* Get Arg # */ RegisterNumber = Op->Asl.AmlOpcode - AML_ARG0; /* 0x68 through 0x6F */ MethodArgs = Node->MethodArgs; + /* Gracefully handle malformed trees where method args were not set up */ + if (!MethodArgs) + { + return_ACPI_STATUS (AE_OK); + } + /* Mark this Arg as referenced */ MethodArgs[RegisterNumber].Flags |= ASL_ARG_REFERENCED; diff --git a/sys/contrib/dev/acpica/compiler/aslxrefout.c b/sys/contrib/dev/acpica/compiler/aslxrefout.c index 67e26b3e69de..86c66868b857 100644 --- a/sys/contrib/dev/acpica/compiler/aslxrefout.c +++ b/sys/contrib/dev/acpica/compiler/aslxrefout.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/cvcompiler.c b/sys/contrib/dev/acpica/compiler/cvcompiler.c index e42dfa8066ac..de8c523e5647 100644 --- a/sys/contrib/dev/acpica/compiler/cvcompiler.c +++ b/sys/contrib/dev/acpica/compiler/cvcompiler.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/cvdisasm.c b/sys/contrib/dev/acpica/compiler/cvdisasm.c index ebc93a0bd194..f4eac2861996 100644 --- a/sys/contrib/dev/acpica/compiler/cvdisasm.c +++ b/sys/contrib/dev/acpica/compiler/cvdisasm.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/cvparser.c b/sys/contrib/dev/acpica/compiler/cvparser.c index 724daa0dea67..db5595e47d3e 100644 --- a/sys/contrib/dev/acpica/compiler/cvparser.c +++ b/sys/contrib/dev/acpica/compiler/cvparser.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c index 873baf397e47..e3447e28e0f0 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompile.c +++ b/sys/contrib/dev/acpica/compiler/dtcompile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -363,18 +363,42 @@ DtInsertCompilerIds ( return; } - /* Walk to the Compiler fields at the end of the header */ + /* Walk to the Compiler fields at the end of the header, with safety checks */ + + if (!FieldList) + { + DtError (ASL_WARNING, ASL_MSG_MALFORMED_HEADER, NULL, NULL); + return; + } Next = FieldList; for (i = 0; i < 7; i++) { + if (!Next || !Next->Next) + { + /* Malformed/short header: cannot insert compiler IDs */ + DtError (ASL_WARNING, ASL_MSG_MALFORMED_HEADER, FieldList, NULL); + return; + } Next = Next->Next; } + /* Ensure both Creator ID and Revision fields exist */ + if (!Next || !Next->Next) + { + DtError (ASL_WARNING, ASL_MSG_MALFORMED_HEADER, FieldList, NULL); + return; + } + Next->Value = ASL_CREATOR_ID; Next->Flags = DT_FIELD_NOT_ALLOCATED; Next = Next->Next; + if (!Next) + { + DtError (ASL_WARNING, ASL_MSG_MALFORMED_HEADER, FieldList, NULL); + return; + } Next->Value = VersionString; Next->Flags = DT_FIELD_NOT_ALLOCATED; } diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h index 505bb6b40bed..6a47bd7b1691 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompiler.h +++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -610,6 +610,10 @@ DtCompileDrtm ( void **PFieldList); ACPI_STATUS +DtCompileDtpr ( + void **PFieldList); + +ACPI_STATUS DtCompileEinj ( void **PFieldList); @@ -819,6 +823,7 @@ extern const unsigned char TemplateDbg2[]; extern const unsigned char TemplateDbgp[]; extern const unsigned char TemplateDmar[]; extern const unsigned char TemplateDrtm[]; +extern const unsigned char TemplateDtpr[]; extern const unsigned char TemplateEcdt[]; extern const unsigned char TemplateEinj[]; extern const unsigned char TemplateErdt[]; diff --git a/sys/contrib/dev/acpica/compiler/dtcompilerparser.l b/sys/contrib/dev/acpica/compiler/dtcompilerparser.l index 322ee225a60d..492468867acd 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompilerparser.l +++ b/sys/contrib/dev/acpica/compiler/dtcompilerparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtcompilerparser.y b/sys/contrib/dev/acpica/compiler/dtcompilerparser.y index f160434e0959..4dab55c0b783 100644 --- a/sys/contrib/dev/acpica/compiler/dtcompilerparser.y +++ b/sys/contrib/dev/acpica/compiler/dtcompilerparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c index 65f10aac9f00..0a503febb22d 100644 --- a/sys/contrib/dev/acpica/compiler/dtexpress.c +++ b/sys/contrib/dev/acpica/compiler/dtexpress.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c index ded7315aaa3f..106db4d04e58 100644 --- a/sys/contrib/dev/acpica/compiler/dtfield.c +++ b/sys/contrib/dev/acpica/compiler/dtfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c index 7bcf16b8f9d1..b0a830386834 100644 --- a/sys/contrib/dev/acpica/compiler/dtio.c +++ b/sys/contrib/dev/acpica/compiler/dtio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -422,6 +422,12 @@ DtParseLine ( End++; } + /* No value characters present */ + if (End <= Start) + { + return (AE_OK); + } + Length = ACPI_PTR_DIFF (End, Start); TmpValue = UtLocalCalloc (Length + 1); diff --git a/sys/contrib/dev/acpica/compiler/dtparser.l b/sys/contrib/dev/acpica/compiler/dtparser.l index 90fc39d8c66a..b7574e77a6ad 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.l +++ b/sys/contrib/dev/acpica/compiler/dtparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y index d6d584b2c6e9..9f6ad8b33d41 100644 --- a/sys/contrib/dev/acpica/compiler/dtparser.y +++ b/sys/contrib/dev/acpica/compiler/dtparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c index 0c660b7ab8bb..82a7b0c8a14c 100644 --- a/sys/contrib/dev/acpica/compiler/dtsubtable.c +++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -430,7 +430,12 @@ DtGetSubtableLength ( case ACPI_DMT_IORTMEM: - Step = 10; + /* + * The ACPI_DMT_IORTMEM type is defined in AcpiDmTableInfoIortAcc. + * TODO: compute number of fields ("Step") directly from the array initialisation. + * This may require some refactoring of dmtbinfo2.c and acdiasasm.h + */ + Step = 11; break; default: diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c index effcf6d65e1c..6e0a0fedb0c0 100644 --- a/sys/contrib/dev/acpica/compiler/dttable.c +++ b/sys/contrib/dev/acpica/compiler/dttable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dttable1.c b/sys/contrib/dev/acpica/compiler/dttable1.c index a513ff9ed009..d82153d6a590 100644 --- a/sys/contrib/dev/acpica/compiler/dttable1.c +++ b/sys/contrib/dev/acpica/compiler/dttable1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -1728,6 +1728,124 @@ DtCompileDrtm ( /****************************************************************************** * + * FUNCTION: DtCompileDtpr + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile DTPR. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileDtpr ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_TABLE_DTPR *Dtpr; + ACPI_TPR_INSTANCE *TprInst; + UINT32 i, InsCnt, SrlCnt, TprCnt; + + + ParentTable = DtPeekSubtable (); + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDtpr, &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + Dtpr = ACPI_SUB_PTR (ACPI_TABLE_DTPR, Subtable->Buffer, + sizeof (ACPI_TABLE_HEADER)); + if (!Dtpr) + { + AcpiOsPrintf ("DTPR buffer pointer is NULL\n"); + return (AE_NULL_OBJECT); + } + + InsCnt = Dtpr->InsCnt; + + while (*PFieldList) + { + for (i = 0; i < InsCnt; i++) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDtprInstance, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + TprInst = ACPI_CAST_PTR (ACPI_TPR_INSTANCE, Subtable->Buffer); + if (!TprInst) + { + AcpiOsPrintf ("Tpr Instance buffer pointer is NULL\n"); + return (AE_NULL_OBJECT); + } + + TprCnt = TprInst->TprCnt; + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + while (*PFieldList && TprCnt) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDtprArr, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + TprCnt--; + } + + DtPopSubtable(); + ParentTable = DtPeekSubtable (); + } + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDtprSerializeReq0, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + SrlCnt = *ACPI_CAST_PTR(UINT32, Subtable->Buffer); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + ParentTable = DtPeekSubtable (); + + while (*PFieldList && SrlCnt) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoDtprSerializeReq1, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + SrlCnt--; + } + + + DtPopSubtable(); + ParentTable = DtPeekSubtable (); + } + + return Status; +} + +/****************************************************************************** + * * FUNCTION: DtCompileEinj * * PARAMETERS: List - Current field list pointer @@ -2984,6 +3102,19 @@ DtCompileIort ( IortRmr->RmrCount = RmrCount; break; + case ACPI_IORT_NODE_IWB: + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort7, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + NodeLength += Subtable->Length; + break; + default: DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT"); diff --git a/sys/contrib/dev/acpica/compiler/dttable2.c b/sys/contrib/dev/acpica/compiler/dttable2.c index 43484490ff3e..e5ecb25332b9 100644 --- a/sys/contrib/dev/acpica/compiler/dttable2.c +++ b/sys/contrib/dev/acpica/compiler/dttable2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -439,6 +439,21 @@ DtCompileMadt ( InfoTable = AcpiDmTableInfoMadt27; break; + case ACPI_MADT_TYPE_GICV5_IRS: + + InfoTable = AcpiDmTableInfoMadt28; + break; + + case ACPI_MADT_TYPE_GICV5_ITS: + + InfoTable = AcpiDmTableInfoMadt29; + break; + + case ACPI_MADT_TYPE_GICV5_ITS_TRANSLATE: + + InfoTable = AcpiDmTableInfoMadt30; + break; + default: if (MadtHeader->Type >= ACPI_MADT_TYPE_OEM_RESERVED) diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c index d7140712d4e6..57d64cba27fa 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.c +++ b/sys/contrib/dev/acpica/compiler/dttemplate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h index 88bc38f25c39..460f3a54afe5 100644 --- a/sys/contrib/dev/acpica/compiler/dttemplate.h +++ b/sys/contrib/dev/acpica/compiler/dttemplate.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -643,6 +643,23 @@ const unsigned char TemplateEcdt[] = 0x09,0x00 /* 00000040 ".." */ }; +const unsigned char TemplateDtpr[] = +{ + 0x44,0x54,0x50,0x52,0x68,0x00,0x00,0x00, /* 00000000 "DTPRh..." */ + 0x01,0x0B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".#INTEL." */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x00,0x00,0x00,0x01,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x04,0x04,0x25,0x20,0x00,0x00,0x00,0x00, /* 00000020 "........" */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */ + 0x02,0x00,0x00,0x00,0x30,0xB0,0xAA,0xFF, /* 00000030 "....0..." */ + 0xFF,0x1F,0x00,0x00,0x38,0xB0,0xAA,0xFF, /* 00000038 "....8..." */ + 0xFF,0x1F,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x02,0x00,0x00,0x00,0x30,0xB0,0xBB,0xFF, /* 00000048 "....0..." */ + 0xFF,0x1F,0x00,0x00,0x38,0xB0,0xBB,0xFF, /* 00000050 "....8..." */ + 0xFF,0x1F,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000058 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000060 "........" */ +}; + const unsigned char TemplateEinj[] = { 0x45,0x49,0x4E,0x4A,0x30,0x01,0x00,0x00, /* 00000000 "EINJ0..." */ @@ -1188,11 +1205,11 @@ const unsigned char TemplateHpet[] = const unsigned char TemplateIort[] = { - 0x49,0x4F,0x52,0x54,0x3C,0x02,0x00,0x00, /* 00000000 "IORT<..." */ - 0x05,0xCB,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ + 0x49,0x4F,0x52,0x54,0x78,0x02,0x00,0x00, /* 00000000 "IORTx..." */ + 0x05,0x85,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x17,0x12,0x21,0x20,0x07,0x00,0x00,0x00, /* 00000020 "..! ...." */ + 0x07,0x08,0x25,0x20,0x08,0x00,0x00,0x00, /* 00000020 "..% ...." */ 0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "4......." */ 0x49,0x4F,0x52,0x54,0x00,0x18,0x00,0x01, /* 00000030 "IORT...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -1204,10 +1221,10 @@ const unsigned char TemplateIort[] = 0x00,0x5C,0x5F,0x53,0x42,0x2E,0x50,0x43, /* 00000068 ".\_SB.PC" */ 0x49,0x30,0x2E,0x44,0x45,0x56,0x30,0x00, /* 00000070 "I0.DEV0." */ 0x49,0x4F,0x52,0x54,0x3C,0x02,0x00,0x00, /* 00000078 "IORT<..." */ - 0x03,0xF1,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000080 "..INTEL " */ + 0x05,0xCB,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000080 "..INTEL " */ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000088 "Template" */ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000090 "....INTL" */ - 0x05,0x01,0x21,0x20,0x07,0x00,0x00,0x00, /* 00000098 "..! ...." */ + 0x17,0x12,0x21,0x20,0x07,0x00,0x00,0x00, /* 00000098 "..! ...." */ 0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "4......." */ 0x49,0x4F,0x52,0x54,0x00,0x18,0x00,0x01, /* 000000A8 "IORT...." */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ @@ -1259,7 +1276,14 @@ const unsigned char TemplateIort[] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000220 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000228 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000230 "........" */ - 0x00,0x00,0x00,0x00 /* 00000238 "...." */ + 0x00,0x00,0x00,0x00,0x07,0x3C,0x00,0x01, /* 00000238 ".....<.." */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000240 "........" */ + 0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x2F, /* 00000248 "(....../" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x5F, /* 00000250 "......\_" */ + 0x53,0x42,0x5F,0x2E,0x49,0x57,0x42,0x30, /* 00000258 "SB_.IWB0" */ + 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 00000260 "........" */ + 0x00,0x40,0x00,0x00,0x00,0x30,0x00,0x00, /* 00000268 ".@...0.." */ + 0x00,0x01,0x00,0x00,0x00 /* 00000270 "....." */ }; const unsigned char TemplateIovt[] = @@ -1387,15 +1411,15 @@ const unsigned char TemplateLpit[] = 0x00,0x00,0x00,0x00 /* 00000090 "...." */ }; -/* MADT with ACPI 6.0 subtables */ +/* MADT with ACPI 6.7 subtables */ const unsigned char TemplateMadt[] = { - 0x41,0x50,0x49,0x43,0x62,0x02,0x00,0x00, /* 00000000 "APICb..." */ - 0x07,0x44,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".DINTEL " */ + 0x41,0x50,0x49,0x43,0xAA,0x02,0x00,0x00, /* 00000000 "APIC...." */ + 0x07,0x5F,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "._INTEL " */ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ - 0x28,0x06,0x23,0x20,0x00,0x00,0x00,0x00, /* 00000020 "(.# ...." */ + 0x07,0x08,0x25,0x20,0x00,0x00,0x00,0x00, /* 00000020 "..% ...." */ 0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */ 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ @@ -1467,7 +1491,16 @@ const unsigned char TemplateMadt[] = 0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00, /* 00000248 "..`....." */ 0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00, /* 00000250 "....`..." */ 0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000258 "........" */ - 0x00,0x00 /* 00000260 ".." */ + 0x00,0x00,0x1D,0x10,0x00,0x00,0x00,0x00, /* 00000260 "........" */ + 0x00,0x00,0x00,0x00,0x12,0x2F,0x00,0x00, /* 00000268 "...../.." */ + 0x00,0x00,0x1E,0x18,0x00,0x00,0x00,0x00, /* 00000270 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000278 "........" */ + 0x00,0x00,0x00,0x00,0x13,0x2F,0x00,0x00, /* 00000280 "...../.." */ + 0x00,0x00,0x1C,0x20,0x05,0x00,0x00,0x00, /* 00000288 "... ...." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000290 "........" */ + 0x00,0x00,0x00,0x00,0x1A,0x2F,0x00,0x00, /* 00000298 "...../.." */ + 0x00,0x00,0x00,0x00,0x1B,0x2F,0x00,0x00, /* 000002A0 "...../.." */ + 0x00,0x00 /* 000002A8 ".." */ }; const unsigned char TemplateMcfg[] = diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c index f3b9fa856dd6..ff3b1b6e9453 100644 --- a/sys/contrib/dev/acpica/compiler/dtutils.c +++ b/sys/contrib/dev/acpica/compiler/dtutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h index 26a11f573402..8e3a602027b8 100644 --- a/sys/contrib/dev/acpica/compiler/preprocess.h +++ b/sys/contrib/dev/acpica/compiler/preprocess.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prexpress.c b/sys/contrib/dev/acpica/compiler/prexpress.c index b2e7b785c5e9..ec430eda1b11 100644 --- a/sys/contrib/dev/acpica/compiler/prexpress.c +++ b/sys/contrib/dev/acpica/compiler/prexpress.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prmacros.c b/sys/contrib/dev/acpica/compiler/prmacros.c index 6d2acf52b980..350839192c42 100644 --- a/sys/contrib/dev/acpica/compiler/prmacros.c +++ b/sys/contrib/dev/acpica/compiler/prmacros.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prparser.l b/sys/contrib/dev/acpica/compiler/prparser.l index fe0495121911..d286cb84da7b 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.l +++ b/sys/contrib/dev/acpica/compiler/prparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y index 47edb20dcba8..7a724e9ed55e 100644 --- a/sys/contrib/dev/acpica/compiler/prparser.y +++ b/sys/contrib/dev/acpica/compiler/prparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c index 81b703cfb081..59ef7cc73bf0 100644 --- a/sys/contrib/dev/acpica/compiler/prscan.c +++ b/sys/contrib/dev/acpica/compiler/prscan.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c index 902baed833c8..2bf700594ae3 100644 --- a/sys/contrib/dev/acpica/compiler/prutils.c +++ b/sys/contrib/dev/acpica/compiler/prutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbcmds.c b/sys/contrib/dev/acpica/components/debugger/dbcmds.c index 17ec5f342618..8b335c0c6ad2 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbcmds.c +++ b/sys/contrib/dev/acpica/components/debugger/dbcmds.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbconvert.c b/sys/contrib/dev/acpica/components/debugger/dbconvert.c index ed464e25bdbe..0a7cc420c07d 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbconvert.c +++ b/sys/contrib/dev/acpica/components/debugger/dbconvert.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbdisply.c b/sys/contrib/dev/acpica/components/debugger/dbdisply.c index c57a19d0dbdb..c2812a1d171e 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbdisply.c +++ b/sys/contrib/dev/acpica/components/debugger/dbdisply.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbexec.c b/sys/contrib/dev/acpica/components/debugger/dbexec.c index 38c7496ebba1..c1f4e8a52f24 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/components/debugger/dbexec.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c index b006ac9d330b..d575f4929d30 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c +++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbhistry.c b/sys/contrib/dev/acpica/components/debugger/dbhistry.c index 45d44d11f315..5a7ecbaa51b8 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbhistry.c +++ b/sys/contrib/dev/acpica/components/debugger/dbhistry.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c index e38364448885..03fa49a63428 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbmethod.c b/sys/contrib/dev/acpica/components/debugger/dbmethod.c index 27e572d5ad17..8f2586784fc4 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbmethod.c +++ b/sys/contrib/dev/acpica/components/debugger/dbmethod.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbnames.c b/sys/contrib/dev/acpica/components/debugger/dbnames.c index fc6a26fe9cdc..64abc3a55172 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbnames.c +++ b/sys/contrib/dev/acpica/components/debugger/dbnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbobject.c b/sys/contrib/dev/acpica/components/debugger/dbobject.c index 0033b61ccab8..5f8d511dca95 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbobject.c +++ b/sys/contrib/dev/acpica/components/debugger/dbobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbstats.c b/sys/contrib/dev/acpica/components/debugger/dbstats.c index 76295cadd337..71ec9b23926e 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbstats.c +++ b/sys/contrib/dev/acpica/components/debugger/dbstats.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbtest.c b/sys/contrib/dev/acpica/components/debugger/dbtest.c index 4e0eb486c35b..eda8013762b0 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbtest.c +++ b/sys/contrib/dev/acpica/components/debugger/dbtest.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbutils.c b/sys/contrib/dev/acpica/components/debugger/dbutils.c index 4a39f9aca9e0..1382a4bcb605 100755 --- a/sys/contrib/dev/acpica/components/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/components/debugger/dbutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/debugger/dbxface.c b/sys/contrib/dev/acpica/components/debugger/dbxface.c index 2150abc16100..885c633f01f6 100644 --- a/sys/contrib/dev/acpica/components/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/components/debugger/dbxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c index d9e2273712e5..0b008559dbe1 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c index ce3aa09084df..89ecc7a39c0f 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmcstyle.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c index 3826f194d6fd..b0cacb4d873f 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmdeferred.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmnames.c b/sys/contrib/dev/acpica/components/disassembler/dmnames.c index 447618b5bc52..0f5df03dbf41 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmnames.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c index 1cb1c81d74eb..73e9d168d7c1 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmopcode.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmopcode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -797,6 +797,7 @@ AcpiDmDisassembleOneOp ( UINT32 Offset; UINT32 Length; ACPI_PARSE_OBJECT *Child; + ACPI_PARSE_OBJECT *MethodCallOp; ACPI_STATUS Status; UINT8 *Aml; const AH_DEVICE_ID *IdInfo; @@ -986,6 +987,13 @@ AcpiDmDisassembleOneOp ( case AML_INT_NAMEPATH_OP: AcpiDmNamestring (Op->Common.Value.Name); + /* If this namepath is a Package element, emit a separating comma */ + if ((Op->Common.Parent) && + ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))) + { + AcpiOsPrintf (", "); + } break; case AML_INT_NAMEDFIELD_OP: @@ -1086,10 +1094,19 @@ AcpiDmDisassembleOneOp ( case AML_INT_METHODCALL_OP: + MethodCallOp = Op; Op = AcpiPsGetDepthNext (NULL, Op); Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiDmNamestring (Op->Common.Value.Name); + + /* If the method name is a Package element, emit a separating comma */ + if ((MethodCallOp->Common.Parent) && + ((MethodCallOp->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (MethodCallOp->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))) + { + AcpiOsPrintf (", "); + } break; case AML_WHILE_OP: diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c index e5a859ed47b7..a91b2c0ee00b 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrc.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -536,10 +536,31 @@ AcpiDmIsResourceTemplate ( return (AE_TYPE); } + /* + * Check if this op was allocated from the extended parse object cache. + * Only extended ops (NAMED_OBJECT, DEFERRED, BYTELIST) have the + * Named.Data and Named.Length fields. Generic ops would overflow. + */ + if (NextOp->Common.Flags == ACPI_PARSEOP_GENERIC) + { + return (AE_TYPE); + } + Aml = NextOp->Named.Data; BufferLength = NextOp->Common.Value.Size; /* + * Validate BufferLength against Named.Length to prevent reading + * beyond the actual data. Named.Length is computed during parsing + * and represents the actual byte count, while Value.Size comes + * from the AML and can be manipulated by malformed AML. + */ + if (BufferLength > NextOp->Named.Length) + { + return (AE_TYPE); + } + + /* * Any buffer smaller than one byte cannot possibly be a resource * template. Two bytes could possibly be a "NULL" resource template * with a lone end tag descriptor (as generated via diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c index b50766bcdf20..f72b96f4a6fa 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c index 551cf8178d94..0ccd03018d73 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c index 1398462cecfc..c601c357c471 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmutils.c b/sys/contrib/dev/acpica/components/disassembler/dmutils.c index 41e26ee4b755..1c674769348a 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmutils.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c index 36f6def2bba5..fda26ecb05b1 100644 --- a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c +++ b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -305,13 +305,6 @@ AcpiDmWalkParseTree ( } } - /* Terminate walk at start op */ - - if (Op == StartOp) - { - break; - } - /* No more children, re-visit this node */ if (!NodePreviouslyVisited) @@ -320,6 +313,13 @@ AcpiDmWalkParseTree ( continue; } + /* Terminate walk at start op */ + + if (Op == StartOp) + { + break; + } + /* No more children, visit peers */ if (Op->Common.Next) diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c index 4a60cde8a15a..e44ad78496dd 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsargs.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsargs.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c index fcf10cf4e856..621655933195 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c b/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c index feb7f58a95de..eba73f94896f 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsdebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c index baa6a2eef262..7972eb03efbb 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsfield.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c index bcf2d4f112c8..eecb4601137d 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsinit.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c index becdb95f8b83..bc7b559a0f3d 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -901,6 +901,8 @@ AcpiDsTerminateControlMethod ( ACPI_OPERAND_OBJECT *MethodDesc, ACPI_WALK_STATE *WalkState) { + UINT32 i; + ACPI_NAMESPACE_NODE *RefNode; ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); @@ -914,6 +916,45 @@ AcpiDsTerminateControlMethod ( if (WalkState) { + /* + * Check if the return value is a RefOf reference to a method local + * or argument. If so, clear the reference to avoid use-after-free + * when the walk state is deleted. + */ + if (WalkState->ReturnDesc && + (WalkState->ReturnDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->ReturnDesc->Reference.Class == ACPI_REFCLASS_REFOF)) + { + RefNode = WalkState->ReturnDesc->Reference.Object; + if (RefNode) + { + /* Check against method locals */ + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + if (RefNode == &WalkState->LocalVariables[i]) + { + AcpiUtRemoveReference (WalkState->ReturnDesc); + WalkState->ReturnDesc = NULL; + break; + } + } + + /* Check against method arguments if not already cleared */ + if (WalkState->ReturnDesc) + { + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + if (RefNode == &WalkState->Arguments[i]) + { + AcpiUtRemoveReference (WalkState->ReturnDesc); + WalkState->ReturnDesc = NULL; + break; + } + } + } + } + } + /* Delete all arguments and locals */ AcpiDsMethodDataDeleteAll (WalkState); diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c index 2c45e8c91f57..8f401774e631 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c index cd9921e59261..cc233ad59acc 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsobject.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c index 23c7065bec5a..7c47bab397da 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c b/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c index 6365ab4b0f20..8e37e9384c4a 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dspkginit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c index 04b65326b51c..4105850932a7 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dsutils.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dsutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c index 1e287fae9977..3243280ae428 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswexec.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswexec.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload.c b/sys/contrib/dev/acpica/components/dispatcher/dswload.c index 8c9969de14f7..5a0caaaf1854 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c index 8ef7ff4090d1..33572fd966e8 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswload2.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswload2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c index faf08bcfb399..f5a7ded02bc6 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswscope.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswscope.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c index f353951961b2..cfd55276391d 100644 --- a/sys/contrib/dev/acpica/components/dispatcher/dswstate.c +++ b/sys/contrib/dev/acpica/components/dispatcher/dswstate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evevent.c b/sys/contrib/dev/acpica/components/events/evevent.c index da5e633e5909..b8e23ec86982 100644 --- a/sys/contrib/dev/acpica/components/events/evevent.c +++ b/sys/contrib/dev/acpica/components/events/evevent.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evglock.c b/sys/contrib/dev/acpica/components/events/evglock.c index 395ca14fb315..bd9a414359ae 100644 --- a/sys/contrib/dev/acpica/components/events/evglock.c +++ b/sys/contrib/dev/acpica/components/events/evglock.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evgpe.c b/sys/contrib/dev/acpica/components/events/evgpe.c index 2ce159c46be2..075e6230cb05 100644 --- a/sys/contrib/dev/acpica/components/events/evgpe.c +++ b/sys/contrib/dev/acpica/components/events/evgpe.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evgpeblk.c b/sys/contrib/dev/acpica/components/events/evgpeblk.c index d30f31c641a1..9eff36bc46e0 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeblk.c +++ b/sys/contrib/dev/acpica/components/events/evgpeblk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evgpeinit.c b/sys/contrib/dev/acpica/components/events/evgpeinit.c index 0ae8bb700369..ab7348807105 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeinit.c +++ b/sys/contrib/dev/acpica/components/events/evgpeinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evgpeutil.c b/sys/contrib/dev/acpica/components/events/evgpeutil.c index 0dc2fdf01b52..841112817035 100644 --- a/sys/contrib/dev/acpica/components/events/evgpeutil.c +++ b/sys/contrib/dev/acpica/components/events/evgpeutil.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evhandler.c b/sys/contrib/dev/acpica/components/events/evhandler.c index 9c69d69b524a..8f29e830faa8 100644 --- a/sys/contrib/dev/acpica/components/events/evhandler.c +++ b/sys/contrib/dev/acpica/components/events/evhandler.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -290,6 +290,13 @@ AcpiEvHasDefaultHandler ( while (HandlerObj) { + /* Validate handler object type before accessing fields */ + + if (HandlerObj->Common.Type != ACPI_TYPE_LOCAL_ADDRESS_HANDLER) + { + break; + } + if (HandlerObj->AddressSpace.SpaceId == SpaceId) { if (HandlerObj->AddressSpace.HandlerFlags & @@ -460,6 +467,11 @@ AcpiEvFindRegionHandler ( while (HandlerObj) { + if (HandlerObj->Common.Type != ACPI_TYPE_LOCAL_ADDRESS_HANDLER) + { + break; + } + /* Same SpaceId indicates a handler is installed */ if (HandlerObj->AddressSpace.SpaceId == SpaceId) diff --git a/sys/contrib/dev/acpica/components/events/evmisc.c b/sys/contrib/dev/acpica/components/events/evmisc.c index 1b8688dd872d..13b2963ac04d 100644 --- a/sys/contrib/dev/acpica/components/events/evmisc.c +++ b/sys/contrib/dev/acpica/components/events/evmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evregion.c b/sys/contrib/dev/acpica/components/events/evregion.c index 23f9ad00bc62..01c49b86f5d6 100644 --- a/sys/contrib/dev/acpica/components/events/evregion.c +++ b/sys/contrib/dev/acpica/components/events/evregion.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evrgnini.c b/sys/contrib/dev/acpica/components/events/evrgnini.c index 1f16655195e1..40943bb0de4b 100644 --- a/sys/contrib/dev/acpica/components/events/evrgnini.c +++ b/sys/contrib/dev/acpica/components/events/evrgnini.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evsci.c b/sys/contrib/dev/acpica/components/events/evsci.c index cd1dc4da6317..156b19d9abdf 100644 --- a/sys/contrib/dev/acpica/components/events/evsci.c +++ b/sys/contrib/dev/acpica/components/events/evsci.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evxface.c b/sys/contrib/dev/acpica/components/events/evxface.c index 54634c61e517..fc4ecaeb1e67 100644 --- a/sys/contrib/dev/acpica/components/events/evxface.c +++ b/sys/contrib/dev/acpica/components/events/evxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evxfevnt.c b/sys/contrib/dev/acpica/components/events/evxfevnt.c index 60837084e86f..0eba3a5028f1 100644 --- a/sys/contrib/dev/acpica/components/events/evxfevnt.c +++ b/sys/contrib/dev/acpica/components/events/evxfevnt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evxfgpe.c b/sys/contrib/dev/acpica/components/events/evxfgpe.c index 1ffcff259a2b..1b99879a7fbc 100644 --- a/sys/contrib/dev/acpica/components/events/evxfgpe.c +++ b/sys/contrib/dev/acpica/components/events/evxfgpe.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/events/evxfregn.c b/sys/contrib/dev/acpica/components/events/evxfregn.c index bbdf4352b415..706b13f2b813 100644 --- a/sys/contrib/dev/acpica/components/events/evxfregn.c +++ b/sys/contrib/dev/acpica/components/events/evxfregn.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exconcat.c b/sys/contrib/dev/acpica/components/executer/exconcat.c index 060dbf946d87..a03d3c1c6515 100644 --- a/sys/contrib/dev/acpica/components/executer/exconcat.c +++ b/sys/contrib/dev/acpica/components/executer/exconcat.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exconfig.c b/sys/contrib/dev/acpica/components/executer/exconfig.c index 6f3f8d24baca..f73863e8d744 100644 --- a/sys/contrib/dev/acpica/components/executer/exconfig.c +++ b/sys/contrib/dev/acpica/components/executer/exconfig.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -247,6 +247,8 @@ AcpiExLoadTableOp ( ACPI_OPERAND_OBJECT *ReturnObj; ACPI_OPERAND_OBJECT *DdbHandle; UINT32 TableIndex; + char OemId[ACPI_OEM_ID_SIZE + 1]; + char OemTableId[ACPI_OEM_TABLE_ID_SIZE + 1]; ACPI_FUNCTION_TRACE (ExLoadTableOp); @@ -262,13 +264,34 @@ AcpiExLoadTableOp ( *ReturnDesc = ReturnObj; + /* + * Validate OEM ID and OEM Table ID string lengths. + * AcpiTbFindTable expects strings that can safely read + * ACPI_OEM_ID_SIZE and ACPI_OEM_TABLE_ID_SIZE bytes. + */ + if ((Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || + (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) + { + return_ACPI_STATUS (AE_AML_STRING_LIMIT); + } + + /* + * Copy OEM strings to local buffers with guaranteed null-termination. + * This prevents heap-buffer-overflow when AcpiTbFindTable reads + * ACPI_OEM_ID_SIZE/ACPI_OEM_TABLE_ID_SIZE bytes. + */ + memcpy (OemId, Operand[1]->String.Pointer, Operand[1]->String.Length); + OemId[Operand[1]->String.Length] = 0; + memcpy (OemTableId, Operand[2]->String.Pointer, Operand[2]->String.Length); + OemTableId[Operand[2]->String.Length] = 0; + /* Find the ACPI table in the RSDT/XSDT */ AcpiExExitInterpreter (); Status = AcpiTbFindTable ( Operand[0]->String.Pointer, - Operand[1]->String.Pointer, - Operand[2]->String.Pointer, &TableIndex); + OemId, + OemTableId, &TableIndex); AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/components/executer/exconvrt.c b/sys/contrib/dev/acpica/components/executer/exconvrt.c index 9c091864d7ef..82397b606582 100644 --- a/sys/contrib/dev/acpica/components/executer/exconvrt.c +++ b/sys/contrib/dev/acpica/components/executer/exconvrt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/excreate.c b/sys/contrib/dev/acpica/components/executer/excreate.c index 75f1d631d110..b1b6d3509dd0 100644 --- a/sys/contrib/dev/acpica/components/executer/excreate.c +++ b/sys/contrib/dev/acpica/components/executer/excreate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exdebug.c b/sys/contrib/dev/acpica/components/executer/exdebug.c index 6a927eb26393..25b05477e06d 100644 --- a/sys/contrib/dev/acpica/components/executer/exdebug.c +++ b/sys/contrib/dev/acpica/components/executer/exdebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exdump.c b/sys/contrib/dev/acpica/components/executer/exdump.c index 581d183d919f..3a7e20e6d6ba 100644 --- a/sys/contrib/dev/acpica/components/executer/exdump.c +++ b/sys/contrib/dev/acpica/components/executer/exdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exfield.c b/sys/contrib/dev/acpica/components/executer/exfield.c index 6c27e7dfcb36..88dc6546fbd4 100644 --- a/sys/contrib/dev/acpica/components/executer/exfield.c +++ b/sys/contrib/dev/acpica/components/executer/exfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exfldio.c b/sys/contrib/dev/acpica/components/executer/exfldio.c index b3d1d73c0960..d164b1186edb 100644 --- a/sys/contrib/dev/acpica/components/executer/exfldio.c +++ b/sys/contrib/dev/acpica/components/executer/exfldio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exmisc.c b/sys/contrib/dev/acpica/components/executer/exmisc.c index 9b9b6b3005c2..d1925921405b 100644 --- a/sys/contrib/dev/acpica/components/executer/exmisc.c +++ b/sys/contrib/dev/acpica/components/executer/exmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exmutex.c b/sys/contrib/dev/acpica/components/executer/exmutex.c index fe1220d6abfb..cda70bcf7ccd 100644 --- a/sys/contrib/dev/acpica/components/executer/exmutex.c +++ b/sys/contrib/dev/acpica/components/executer/exmutex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exnames.c b/sys/contrib/dev/acpica/components/executer/exnames.c index 105103f81f11..1d287c7e4956 100644 --- a/sys/contrib/dev/acpica/components/executer/exnames.c +++ b/sys/contrib/dev/acpica/components/executer/exnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exoparg1.c b/sys/contrib/dev/acpica/components/executer/exoparg1.c index 13af957693b4..b15335c0cc3e 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg1.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exoparg2.c b/sys/contrib/dev/acpica/components/executer/exoparg2.c index 4bc3cf79e1eb..7dfcff0ece0e 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg2.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exoparg3.c b/sys/contrib/dev/acpica/components/executer/exoparg3.c index 30de8487e676..e29b322ec9c2 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg3.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg3.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -225,11 +225,18 @@ AcpiExOpcode_3A_0T_0R ( AcpiOsSignal (ACPI_SIGNAL_FATAL, &Fatal); +#ifndef ACPI_CONTINUE_ON_FATAL /* * Might return while OS is shutting down, so abort the AML execution * by returning an error. */ return_ACPI_STATUS (AE_ERROR); +#else + /* + * The alstests require that the Fatal() opcode does not return an error. + */ + return_ACPI_STATUS (AE_OK); +#endif case AML_EXTERNAL_OP: /* @@ -313,7 +320,8 @@ AcpiExOpcode_3A_1T_1R ( /* Truncate request if larger than the actual String/Buffer */ - else if ((Index + Length) > Operand[0]->String.Length) + else if ((Index + Length) > Operand[0]->String.Length || + (Index + Length) < Index) /* Check for overflow */ { Length = (ACPI_SIZE) Operand[0]->String.Length - (ACPI_SIZE) Index; diff --git a/sys/contrib/dev/acpica/components/executer/exoparg6.c b/sys/contrib/dev/acpica/components/executer/exoparg6.c index a9092ba2e4e2..9fe874576bec 100644 --- a/sys/contrib/dev/acpica/components/executer/exoparg6.c +++ b/sys/contrib/dev/acpica/components/executer/exoparg6.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exprep.c b/sys/contrib/dev/acpica/components/executer/exprep.c index dc04b77b7ea5..2f70b14d5f30 100644 --- a/sys/contrib/dev/acpica/components/executer/exprep.c +++ b/sys/contrib/dev/acpica/components/executer/exprep.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exregion.c b/sys/contrib/dev/acpica/components/executer/exregion.c index 4e9f535ef9ac..7d4e182f4fee 100644 --- a/sys/contrib/dev/acpica/components/executer/exregion.c +++ b/sys/contrib/dev/acpica/components/executer/exregion.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exresnte.c b/sys/contrib/dev/acpica/components/executer/exresnte.c index 0c66f0b4d4f8..3fad5e38beec 100644 --- a/sys/contrib/dev/acpica/components/executer/exresnte.c +++ b/sys/contrib/dev/acpica/components/executer/exresnte.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exresolv.c b/sys/contrib/dev/acpica/components/executer/exresolv.c index 81d934418983..62c26854511a 100644 --- a/sys/contrib/dev/acpica/components/executer/exresolv.c +++ b/sys/contrib/dev/acpica/components/executer/exresolv.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exresop.c b/sys/contrib/dev/acpica/components/executer/exresop.c index 0a89bc78d3e3..ad82bfad9d03 100644 --- a/sys/contrib/dev/acpica/components/executer/exresop.c +++ b/sys/contrib/dev/acpica/components/executer/exresop.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exserial.c b/sys/contrib/dev/acpica/components/executer/exserial.c index 6d17c29569e0..5b14147b75a2 100644 --- a/sys/contrib/dev/acpica/components/executer/exserial.c +++ b/sys/contrib/dev/acpica/components/executer/exserial.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exstore.c b/sys/contrib/dev/acpica/components/executer/exstore.c index ebe767abd637..b7776ae192af 100644 --- a/sys/contrib/dev/acpica/components/executer/exstore.c +++ b/sys/contrib/dev/acpica/components/executer/exstore.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exstoren.c b/sys/contrib/dev/acpica/components/executer/exstoren.c index ed9fa9a7f13b..07747f5e9f8a 100644 --- a/sys/contrib/dev/acpica/components/executer/exstoren.c +++ b/sys/contrib/dev/acpica/components/executer/exstoren.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exstorob.c b/sys/contrib/dev/acpica/components/executer/exstorob.c index e9ddabd6c25a..5938a9a10036 100644 --- a/sys/contrib/dev/acpica/components/executer/exstorob.c +++ b/sys/contrib/dev/acpica/components/executer/exstorob.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exsystem.c b/sys/contrib/dev/acpica/components/executer/exsystem.c index f91d8d04b3ba..9a752d6e0366 100644 --- a/sys/contrib/dev/acpica/components/executer/exsystem.c +++ b/sys/contrib/dev/acpica/components/executer/exsystem.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/extrace.c b/sys/contrib/dev/acpica/components/executer/extrace.c index b48a5fcb289b..49cf4d755bdd 100644 --- a/sys/contrib/dev/acpica/components/executer/extrace.c +++ b/sys/contrib/dev/acpica/components/executer/extrace.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/executer/exutils.c b/sys/contrib/dev/acpica/components/executer/exutils.c index 995edbc5990e..3f42b2466188 100644 --- a/sys/contrib/dev/acpica/components/executer/exutils.c +++ b/sys/contrib/dev/acpica/components/executer/exutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwacpi.c b/sys/contrib/dev/acpica/components/hardware/hwacpi.c index 74cfecfcc2a2..859659706ad2 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwacpi.c +++ b/sys/contrib/dev/acpica/components/hardware/hwacpi.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwesleep.c b/sys/contrib/dev/acpica/components/hardware/hwesleep.c index 329d8a20b4b7..9c525ca72bdd 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwesleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwesleep.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwgpe.c b/sys/contrib/dev/acpica/components/hardware/hwgpe.c index 681ca9a1b9de..f4dbbc3faf25 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwgpe.c +++ b/sys/contrib/dev/acpica/components/hardware/hwgpe.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwpci.c b/sys/contrib/dev/acpica/components/hardware/hwpci.c index a9fc5cba2fff..d0403dfb3ab3 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwpci.c +++ b/sys/contrib/dev/acpica/components/hardware/hwpci.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwregs.c b/sys/contrib/dev/acpica/components/hardware/hwregs.c index d0f47b874ead..33ff9177f87f 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwregs.c +++ b/sys/contrib/dev/acpica/components/hardware/hwregs.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwsleep.c b/sys/contrib/dev/acpica/components/hardware/hwsleep.c index 210f4ea62dee..9503617ccc3f 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwsleep.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwtimer.c b/sys/contrib/dev/acpica/components/hardware/hwtimer.c index 9a9602e04232..95361aa3c1a0 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwtimer.c +++ b/sys/contrib/dev/acpica/components/hardware/hwtimer.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwvalid.c b/sys/contrib/dev/acpica/components/hardware/hwvalid.c index 5c4df25d2c38..616b07101ba8 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwvalid.c +++ b/sys/contrib/dev/acpica/components/hardware/hwvalid.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwxface.c b/sys/contrib/dev/acpica/components/hardware/hwxface.c index 5f645617cbce..4e5bf8c3f817 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxface.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c index 1d79e908cf08..fd0563b4104f 100644 --- a/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c +++ b/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsaccess.c b/sys/contrib/dev/acpica/components/namespace/nsaccess.c index 35d30ded0a60..2ef88ff7b5b6 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsaccess.c +++ b/sys/contrib/dev/acpica/components/namespace/nsaccess.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsalloc.c b/sys/contrib/dev/acpica/components/namespace/nsalloc.c index 69d1d7fa053a..648c6ff8c13e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsalloc.c +++ b/sys/contrib/dev/acpica/components/namespace/nsalloc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsarguments.c b/sys/contrib/dev/acpica/components/namespace/nsarguments.c index 8916484053b9..73ce74ab921d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsarguments.c +++ b/sys/contrib/dev/acpica/components/namespace/nsarguments.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsconvert.c b/sys/contrib/dev/acpica/components/namespace/nsconvert.c index ad4890b591a3..104324735436 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsconvert.c +++ b/sys/contrib/dev/acpica/components/namespace/nsconvert.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsdump.c b/sys/contrib/dev/acpica/components/namespace/nsdump.c index bf4aa1455075..300672e261ef 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdump.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c index dc370a6e3018..172935d986e5 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c +++ b/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nseval.c b/sys/contrib/dev/acpica/components/namespace/nseval.c index 765b270ad2a1..a977b65672be 100644 --- a/sys/contrib/dev/acpica/components/namespace/nseval.c +++ b/sys/contrib/dev/acpica/components/namespace/nseval.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsinit.c b/sys/contrib/dev/acpica/components/namespace/nsinit.c index ed37aee82502..da4775f1563e 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsinit.c +++ b/sys/contrib/dev/acpica/components/namespace/nsinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsload.c b/sys/contrib/dev/acpica/components/namespace/nsload.c index bbd36a8a29a3..c81ecde79239 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsload.c +++ b/sys/contrib/dev/acpica/components/namespace/nsload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsnames.c b/sys/contrib/dev/acpica/components/namespace/nsnames.c index a5aa1139792d..c1fc31b4bdad 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsnames.c +++ b/sys/contrib/dev/acpica/components/namespace/nsnames.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -400,6 +400,13 @@ AcpiNsBuildNormalizedPath ( goto BuildTrailingNull; } + /* Validate the Node to avoid use-after-free vulnerabilities */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + goto BuildTrailingNull; + } + NextNode = Node; while (NextNode && NextNode != AcpiGbl_RootNode) { diff --git a/sys/contrib/dev/acpica/components/namespace/nsobject.c b/sys/contrib/dev/acpica/components/namespace/nsobject.c index fd6f0a524699..246d93ce74f6 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsobject.c +++ b/sys/contrib/dev/acpica/components/namespace/nsobject.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -336,6 +336,13 @@ AcpiNsDetachObject ( ObjDesc = Node->Object; + /* Alias nodes point directly to other namespace nodes; skip teardown */ + if (Node->Flags & ANOBJ_IS_ALIAS) + { + Node->Object = NULL; + return_VOID; + } + if (!ObjDesc || (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) { diff --git a/sys/contrib/dev/acpica/components/namespace/nsparse.c b/sys/contrib/dev/acpica/components/namespace/nsparse.c index c5d35bac831c..ee9e9a6ce035 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsparse.c +++ b/sys/contrib/dev/acpica/components/namespace/nsparse.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nspredef.c b/sys/contrib/dev/acpica/components/namespace/nspredef.c index 5bb5d5bf67ca..b63a1e2ada26 100644 --- a/sys/contrib/dev/acpica/components/namespace/nspredef.c +++ b/sys/contrib/dev/acpica/components/namespace/nspredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c index 6fced55328bf..2deadcf39d75 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c +++ b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -779,6 +779,13 @@ AcpiNsCustomPackage ( /* Get version number, must be Integer */ + if (!(*Elements)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, + "Return Package has a NULL version element")); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + if ((*Elements)->Common.Type != ACPI_TYPE_INTEGER) { ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags, diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair.c b/sys/contrib/dev/acpica/components/namespace/nsrepair.c index 8d0e86932e1d..edecc8ddfd6c 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c index 0dddebda980b..c70e3b9027a7 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsrepair2.c +++ b/sys/contrib/dev/acpica/components/namespace/nsrepair2.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nssearch.c b/sys/contrib/dev/acpica/components/namespace/nssearch.c index d956358e8e35..8e6fa7cae3f9 100644 --- a/sys/contrib/dev/acpica/components/namespace/nssearch.c +++ b/sys/contrib/dev/acpica/components/namespace/nssearch.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsutils.c b/sys/contrib/dev/acpica/components/namespace/nsutils.c index bf400ed2370d..20031654469d 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsutils.c +++ b/sys/contrib/dev/acpica/components/namespace/nsutils.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nswalk.c b/sys/contrib/dev/acpica/components/namespace/nswalk.c index 14a608bc28fe..0ef306cc5629 100644 --- a/sys/contrib/dev/acpica/components/namespace/nswalk.c +++ b/sys/contrib/dev/acpica/components/namespace/nswalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c index f6a1ead7ddd5..b996bf834469 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfeval.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfeval.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfname.c b/sys/contrib/dev/acpica/components/namespace/nsxfname.c index 94800cb531c6..9b18825c0473 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfname.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfname.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c index ea0654285a90..42dd10828614 100644 --- a/sys/contrib/dev/acpica/components/namespace/nsxfobj.c +++ b/sys/contrib/dev/acpica/components/namespace/nsxfobj.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psargs.c b/sys/contrib/dev/acpica/components/parser/psargs.c index d9110c09fcb5..fecb11677c31 100644 --- a/sys/contrib/dev/acpica/components/parser/psargs.c +++ b/sys/contrib/dev/acpica/components/parser/psargs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -197,6 +197,7 @@ AcpiPsGetNextPackageLength ( UINT32 PackageLength = 0; UINT32 ByteCount; UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ + UINT32 Remaining; ACPI_FUNCTION_TRACE (PsGetNextPackageLength); @@ -206,7 +207,24 @@ AcpiPsGetNextPackageLength ( * Byte 0 bits [6:7] contain the number of additional bytes * used to encode the package length, either 0,1,2, or 3 */ + + /* Check if we have at least one byte to read */ + Remaining = (UINT32) ACPI_PTR_DIFF (ParserState->AmlEnd, Aml); + if (Remaining == 0) + { + return_UINT32 (0); + } + ByteCount = (Aml[0] >> 6); + + /* Validate ByteCount and ensure we have enough bytes to read */ + if (ByteCount >= Remaining) + { + /* Clamp to available bytes and advance to end */ + ParserState->Aml = ParserState->AmlEnd; + return_UINT32 (0); + } + ParserState->Aml += ((ACPI_SIZE) ByteCount + 1); /* Get bytes 3, 2, 1 as needed */ @@ -545,6 +563,8 @@ AcpiPsGetNextSimpleArg ( UINT32 Length; UINT16 Opcode; UINT8 *Aml = ParserState->Aml; + UINT32 Remaining = (UINT32) ACPI_PTR_DIFF (ParserState->AmlEnd, Aml); + UINT64 PartialValue; ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); @@ -557,8 +577,16 @@ AcpiPsGetNextSimpleArg ( /* Get 1 byte from the AML stream */ Opcode = AML_BYTE_OP; - Arg->Common.Value.Integer = (UINT64) *Aml; - Length = 1; + if (Remaining >= 1) + { + Arg->Common.Value.Integer = (UINT64) *Aml; + Length = 1; + } + else + { + Arg->Common.Value.Integer = 0; + Length = 0; + } break; case ARGP_WORDDATA: @@ -566,8 +594,23 @@ AcpiPsGetNextSimpleArg ( /* Get 2 bytes from the AML stream */ Opcode = AML_WORD_OP; - ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); - Length = 2; + if (Remaining >= 2) + { + ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 2; + } + else + { + Arg->Common.Value.Integer = 0; + Length = 0; + if (Remaining > 0) + { + PartialValue = 0; + memcpy (&PartialValue, Aml, Remaining); + Arg->Common.Value.Integer = PartialValue; + Length = Remaining; + } + } break; case ARGP_DWORDDATA: @@ -575,8 +618,23 @@ AcpiPsGetNextSimpleArg ( /* Get 4 bytes from the AML stream */ Opcode = AML_DWORD_OP; - ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); - Length = 4; + if (Remaining >= 4) + { + ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 4; + } + else + { + Arg->Common.Value.Integer = 0; + Length = 0; + if (Remaining > 0) + { + PartialValue = 0; + memcpy (&PartialValue, Aml, Remaining); + Arg->Common.Value.Integer = PartialValue; + Length = Remaining; + } + } break; case ARGP_QWORDDATA: @@ -584,8 +642,23 @@ AcpiPsGetNextSimpleArg ( /* Get 8 bytes from the AML stream */ Opcode = AML_QWORD_OP; - ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); - Length = 8; + if (Remaining >= 8) + { + ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 8; + } + else + { + Arg->Common.Value.Integer = 0; + Length = 0; + if (Remaining > 0) + { + PartialValue = 0; + memcpy (&PartialValue, Aml, Remaining); + Arg->Common.Value.Integer = PartialValue; + Length = Remaining; + } + } break; case ARGP_CHARLIST: @@ -598,11 +671,32 @@ AcpiPsGetNextSimpleArg ( /* Find the null terminator */ Length = 0; - while (Aml[Length]) + while ((Length < Remaining) && Aml[Length]) + { + Length++; + } + if (Length < Remaining) { + /* Account for the terminating null */ Length++; } - Length++; + else + { + /* + * No terminator found - add null at buffer boundary + * and report a warning + */ + ACPI_WARNING ((AE_INFO, + "Invalid AML string: no null terminator, truncating at offset %u", + (UINT32) (Aml - ParserState->Aml))); + + /* Add null terminator at the boundary */ + if (Remaining > 0) + { + Aml[Remaining - 1] = 0; + Length = Remaining; + } + } break; case ARGP_NAME: @@ -659,6 +753,11 @@ AcpiPsGetNextField ( ASL_CV_CAPTURE_COMMENTS_ONLY (ParserState); Aml = ParserState->Aml; + if (Aml >= ParserState->AmlEnd) + { + return_PTR (NULL); + } + /* Determine field type */ switch (ACPI_GET8 (ParserState->Aml)) @@ -710,6 +809,11 @@ AcpiPsGetNextField ( /* Get the 4-character name */ + if ((ParserState->Aml + ACPI_NAMESEG_SIZE) > ParserState->AmlEnd) + { + AcpiPsFreeOp (Field); + return_PTR (NULL); + } ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); AcpiPsSetName (Field, Name); ParserState->Aml += ACPI_NAMESEG_SIZE; @@ -756,6 +860,11 @@ AcpiPsGetNextField ( /* Get the two bytes (Type/Attribute) */ + if ((ParserState->Aml + 2) > ParserState->AmlEnd) + { + AcpiPsFreeOp (Field); + return_PTR (NULL); + } AccessType = ACPI_GET8 (ParserState->Aml); ParserState->Aml++; AccessAttribute = ACPI_GET8 (ParserState->Aml); @@ -768,6 +877,11 @@ AcpiPsGetNextField ( if (Opcode == AML_INT_EXTACCESSFIELD_OP) { + if (ParserState->Aml >= ParserState->AmlEnd) + { + AcpiPsFreeOp (Field); + return_PTR (NULL); + } AccessLength = ACPI_GET8 (ParserState->Aml); ParserState->Aml++; diff --git a/sys/contrib/dev/acpica/components/parser/psloop.c b/sys/contrib/dev/acpica/components/parser/psloop.c index f4cac83e6069..b7e4bac02e09 100644 --- a/sys/contrib/dev/acpica/components/parser/psloop.c +++ b/sys/contrib/dev/acpica/components/parser/psloop.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -566,7 +566,8 @@ AcpiPsParseLoop ( WalkState->Aml = ParserState->Aml; ACPI_ERROR ((AE_INFO, "Skipping While/If block")); - if (*WalkState->Aml == AML_ELSE_OP) + if ((WalkState->Aml < ParserState->AmlEnd) && + (*WalkState->Aml == AML_ELSE_OP)) { ACPI_ERROR ((AE_INFO, "Skipping Else block")); WalkState->ParserState.Aml = WalkState->Aml + 1; diff --git a/sys/contrib/dev/acpica/components/parser/psobject.c b/sys/contrib/dev/acpica/components/parser/psobject.c index 5457d9d0be7d..5039d81c05ef 100644 --- a/sys/contrib/dev/acpica/components/parser/psobject.c +++ b/sys/contrib/dev/acpica/components/parser/psobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psopcode.c b/sys/contrib/dev/acpica/components/parser/psopcode.c index a317fab3005e..a8bba0cefc0d 100644 --- a/sys/contrib/dev/acpica/components/parser/psopcode.c +++ b/sys/contrib/dev/acpica/components/parser/psopcode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psopinfo.c b/sys/contrib/dev/acpica/components/parser/psopinfo.c index 1db32f4e8246..8ebcf05f1a66 100644 --- a/sys/contrib/dev/acpica/components/parser/psopinfo.c +++ b/sys/contrib/dev/acpica/components/parser/psopinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psparse.c b/sys/contrib/dev/acpica/components/parser/psparse.c index f294033a0039..1cb4dd905036 100644 --- a/sys/contrib/dev/acpica/components/parser/psparse.c +++ b/sys/contrib/dev/acpica/components/parser/psparse.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psscope.c b/sys/contrib/dev/acpica/components/parser/psscope.c index 4f9f496f5018..cb1d2abf815a 100644 --- a/sys/contrib/dev/acpica/components/parser/psscope.c +++ b/sys/contrib/dev/acpica/components/parser/psscope.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/pstree.c b/sys/contrib/dev/acpica/components/parser/pstree.c index b561ba4b0721..657d59064dea 100644 --- a/sys/contrib/dev/acpica/components/parser/pstree.c +++ b/sys/contrib/dev/acpica/components/parser/pstree.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/psutils.c b/sys/contrib/dev/acpica/components/parser/psutils.c index 3c647940e287..8554264f8c30 100644 --- a/sys/contrib/dev/acpica/components/parser/psutils.c +++ b/sys/contrib/dev/acpica/components/parser/psutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/parser/pswalk.c b/sys/contrib/dev/acpica/components/parser/pswalk.c index a0941d44cc03..174e6aefec19 100644 --- a/sys/contrib/dev/acpica/components/parser/pswalk.c +++ b/sys/contrib/dev/acpica/components/parser/pswalk.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -198,7 +198,7 @@ AcpiPsDeleteParseTree ( { /* This debug option will print the entire parse tree */ - AcpiOsPrintf (" %*.s%s %p", (Level * 4), " ", + AcpiOsPrintf (" %*s%s %p", (Level * 4), "", AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Op); if (Op->Named.AmlOpcode == AML_INT_NAMEPATH_OP) diff --git a/sys/contrib/dev/acpica/components/parser/psxface.c b/sys/contrib/dev/acpica/components/parser/psxface.c index 08c1c2bb4f0d..2fad9ccd030e 100644 --- a/sys/contrib/dev/acpica/components/parser/psxface.c +++ b/sys/contrib/dev/acpica/components/parser/psxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsaddr.c b/sys/contrib/dev/acpica/components/resources/rsaddr.c index 9074c6dbaa35..bb07db852451 100644 --- a/sys/contrib/dev/acpica/components/resources/rsaddr.c +++ b/sys/contrib/dev/acpica/components/resources/rsaddr.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rscalc.c b/sys/contrib/dev/acpica/components/resources/rscalc.c index fc7575c2ddfb..daffc696803d 100644 --- a/sys/contrib/dev/acpica/components/resources/rscalc.c +++ b/sys/contrib/dev/acpica/components/resources/rscalc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rscreate.c b/sys/contrib/dev/acpica/components/resources/rscreate.c index b930ced8396f..a625b65194dc 100644 --- a/sys/contrib/dev/acpica/components/resources/rscreate.c +++ b/sys/contrib/dev/acpica/components/resources/rscreate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsdump.c b/sys/contrib/dev/acpica/components/resources/rsdump.c index 2f3e996af9af..d485b047d24e 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdump.c +++ b/sys/contrib/dev/acpica/components/resources/rsdump.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c index 293eeb596928..4238772408fb 100644 --- a/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsdumpinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsinfo.c b/sys/contrib/dev/acpica/components/resources/rsinfo.c index 7a1bb07abb94..222ef95c600b 100644 --- a/sys/contrib/dev/acpica/components/resources/rsinfo.c +++ b/sys/contrib/dev/acpica/components/resources/rsinfo.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsio.c b/sys/contrib/dev/acpica/components/resources/rsio.c index 46d9b2f8aa4b..b51cb2ed18dd 100644 --- a/sys/contrib/dev/acpica/components/resources/rsio.c +++ b/sys/contrib/dev/acpica/components/resources/rsio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsirq.c b/sys/contrib/dev/acpica/components/resources/rsirq.c index 80482eb097d6..a1c32a13ffbd 100644 --- a/sys/contrib/dev/acpica/components/resources/rsirq.c +++ b/sys/contrib/dev/acpica/components/resources/rsirq.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rslist.c b/sys/contrib/dev/acpica/components/resources/rslist.c index 2de70ad4fc58..0f6c6ad2ac4a 100644 --- a/sys/contrib/dev/acpica/components/resources/rslist.c +++ b/sys/contrib/dev/acpica/components/resources/rslist.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsmemory.c b/sys/contrib/dev/acpica/components/resources/rsmemory.c index 0430379a0f05..7a274e6695ba 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmemory.c +++ b/sys/contrib/dev/acpica/components/resources/rsmemory.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsmisc.c b/sys/contrib/dev/acpica/components/resources/rsmisc.c index 725a130a2cec..72165acfffa9 100644 --- a/sys/contrib/dev/acpica/components/resources/rsmisc.c +++ b/sys/contrib/dev/acpica/components/resources/rsmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsserial.c b/sys/contrib/dev/acpica/components/resources/rsserial.c index ab09939850c0..55fb82d8ffff 100644 --- a/sys/contrib/dev/acpica/components/resources/rsserial.c +++ b/sys/contrib/dev/acpica/components/resources/rsserial.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -447,7 +447,7 @@ ACPI_RSCONVERT_INFO AcpiRsConvertCsi2SerialBus[14] = * ******************************************************************************/ -ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[17] = +ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[18] = { {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS), @@ -515,6 +515,11 @@ ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[17] = AML_OFFSET (I2cSerialBus.TypeSpecificFlags), 0}, + /* Read LVR from Type Specific Flags, bits[15:8] */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.I2cSerialBus.Lvr), + AML_OFFSET (I2cSerialBus.TypeSpecificFlags) + 1, + 1}, + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed), AML_OFFSET (I2cSerialBus.ConnectionSpeed), 1}, diff --git a/sys/contrib/dev/acpica/components/resources/rsutils.c b/sys/contrib/dev/acpica/components/resources/rsutils.c index cc89fcfbb356..e9e797e43e1e 100644 --- a/sys/contrib/dev/acpica/components/resources/rsutils.c +++ b/sys/contrib/dev/acpica/components/resources/rsutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/resources/rsxface.c b/sys/contrib/dev/acpica/components/resources/rsxface.c index 89cc58864ead..ada8a44448fc 100644 --- a/sys/contrib/dev/acpica/components/resources/rsxface.c +++ b/sys/contrib/dev/acpica/components/resources/rsxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbdata.c b/sys/contrib/dev/acpica/components/tables/tbdata.c index 46c7724bdda4..b36e971fcceb 100644 --- a/sys/contrib/dev/acpica/components/tables/tbdata.c +++ b/sys/contrib/dev/acpica/components/tables/tbdata.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbfadt.c b/sys/contrib/dev/acpica/components/tables/tbfadt.c index 70490b5d0e70..8fea0572eb74 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfadt.c +++ b/sys/contrib/dev/acpica/components/tables/tbfadt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -736,8 +736,11 @@ AcpiTbConvertFadt ( * Note: If the legacy length field is > 0xFF bits, ignore * this check. (GPE registers can be larger than the * 64-bit GAS structure can accommodate, 0xFF bits). + * Also skip if BitWidth is 0, indicating the 64-bit field + * was not populated - legacy length will be used instead. */ if ((ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) && + (Address64->BitWidth != 0) && (Address64->BitWidth != ACPI_MUL_8 (Length))) { ACPI_BIOS_WARNING ((AE_INFO, diff --git a/sys/contrib/dev/acpica/components/tables/tbfind.c b/sys/contrib/dev/acpica/components/tables/tbfind.c index e497cca9b553..070debef1fac 100644 --- a/sys/contrib/dev/acpica/components/tables/tbfind.c +++ b/sys/contrib/dev/acpica/components/tables/tbfind.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbinstal.c b/sys/contrib/dev/acpica/components/tables/tbinstal.c index 309ec5b68472..aa508042910e 100644 --- a/sys/contrib/dev/acpica/components/tables/tbinstal.c +++ b/sys/contrib/dev/acpica/components/tables/tbinstal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbprint.c b/sys/contrib/dev/acpica/components/tables/tbprint.c index cc4badd84801..01dee2953fc8 100644 --- a/sys/contrib/dev/acpica/components/tables/tbprint.c +++ b/sys/contrib/dev/acpica/components/tables/tbprint.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbutils.c b/sys/contrib/dev/acpica/components/tables/tbutils.c index 61d8ac597afa..db18a24413fe 100644 --- a/sys/contrib/dev/acpica/components/tables/tbutils.c +++ b/sys/contrib/dev/acpica/components/tables/tbutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbxface.c b/sys/contrib/dev/acpica/components/tables/tbxface.c index 0b16c0a9ebec..7e732809b6a1 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxface.c +++ b/sys/contrib/dev/acpica/components/tables/tbxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbxfload.c b/sys/contrib/dev/acpica/components/tables/tbxfload.c index af49869d626c..f3c8d0b900ae 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfload.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/tables/tbxfroot.c b/sys/contrib/dev/acpica/components/tables/tbxfroot.c index 7c444bda9c8c..7e4b05abe60f 100644 --- a/sys/contrib/dev/acpica/components/tables/tbxfroot.c +++ b/sys/contrib/dev/acpica/components/tables/tbxfroot.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utaddress.c b/sys/contrib/dev/acpica/components/utilities/utaddress.c index 7ea0ff3e91b7..d7296a08f6e5 100644 --- a/sys/contrib/dev/acpica/components/utilities/utaddress.c +++ b/sys/contrib/dev/acpica/components/utilities/utaddress.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utalloc.c b/sys/contrib/dev/acpica/components/utilities/utalloc.c index 0dfdec633c2f..7b7d86a7268c 100644 --- a/sys/contrib/dev/acpica/components/utilities/utalloc.c +++ b/sys/contrib/dev/acpica/components/utilities/utalloc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utascii.c b/sys/contrib/dev/acpica/components/utilities/utascii.c index cf64bdee02df..925355121184 100644 --- a/sys/contrib/dev/acpica/components/utilities/utascii.c +++ b/sys/contrib/dev/acpica/components/utilities/utascii.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utbuffer.c b/sys/contrib/dev/acpica/components/utilities/utbuffer.c index b22530412b2f..c72b3065e03e 100644 --- a/sys/contrib/dev/acpica/components/utilities/utbuffer.c +++ b/sys/contrib/dev/acpica/components/utilities/utbuffer.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utcache.c b/sys/contrib/dev/acpica/components/utilities/utcache.c index 232154696307..271920a69134 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcache.c +++ b/sys/contrib/dev/acpica/components/utilities/utcache.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utcksum.c b/sys/contrib/dev/acpica/components/utilities/utcksum.c index 50f8f80570ef..c9d137a7ef3a 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcksum.c +++ b/sys/contrib/dev/acpica/components/utilities/utcksum.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utcopy.c b/sys/contrib/dev/acpica/components/utilities/utcopy.c index fd4d6922a1f2..3a3f4d317385 100644 --- a/sys/contrib/dev/acpica/components/utilities/utcopy.c +++ b/sys/contrib/dev/acpica/components/utilities/utcopy.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -918,7 +918,16 @@ AcpiUtCopySimpleObject ( break; } - AcpiUtAddReference (SourceDesc->Reference.Object); + /* + * Local/Arg/Debug references do not have a valid Object pointer + * that can be referenced + */ + if ((SourceDesc->Reference.Class != ACPI_REFCLASS_LOCAL) && + (SourceDesc->Reference.Class != ACPI_REFCLASS_ARG) && + (SourceDesc->Reference.Class != ACPI_REFCLASS_DEBUG)) + { + AcpiUtAddReference (SourceDesc->Reference.Object); + } break; case ACPI_TYPE_REGION: diff --git a/sys/contrib/dev/acpica/components/utilities/utdebug.c b/sys/contrib/dev/acpica/components/utilities/utdebug.c index 90b8e246a1a9..1b6b56fca02d 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdebug.c +++ b/sys/contrib/dev/acpica/components/utilities/utdebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utdecode.c b/sys/contrib/dev/acpica/components/utilities/utdecode.c index 00a2de9e9a5d..85a948476d05 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdecode.c +++ b/sys/contrib/dev/acpica/components/utilities/utdecode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utdelete.c b/sys/contrib/dev/acpica/components/utilities/utdelete.c index e88cc736990b..2668398ac4cc 100644 --- a/sys/contrib/dev/acpica/components/utilities/utdelete.c +++ b/sys/contrib/dev/acpica/components/utilities/utdelete.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/uterror.c b/sys/contrib/dev/acpica/components/utilities/uterror.c index 1537f69a2a2b..1eec656e0c56 100644 --- a/sys/contrib/dev/acpica/components/utilities/uterror.c +++ b/sys/contrib/dev/acpica/components/utilities/uterror.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/uteval.c b/sys/contrib/dev/acpica/components/utilities/uteval.c index 53f843062179..ab0109c88af9 100644 --- a/sys/contrib/dev/acpica/components/utilities/uteval.c +++ b/sys/contrib/dev/acpica/components/utilities/uteval.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utexcep.c b/sys/contrib/dev/acpica/components/utilities/utexcep.c index b3e606ceef57..c1bd798f146e 100644 --- a/sys/contrib/dev/acpica/components/utilities/utexcep.c +++ b/sys/contrib/dev/acpica/components/utilities/utexcep.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utglobal.c b/sys/contrib/dev/acpica/components/utilities/utglobal.c index 95d679a20746..ec24f1f1f9ac 100644 --- a/sys/contrib/dev/acpica/components/utilities/utglobal.c +++ b/sys/contrib/dev/acpica/components/utilities/utglobal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/uthex.c b/sys/contrib/dev/acpica/components/utilities/uthex.c index 2806f1c48148..751f7af6501f 100644 --- a/sys/contrib/dev/acpica/components/utilities/uthex.c +++ b/sys/contrib/dev/acpica/components/utilities/uthex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utids.c b/sys/contrib/dev/acpica/components/utilities/utids.c index 3dfb908302c6..0fffb8377c83 100644 --- a/sys/contrib/dev/acpica/components/utilities/utids.c +++ b/sys/contrib/dev/acpica/components/utilities/utids.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utinit.c b/sys/contrib/dev/acpica/components/utilities/utinit.c index b5a4b7e7d936..a32361a53e17 100644 --- a/sys/contrib/dev/acpica/components/utilities/utinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utlock.c b/sys/contrib/dev/acpica/components/utilities/utlock.c index a06b27525cc3..4f4c3036bc4f 100644 --- a/sys/contrib/dev/acpica/components/utilities/utlock.c +++ b/sys/contrib/dev/acpica/components/utilities/utlock.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utmath.c b/sys/contrib/dev/acpica/components/utilities/utmath.c index 48bbe8f3d8c8..c9c5bd3f2a31 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmath.c +++ b/sys/contrib/dev/acpica/components/utilities/utmath.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utmisc.c b/sys/contrib/dev/acpica/components/utilities/utmisc.c index 13dffc6674d3..4723349ac6f3 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmisc.c +++ b/sys/contrib/dev/acpica/components/utilities/utmisc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utmutex.c b/sys/contrib/dev/acpica/components/utilities/utmutex.c index b0b26458818e..ba1d477b0bed 100644 --- a/sys/contrib/dev/acpica/components/utilities/utmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utmutex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utnonansi.c b/sys/contrib/dev/acpica/components/utilities/utnonansi.c index f8b3a29e3283..e6cacbad00e8 100644 --- a/sys/contrib/dev/acpica/components/utilities/utnonansi.c +++ b/sys/contrib/dev/acpica/components/utilities/utnonansi.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utobject.c b/sys/contrib/dev/acpica/components/utilities/utobject.c index 6988afdcbaec..3e388dd1a968 100644 --- a/sys/contrib/dev/acpica/components/utilities/utobject.c +++ b/sys/contrib/dev/acpica/components/utilities/utobject.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utosi.c b/sys/contrib/dev/acpica/components/utilities/utosi.c index 7118313f7b16..fc886276a3ab 100644 --- a/sys/contrib/dev/acpica/components/utilities/utosi.c +++ b/sys/contrib/dev/acpica/components/utilities/utosi.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utownerid.c b/sys/contrib/dev/acpica/components/utilities/utownerid.c index 7e39b7851af4..40139f481c87 100644 --- a/sys/contrib/dev/acpica/components/utilities/utownerid.c +++ b/sys/contrib/dev/acpica/components/utilities/utownerid.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utpredef.c b/sys/contrib/dev/acpica/components/utilities/utpredef.c index 23e6606d167c..3131e16f046f 100644 --- a/sys/contrib/dev/acpica/components/utilities/utpredef.c +++ b/sys/contrib/dev/acpica/components/utilities/utpredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utresdecode.c b/sys/contrib/dev/acpica/components/utilities/utresdecode.c index d14259911a07..8ff5dd12cc5f 100644 --- a/sys/contrib/dev/acpica/components/utilities/utresdecode.c +++ b/sys/contrib/dev/acpica/components/utilities/utresdecode.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utresrc.c b/sys/contrib/dev/acpica/components/utilities/utresrc.c index 109395435d45..5a1220c6ee70 100644 --- a/sys/contrib/dev/acpica/components/utilities/utresrc.c +++ b/sys/contrib/dev/acpica/components/utilities/utresrc.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -322,6 +322,29 @@ AcpiUtWalkAmlResources ( while (Aml < EndAml) { + /* + * Validate that the remaining buffer space can hold enough + * bytes to safely access fields during validation. + * For large resource descriptors (bit 7 set), we need enough + * bytes to access the Type field in SerialBus resources. + * Small resource descriptors only need sizeof(AML_RESOURCE_END_TAG). + */ + if ((ACPI_SIZE) (EndAml - Aml) < sizeof (AML_RESOURCE_END_TAG)) + { + return_ACPI_STATUS (AE_AML_BUFFER_LENGTH); + } + + /* + * For large resource descriptors, ensure enough space for + * the header plus SerialBus Type field access. + */ + if ((ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) && + ((ACPI_SIZE) (EndAml - Aml) < + ACPI_OFFSET (AML_RESOURCE_COMMON_SERIALBUS, Type) + 1)) + { + return_ACPI_STATUS (AE_AML_BUFFER_LENGTH); + } + /* Validate the Resource Type and Resource Length */ Status = AcpiUtValidateResource (WalkState, Aml, &ResourceIndex); @@ -338,6 +361,15 @@ AcpiUtWalkAmlResources ( Length = AcpiUtGetDescriptorLength (Aml); + /* + * Validate that the descriptor length doesn't exceed the + * remaining buffer size to prevent reading beyond the end. + */ + if (Length > (ACPI_SIZE) (EndAml - Aml)) + { + return_ACPI_STATUS (AE_AML_BUFFER_LENGTH); + } + /* Invoke the user function */ if (UserFunction) diff --git a/sys/contrib/dev/acpica/components/utilities/utstate.c b/sys/contrib/dev/acpica/components/utilities/utstate.c index 02fec7d15bf5..5789cd3309d1 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstate.c +++ b/sys/contrib/dev/acpica/components/utilities/utstate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utstring.c b/sys/contrib/dev/acpica/components/utilities/utstring.c index 59e34e7c8a79..5ece4de3c50b 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstring.c +++ b/sys/contrib/dev/acpica/components/utilities/utstring.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c b/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c index 1537d8a02949..4d54ab287e91 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c +++ b/sys/contrib/dev/acpica/components/utilities/utstrsuppt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c b/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c index 2683c37c35db..75659ef3d9c5 100644 --- a/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c +++ b/sys/contrib/dev/acpica/components/utilities/utstrtoul64.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/uttrack.c b/sys/contrib/dev/acpica/components/utilities/uttrack.c index 2c60c1c7b1f1..362018ecf330 100644 --- a/sys/contrib/dev/acpica/components/utilities/uttrack.c +++ b/sys/contrib/dev/acpica/components/utilities/uttrack.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utuuid.c b/sys/contrib/dev/acpica/components/utilities/utuuid.c index 669cce69b1f3..cc633e84aa47 100644 --- a/sys/contrib/dev/acpica/components/utilities/utuuid.c +++ b/sys/contrib/dev/acpica/components/utilities/utuuid.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utxface.c b/sys/contrib/dev/acpica/components/utilities/utxface.c index 9b5f8b3c9d84..aee0a5559f4b 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxface.c +++ b/sys/contrib/dev/acpica/components/utilities/utxface.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utxferror.c b/sys/contrib/dev/acpica/components/utilities/utxferror.c index 08a3ab986c3f..1b5b0812ea14 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxferror.c +++ b/sys/contrib/dev/acpica/components/utilities/utxferror.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utxfinit.c b/sys/contrib/dev/acpica/components/utilities/utxfinit.c index f295471031d0..c1d23d4138c5 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfinit.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfinit.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c index 595904977f23..7208ac78c76b 100644 --- a/sys/contrib/dev/acpica/components/utilities/utxfmutex.c +++ b/sys/contrib/dev/acpica/components/utilities/utxfmutex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acapps.h b/sys/contrib/dev/acpica/include/acapps.h index ccaea124afb1..be9bfdfc4857 100644 --- a/sys/contrib/dev/acpica/include/acapps.h +++ b/sys/contrib/dev/acpica/include/acapps.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -159,7 +159,7 @@ /* Common info for tool signons */ #define ACPICA_NAME "Intel ACPI Component Architecture" -#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2025 Intel Corporation" +#define ACPICA_COPYRIGHT "Copyright (c) 2000 - 2026 Intel Corporation" #if ACPI_MACHINE_WIDTH == 64 #define ACPI_WIDTH " (64-bit version)" diff --git a/sys/contrib/dev/acpica/include/acbuffer.h b/sys/contrib/dev/acpica/include/acbuffer.h index 682ddcd72625..2a88d9789c5f 100644 --- a/sys/contrib/dev/acpica/include/acbuffer.h +++ b/sys/contrib/dev/acpica/include/acbuffer.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acclib.h b/sys/contrib/dev/acpica/include/acclib.h index 3960ffd2582e..d6c81823f354 100644 --- a/sys/contrib/dev/acpica/include/acclib.h +++ b/sys/contrib/dev/acpica/include/acclib.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/accommon.h b/sys/contrib/dev/acpica/include/accommon.h index 10a39803842b..4ac4c0db87d7 100644 --- a/sys/contrib/dev/acpica/include/accommon.h +++ b/sys/contrib/dev/acpica/include/accommon.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acconfig.h b/sys/contrib/dev/acpica/include/acconfig.h index 983dc3021185..e139f5837008 100644 --- a/sys/contrib/dev/acpica/include/acconfig.h +++ b/sys/contrib/dev/acpica/include/acconfig.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acconvert.h b/sys/contrib/dev/acpica/include/acconvert.h index 9dedc51a7ef9..ac2e3f9c3a30 100644 --- a/sys/contrib/dev/acpica/include/acconvert.h +++ b/sys/contrib/dev/acpica/include/acconvert.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acdebug.h b/sys/contrib/dev/acpica/include/acdebug.h index 63f39051a8ac..4a6b392d8d33 100644 --- a/sys/contrib/dev/acpica/include/acdebug.h +++ b/sys/contrib/dev/acpica/include/acdebug.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acdisasm.h b/sys/contrib/dev/acpica/include/acdisasm.h index 29ce0d536df3..7f055125bbd3 100644 --- a/sys/contrib/dev/acpica/include/acdisasm.h +++ b/sys/contrib/dev/acpica/include/acdisasm.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -467,6 +467,11 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm0a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1a[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDtpr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDtprInstance[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDtprArr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDtprSerializeReq0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDtprSerializeReq1[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[]; @@ -874,6 +879,10 @@ AcpiDmDumpDrtm ( ACPI_TABLE_HEADER *Table); void +AcpiDmDumpDtpr ( + ACPI_TABLE_HEADER *Table); + +void AcpiDmDumpEinj ( ACPI_TABLE_HEADER *Table); diff --git a/sys/contrib/dev/acpica/include/acdispat.h b/sys/contrib/dev/acpica/include/acdispat.h index 0573e5817dff..4d80aeba95cf 100644 --- a/sys/contrib/dev/acpica/include/acdispat.h +++ b/sys/contrib/dev/acpica/include/acdispat.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acevents.h b/sys/contrib/dev/acpica/include/acevents.h index 22eff360559c..c765abf7ffb3 100644 --- a/sys/contrib/dev/acpica/include/acevents.h +++ b/sys/contrib/dev/acpica/include/acevents.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acexcep.h b/sys/contrib/dev/acpica/include/acexcep.h index 7216e0d49148..643426fb47e6 100644 --- a/sys/contrib/dev/acpica/include/acexcep.h +++ b/sys/contrib/dev/acpica/include/acexcep.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h index 02167c3af092..b77f5a0d0444 100644 --- a/sys/contrib/dev/acpica/include/acglobal.h +++ b/sys/contrib/dev/acpica/include/acglobal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/achware.h b/sys/contrib/dev/acpica/include/achware.h index 46efffb50708..fa20fcd8092d 100644 --- a/sys/contrib/dev/acpica/include/achware.h +++ b/sys/contrib/dev/acpica/include/achware.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acinterp.h b/sys/contrib/dev/acpica/include/acinterp.h index b7f9e8f615e4..c0d372e52c64 100644 --- a/sys/contrib/dev/acpica/include/acinterp.h +++ b/sys/contrib/dev/acpica/include/acinterp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h index ff18d617f79a..d9f126f0f6a1 100644 --- a/sys/contrib/dev/acpica/include/aclocal.h +++ b/sys/contrib/dev/acpica/include/aclocal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -332,6 +332,7 @@ typedef struct acpi_namespace_node #define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ #define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ +#define ANOBJ_IS_ALIAS 0x40 /* iASL only: Node is an alias to another node */ #define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ diff --git a/sys/contrib/dev/acpica/include/acmacros.h b/sys/contrib/dev/acpica/include/acmacros.h index eabe403b3998..03ebb8848b5f 100644 --- a/sys/contrib/dev/acpica/include/acmacros.h +++ b/sys/contrib/dev/acpica/include/acmacros.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acnames.h b/sys/contrib/dev/acpica/include/acnames.h index 070e318fb8cc..24915ab7c407 100644 --- a/sys/contrib/dev/acpica/include/acnames.h +++ b/sys/contrib/dev/acpica/include/acnames.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acnamesp.h b/sys/contrib/dev/acpica/include/acnamesp.h index 41f704b3d74b..cc6b5989436f 100644 --- a/sys/contrib/dev/acpica/include/acnamesp.h +++ b/sys/contrib/dev/acpica/include/acnamesp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acobject.h b/sys/contrib/dev/acpica/include/acobject.h index 95be1a95b4c7..739b981b43e1 100644 --- a/sys/contrib/dev/acpica/include/acobject.h +++ b/sys/contrib/dev/acpica/include/acobject.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acopcode.h b/sys/contrib/dev/acpica/include/acopcode.h index c8d17c3554d0..38e18f8593e4 100644 --- a/sys/contrib/dev/acpica/include/acopcode.h +++ b/sys/contrib/dev/acpica/include/acopcode.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acoutput.h b/sys/contrib/dev/acpica/include/acoutput.h index 49a466dba33a..c0c37ef611f0 100644 --- a/sys/contrib/dev/acpica/include/acoutput.h +++ b/sys/contrib/dev/acpica/include/acoutput.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acparser.h b/sys/contrib/dev/acpica/include/acparser.h index 8b3d3702f4a2..baf43876fb76 100644 --- a/sys/contrib/dev/acpica/include/acparser.h +++ b/sys/contrib/dev/acpica/include/acparser.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acpi.h b/sys/contrib/dev/acpica/include/acpi.h index 07e5e93e2309..29081e0ef26e 100644 --- a/sys/contrib/dev/acpica/include/acpi.h +++ b/sys/contrib/dev/acpica/include/acpi.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acpiosxf.h b/sys/contrib/dev/acpica/include/acpiosxf.h index 77a22eee7442..56112270b90e 100644 --- a/sys/contrib/dev/acpica/include/acpiosxf.h +++ b/sys/contrib/dev/acpica/include/acpiosxf.h @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h index 00f0c08d4789..b19f7b334b5c 100644 --- a/sys/contrib/dev/acpica/include/acpixf.h +++ b/sys/contrib/dev/acpica/include/acpixf.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -154,7 +154,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20251212 +#define ACPI_CA_VERSION 0x20260408 #include <contrib/dev/acpica/include/acconfig.h> #include <contrib/dev/acpica/include/actypes.h> diff --git a/sys/contrib/dev/acpica/include/acpredef.h b/sys/contrib/dev/acpica/include/acpredef.h index 8cf6cf2dfcad..684c5a553e18 100644 --- a/sys/contrib/dev/acpica/include/acpredef.h +++ b/sys/contrib/dev/acpica/include/acpredef.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -522,7 +522,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = {{"_CPC", METHOD_0ARGS, METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Bufs) */ - PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0,0,0,0), + PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER | ACPI_RTYPE_PACKAGE, 0,0,0,0), {{"_CR3", METHOD_0ARGS, /* ACPI 6.0 */ METHOD_RETURNS (ACPI_RTYPE_INTEGER)}}, @@ -587,7 +587,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] = METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */ PACKAGE_INFO (ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_PACKAGE, 1,0), - {{"_DSM", METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_ANY | ACPI_TYPE_PACKAGE) | ARG_COUNT_IS_MINIMUM, + {{"_DSM", METHOD_4ARGS (ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_PACKAGE | ACPI_TYPE_ANY) | ARG_COUNT_IS_MINIMUM, METHOD_RETURNS (ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */ {{"_DSS", METHOD_1ARGS (ACPI_TYPE_INTEGER), diff --git a/sys/contrib/dev/acpica/include/acresrc.h b/sys/contrib/dev/acpica/include/acresrc.h index 2e3c7d3d1d40..781ecaa246d7 100644 --- a/sys/contrib/dev/acpica/include/acresrc.h +++ b/sys/contrib/dev/acpica/include/acresrc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acrestyp.h b/sys/contrib/dev/acpica/include/acrestyp.h index ab48a3911ae6..e9a20fa23e28 100644 --- a/sys/contrib/dev/acpica/include/acrestyp.h +++ b/sys/contrib/dev/acpica/include/acrestyp.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -641,6 +641,7 @@ typedef struct acpi_resource_i2c_serialbus UINT8 AccessMode; UINT16 SlaveAddress; UINT32 ConnectionSpeed; + UINT8 Lvr; } ACPI_RESOURCE_I2C_SERIALBUS; diff --git a/sys/contrib/dev/acpica/include/acstruct.h b/sys/contrib/dev/acpica/include/acstruct.h index b1c54f09fe55..3c6ebfc2d179 100644 --- a/sys/contrib/dev/acpica/include/acstruct.h +++ b/sys/contrib/dev/acpica/include/acstruct.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/actables.h b/sys/contrib/dev/acpica/include/actables.h index 6f2cacbde3a1..edf3b80afc38 100644 --- a/sys/contrib/dev/acpica/include/actables.h +++ b/sys/contrib/dev/acpica/include/actables.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/actbinfo.h b/sys/contrib/dev/acpica/include/actbinfo.h index 0d80f67b6982..ff61c1861ee2 100644 --- a/sys/contrib/dev/acpica/include/actbinfo.h +++ b/sys/contrib/dev/acpica/include/actbinfo.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -168,6 +168,7 @@ #define ACPI_DBGP_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_DBGP,f) #define ACPI_DMAR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_DMAR,f) #define ACPI_DRTM_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_DRTM,f) +#define ACPI_DTPR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_DTPR,f) #define ACPI_ECDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_ECDT,f) #define ACPI_EINJ_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_EINJ,f) #define ACPI_ERDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_ERDT,f) @@ -284,6 +285,10 @@ #define ACPI_DRTM1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST,f) #define ACPI_DRTM1a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_RESOURCE,f) #define ACPI_DRTM2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_DPS_ID,f) +#define ACPI_DTPR_INST_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TPR_INSTANCE,f) +#define ACPI_DTPR_ARR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TPR_ARRAY,f) +#define ACPI_DTPR_AUX_SR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TPR_AUX_SR,f) +#define ACPI_DTPR_SR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TPR_SERIALIZE_REQUEST,f) #define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f) #define ACPI_ERDT_HDR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SUBTBL_HDR_16,f) #define ACPI_ERDT_CACD_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_ERDT_CACD,f) @@ -496,6 +501,9 @@ #define ACPI_DMAR0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_DMAR_HARDWARE_UNIT,f,o) #define ACPI_DRTM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_DRTM,f,o) #define ACPI_DRTM1a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_DRTM_RESOURCE,f,o) +#define ACPI_DTPR_BASE_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TPRN_BASE_REG,f,o) +#define ACPI_DTPR_LIM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TPRN_LIMIT_REG,f,o) +#define ACPI_DTPR_SR_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TPR_SERIALIZE_REQUEST,f,o) #define ACPI_ERDT_RMDD_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_ERDT_RMDD,f,o) #define ACPI_FADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_FADT,f,o) #define ACPI_FACS_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_FACS,f,o) diff --git a/sys/contrib/dev/acpica/include/actbl.h b/sys/contrib/dev/acpica/include/actbl.h index ae52bd452c90..6e0ebda54e45 100644 --- a/sys/contrib/dev/acpica/include/actbl.h +++ b/sys/contrib/dev/acpica/include/actbl.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/actbl1.h b/sys/contrib/dev/acpica/include/actbl1.h index 6e7937999a5b..72a5c47d99c8 100644 --- a/sys/contrib/dev/acpica/include/actbl1.h +++ b/sys/contrib/dev/acpica/include/actbl1.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -181,6 +181,7 @@ #define ACPI_SIG_DBGP "DBGP" /* Debug Port table */ #define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */ #define ACPI_SIG_DRTM "DRTM" /* Dynamic Root of Trust for Measurement table */ +#define ACPI_SIG_DTPR "DTPR" /* DMA TXT Protection Ranges table */ #define ACPI_SIG_ECDT "ECDT" /* Embedded Controller Boot Resources Table */ #define ACPI_SIG_EINJ "EINJ" /* Error Injection table */ #define ACPI_SIG_ERST "ERST" /* Error Record Serialization Table */ @@ -1344,6 +1345,291 @@ typedef struct acpi_drtm_dps_id /******************************************************************************* * + * DTPR - DMA TXT Protection Ranges Table + * Version 1 + * + * Conforms to "Intel® Trusted Execution Technology (Intel® TXT) DMA Protection + * Ranges", + * Revision 0.73, August 2021 + * + ******************************************************************************/ + +typedef struct acpi_table_dtpr { + ACPI_TABLE_HEADER header; + UINT32 Flags; /* 36 */ + UINT32 InsCnt; + +} ACPI_TABLE_DTPR; + +typedef struct acpi_tpr_array { + UINT64 Base; + +} ACPI_TPR_ARRAY; + +typedef struct acpi_tpr_instance { + UINT32 Flags; + UINT32 TprCnt; + +} ACPI_TPR_INSTANCE; + +typedef struct acpi_tpr_aux_sr { + UINT32 SrlCnt; + +} ACPI_TPR_AUX_SR; + + +/* + * TPRn_BASE (ACPI_TPRN_BASE_REG) + * + * Specifies the start address of TPRn region. TPR region address and size must + * be with 1MB resolution. These bits are compared with the result of the + * TPRn_LIMIT[63:20], which is applied to the incoming address, to + * determine if an access fall within the TPRn defined region. + * + * Minimal TPRn_Base resolution is 1MB. Applied to the incoming address, to + * determine if an access fall within the TPRn defined region. Width is + * determined by a bus width which can be obtained via CPUID + * function 0x80000008. + */ + +typedef UINT64 ACPI_TPRN_BASE_REG; + + +/* TPRn_BASE Register Bit Masks */ + +/* Bit 3 - RW: access: 1 == RO, 0 == RW register (for TPR must be RW) */ +#define ACPI_TPRN_BASE_RW_SHIFT 3 + + +#define ACPI_TPRN_BASE_RW_MASK ((UINT64) 1 << ACPI_TPRN_BASE_RW_SHIFT) + + +/* + * Bit 4 - Enable: 0 – TPRn address range enabled; + * 1 – TPRn address range disabled. + */ +#define ACPI_TPRN_BASE_ENABLE_SHIFT 4 + + +#define ACPI_TPRN_BASE_ENABLE_MASK ((UINT64) 1 << ACPI_TPRN_BASE_ENABLE_SHIFT) + + +/* Bits 63:20 - TprBaseRw */ +#define ACPI_TPRN_BASE_ADDR_SHIFT 20 + + +#define ACPI_TPRN_BASE_ADDR_MASK ((UINT64) 0xFFFFFFFFFFF << \ + ACPI_TPRN_BASE_ADDR_SHIFT) + + +/* TPRn_BASE Register Bit Handlers*/ + +/* + * GET_TPRN_BASE_RW: + * + * Read RW bit from TPRn Base Register - bit 3. + * + * Input: + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * + * Output: + * + * Returns RW bit value (UINT64). + */ +#define GET_TPRN_BASE_RW(reg) (((UINT64) reg & ACPI_TPRN_BASE_RW_MASK) >> \ + ACPI_TPRN_BASE_RW_SHIFT) + + +/* + * GET_TPRN_BASE_ENABLE: + * + * Read Enable bit from TPRn Base Register - bit 4. + * + * Input: + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * + * Output: + * + * Returns Enable bit value (UINT64). + */ +#define GET_TPRN_BASE_ENABLE(reg) (((UINT64) reg & ACPI_TPRN_BASE_ENABLE_MASK) \ + >> ACPI_TPRN_BASE_ENABLE_SHIFT) + + +/* + * GET_TPRN_BASE_ADDR: + * + * Read TPRn Base Register address from bits 63:20. + * + * Input: + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * + * Output: + * + * Returns TPRn Base Register address (UINT64). + */ +#define GET_TPRN_BASE_ADDR(reg) (((UINT64) reg & ACPI_TPRN_BASE_ADDR_MASK) \ + >> ACPI_TPRN_BASE_ADDR_SHIFT) + + +/* + * SET_TPRN_BASE_RW: + * + * Set RW bit in TPRn Base Register - bit 3. + * + * Input: + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * - val (represents RW value to be set (UINT64)) + */ +#define SET_TPRN_BASE_RW(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ + ACPI_TPRN_BASE_RW_SHIFT, \ + ACPI_TPRN_BASE_RW_MASK, val); + + +/* + * SET_TPRN_BASE_ENABLE: + * + * Set Enable bit in TPRn Base Register - bit 4. + * + * Input: + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * - val (represents Enable value to be set (UINT64)) + */ +#define SET_TPRN_BASE_ENABLE(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ + ACPI_TPRN_BASE_ENABLE_SHIFT, \ + ACPI_TPRN_BASE_ENABLE_MASK, val); + + +/* + * SET_TPRN_BASE_ADDR: + * + * Set TPRn Base Register address - bits 63:20 + * + * Input + * - reg (represents TPRn Base Register (ACPI_TPRN_BASE_REG)) + * - val (represents address value to be set (UINT64)) + */ +#define SET_TPRN_BASE_ADDR(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ + ACPI_TPRN_BASE_ADDR_SHIFT, \ + ACPI_TPRN_BASE_ADDR_MASK, val); + + +/* + * TPRn_LIMIT + * + * This register defines an isolated region of memory that can be enabled + * to prohibit certain system agents from accessing memory. When an agent + * sends a request upstream, whether snooped or not, a TPR prevents that + * transaction from changing the state of memory. + * + * Minimal TPRn_Limit resolution is 1MB. Width is determined by a bus width. + */ + +typedef UINT64 ACPI_TPRN_LIMIT_REG; + + +/* TPRn_LIMIT Register Bit Masks */ + + +/* Bit 3 - RW: access: 1 == RO, 0 == RW register (for TPR must be RW) */ +#define ACPI_TPRN_LIMIT_RW_SHIFT 3 + + +#define ACPI_TPRN_LIMIT_RW_MASK ((UINT64) 1 << ACPI_TPRN_LIMIT_RW_SHIFT) + + +/* Bits 63:20 - TprLimitRw */ +#define ACPI_TPRN_LIMIT_ADDR_SHIFT 20 + + +#define ACPI_TPRN_LIMIT_ADDR_MASK ((UINT64) 0xFFFFFFFFFFF << \ + ACPI_TPRN_LIMIT_ADDR_SHIFT) + + +/* TPRn_LIMIT Register Bit Handlers*/ + +/* + * GET_TPRN_LIMIT_RW: + * + * Read RW bit from TPRn Limit Register - bit 3. + * + * Input: + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) + * + * Output: + * + * Returns RW bit value (UINT64). + */ +#define GET_TPRN_LIMIT_RW(reg) (((UINT64) reg & ACPI_TPRN_LIMIT_RW_MASK) \ + >> ACPI_TPRN_LIMIT_RW_SHIFT) + + +/* + * GET_TPRN_LIMIT_ADDR: + * + * Read TPRn Limit Register address from bits 63:20. + * + * Input: + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) + * + * Output: + * + * Returns TPRn Limit Register address (UINT64). + */ +#define GET_TPRN_LIMIT_ADDR(reg) (((UINT64) reg & ACPI_TPRN_LIMIT_ADDR_MASK) \ + >> ACPI_TPRN_LIMIT_ADDR_SHIFT) + + +/* + * SET_TPRN_LIMIT_RW: + * + * Set RW bit in TPRn Limit Register - bit 3. + * + * Input: + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) + * - val (represents RW value to be set (UINT64)) + */ +#define SET_TPRN_LIMIT_RW(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ + ACPI_TPRN_LIMIT_RW_SHIFT, \ + ACPI_TPRN_LIMIT_RW_MASK, val); + + +/* + * SET_TPRN_LIMIT_ADDR: + * + * Set TPRn Limit Register address - bits 63:20. + * + * Input: + * - reg (represents TPRn Limit Register (ACPI_TPRN_LIMIT_REG)) + * - val (represents address value to be set (UINT64)) + */ +#define SET_TPRN_LIMIT_ADDR(reg, val) ACPI_REGISTER_INSERT_VALUE(reg, \ + ACPI_TPRN_LIMIT_ADDR_SHIFT, \ + ACPI_TPRN_LIMIT_ADDR_MASK, val); + + +/* + * SERIALIZE_REQUEST + * + * This register is used to request serialization of non-coherent DMA + * transactions. OS shall issue it before changing of TPR settings + * (base / size). + */ + +typedef struct acpi_tpr_serialize_request { + UINT64 SrRegister; + /* + * BIT 1 - Status of serialization request (RO) + * 0 == register idle, 1 == serialization in progress + * BIT 2 - Control field to initiate serialization (RW) + * 0 == normal, 1 == initialize serialization + * (self-clear to allow multiple serialization requests) + */ +} ACPI_TPR_SERIALIZE_REQUEST; + + +/******************************************************************************* + * * ECDT - Embedded Controller Boot Resources Table * Version 1 * @@ -2473,7 +2759,6 @@ typedef struct acpi_ibft_target } ACPI_IBFT_TARGET; - /* Reset to default packing */ #pragma pack() diff --git a/sys/contrib/dev/acpica/include/actbl2.h b/sys/contrib/dev/acpica/include/actbl2.h index a51ff1ecaa09..a5e71e67285a 100644 --- a/sys/contrib/dev/acpica/include/actbl2.h +++ b/sys/contrib/dev/acpica/include/actbl2.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/actbl3.h b/sys/contrib/dev/acpica/include/actbl3.h index 6392359249c9..4886b12c0315 100644 --- a/sys/contrib/dev/acpica/include/actbl3.h +++ b/sys/contrib/dev/acpica/include/actbl3.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h index 3c95887b1678..38f3afa8c811 100644 --- a/sys/contrib/dev/acpica/include/actypes.h +++ b/sys/contrib/dev/acpica/include/actypes.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acutils.h b/sys/contrib/dev/acpica/include/acutils.h index 06b8eb0bda6b..f306f93c1a9b 100644 --- a/sys/contrib/dev/acpica/include/acutils.h +++ b/sys/contrib/dev/acpica/include/acutils.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/acuuid.h b/sys/contrib/dev/acpica/include/acuuid.h index a950972b01b3..9546baa7f1de 100644 --- a/sys/contrib/dev/acpica/include/acuuid.h +++ b/sys/contrib/dev/acpica/include/acuuid.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License @@ -205,6 +205,11 @@ #define UUID_CACHE_PROPERTIES "6DC63E77-257E-4E78-A973-A21F2796898D" #define UUID_PHYSICAL_PROPERTY "DDE4D59A-AA42-4349-B407-EA40F57D9FB7" +/* Modern Standby */ +#define UUID_LPS0_MICROSOFT "11E00D56-CE64-47CE-837B-1F898F9AA461" +#define UUID_LPS0_INTEL "C4EB40A0-6CD2-11E2-BCFD-0800200C9A66" +#define UUID_LPS0_AMD "E3F32452-FEBC-43CE-9039-932122D37721" + /* Miscellaneous */ #define UUID_PLATFORM_CAPABILITIES "0811b06e-4a27-44f9-8d60-3cbbc22e7b48" diff --git a/sys/contrib/dev/acpica/include/amlcode.h b/sys/contrib/dev/acpica/include/amlcode.h index 6bb591904794..ffd48e9e6751 100644 --- a/sys/contrib/dev/acpica/include/amlcode.h +++ b/sys/contrib/dev/acpica/include/amlcode.h @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/amlresrc.h b/sys/contrib/dev/acpica/include/amlresrc.h index 4482ed378ab1..3362b52b3205 100644 --- a/sys/contrib/dev/acpica/include/amlresrc.h +++ b/sys/contrib/dev/acpica/include/amlresrc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/platform/acenv.h b/sys/contrib/dev/acpica/include/platform/acenv.h index b842965bfca0..8b821f176309 100644 --- a/sys/contrib/dev/acpica/include/platform/acenv.h +++ b/sys/contrib/dev/acpica/include/platform/acenv.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/platform/acenvex.h b/sys/contrib/dev/acpica/include/platform/acenvex.h index e9632619abf5..2735e02174de 100644 --- a/sys/contrib/dev/acpica/include/platform/acenvex.h +++ b/sys/contrib/dev/acpica/include/platform/acenvex.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/platform/acfreebsd.h b/sys/contrib/dev/acpica/include/platform/acfreebsd.h index b537a25f9fbd..c039ba1c2ded 100644 --- a/sys/contrib/dev/acpica/include/platform/acfreebsd.h +++ b/sys/contrib/dev/acpica/include/platform/acfreebsd.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/platform/acgcc.h b/sys/contrib/dev/acpica/include/platform/acgcc.h index 39ff864fa5d7..9ed3be2b0658 100644 --- a/sys/contrib/dev/acpica/include/platform/acgcc.h +++ b/sys/contrib/dev/acpica/include/platform/acgcc.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/include/platform/acgccex.h b/sys/contrib/dev/acpica/include/platform/acgccex.h index bb3b55cf2ca6..fae2413bf712 100644 --- a/sys/contrib/dev/acpica/include/platform/acgccex.h +++ b/sys/contrib/dev/acpica/include/platform/acgccex.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/osgendbg.c b/sys/contrib/dev/acpica/os_specific/service_layers/osgendbg.c index eb34274ce670..854a8509fb85 100644 --- a/sys/contrib/dev/acpica/os_specific/service_layers/osgendbg.c +++ b/sys/contrib/dev/acpica/os_specific/service_layers/osgendbg.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c index 81cda5e4eb65..0a1a0c0bf9d9 100644 --- a/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c +++ b/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2026, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c index 1221384e7d8a..2967832a0878 100644 --- a/sys/dev/acpi_support/acpi_ibm.c +++ b/sys/dev/acpi_support/acpi_ibm.c @@ -1453,7 +1453,7 @@ acpi_ibm_eventhandler(struct acpi_ibm_softc *sc, int arg) * instead of suspend-to-RAM. */ case IBM_EVENT_SUSPEND_TO_RAM: - power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND); + power_pm_suspend(POWER_TRANSITION_SUSPEND); break; case IBM_EVENT_BLUETOOTH: diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index bdc197a4fb59..ec1f002150c1 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -672,12 +672,12 @@ acpi_attach(device_t dev) * s2idle when ACPI_FADT_LOW_POWER_S0 is set. */ sc->acpi_sleep_button_stype = POWER_STYPE_UNKNOWN; - for (stype = POWER_STYPE_STANDBY; stype <= POWER_STYPE_HIBERNATE; stype++) + for (stype = POWER_STYPE_STANDBY; stype <= POWER_STYPE_FW_HIBERNATE; stype++) if (acpi_supported_stypes[stype]) { sc->acpi_sleep_button_stype = stype; break; } - if (sc->acpi_sleep_button_stype == POWER_STYPE_HIBERNATE || + if (sc->acpi_sleep_button_stype == POWER_STYPE_FW_HIBERNATE || sc->acpi_sleep_button_stype == POWER_STYPE_UNKNOWN) { if (acpi_supported_stypes[POWER_STYPE_SUSPEND_TO_IDLE]) sc->acpi_sleep_button_stype = POWER_STYPE_SUSPEND_TO_IDLE; @@ -816,9 +816,9 @@ acpi_stype_to_sstate(struct acpi_softc *sc, enum power_stype stype) return (ACPI_STATE_S0); case POWER_STYPE_STANDBY: return (sc->acpi_standby_sx); - case POWER_STYPE_SUSPEND_TO_MEM: + case POWER_STYPE_FW_SUSPEND: return (ACPI_STATE_S3); - case POWER_STYPE_HIBERNATE: + case POWER_STYPE_FW_HIBERNATE: return (ACPI_STATE_S4); case POWER_STYPE_POWEROFF: return (ACPI_STATE_S5); @@ -851,9 +851,9 @@ acpi_sstate_to_stype(int sstate) case ACPI_STATE_S2: return (POWER_STYPE_STANDBY); case ACPI_STATE_S3: - return (POWER_STYPE_SUSPEND_TO_MEM); + return (POWER_STYPE_FW_SUSPEND); case ACPI_STATE_S4: - return (POWER_STYPE_HIBERNATE); + return (POWER_STYPE_FW_HIBERNATE); case ACPI_STATE_S5: return (POWER_STYPE_POWEROFF); } @@ -3723,8 +3723,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype) case POWER_STYPE_STANDBY: do_standby(sc, &slp_state, intr); break; - case POWER_STYPE_SUSPEND_TO_MEM: - case POWER_STYPE_HIBERNATE: + case POWER_STYPE_FW_SUSPEND: + case POWER_STYPE_FW_HIBERNATE: do_sleep(sc, &slp_state, intr, acpi_sstate); break; case POWER_STYPE_SUSPEND_TO_IDLE: diff --git a/sys/dev/cxgbe/common/t4_regs.h b/sys/dev/cxgbe/common/t4_regs.h index 09d0d4aa2c08..9984461352d0 100644 --- a/sys/dev/cxgbe/common/t4_regs.h +++ b/sys/dev/cxgbe/common/t4_regs.h @@ -1465,10 +1465,10 @@ #define A_SGE_INT_ENABLE3 0x1040 #define A_SGE_FL_BUFFER_SIZE0 0x1044 -#define S_SIZE 4 +#define CXGBE_S_SIZE 4 #define CXGBE_M_SIZE 0xfffffffU -#define V_SIZE(x) ((x) << S_SIZE) -#define G_SIZE(x) (((x) >> S_SIZE) & CXGBE_M_SIZE) +#define CXGBE_V_SIZE(x) ((x) << S_SIZE) +#define CXGBE_G_SIZE(x) (((x) >> S_SIZE) & CXGBE_M_SIZE) #define S_T6_SIZE 4 #define M_T6_SIZE 0xfffffU @@ -26578,15 +26578,10 @@ #define V_CIM_ULP_TX_PKT_ERR_CODE(x) ((x) << S_CIM_ULP_TX_PKT_ERR_CODE) #define G_CIM_ULP_TX_PKT_ERR_CODE(x) (((x) >> S_CIM_ULP_TX_PKT_ERR_CODE) & M_CIM_ULP_TX_PKT_ERR_CODE) -#define S_CIM_SGE1_PKT_ERR_CODE 8 -#define M_CIM_SGE1_PKT_ERR_CODE 0xffU -#define V_CIM_SGE1_PKT_ERR_CODE(x) ((x) << S_CIM_SGE1_PKT_ERR_CODE) -#define G_CIM_SGE1_PKT_ERR_CODE(x) (((x) >> S_CIM_SGE1_PKT_ERR_CODE) & M_CIM_SGE1_PKT_ERR_CODE) - -#define S_CIM_SGE0_PKT_ERR_CODE 0 -#define M_CIM_SGE0_PKT_ERR_CODE 0xffU -#define V_CIM_SGE0_PKT_ERR_CODE(x) ((x) << S_CIM_SGE0_PKT_ERR_CODE) -#define G_CIM_SGE0_PKT_ERR_CODE(x) (((x) >> S_CIM_SGE0_PKT_ERR_CODE) & M_CIM_SGE0_PKT_ERR_CODE) +#define S_CIM_SGE_PKT_ERR_CODE 0 +#define M_CIM_SGE_PKT_ERR_CODE 0xffU +#define V_CIM_SGE_PKT_ERR_CODE(x) ((x) << S_CIM_SGE_PKT_ERR_CODE) +#define G_CIM_SGE_PKT_ERR_CODE(x) (((x) >> S_CIM_SGE_PKT_ERR_CODE) & M_CIM_SGE_PKT_ERR_CODE) #define S_CIM_PCIE_PKT_ERR_CODE 8 #define M_CIM_PCIE_PKT_ERR_CODE 0xffU @@ -60550,17 +60545,15 @@ #define A_MAC_PORT_PTP_DRIFT_ADJUST_COUNT 0x9a0 #define A_MAC_PORT_PTP_OFFSET_ADJUST_FINE 0x9a4 -#if 0 -#define S_B 16 -#define M_B 0xffffU -#define V_B(x) ((x) << S_B) -#define G_B(x) (((x) >> S_B) & M_B) -#endif +#define CXGBE_S_B 16 +#define CXGBE_M_B 0xffffU +#define CXGBE_V_B(x) ((x) << CXGBE_S_B) +#define CXGBE_G_B(x) (((x) >> CXGBE_S_B) & CXGBE_M_B) -#define S_A 0 -#define M_A 0xffffU -#define V_A(x) ((x) << S_A) -#define G_A(x) (((x) >> S_A) & M_A) +#define CXGBE_S_A 0 +#define CXGBE_M_A 0xffffU +#define CXGBE_V_A(x) ((x) << CXGBE_S_A) +#define CXGBE_G_A(x) (((x) >> CXGBE_S_A) & CXGBE_M_A) #define A_MAC_PORT_PTP_OFFSET_ADJUST_TOTAL 0x9a8 #define A_MAC_PORT_PTP_CFG 0x9ac @@ -62257,10 +62250,10 @@ #define A_MAC_PORT_MTIP_VLAN_TPID_0 0x1a00 -#define S_VLANTAG 0 +#define CXGBE_S_VLANTAG 0 #define CXGBE_M_VLANTAG 0xffffU -#define V_VLANTAG(x) ((x) << S_VLANTAG) -#define G_VLANTAG(x) (((x) >> S_VLANTAG) & M_VLANTAG) +#define CXGBE_V_VLANTAG(x) ((x) << CXGBE_S_VLANTAG) +#define CXGBE_G_VLANTAG(x) (((x) >> CXGBE_S_VLANTAG) & CXGBE_M_VLANTAG) #define A_MAC_PORT_MTIP_VLAN_TPID_1 0x1a04 #define A_MAC_PORT_MTIP_VLAN_TPID_2 0x1a08 @@ -69613,10 +69606,10 @@ #define V_INIT_ENABLE(x) ((x) << S_INIT_ENABLE) #define F_INIT_ENABLE V_INIT_ENABLE(1U) -#define S_WAIT 16 -#define M_WAIT 0xfffU -#define CXGBE_V_WAIT(x) ((x) << S_WAIT) -#define G_WAIT(x) (((x) >> S_WAIT) & M_WAIT) +#define CXGBE_S_WAIT 16 +#define CXGBE_M_WAIT 0xfffU +#define CXGBE_V_WAIT(x) ((x) << CXGBE_S_WAIT) +#define CXGBE_G_WAIT(x) (((x) >> CXGBE_S_WAIT) & CXGBE_M_WAIT) #define S_EN_MULTI_RANK_SEL 4 #define V_EN_MULTI_RANK_SEL(x) ((x) << S_EN_MULTI_RANK_SEL) diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index b11552dce021..6235a2c3fab4 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -2560,6 +2560,22 @@ struct fw_ri_wr { __be32 tpt_offset_t10_config; __be32 r8[2]; } nvmet_init; + struct fw_ri_iscsi_init { + __u8 type; + __u8 dcrc_dis_to_hcrc; + __u8 r4[3]; + __u8 qp_caps; + __be16 r5; + __be32 pdid; + __be32 qpid; + __be32 sq_eqid; + __be32 r6; + __be32 scqid; + __be32 rcqid; + __be32 r7[4]; + __be32 r8[2]; + __be64 r9; + } iscsi_init; struct fw_ri_fini { __u8 type; __u8 r3[7]; @@ -2634,6 +2650,37 @@ struct fw_ri_wr { #define G_FW_RI_WR_T10_CONFIG(x) \ (((x) >> S_FW_RI_WR_T10_CONFIG) & M_FW_RI_WR_T10_CONFIG) +#define S_FW_RI_WR_DCRC_DIS 7 +#define M_FW_RI_WR_DCRC_DIS 0x1 +#define V_FW_RI_WR_DCRC_DIS(x) ((x) << S_FW_RI_WR_DCRC_DIS) +#define G_FW_RI_WR_DCRC_DIS(x) \ + (((x) >> S_FW_RI_WR_DCRC_DIS) & M_FW_RI_WR_DCRC_DIS) +#define F_FW_RI_WR_DCRC_DIS V_FW_RI_WR_DCRC_DIS(1U) + +#define S_FW_RI_WR_HCRC_DIS 6 +#define M_FW_RI_WR_HCRC_DIS 0x1 +#define V_FW_RI_WR_HCRC_DIS(x) ((x) << S_FW_RI_WR_HCRC_DIS) +#define G_FW_RI_WR_HCRC_DIS(x) \ + (((x) >> S_FW_RI_WR_HCRC_DIS) & M_FW_RI_WR_HCRC_DIS) +#define F_FW_RI_WR_HCRC_DIS V_FW_RI_WR_HCRC_DIS(1U) + +#define S_FW_RI_WR_PSZ_IDX 4 +#define M_FW_RI_WR_PSZ_IDX 0x3 +#define V_FW_RI_WR_PSZ_IDX(x) ((x) << S_FW_RI_WR_PSZ_IDX) +#define G_FW_RI_WR_PSZ_IDX(x) \ + (((x) >> S_FW_RI_WR_PSZ_IDX) & M_FW_RI_WR_PSZ_IDX) + +#define S_FW_RI_WR_DCRC 1 +#define M_FW_RI_WR_DCRC 0x1 +#define V_FW_RI_WR_DCRC(x) ((x) << S_FW_RI_WR_DCRC) +#define G_FW_RI_WR_DCRC(x) (((x) >> S_FW_RI_WR_DCRC) & M_FW_RI_WR_DCRC) +#define F_FW_RI_WR_DCRC V_FW_RI_WR_DCRC(1U) + +#define S_FW_RI_WR_HCRC 0 +#define M_FW_RI_WR_HCRC 0x1 +#define V_FW_RI_WR_HCRC(x) ((x) << S_FW_RI_WR_HCRC) +#define G_FW_RI_WR_HCRC(x) (((x) >> S_FW_RI_WR_HCRC) & M_FW_RI_WR_HCRC) +#define F_FW_RI_WR_HCRC V_FW_RI_WR_HCRC(1U) /****************************************************************************** * R o C E V 2 W O R K R E Q U E S T s @@ -2951,6 +2998,24 @@ struct fw_v2_nvmet_tx_data_wr { #endif }; +#define S_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE 20 +#define M_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE 0x1 +#define V_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE(x) \ + ((x) << S_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE) +#define G_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE(x) \ + (((x) >> S_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE) & \ + M_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE) +#define F_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE \ + V_FW_V2_NVMET_TX_DATA_WR_DACK_CHANGE(1U) + +#define S_FW_V2_NVMET_TX_DATA_WR_DACK_MODE 18 +#define M_FW_V2_NVMET_TX_DATA_WR_DACK_MODE 0x3 +#define V_FW_V2_NVMET_TX_DATA_WR_DACK_MODE(x) \ + ((x) << S_FW_V2_NVMET_TX_DATA_WR_DACK_MODE) +#define G_FW_V2_NVMET_TX_DATA_WR_DACK_MODE(x) \ + (((x) >> S_FW_V2_NVMET_TX_DATA_WR_DACK_MODE) & \ + M_FW_V2_NVMET_TX_DATA_WR_DACK_MODE) + #define S_FW_V2_NVMET_TX_DATA_WR_FLAGS_HI 10 #define M_FW_V2_NVMET_TX_DATA_WR_FLAGS_HI 0x3fffff #define V_FW_V2_NVMET_TX_DATA_WR_FLAGS_HI(x) \ @@ -4990,6 +5055,16 @@ struct fw_crypto_update_sa_wr { } key; }; +#define S_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER 3 +#define M_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER 0x1 +#define V_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER(x) \ + ((x) << S_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER) +#define G_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER(x) \ + (((x) >> S_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER) & \ + M_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER) +#define F_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER \ + V_FW_CRYPTO_UPDATE_SA_WR_EG_IPVER(1U) + #define S_FW_CRYPTO_UPDATE_SA_WR_SAOP 2 #define M_FW_CRYPTO_UPDATE_SA_WR_SAOP 0x1 #define V_FW_CRYPTO_UPDATE_SA_WR_SAOP(x) \ @@ -8952,24 +9027,40 @@ enum fw_port_type { FW_PORT_TYPE_KX4 = 5, /* No, 4, No, No, Yes, Yes, 10G */ FW_PORT_TYPE_CX4 = 6, /* No, 4, No, No, No, No, 10G */ FW_PORT_TYPE_KX = 7, /* No, 1, No, No, Yes, No, 1G */ - FW_PORT_TYPE_KR = 8, /* No, 1, No, No, Yes, Yes, 10G */ + FW_PORT_TYPE_KR = 8, /* No, 1, No, No, Yes, Yes, 10G BP AN */ FW_PORT_TYPE_SFP = 9, /* No, 1, Yes, No, No, No, 10G */ - FW_PORT_TYPE_BP_AP = 10, /* No, 1, No, No, Yes, Yes, 10G, BP ANGE */ - FW_PORT_TYPE_BP4_AP = 11, /* No, 4, No, No, Yes, Yes, 10G, BP ANGE */ + FW_PORT_TYPE_BP_AP = 10, /* No, 1, No, No, Yes, Yes, 10G, BP AN */ + FW_PORT_TYPE_BP4_AP = 11, /* No, 4, No, No, Yes, Yes, 10G, BP AN */ FW_PORT_TYPE_QSFP_10G = 12, /* No, 1, Yes, No, No, No, 10G */ FW_PORT_TYPE_QSA = 13, /* No, 1, Yes, No, No, No, 10G */ FW_PORT_TYPE_QSFP = 14, /* No, 4, Yes, No, No, No, 40G */ - FW_PORT_TYPE_BP40_BA = 15, /* No, 4, No, No, Yes, Yes, 40G/10G/1G, BP ANGE */ - FW_PORT_TYPE_KR4_100G = 16, /* No, 4, 100G/40G/25G, Backplane */ + FW_PORT_TYPE_BP40_BA = 15, /* No, 4, No, No, Yes, Yes, 40G/10G/1G, BP AN */ + FW_PORT_TYPE_KR4_100G = 16, /* No, 4, 100G/40G/50G/25G/10G/1G, BP AN */ FW_PORT_TYPE_CR4_QSFP = 17, /* No, 4, 100G/40G/25G */ - FW_PORT_TYPE_CR_QSFP = 18, /* No, 1, 25G Spider cable */ - FW_PORT_TYPE_CR2_QSFP = 19, /* No, 2, 50G */ + FW_PORT_TYPE_CR_QSFP = 18, /* No, 1, 25G, Spider cable */ + FW_PORT_TYPE_CR2_QSFP = 19, /* No, 2, 50G, Spider cable */ FW_PORT_TYPE_SFP28 = 20, /* No, 1, 25G/10G/1G */ FW_PORT_TYPE_KR_SFP28 = 21, /* No, 1, 25G/10G/1G using Backplane */ FW_PORT_TYPE_KR_XLAUI = 22, /* No, 4, 40G/10G/1G, No AN*/ + FW_PORT_TYPE_BARE_LINK_50G = 23, /* No, 1, 50G */ + FW_PORT_TYPE_BARE_LINK_100G = 24, /* No, 2, 100G/50G */ + FW_PORT_TYPE_BARE_LINK_200G = 25, /* No, 4, 200G/100G/50G */ FW_PORT_TYPE_SFP56 = 26, /* No, 1, 50G/25G */ FW_PORT_TYPE_QSFP56 = 27, /* No, 4, 200G/100G/50G/25G */ - FW_PORT_TYPE_QSFPDD = 34, /* No, 8, 400G/200G/100G/50G */ + FW_PORT_TYPE_QSFP56_4_50G = 28, /* No, 1, 50G, Spider cable */ + FW_PORT_TYPE_KR_50G = 29, /* No, 1, 50G/25G/10G/1G, BP AN */ + FW_PORT_TYPE_KR2_100G = 30, /* No, 2, 100G/50G/25G/10G/1G, BP AN */ + FW_PORT_TYPE_KR4_200G = 31, /* No, 4, 200G/100G/40G/50G/25G/10G/1G, BP AN */ + FW_PORT_TYPE_QSFP56_2_50G = 32, /* No, 1, 50G, Spider cable */ + FW_PORT_TYPE_OSFP = 33, /* No, 8, 400G/200G/100G/50G */ + FW_PORT_TYPE_QSFPDD = 34, /* No, 8, 400G/200G/100G/50G */ + FW_PORT_TYPE_OSFP_2_200G = 35, /* No, 4, 200G, Spider cable */ + FW_PORT_TYPE_QSFPDD_2_200G = 36,/* No, 4, 200G, Spider cable */ + FW_PORT_TYPE_KR8_400G = 37, /* No, 8, 400G/200G/100G/50G/40G/25G/10G/1G, BP AN */ + FW_PORT_TYPE_QSFP56_2_100G = 38,/* No, 2, 100G, Spider cable */ + FW_PORT_TYPE_QSFPDD_4_100G = 39,/* No, 2, 100G, Spider cable */ + FW_PORT_TYPE_KR2_50G = 40, /* No, 1, 50G/25G/10G/1G, BP AN */ + FW_PORT_TYPE_MAX, FW_PORT_TYPE_NONE = M_FW_PORT_CMD_PORTTYPE32 }; diff --git a/sys/dev/cxgbe/firmware/t7fw_cfg.txt b/sys/dev/cxgbe/firmware/t7fw_cfg.txt index 70b05da04a23..33c703fdc9d7 100644 --- a/sys/dev/cxgbe/firmware/t7fw_cfg.txt +++ b/sys/dev/cxgbe/firmware/t7fw_cfg.txt @@ -175,6 +175,11 @@ # TPT error. # Err2uP = 0 + # ULP_TX_ACCELERATOR_CTL + reg[0x8f90] = 0x00000015/0x00000015 # Compression block clock gating + # Dedupe clock gating + # Erasure Coding clock gating + #ULP_RX_CTL1 reg[0x19330] = 0x000000f0/0x000000f0 # RDMA_Invld_Msg_Dis = 3 # ROCE_Invld_Msg_Dis = 3 @@ -201,7 +206,7 @@ # default gc enabled. # HMA configuration (uncomment following lines to enable HMA) - hma_size = 128 # Size (in MBs) of host memory expected + hma_size = 256 # Size (in MBs) of host memory expected hma_regions = iscsi,rrq,tls,ddp,pmrx,stag,pbl,rq # What all regions to place in host memory #mc[0]=0 @@ -394,8 +399,7 @@ neq = 16 # niqflint + nethctrl Egress Queues nexactf = 8 # number of exact MPSTCAM MAC filters cmask = all # access to all channels - #pmask = 0x4 # access to only one port - pmask = 0x1 # access to only one port + pmask = 0x4 # access to only one port [function "3"] nvf = 16 # NVF on this function @@ -407,7 +411,7 @@ neq = 16 # niqflint + nethctrl Egress Queues nexactf = 8 # number of exact MPSTCAM MAC filters cmask = all # access to all channels - #pmask = 0x2 # access to only one port + pmask = 0x8 # access to only one port # Some OS Drivers manage all application functions for all ports via PF4. # Thus we need to provide a large number of resources here. For Egress @@ -421,7 +425,7 @@ r_caps = all # read permissions for all commands nvi = 28 # NVI_UNIFIED niqflint = 170 # NFLIQ_UNIFIED + NLFIQ_WD - nethctrl = 224 # NETHCTRL_UNIFIED + NETHCTRL_WD + nethctrl = 288 # NETHCTRL_UNIFIED + NETHCTRL_WD neq = 252 # NEQ_UNIFIED + NEQ_WD nqpcq = 12288 nexactf = 40 # NMPSTCAM_UNIFIED @@ -435,8 +439,7 @@ nserver = 480 # number of server region entries nhash = 12288 # number of hash region entries nhpfilter = 64 # number of high priority filter region entries - #protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, ofld_sendpath - protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, nvme_tcp + protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, nvme_tcp, ofld_sendpath tp_l2t = 3072 tp_ddp = 2 tp_ddp_iscsi = 2 @@ -643,7 +646,7 @@ [fini] version = 0x1425001d - checksum = 0x3671da3b + checksum = 0x2419f987 # Total resources used by above allocations: # Virtual Interfaces: 104 diff --git a/sys/dev/cxgbe/firmware/t7fw_cfg_uwire.txt b/sys/dev/cxgbe/firmware/t7fw_cfg_uwire.txt index b1f5129238eb..9da841153138 100644 --- a/sys/dev/cxgbe/firmware/t7fw_cfg_uwire.txt +++ b/sys/dev/cxgbe/firmware/t7fw_cfg_uwire.txt @@ -175,6 +175,11 @@ # TPT error. # Err2uP = 0 + # ULP_TX_ACCELERATOR_CTL + reg[0x8f90] = 0x00000015/0x00000015 # Compression block clock gating + # Dedupe clock gating + # Erasure Coding clock gating + #ULP_RX_CTL1 reg[0x19330] = 0x000000f0/0x000000f0 # RDMA_Invld_Msg_Dis = 3 # ROCE_Invld_Msg_Dis = 3 @@ -201,7 +206,7 @@ # default gc enabled. # HMA configuration (uncomment following lines to enable HMA) - hma_size = 128 # Size (in MBs) of host memory expected + hma_size = 256 # Size (in MBs) of host memory expected hma_regions = iscsi,rrq,tls,ddp,pmrx,stag,pbl,rq # What all regions to place in host memory #mc[0]=0 @@ -394,8 +399,7 @@ neq = 16 # niqflint + nethctrl Egress Queues nexactf = 8 # number of exact MPSTCAM MAC filters cmask = all # access to all channels - #pmask = 0x4 # access to only one port - pmask = 0x1 # access to only one port + pmask = 0x4 # access to only one port [function "3"] nvf = 16 # NVF on this function @@ -407,7 +411,7 @@ neq = 16 # niqflint + nethctrl Egress Queues nexactf = 8 # number of exact MPSTCAM MAC filters cmask = all # access to all channels - #pmask = 0x2 # access to only one port + pmask = 0x8 # access to only one port # Some OS Drivers manage all application functions for all ports via PF4. # Thus we need to provide a large number of resources here. For Egress @@ -421,7 +425,7 @@ r_caps = all # read permissions for all commands nvi = 28 # NVI_UNIFIED niqflint = 170 # NFLIQ_UNIFIED + NLFIQ_WD - nethctrl = 224 # NETHCTRL_UNIFIED + NETHCTRL_WD + nethctrl = 288 # NETHCTRL_UNIFIED + NETHCTRL_WD neq = 252 # NEQ_UNIFIED + NEQ_WD nqpcq = 12288 nexactf = 40 # NMPSTCAM_UNIFIED @@ -435,8 +439,7 @@ nserver = 480 # number of server region entries nhash = 12288 # number of hash region entries nhpfilter = 64 # number of high priority filter region entries - #protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, ofld_sendpath - protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, nvme_tcp + protocol = nic_vm, ofld, rddp, rdmac, iscsi_initiator_pdu, iscsi_target_pdu, iscsi_t10dif, tlskeys, crypto_lookaside, ipsec_inline, rocev2, nic_hashfilter, nvme_tcp, ofld_sendpath tp_l2t = 3072 tp_ddp = 2 tp_ddp_iscsi = 2 @@ -643,7 +646,7 @@ [fini] version = 0x1425001d - checksum = 0x96513217 + checksum = 0x83f95163 # Total resources used by above allocations: # Virtual Interfaces: 104 diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 69ecfce1dade..d73204eb808c 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3760,10 +3760,17 @@ port_mword(struct port_info *pi, uint32_t speed) return (IFM_NONE); } break; - case M_FW_PORT_CMD_PTYPE: /* FW_PORT_TYPE_NONE for old firmware */ - if (chip_id(pi->adapter) >= CHELSIO_T7) - return (IFM_UNKNOWN); - /* fall through */ + case FW_PORT_TYPE_KR4_200G: { + /* + * Pre-T7 firmware used M_FW_PORT_CMD_PTYPE for PORT_TYPE_NONE + * and driver needs to deal with both. + */ + _Static_assert(M_FW_PORT_CMD_PTYPE == FW_PORT_TYPE_KR4_200G, + "driver/firmware mismatch"); + if (chip_id(pi->adapter) < CHELSIO_T7) + return (IFM_NONE); + return (IFM_200G_KR4_PAM4); + } case FW_PORT_TYPE_NONE: return (IFM_NONE); } diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 0dddd2dd263f..b5a3012accd6 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3756,7 +3756,7 @@ xhci_early_takeover(device_t self) struct resource *res; uint32_t cparams; uint32_t eec; - uint8_t eecp; + uint32_t eecp; uint8_t bios_sem; uint8_t offs; int rid; diff --git a/sys/dev/rge/if_rge.c b/sys/dev/rge/if_rge.c index 8887e8d39ae4..06f034ebd61d 100644 --- a/sys/dev/rge/if_rge.c +++ b/sys/dev/rge/if_rge.c @@ -113,6 +113,7 @@ struct rge_matchid { const struct rge_matchid rge_devices[] = { { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_E3000, "Killer E3000" }, + { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_E5000, "Killer E5000" }, { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8125, "RTL8125" }, { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8126, "RTL8126", }, { PCI_VENDOR_REALTEK, PCI_PRODUCT_REALTEK_RTL8127, "RTL8127" }, diff --git a/sys/dev/rge/if_rge_vendor.h b/sys/dev/rge/if_rge_vendor.h index eea94e39e20b..f80b99f1f8b6 100644 --- a/sys/dev/rge/if_rge_vendor.h +++ b/sys/dev/rge/if_rge_vendor.h @@ -21,6 +21,7 @@ #define PCI_VENDOR_REALTEK 0x10ec #define PCI_PRODUCT_REALTEK_E3000 0x3000 +#define PCI_PRODUCT_REALTEK_E5000 0x5000 #define PCI_PRODUCT_REALTEK_RTL8125 0x8125 #define PCI_PRODUCT_REALTEK_RTL8126 0x8126 #define PCI_PRODUCT_REALTEK_RTL8127 0x8127 diff --git a/sys/dev/smartpqi/smartpqi_cam.c b/sys/dev/smartpqi/smartpqi_cam.c index 690b38c9f855..6ded8aa97e39 100644 --- a/sys/dev/smartpqi/smartpqi_cam.c +++ b/sys/dev/smartpqi/smartpqi_cam.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1300,7 +1300,7 @@ register_sim(struct pqisrc_softstate *softs, int card_index) csa.callback_arg = softs; xpt_action((union ccb *)&csa); if (csa.ccb_h.status != CAM_REQ_CMP) { - DBG_ERR("Unable to register smartpqi_aysnc handler: %d!\n", + DBG_ERR("Unable to register smartpqi_async handler: %d!\n", csa.ccb_h.status); } diff --git a/sys/dev/smartpqi/smartpqi_defines.h b/sys/dev/smartpqi/smartpqi_defines.h index 0277abd3e318..c4084f069588 100644 --- a/sys/dev/smartpqi/smartpqi_defines.h +++ b/sys/dev/smartpqi/smartpqi_defines.h @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -944,12 +944,12 @@ typedef uint8_t *passthru_buf_type_t; #define PQISRC_DRIVER_MAJOR __FreeBSD__ #if __FreeBSD__ <= 14 -#define PQISRC_DRIVER_MINOR 4690 +#define PQISRC_DRIVER_MINOR 4691 #else #define PQISRC_DRIVER_MINOR 2 #endif -#define PQISRC_DRIVER_RELEASE 0 -#define PQISRC_DRIVER_REVISION 2008 +#define PQISRC_DRIVER_RELEASE 1 +#define PQISRC_DRIVER_REVISION 2000 #define STR(s) # s #define PQISRC_VERSION(a, b, c, d) STR(a.b.c-d) diff --git a/sys/dev/smartpqi/smartpqi_discovery.c b/sys/dev/smartpqi/smartpqi_discovery.c index a7de5a149810..8682e6cabd7e 100644 --- a/sys/dev/smartpqi/smartpqi_discovery.c +++ b/sys/dev/smartpqi/smartpqi_discovery.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -155,7 +155,7 @@ pqisrc_remove_target_bit(pqisrc_softstate_t *softs, int target) softs->bit_map.bit_vector[target] = SLOT_AVAILABLE; } -/* Use bit map to find availible targets */ +/* Use bit map to find available targets */ int pqisrc_find_avail_target(pqisrc_softstate_t *softs) { @@ -1423,7 +1423,11 @@ pqisrc_add_device(pqisrc_softstate_t *softs, pqi_scsi_dev_t *device) if(device->expose_device) { pqisrc_init_device_active_io(softs, device); - /* TBD: Call OS upper layer function to add the device entry */ + device_printf(softs->os_specific.pqi_dev, + "device added: vendor=%s model=%s B%d:T%d:L%d type=%s\n", + device->vendor, device->model, + device->bus, device->target, device->lun, + device->is_physical_device ? "physical" : "logical"); os_add_device(softs,device); } DBG_FUNC("OUT\n"); @@ -1451,6 +1455,11 @@ pqisrc_remove_device(pqisrc_softstate_t *softs, pqi_scsi_dev_t *device) } /* Wait for device outstanding Io's */ pqisrc_wait_for_device_commands_to_complete(softs, device); + device_printf(softs->os_specific.pqi_dev, + "device removed: vendor=%s model=%s B%d:T%d:L%d type=%s\n", + device->vendor, device->model, + device->bus, device->target, device->lun, + device->is_physical_device ? "physical" : "logical"); /* Call OS upper layer function to remove the exposed device entry */ os_remove_device(softs,device); DBG_FUNC("OUT\n"); @@ -1674,10 +1683,14 @@ pqisrc_update_device_list(pqisrc_softstate_t *softs, case DEVICE_NOT_FOUND: /* Device not found in existing list */ device->new_device = true; + DBG_DISC("new device found B%d:T%d:L%d\n", + device->bus, device->target, device->lun); break; case DEVICE_CHANGED: /* Actual device gone need to add device to list*/ device->new_device = true; + DBG_DISC("device changed B%d:T%d:L%d\n", + device->bus, device->target, device->lun); break; case DEVICE_IN_REMOVE: /*Older device with same target/lun is in removal stage*/ @@ -1686,6 +1699,8 @@ pqisrc_update_device_list(pqisrc_softstate_t *softs, * free call*/ device->new_device = false; same_device->schedule_rescan = true; + DBG_DISC("device in removal B%d:T%d:L%d, scheduling rescan\n", + device->bus, device->target, device->lun); break; default: break; diff --git a/sys/dev/smartpqi/smartpqi_event.c b/sys/dev/smartpqi/smartpqi_event.c index 77a70f9fb031..c3c27c9e1c0b 100644 --- a/sys/dev/smartpqi/smartpqi_event.c +++ b/sys/dev/smartpqi/smartpqi_event.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -204,6 +204,17 @@ pqisrc_process_event_intr_src(pqisrc_softstate_t *softs,int obq_id) } if (event_index >= 0) { + static const char *event_names[] = { + [PQI_EVENT_HOTPLUG] = "hotplug", + [PQI_EVENT_HARDWARE] = "hardware", + [PQI_EVENT_PHYSICAL_DEVICE] = "physical device", + [PQI_EVENT_LOGICAL_DEVICE] = "logical device", + [PQI_EVENT_AIO_STATE_CHANGE] = "AIO state change", + [PQI_EVENT_AIO_CONFIG_CHANGE] = "AIO config change", + }; + device_printf(softs->os_specific.pqi_dev, + "event: %s (type=0x%x)\n", + event_names[event_index], response.event_type); if(response.request_acknowledge) { pending_event = &softs->pending_events[event_index]; pending_event->pending = true; @@ -385,7 +396,7 @@ pqisrc_report_event_config(pqisrc_softstate_t *softs) pqi_event_config_request_t request; pqi_event_config_t *event_config_p ; dma_mem_t buf_report_event ; - /*bytes to be allocaed for report event config data-in buffer */ + /*bytes to be allocated for report event config data-in buffer */ uint32_t alloc_size = sizeof(pqi_event_config_t) ; memset(&request, 0 , sizeof(request)); @@ -446,7 +457,7 @@ pqisrc_set_event_config(pqisrc_softstate_t *softs) pqi_event_config_request_t request; pqi_event_config_t *event_config_p; dma_mem_t buf_set_event; - /*bytes to be allocaed for set event config data-out buffer */ + /*bytes to be allocated for set event config data-out buffer */ uint32_t alloc_size = sizeof(pqi_event_config_t); memset(&request, 0 , sizeof(request)); diff --git a/sys/dev/smartpqi/smartpqi_main.c b/sys/dev/smartpqi/smartpqi_main.c index 1f006939bf7c..fbfbcc962f35 100644 --- a/sys/dev/smartpqi/smartpqi_main.c +++ b/sys/dev/smartpqi/smartpqi_main.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -427,6 +427,16 @@ smartpqi_attach(device_t dev) goto out; } + /* Register sysctl for runtime debug_level changes */ + { + struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); + struct sysctl_oid *tree = device_get_sysctl_tree(dev); + + SYSCTL_ADD_ULONG(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "debug_level", CTLFLAG_RW, &logging_level, + "Debug logging bitmask"); + } + goto out; dma_out: diff --git a/sys/dev/smartpqi/smartpqi_misc.c b/sys/dev/smartpqi/smartpqi_misc.c index 6db0d80ed993..fd0b907aa252 100644 --- a/sys/dev/smartpqi/smartpqi_misc.c +++ b/sys/dev/smartpqi/smartpqi_misc.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -252,7 +252,7 @@ bsd_set_hint_scatter_gather_config(struct pqisrc_softstate *softs) DBG_FUNC("IN\n"); - /* At least > 16 sg's required to wotk hint correctly. + /* At least > 16 sg's required to work hint correctly. * Default the sg count set by driver/controller. */ if ((!softs->hint.sg_segments) || (softs->hint.sg_segments > diff --git a/sys/dev/smartpqi/smartpqi_queue.c b/sys/dev/smartpqi/smartpqi_queue.c index e8a467531aa4..679d956f6f36 100644 --- a/sys/dev/smartpqi/smartpqi_queue.c +++ b/sys/dev/smartpqi/smartpqi_queue.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -729,7 +729,7 @@ pqisrc_create_op_ibq(pqisrc_softstate_t *softs, op_ib_q->pi_register_offset); } else { int i = 0; - DBG_WARN("Error Status Decsriptors\n"); + DBG_WARN("Error Status Descriptors\n"); for (i = 0; i < 4; i++) DBG_WARN(" %x\n",admin_resp.resp_type.create_op_iq.status_desc[i]); } diff --git a/sys/dev/smartpqi/smartpqi_request.c b/sys/dev/smartpqi/smartpqi_request.c index c5f8ac3c41ba..655660615797 100644 --- a/sys/dev/smartpqi/smartpqi_request.c +++ b/sys/dev/smartpqi/smartpqi_request.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1998,7 +1998,7 @@ pqisrc_send_raid_tmf(pqisrc_softstate_t *softs, pqi_scsi_dev_t const *devp, if (softs->timeout_in_tmf && tmf_type == SOP_TASK_MANAGEMENT_LUN_RESET) { - /* OS_TMF_TIMEOUT_SEC - 1 to accomodate driver processing */ + /* OS_TMF_TIMEOUT_SEC - 1 to accommodate driver processing */ tmf_req.timeout_in_sec = OS_TMF_TIMEOUT_SEC - 1; } diff --git a/sys/dev/smartpqi/smartpqi_response.c b/sys/dev/smartpqi/smartpqi_response.c index 38695860e520..1ae74a5b95ff 100644 --- a/sys/dev/smartpqi/smartpqi_response.c +++ b/sys/dev/smartpqi/smartpqi_response.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -275,7 +275,7 @@ pqisrc_is_innocuous_error(pqisrc_softstate_t *softs, rcb_t *rcb, void *err_info) if (raid_err->data_out_result == PQI_RAID_DATA_IN_OUT_UNDERFLOW) return true; - /* We get these a alot: leave a tiny breadcrumb about the error, + /* We get these a lot: leave a tiny breadcrumb about the error, but don't do full spew about it */ if (raid_err->status == PQI_AIO_STATUS_CHECK_CONDITION) { diff --git a/sys/dev/smartpqi/smartpqi_sis.c b/sys/dev/smartpqi/smartpqi_sis.c index 82eb999ca4b8..99aa952eb149 100644 --- a/sys/dev/smartpqi/smartpqi_sis.c +++ b/sys/dev/smartpqi/smartpqi_sis.c @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,7 +26,7 @@ #include "smartpqi_includes.h" -/* Function for disabling msix interrupots */ +/* Function for disabling msix interrupts */ void sis_disable_msix(pqisrc_softstate_t *softs) { @@ -96,7 +96,7 @@ sis_disable_interrupt(pqisrc_softstate_t *softs) sis_disable_msix(softs); break; default: - DBG_ERR("Inerrupt mode none!\n"); + DBG_ERR("Interrupt mode none!\n"); break; } diff --git a/sys/dev/smartpqi/smartpqi_structures.h b/sys/dev/smartpqi/smartpqi_structures.h index 0c9ad375823d..ada6676ada8f 100644 --- a/sys/dev/smartpqi/smartpqi_structures.h +++ b/sys/dev/smartpqi/smartpqi_structures.h @@ -1,5 +1,5 @@ /*- - * Copyright 2016-2025 Microchip Technology, Inc. and/or its subsidiaries. + * Copyright 2016-2026 Microchip Technology, Inc. and/or its subsidiaries. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -1168,7 +1168,7 @@ typedef struct bmic_sense_feature_page_header { uint8_t page; uint8_t sub_page; uint16_t total_length; /** Total length of the page. - * The length is the same wheteher the request buffer is too short or not. + * The length is the same whether the request buffer is too short or not. * When printing out the page, only print the buffer length. */ } OS_ATTRIBUTE_PACKED bmic_sense_feature_page_header_t; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 1a2969d6f2d8..fe440b68f209 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -3987,10 +3987,10 @@ next_code: break; case SUSP: - power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND); + power_pm_suspend(POWER_TRANSITION_SUSPEND); break; case STBY: - power_pm_suspend(POWER_SSTATE_TRANSITION_STANDBY); + power_pm_suspend(POWER_TRANSITION_STANDBY); break; case DBG: diff --git a/sys/dev/thunderbolt/tbcfg_reg.h b/sys/dev/thunderbolt/tbcfg_reg.h index bb68faa543b0..6ae5c6fea7fa 100644 --- a/sys/dev/thunderbolt/tbcfg_reg.h +++ b/sys/dev/thunderbolt/tbcfg_reg.h @@ -52,7 +52,7 @@ struct tb_cfg_read { uint32_t crc; }; -/* Config space read request, 6.4.2.4 */ +/* Config space read response, 6.4.2.4 */ struct tb_cfg_read_resp { tb_route_t route; uint32_t addr_attrs; diff --git a/sys/dev/ufshci/ufshci_private.h b/sys/dev/ufshci/ufshci_private.h index 067b51a419e8..8d18fab982d7 100644 --- a/sys/dev/ufshci/ufshci_private.h +++ b/sys/dev/ufshci/ufshci_private.h @@ -262,11 +262,11 @@ static const struct ufshci_power_entry power_map[POWER_STYPE_COUNT] = { UFSHCI_UIC_LINK_STATE_ACTIVE }, [POWER_STYPE_STANDBY] = { UFSHCI_DEV_PWR_SLEEP, SSS_PC_IDLE, UFSHCI_UIC_LINK_STATE_HIBERNATE }, - [POWER_STYPE_SUSPEND_TO_MEM] = { UFSHCI_DEV_PWR_POWERDOWN, + [POWER_STYPE_FW_SUSPEND] = { UFSHCI_DEV_PWR_POWERDOWN, SSS_PC_STANDBY, UFSHCI_UIC_LINK_STATE_HIBERNATE }, [POWER_STYPE_SUSPEND_TO_IDLE] = { UFSHCI_DEV_PWR_SLEEP, SSS_PC_IDLE, UFSHCI_UIC_LINK_STATE_HIBERNATE }, - [POWER_STYPE_HIBERNATE] = { UFSHCI_DEV_PWR_DEEPSLEEP, 0x40, + [POWER_STYPE_FW_HIBERNATE] = { UFSHCI_DEV_PWR_DEEPSLEEP, 0x40, UFSHCI_UIC_LINK_STATE_OFF }, [POWER_STYPE_POWEROFF] = { UFSHCI_DEV_PWR_POWERDOWN, SSS_PC_STANDBY, UFSHCI_UIC_LINK_STATE_OFF }, diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index f7cffcea5b92..68e9f45cff56 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -804,11 +804,11 @@ vt_machine_kbdevent(struct vt_device *vd, int c) return (1); case SPCLKEY | STBY: /* XXX Not present in kbdcontrol parser. */ /* Put machine into Stand-By mode. */ - power_pm_suspend(POWER_SSTATE_TRANSITION_STANDBY); + power_pm_suspend(POWER_TRANSITION_STANDBY); return (1); case SPCLKEY | SUSP: /* kbdmap(5) keyword `susp`. */ /* Suspend machine. */ - power_pm_suspend(POWER_SSTATE_TRANSITION_SUSPEND); + power_pm_suspend(POWER_TRANSITION_SUSPEND); return (1); } diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index 2c61b48c0451..e363ea1700f6 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -176,12 +176,12 @@ xctrl_suspend(void) cpuset_t cpu_suspend_map; #endif - EVENTHANDLER_INVOKE(power_suspend_early, POWER_STYPE_SUSPEND_TO_MEM); + EVENTHANDLER_INVOKE(power_suspend_early, POWER_STYPE_FW_SUSPEND); xs_lock(); stop_all_proc(); xs_unlock(); suspend_all_fs(); - EVENTHANDLER_INVOKE(power_suspend, POWER_STYPE_SUSPEND_TO_MEM); + EVENTHANDLER_INVOKE(power_suspend, POWER_STYPE_FW_SUSPEND); #ifdef EARLY_AP_STARTUP MPASS(mp_ncpus == 1 || smp_started); @@ -298,7 +298,7 @@ xctrl_suspend(void) resume_all_fs(); resume_all_proc(); - EVENTHANDLER_INVOKE(power_resume, POWER_STYPE_SUSPEND_TO_MEM); + EVENTHANDLER_INVOKE(power_resume, POWER_STYPE_FW_SUSPEND); if (bootverbose) printf("System resumed after suspension\n"); diff --git a/sys/i386/linux/linux_locore.asm b/sys/i386/linux/linux_locore.asm index dbd0757c44bc..c188ad72f009 100644 --- a/sys/i386/linux/linux_locore.asm +++ b/sys/i386/linux/linux_locore.asm @@ -122,3 +122,5 @@ END(__kernel_vsyscall) .balign 4 .previous #endif + + .section .note.GNU-stack,"",%progbits diff --git a/sys/kern/subr_power.c b/sys/kern/subr_power.c index 13448cfa4d1e..47682a0ee75e 100644 --- a/sys/kern/subr_power.c +++ b/sys/kern/subr_power.c @@ -153,12 +153,12 @@ power_pm_register(u_int pm_type, power_pm_fn_t pm_fn, void *pm_arg, sizeof(power_pm_supported)); if (power_pm_supported[POWER_STYPE_STANDBY]) power_standby_stype = POWER_STYPE_STANDBY; - if (power_pm_supported[POWER_STYPE_SUSPEND_TO_MEM]) - power_suspend_stype = POWER_STYPE_SUSPEND_TO_MEM; + if (power_pm_supported[POWER_STYPE_FW_SUSPEND]) + power_suspend_stype = POWER_STYPE_FW_SUSPEND; else if (power_pm_supported[POWER_STYPE_SUSPEND_TO_IDLE]) power_suspend_stype = POWER_STYPE_SUSPEND_TO_IDLE; - if (power_pm_supported[POWER_STYPE_HIBERNATE]) - power_hibernate_stype = POWER_STYPE_HIBERNATE; + if (power_pm_supported[POWER_STYPE_FW_HIBERNATE]) + power_hibernate_stype = POWER_STYPE_FW_HIBERNATE; error = 0; TASK_INIT(&power_pm_task, 0, power_pm_deferred_fn, NULL); } else { @@ -176,7 +176,7 @@ power_pm_get_type(void) } void -power_pm_suspend(enum power_sstate_transition trans) +power_pm_suspend(enum power_transition trans) { enum power_stype stype; @@ -184,13 +184,13 @@ power_pm_suspend(enum power_sstate_transition trans) return; switch (trans) { - case POWER_SSTATE_TRANSITION_STANDBY: + case POWER_TRANSITION_STANDBY: stype = power_standby_stype; break; - case POWER_SSTATE_TRANSITION_SUSPEND: + case POWER_TRANSITION_SUSPEND: stype = power_suspend_stype; break; - case POWER_SSTATE_TRANSITION_HIBERNATE: + case POWER_TRANSITION_HIBERNATE: stype = power_hibernate_stype; break; default: diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 8ff9822ee9eb..2508f7edd1c5 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -83,6 +83,7 @@ #include <sys/socketvar.h> #include <sys/signalvar.h> #include <sys/stat.h> +#include <sys/sysent.h> #include <sys/sx.h> #include <sys/sysctl.h> #include <sys/systm.h> @@ -2752,8 +2753,24 @@ uipc_ctloutput(struct socket *so, struct sockopt *sopt) error = EINVAL; } UNP_PCB_UNLOCK(unp); - if (error == 0) - error = sooptcopyout(sopt, &xu, sizeof(xu)); + if (error != 0) + break; +#ifdef COMPAT_FREEBSD32 + if (SV_PROC_FLAG(sopt->sopt_td->td_proc, SV_ILP32)) { + struct xucred32 xu32 = {}; + int i; + + xu32.cr_version = xu.cr_version; + xu32.cr_uid = xu.cr_uid; + xu32.cr_ngroups = xu.cr_ngroups; + for (i = 0; i < XU_NGROUPS; i++) + xu32.cr_groups[i] = xu.cr_groups[i]; + xu32.cr_pid = xu.cr_pid; + error = sooptcopyout(sopt, &xu32, sizeof(xu32)); + break; + } +#endif + error = sooptcopyout(sopt, &xu, sizeof(xu)); break; case LOCAL_CREDS: diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 8f47a7abbc5e..675f6fb4e526 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -727,7 +727,8 @@ bufspace_wait(struct bufdomain *bd, struct vnode *vp, int gbflags, BD_LOCK(bd); while (bd->bd_wanted) { if (vp != NULL && vp->v_type != VCHR && - (td->td_pflags & TDP_BUFNEED) == 0) { + (td->td_pflags & TDP_BUFNEED) == 0 && + vp->v_bufobj.bo_dirty.bv_cnt > 0) { BD_UNLOCK(bd); /* * getblk() is called with a vnode locked, and diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 3f8591bd0ba7..66210bf58a7c 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -5737,7 +5737,7 @@ cache_fplookup_climb_mount(struct cache_fpl *fpl) prev_mp = NULL; for (;;) { - if (!vfs_op_thread_enter_crit(mp, mpcpu)) { + if (!vfs_op_thread_enter_crit(mp, &mpcpu)) { if (prev_mp != NULL) vfs_op_thread_exit_crit(prev_mp, prev_mpcpu); return (cache_fpl_partial(fpl)); @@ -5792,7 +5792,7 @@ cache_fplookup_cross_mount(struct cache_fpl *fpl) return (0); } - if (!vfs_op_thread_enter_crit(mp, mpcpu)) { + if (!vfs_op_thread_enter_crit(mp, &mpcpu)) { return (cache_fpl_partial(fpl)); } if (!vn_seqc_consistent(vp, vp_seqc)) { diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index ddc5a1b70887..fff05a627162 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -500,7 +500,7 @@ vfs_ref_from_vp(struct vnode *vp) if (__predict_false(mp == NULL)) { return (mp); } - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { if (__predict_true(mp == vp->v_mount)) { vfs_mp_count_add_pcpu(mpcpu, ref, 1); vfs_op_thread_exit(mp, mpcpu); @@ -527,7 +527,7 @@ vfs_ref(struct mount *mp) struct mount_pcpu *mpcpu; CTR2(KTR_VFS, "%s: mp %p", __func__, mp); - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { vfs_mp_count_add_pcpu(mpcpu, ref, 1); vfs_op_thread_exit(mp, mpcpu); return; @@ -645,7 +645,7 @@ vfs_rel(struct mount *mp) struct mount_pcpu *mpcpu; CTR2(KTR_VFS, "%s: mp %p", __func__, mp); - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { vfs_mp_count_sub_pcpu(mpcpu, ref, 1); vfs_op_thread_exit(mp, mpcpu); return; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 823ccc6cab71..4bfbc0a7057e 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -237,15 +237,15 @@ static struct mtx mntid_mtx; */ static struct mtx __exclusive_cache_line vnode_list_mtx; -static uma_zone_t buf_trie_zone; -static smr_t buf_trie_smr; +static __read_mostly uma_zone_t buf_trie_zone; +static __read_mostly smr_t buf_trie_smr; /* Zone for allocation of new vnodes - used exclusively by getnewvnode() */ -static uma_zone_t vnode_zone; -MALLOC_DEFINE(M_VNODEPOLL, "VN POLL", "vnode poll"); - +static __read_mostly uma_zone_t vnode_zone; __read_frequently smr_t vfs_smr; +MALLOC_DEFINE(M_VNODEPOLL, "VN POLL", "vnode poll"); + /* * The workitem queue. * @@ -876,7 +876,7 @@ vfs_busy(struct mount *mp, int flags) MPASS((flags & ~MBF_MASK) == 0); CTR3(KTR_VFS, "%s: mp %p with flags %d", __func__, mp, flags); - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0); MPASS((mp->mnt_kern_flag & MNTK_UNMOUNT) == 0); MPASS((mp->mnt_kern_flag & MNTK_REFEXPIRE) == 0); @@ -939,7 +939,7 @@ vfs_unbusy(struct mount *mp) CTR2(KTR_VFS, "%s: mp %p", __func__, mp); - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { MPASS((mp->mnt_kern_flag & MNTK_DRAINING) == 0); vfs_mp_count_sub_pcpu(mpcpu, lockref, 1); vfs_mp_count_sub_pcpu(mpcpu, ref, 1); @@ -6090,7 +6090,7 @@ vop_create_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (!rc) { + if (rc == 0) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6244,7 +6244,7 @@ vop_mknod_post(void *ap, int rc) a = ap; dvp = a->a_dvp; vn_seqc_write_end(dvp); - if (!rc) { + if (rc == 0) { VFS_KNOTE_LOCKED(dvp, NOTE_WRITE); INOTIFY_NAME(*a->a_vpp, dvp, a->a_cnp, IN_CREATE); } @@ -6512,8 +6512,10 @@ vop_read_pgcache_post(void *ap, int rc) { struct vop_read_pgcache_args *a = ap; - if (!rc) - VFS_KNOTE_UNLOCKED(a->a_vp, NOTE_READ); + if (rc == 0) { + VFS_KNOTE_LOCKED(a->a_vp, NOTE_READ); + INOTIFY(a->a_vp, IN_ACCESS); + } } static struct knlist fs_knlist; @@ -6659,6 +6661,8 @@ vfs_knlunlock(void *arg) { struct vnode *vp = arg; + if (KNLIST_EMPTY(&vp->v_pollinfo->vpi_selinfo.si_note)) + vn_irflag_unset(vp, VIRF_KNOTE); VOP_UNLOCK(vp); } @@ -6706,7 +6710,11 @@ vfs_kqfilter(struct vop_kqfilter_args *ap) return (ENOMEM); knl = &vp->v_pollinfo->vpi_selinfo.si_note; vhold(vp); - knlist_add(knl, kn, 0); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + knlist_add(knl, kn, 1); + if ((vn_irflag_read(vp) & VIRF_KNOTE) == 0) + vn_irflag_set(vp, VIRF_KNOTE); + VOP_UNLOCK(vp); return (0); } @@ -6985,7 +6993,7 @@ vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp) struct vnode *vp; int error; - if (!vfs_op_thread_enter(mp, mpcpu)) + if (!vfs_op_thread_enter(mp, &mpcpu)) return (vfs_cache_root_fallback(mp, flags, vpp)); vp = atomic_load_ptr(&mp->mnt_rootvnode); if (vp == NULL || VN_IS_DOOMED(vp)) { diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 4061b2272193..15704634ff62 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -2083,7 +2083,7 @@ vn_start_write_refed(struct mount *mp, int flags) struct mount_pcpu *mpcpu; int error, mflags; - if ((flags & V_XSLEEP) == 0 && vfs_op_thread_enter(mp, mpcpu)) { + if ((flags & V_XSLEEP) == 0 && vfs_op_thread_enter(mp, &mpcpu)) { MPASS((mp->mnt_kern_flag & MNTK_SUSPEND) == 0); vfs_mp_count_add_pcpu(mpcpu, writeopcount, 1); vfs_op_thread_exit(mp, mpcpu); @@ -2252,7 +2252,7 @@ vn_finished_write(struct mount *mp) if (mp == NULL) return; - if (vfs_op_thread_enter(mp, mpcpu)) { + if (vfs_op_thread_enter(mp, &mpcpu)) { vfs_mp_count_sub_pcpu(mpcpu, writeopcount, 1); vfs_mp_count_sub_pcpu(mpcpu, ref, 1); vfs_op_thread_exit(mp, mpcpu); diff --git a/sys/net/if_geneve.c b/sys/net/if_geneve.c index ab8b313e860a..59822045b77b 100644 --- a/sys/net/if_geneve.c +++ b/sys/net/if_geneve.c @@ -3021,6 +3021,7 @@ geneve_udp_input(struct mbuf *m, int offset, struct inpcb *inpcb, if (sc == NULL) return (false); + ifp = sc->gnv_ifp; if ((sc->gnv_flags & GENEVE_FLAG_RUNNING) == 0) goto out; @@ -3043,7 +3044,6 @@ geneve_udp_input(struct mbuf *m, int offset, struct inpcb *inpcb, if (error != 0) goto out; - ifp = sc->gnv_ifp; if (ifp == m->m_pkthdr.rcvif) /* XXX Does not catch more complex loops. */ goto out; diff --git a/sys/net/if_media.h b/sys/net/if_media.h index 892b7d1e3e52..5cc8714219c8 100644 --- a/sys/net/if_media.h +++ b/sys/net/if_media.h @@ -262,6 +262,8 @@ uint64_t ifmedia_baudrate(int); #define IFM_1000_BX IFM_X(121) /* 1000Base-BX */ #define IFM_400G_SR8 IFM_X(122) /* 400GBase-SR8 */ #define IFM_400G_CR8 IFM_X(123) /* 400GBase-CR8 */ +#define IFM_10_T1S IFM_X(124) /* 10BASE-T1S */ +#define IFM_10_T1L IFM_X(125) /* 10BASE-T1L */ /* * Please update ieee8023ad_lacp.c:lacp_compose_key() @@ -554,6 +556,8 @@ struct ifmedia_description { { IFM_400G_AUI8, "400G-AUI8" }, \ { IFM_400G_SR8, "400GBase-SR8" }, \ { IFM_400G_CR8, "400GBase-CR8" }, \ + { IFM_10_T1S, "10BASE-T1S" }, \ + { IFM_10_T1L, "10BASE-T1L" }, \ { 0, NULL }, \ } @@ -903,6 +907,8 @@ struct ifmedia_baudrate { { IFM_ETHER | IFM_400G_AUI8, IF_Gbps(400ULL) }, \ { IFM_ETHER | IFM_400G_SR8, IF_Gbps(400ULL) }, \ { IFM_ETHER | IFM_400G_CR8, IF_Gbps(400ULL) }, \ + { IFM_ETHER | IFM_10_T1S, IF_Mbps(10) }, \ + { IFM_ETHER | IFM_10_T1L, IF_Mbps(10) }, \ \ { IFM_IEEE80211 | IFM_IEEE80211_FH1, IF_Mbps(1) }, \ { IFM_IEEE80211 | IFM_IEEE80211_FH2, IF_Mbps(2) }, \ diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index 10690920e6fd..133aeeb969a6 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -780,7 +780,9 @@ static int flow6id_match(int curr_flow, ipfw_insn_u32 *cmd) { int i; - for (i=0; i <= cmd->o.arg1; ++i) + /* Mask proto version and traffic class out before comparing flow-id */ + curr_flow &= ntohl(IPV6_FLOWLABEL_MASK); + for (i=0; i < cmd->o.arg1; ++i) if (curr_flow == cmd->d[i]) return 1; return 0; diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c index e4ce9e64f637..d1beb7681c21 100644 --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -51,8 +51,11 @@ #include <netlink/netlink_debug.h> _DECLARE_DEBUG(LOG_DEBUG); +static bool nlattr_add_labels(struct nl_writer *nw, int attrtype, + const struct pf_krule *r); +static bool nlattr_add_rule(struct nl_writer *nw, const struct pf_krule *rule); static bool nlattr_add_pf_threshold(struct nl_writer *, int, - struct pf_kthreshold *); + const struct pf_kthreshold *); struct nl_parsed_state { uint8_t version; @@ -63,6 +66,7 @@ struct nl_parsed_state { sa_family_t af; struct pf_addr addr; struct pf_addr mask; + bool include_rule; }; #define _IN(_field) offsetof(struct genlmsghdr, _field) @@ -75,6 +79,7 @@ static const struct nlattr_parser nla_p_state[] = { { .type = PF_ST_PROTO, .off = _OUT(proto), .cb = nlattr_get_uint16 }, { .type = PF_ST_FILTER_ADDR, .off = _OUT(addr), .cb = nlattr_get_in6_addr }, { .type = PF_ST_FILTER_MASK, .off = _OUT(mask), .cb = nlattr_get_in6_addr }, + { .type = PF_ST_INCLUDE_RULE, .off = _OUT(include_rule), .cb = nlattr_get_bool }, }; static const struct nlfield_parser nlf_p_generic[] = { { .off_in = _IN(version), .off_out = _OUT(version), .cb = nlf_get_u8 }, @@ -146,8 +151,26 @@ dump_state_key(struct nl_writer *nw, int attr, const struct pf_state_key *key) return (true); } +static bool +nlattr_add_rule_nested(struct nl_writer *nw, int attr, const struct pf_krule *r) +{ + int off; + bool ret; + + off = nlattr_add_nested(nw, attr); + if (off == 0) + return (false); + + ret = nlattr_add_rule(nw, r); + + nlattr_set_len(nw, off); + + return (ret); +} + static int -dump_state(struct nlpcb *nlp, const struct nlmsghdr *hdr, struct pf_kstate *s, +dump_state(struct nlpcb *nlp, const struct nlmsghdr *hdr, + struct nl_parsed_state *attrs, struct pf_kstate *s, struct nl_pstate *npt) { struct nl_writer *nw = npt->nw; @@ -231,6 +254,9 @@ dump_state(struct nlpcb *nlp, const struct nlmsghdr *hdr, struct pf_kstate *s, if (!dump_state_peer(nw, PF_ST_PEER_DST, &s->dst)) goto enomem; + if (attrs->include_rule && s->rule != NULL) + nlattr_add_rule_nested(nw, PF_ST_CREATED_BY_RULE, s->rule); + if (nlmsg_end(nw)) return (0); @@ -282,7 +308,7 @@ handle_dumpstates(struct nlpcb *nlp, struct nl_parsed_state *attrs, &attrs->mask, &attrs->addr, af)) continue; - error = dump_state(nlp, hdr, s, npt); + error = dump_state(nlp, hdr, attrs, s, npt); if (error != 0) break; } @@ -307,7 +333,7 @@ handle_getstate(struct nlpcb *nlp, struct nl_parsed_state *attrs, s = pf_find_state_byid(attrs->id, attrs->creatorid); if (s == NULL) return (ENOENT); - ret = dump_state(nlp, hdr, s, npt); + ret = dump_state(nlp, hdr, attrs, s, npt); PF_STATE_UNLOCK(s); return (ret); @@ -465,7 +491,8 @@ NL_DECLARE_ATTR_PARSER(rule_addr_parser, nla_p_ruleaddr); #undef _OUT static bool -nlattr_add_rule_addr(struct nl_writer *nw, int attrtype, struct pf_rule_addr *r) +nlattr_add_rule_addr(struct nl_writer *nw, int attrtype, + const struct pf_rule_addr *r) { struct pf_addr_wrap aw = {0}; int off = nlattr_add_nested(nw, attrtype); @@ -687,7 +714,8 @@ nlattr_get_nested_timeouts(struct nlattr *nla, struct nl_pstate *npt, const void } static bool -nlattr_add_timeout(struct nl_writer *nw, int attrtype, uint32_t *timeout) +nlattr_add_timeout(struct nl_writer *nw, int attrtype, + const uint32_t *timeout) { int off = nlattr_add_nested(nw, attrtype); @@ -875,76 +903,10 @@ out: return (error); } -struct nl_parsed_get_rule { - char anchor[MAXPATHLEN]; - uint8_t action; - uint32_t nr; - uint32_t ticket; - uint8_t clear; -}; -#define _OUT(_field) offsetof(struct nl_parsed_get_rule, _field) -static const struct nlattr_parser nla_p_getrule[] = { - { .type = PF_GR_ANCHOR, .off = _OUT(anchor), .arg = (void *)MAXPATHLEN, .cb = nlattr_get_chara }, - { .type = PF_GR_ACTION, .off = _OUT(action), .cb = nlattr_get_uint8 }, - { .type = PF_GR_NR, .off = _OUT(nr), .cb = nlattr_get_uint32 }, - { .type = PF_GR_TICKET, .off = _OUT(ticket), .cb = nlattr_get_uint32 }, - { .type = PF_GR_CLEAR, .off = _OUT(clear), .cb = nlattr_get_uint8 }, -}; -#undef _OUT -NL_DECLARE_PARSER(getrule_parser, struct genlmsghdr, nlf_p_empty, nla_p_getrule); - -static int -pf_handle_getrule(struct nlmsghdr *hdr, struct nl_pstate *npt) +static bool +nlattr_add_rule(struct nl_writer *nw, const struct pf_krule *rule) { - char anchor_call[MAXPATHLEN]; - struct nl_parsed_get_rule attrs = {}; - struct nl_writer *nw = npt->nw; - struct genlmsghdr *ghdr_new; - struct pf_kruleset *ruleset; - struct pf_krule *rule; - u_int64_t src_nodes_total = 0; - int rs_num; - int error; - - error = nl_parse_nlmsg(hdr, &getrule_parser, npt, &attrs); - if (error != 0) - return (error); - - if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) - return (ENOMEM); - - ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr); - ghdr_new->cmd = PFNL_CMD_GETRULE; - - PF_RULES_WLOCK(); - ruleset = pf_find_kruleset(attrs.anchor); - if (ruleset == NULL) { - PF_RULES_WUNLOCK(); - error = ENOENT; - goto out; - } - - rs_num = pf_get_ruleset_number(attrs.action); - if (rs_num >= PF_RULESET_MAX) { - PF_RULES_WUNLOCK(); - error = EINVAL; - goto out; - } - - if (attrs.ticket != ruleset->rules[rs_num].active.ticket) { - PF_RULES_WUNLOCK(); - error = EBUSY; - goto out; - } - - rule = TAILQ_FIRST(ruleset->rules[rs_num].active.ptr); - while ((rule != NULL) && (rule->nr != attrs.nr)) - rule = TAILQ_NEXT(rule, entries); - if (rule == NULL) { - PF_RULES_WUNLOCK(); - error = EBUSY; - goto out; - } + u_int64_t src_nodes_total = 0; nlattr_add_rule_addr(nw, PF_RT_SRC, &rule->src); nlattr_add_rule_addr(nw, PF_RT_DST, &rule->dst); @@ -1050,6 +1012,81 @@ pf_handle_getrule(struct nlmsghdr *hdr, struct nl_pstate *npt) nlattr_add_u8(nw, PF_RT_SOURCE_LIMIT, rule->sourcelim.id); nlattr_add_u32(nw, PF_RT_SOURCE_LIMIT_ACTION, rule->sourcelim.limiter_action); + return (true); +} + +struct nl_parsed_get_rule { + char anchor[MAXPATHLEN]; + uint8_t action; + uint32_t nr; + uint32_t ticket; + uint8_t clear; +}; +#define _OUT(_field) offsetof(struct nl_parsed_get_rule, _field) +static const struct nlattr_parser nla_p_getrule[] = { + { .type = PF_GR_ANCHOR, .off = _OUT(anchor), .arg = (void *)MAXPATHLEN, .cb = nlattr_get_chara }, + { .type = PF_GR_ACTION, .off = _OUT(action), .cb = nlattr_get_uint8 }, + { .type = PF_GR_NR, .off = _OUT(nr), .cb = nlattr_get_uint32 }, + { .type = PF_GR_TICKET, .off = _OUT(ticket), .cb = nlattr_get_uint32 }, + { .type = PF_GR_CLEAR, .off = _OUT(clear), .cb = nlattr_get_uint8 }, +}; +#undef _OUT +NL_DECLARE_PARSER(getrule_parser, struct genlmsghdr, nlf_p_empty, nla_p_getrule); + +static int +pf_handle_getrule(struct nlmsghdr *hdr, struct nl_pstate *npt) +{ + char anchor_call[MAXPATHLEN]; + struct nl_parsed_get_rule attrs = {}; + struct nl_writer *nw = npt->nw; + struct genlmsghdr *ghdr_new; + struct pf_kruleset *ruleset; + struct pf_krule *rule; + int rs_num; + int error; + + error = nl_parse_nlmsg(hdr, &getrule_parser, npt, &attrs); + if (error != 0) + return (error); + + if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) + return (ENOMEM); + + ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr); + ghdr_new->cmd = PFNL_CMD_GETRULE; + + PF_RULES_WLOCK(); + ruleset = pf_find_kruleset(attrs.anchor); + if (ruleset == NULL) { + PF_RULES_WUNLOCK(); + error = ENOENT; + goto out; + } + + rs_num = pf_get_ruleset_number(attrs.action); + if (rs_num >= PF_RULESET_MAX) { + PF_RULES_WUNLOCK(); + error = EINVAL; + goto out; + } + + if (attrs.ticket != ruleset->rules[rs_num].active.ticket) { + PF_RULES_WUNLOCK(); + error = EBUSY; + goto out; + } + + rule = TAILQ_FIRST(ruleset->rules[rs_num].active.ptr); + while ((rule != NULL) && (rule->nr != attrs.nr)) + rule = TAILQ_NEXT(rule, entries); + if (rule == NULL) { + PF_RULES_WUNLOCK(); + error = EBUSY; + goto out; + } + + nlattr_add_rule(nw, rule); + error = pf_kanchor_copyout(ruleset, rule, anchor_call, sizeof(anchor_call)); MPASS(error == 0); @@ -1729,7 +1766,7 @@ pf_handle_get_ruleset(struct nlmsghdr *hdr, struct nl_pstate *npt) static bool nlattr_add_pf_threshold(struct nl_writer *nw, int attrtype, - struct pf_kthreshold *t) + const struct pf_kthreshold *t) { int off = nlattr_add_nested(nw, attrtype); int conn_rate_count = 0; diff --git a/sys/netpfil/pf/pf_nl.h b/sys/netpfil/pf/pf_nl.h index 6591c707d9a4..4d0186ea86a5 100644 --- a/sys/netpfil/pf/pf_nl.h +++ b/sys/netpfil/pf/pf_nl.h @@ -152,6 +152,8 @@ enum pfstate_type_t { PF_ST_RT_IFNAME = 37, /* string */ PF_ST_SRC_NODE_FLAGS = 38, /* u8 */ PF_ST_RT_AF = 39, /* u8 */ + PF_ST_INCLUDE_RULE = 40, /* bool */ + PF_ST_CREATED_BY_RULE = 41, /* nested, pf_rule_type_t */ }; enum pf_addr_type_t { diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h index 33cc6e731b50..746f9a4837c6 100644 --- a/sys/powerpc/include/_types.h +++ b/sys/powerpc/include/_types.h @@ -66,6 +66,7 @@ typedef __int32_t __register_t; typedef __int32_t __segsz_t; /* segment size (in pages) */ #endif typedef __int64_t __time_t; /* time()... */ +#define __SIZEOF_TIME_T __SIZEOF_INT64_T typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index 827d5efef50b..cce2787ed5d7 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -77,6 +77,7 @@ options RACCT # Resource accounting framework options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options RCTL # Resource limits options SMP +options IOMMU # RISC-V SBI console device rcons diff --git a/sys/riscv/include/_types.h b/sys/riscv/include/_types.h index 3e9abd27a156..a9f95d4b6839 100644 --- a/sys/riscv/include/_types.h +++ b/sys/riscv/include/_types.h @@ -51,6 +51,7 @@ typedef __int64_t __int_fast64_t; typedef __int64_t __register_t; typedef __int64_t __segsz_t; /* segment size (in pages) */ typedef __int64_t __time_t; /* time()... */ +#define __SIZEOF_TIME_T __SIZEOF_INT64_T typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; diff --git a/sys/riscv/include/bus_dma_impl.h b/sys/riscv/include/bus_dma_impl.h index 09fd29b74f8e..8c2040a68f52 100644 --- a/sys/riscv/include/bus_dma_impl.h +++ b/sys/riscv/include/bus_dma_impl.h @@ -41,6 +41,7 @@ struct bus_dma_tag_common { int flags; bus_dma_lock_t *lockfunc; void *lockfuncarg; + int domain; }; struct bus_dma_impl { @@ -52,6 +53,8 @@ struct bus_dma_impl { int (*tag_destroy)(bus_dma_tag_t dmat); int (*map_create)(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp); int (*map_destroy)(bus_dma_tag_t dmat, bus_dmamap_t map); + int (*tag_set_domain)(bus_dma_tag_t); + bool (*id_mapped)(bus_dma_tag_t, vm_paddr_t, bus_size_t); int (*mem_alloc)(bus_dma_tag_t dmat, void** vaddr, int flags, bus_dmamap_t *mapp); void (*mem_free)(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map); diff --git a/sys/riscv/include/iommu.h b/sys/riscv/include/iommu.h new file mode 100644 index 000000000000..38214b7003f4 --- /dev/null +++ b/sys/riscv/include/iommu.h @@ -0,0 +1,10 @@ +/*- + * This file is in the public domain. + */ + +#ifndef _MACHINE_IOMMU_H_ +#define _MACHINE_IOMMU_H_ + +#include <riscv/iommu/iommu_frontend.h> + +#endif /* !_MACHINE_IOMMU_H_ */ diff --git a/sys/riscv/iommu/iommu.c b/sys/riscv/iommu/iommu.c new file mode 100644 index 000000000000..59df2e68384f --- /dev/null +++ b/sys/riscv/iommu/iommu.c @@ -0,0 +1,1351 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/bitstring.h> +#include <sys/bus.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/mutex.h> +#include <sys/rman.h> +#include <sys/lock.h> +#include <sys/sysctl.h> +#include <sys/tree.h> +#include <sys/taskqueue.h> +#include <sys/refcount.h> +#include <vm/vm.h> +#include <vm/vm_page.h> + +#include <sys/bus.h> +#include <sys/conf.h> +#include <sys/rman.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> + +#include <machine/bus.h> +#include <machine/resource.h> + +#include <dev/iommu/iommu.h> +#include <riscv/iommu/iommu_pmap.h> +#include <riscv/iommu/iommu.h> + +#include "iommu_if.h" + +#define dprintf(fmt, ...) + +MALLOC_DEFINE(M_IOMMU, "RISCV_IOMMU", "RISC-V IOMMU"); + +#define RD4(sc, reg) bus_read_4(sc->res[0], (reg)) +#define WR4(sc, reg, val) bus_write_4(sc->res[0], (reg), (val)) +#define RD8(sc, reg) bus_read_8(sc->res[0], (reg)) +#define WR8(sc, reg, val) bus_write_8(sc->res[0], (reg), (val)) + +#define CQ_ENTRY_DWORDS 2 /* 16-byte */ +#define CQ_ENTRY_COUNT 8192 /* Amount of 16-byte entries. */ +#define FQ_ENTRY_DWORDS 4 /* 32-byte */ +#define FQ_ENTRY_COUNT 8192 /* Amount of 32-byte entries. */ +#define PQ_ENTRY_DWORDS 2 /* 16-byte */ +#define PQ_ENTRY_COUNT 8192 /* Amount of 16-byte entries. */ + +#define DDT_NON_LEAF_DWORDS 1 +#define DDT_DC_STD_DWORDS 4 /* Standard-format DC. */ +#define DDT_DC_EXT_DWORDS 8 /* Extended-format DC. */ +#define DDT_L1_DID_BITS 9 /* All formats. */ + +#define QUEUE_ALIGN (1024 * 1024) /* TODO */ +#define QUEUE_HEAD(q) ((q)->csr + RISCV_IOMMU_CQH - RISCV_IOMMU_CQB) +#define QUEUE_TAIL(q) ((q)->csr + RISCV_IOMMU_CQT - RISCV_IOMMU_CQB) +#define QUEUE_IPSR(q) (1 << (q)->idx) + +#define PHYS_TO_PPN(p) ((p) >> 12) + +struct riscv_iommu_fq_event { + uint16_t cause_id; + char *descr; +}; + +static struct riscv_iommu_fq_event fq_events[] = { + { FQ_CAUSE_INST_FAULT, "Instruction access fault" }, + { FQ_CAUSE_RD_ADDR_MISALIGNED, "Read address misaligned" }, + { FQ_CAUSE_RD_FAULT, "Read access fault" }, + { FQ_CAUSE_WR_ADDR_MISALIGNED, "Write/AMO address misaligned" }, + { FQ_CAUSE_WR_FAULT, "Write/AMO access fault" }, + { FQ_CAUSE_INST_FAULT_S, "Instruction page fault" }, + { FQ_CAUSE_RD_FAULT_S, "Read page fault" }, + { FQ_CAUSE_WR_FAULT_S, "Write/AMO page fault" }, + { FQ_CAUSE_INST_FAULT_VS, "Instruction guest page fault" }, + { FQ_CAUSE_RD_FAULT_VS, "Read guest-page fault" }, + { FQ_CAUSE_WR_FAULT_VS, "Write/AMO guest-page fault" }, + { FQ_CAUSE_DMA_DISABLED, "All inbound transactions disallowed" }, + { FQ_CAUSE_DDT_LOAD_FAULT, "DDT entry load access fault" }, + { FQ_CAUSE_DDT_INVALID, "DDT entry not valid" }, + { FQ_CAUSE_DDT_MISCONFIGURED, "DDT entry misconfigured" }, + { FQ_CAUSE_TR_TYPE_DISALLOWED, "Transaction type disallowed" }, + { FQ_CAUSE_MSI_LOAD_FAULT, "MSI PTE load access fault" }, + { FQ_CAUSE_MSI_INVALID, "MSI PTE not valid" }, + { FQ_CAUSE_MSI_MISCONFIGURED, "MSI PTE misconfigured" }, + { FQ_CAUSE_MRIF_FAULT, "MRIF access fault" }, + { FQ_CAUSE_PDT_LOAD_FAULT, "PDT entry load access fault" }, + { FQ_CAUSE_PDT_INVALID, "PDT entry not valid" }, + { FQ_CAUSE_PDT_MISCONFIGURED, "PDT entry misconfigured" }, + { FQ_CAUSE_DDT_CORRUPTED, "DDT data corruption" }, + { FQ_CAUSE_PDT_CORRUPTED, "PDT data corruption" }, + { FQ_CAUSE_MSI_PT_CORRUPTED, "MSI PT data corruption" }, + { FQ_CAUSE_MRIF_CORRUPTED, "MSI MRIF data corruption" }, + { FQ_CAUSE_INTERNAL_DP_ERROR, "Internal data path error" }, + { FQ_CAUSE_MSI_WR_FAULT, "IOMMU MSI write access fault" }, + { FQ_CAUSE_PT_CORRUPTED, "1st/2nd-stage PT data corruption" }, + { 0, NULL }, +}; + +static void +riscv_iommu_init_pscids(struct riscv_iommu_softc *sc) +{ + + sc->pscid_set_size = (1 << sc->pscid_bits); + sc->pscid_set = bit_alloc(sc->pscid_set_size, M_IOMMU, M_WAITOK); + mtx_init(&sc->pscid_set_mutex, "pscid set", NULL, MTX_SPIN); +} + +static int +riscv_iommu_pscid_alloc(struct riscv_iommu_softc *sc, int *new_pscid) +{ + + mtx_lock_spin(&sc->pscid_set_mutex); + bit_ffc(sc->pscid_set, sc->pscid_set_size, new_pscid); + if (*new_pscid == -1) { + mtx_unlock_spin(&sc->pscid_set_mutex); + return (ENOMEM); + } + bit_set(sc->pscid_set, *new_pscid); + mtx_unlock_spin(&sc->pscid_set_mutex); + + return (0); +} + +static void +riscv_iommu_pscid_free(struct riscv_iommu_softc *sc, int pscid) +{ + + mtx_lock_spin(&sc->pscid_set_mutex); + bit_clear(sc->pscid_set, pscid); + mtx_unlock_spin(&sc->pscid_set_mutex); +} + +static uint32_t +riscv_iommu_q_inc_tail(struct riscv_iommu_queue *q) +{ + + return ((q->lc.tail + 1) & q->mask); +} + +static uint32_t +riscv_iommu_q_inc_head(struct riscv_iommu_queue *q) +{ + + return ((q->lc.head + 1) & q->mask); +} + +static int +riscv_iommu_q_has_space(struct riscv_iommu_queue *q) +{ + + if (riscv_iommu_q_inc_tail(q) != q->lc.head) + return (1); + + return (0); +} + +static int +riscv_iommu_q_empty(struct riscv_iommu_queue *q) +{ + + if (q->lc.tail == q->lc.head) + return (1); + + return (0); +} + +static int +riscv_iommu_dequeue(struct riscv_iommu_softc *sc, struct riscv_iommu_queue *q, + void *data) +{ + void *entry_addr; + + q->lc.val = RD8(sc, q->head_off); + entry_addr = (void *)((uint64_t)q->vaddr + q->lc.head * q->entry_size); + memcpy(data, entry_addr, q->entry_size); + q->lc.head = riscv_iommu_q_inc_head(q); + WR4(sc, q->head_off, q->lc.head); + + return (0); +} + +static int +riscv_iommu_enqueue(struct riscv_iommu_softc *sc, struct riscv_iommu_queue *q, + void *data) +{ + void *entry_addr; + + RISCV_IOMMU_LOCK(sc); + + /* Ensure that a space is available. */ + do { + q->lc.head = RD4(sc, q->head_off); + } while (riscv_iommu_q_has_space(q) == 0); + + /* Write the command to the current tail entry. */ + entry_addr = (void *)((uint64_t)q->vaddr + q->lc.tail * q->entry_size); + memcpy(entry_addr, data, q->entry_size); + + /* Increment tail index. */ + q->lc.tail = riscv_iommu_q_inc_tail(q); + WR4(sc, q->tail_off, q->lc.tail); + + RISCV_IOMMU_UNLOCK(sc); + + return (0); +} + +static void +riscv_iommu_sync(struct riscv_iommu_softc *sc, struct riscv_iommu_queue *q) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IOFENCE; + reg |= FUNC_IOFENCE_FUNC_C | FUNC_IOFENCE_PR | FUNC_IOFENCE_PW; + cmd.dword0 = reg; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + /* + * FUNC_IOFENCE_WSI does not seem to be implemented in QEMU, + * so ensure all requests are processed in polling mode; + */ + do { + q->lc.head = RD4(sc, q->head_off); + } while (riscv_iommu_q_empty(q) == 0); +} + +static int +riscv_iommu_inval_ddt(struct riscv_iommu_softc *sc) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IODIR; + reg |= FUNC_IODIR_INVAL_DDT; + cmd.dword0 = reg; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + return (0); +} + +static int +riscv_iommu_inval_ddt_did(struct riscv_iommu_softc *sc, int did) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IODIR; + reg |= FUNC_IODIR_INVAL_DDT; + reg |= FUNC_IODIR_DV; + reg |= (uint64_t)did << FUNC_IODIR_DID_S; + cmd.dword0 = reg; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + return (0); +} + +/* Invalidate entire address space. */ +static int +riscv_iommu_inval_vma(struct riscv_iommu_softc *sc) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IOTINVAL; + reg |= FUNC_IOTINVAL_VMA; + cmd.dword0 = reg; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + return (0); +} + +static int +riscv_iommu_inval_vma_page(struct riscv_iommu_softc *sc, vm_offset_t addr, + int pscid) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IOTINVAL; + reg |= FUNC_IOTINVAL_VMA; + reg |= FUNC_IOTINVAL_AV; + reg |= FUNC_IOTINVAL_PSCV; + reg |= pscid << FUNC_IOTINVAL_PSCID_S; + cmd.dword0 = reg; + cmd.dword1 = PHYS_TO_PPN(addr) << FUNC_IOTINVAL_ADDR_S; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + return (0); +} + +static int +riscv_iommu_inval_vma_pscid(struct riscv_iommu_softc *sc, int pscid) +{ + struct riscv_iommu_command cmd; + uint64_t reg; + + bzero(&cmd, sizeof(struct riscv_iommu_command)); + reg = COMMAND_OPCODE_IOTINVAL; + reg |= FUNC_IOTINVAL_VMA; + reg |= FUNC_IOTINVAL_PSCV; + reg |= pscid << FUNC_IOTINVAL_PSCID_S; + cmd.dword0 = reg; + + riscv_iommu_enqueue(sc, &sc->cq, (void *)&cmd); + + return (0); +} + +static int +riscv_iommu_set_mode(struct riscv_iommu_softc *sc) +{ + struct riscv_iommu_ddt *ddt; + uint64_t reg; + uint64_t base; + + reg = RD8(sc, RISCV_IOMMU_DDTP); + if (reg & DDTP_BUSY) + return (ENXIO); + + ddt = &sc->ddt; + base = ddt->base | (sc->iommu_mode << DDTP_IOMMU_MODE_S); + WR8(sc, RISCV_IOMMU_DDTP, base); + + reg = RD8(sc, RISCV_IOMMU_DDTP); + if (reg != base) { + device_printf(sc->dev, "could not set mode\n"); + return (ENXIO); + } + + riscv_iommu_inval_ddt(sc); + riscv_iommu_inval_vma(sc); + + return (0); +} + +static int +riscv_iommu_enable_queue(struct riscv_iommu_softc *sc, + struct riscv_iommu_queue *q) +{ + uint32_t reg; + int timeout; + + if (q == &sc->cq) + WR4(sc, QUEUE_TAIL(q), 0); + else + WR4(sc, QUEUE_HEAD(q), 0); + + reg = CQCSR_CQEN | CQCSR_CIE | CQCSR_CQMF; + WR4(sc, q->csr, reg); + + timeout = 1000; + do { + reg = RD4(sc, RISCV_IOMMU_CQCSR); + if ((reg & CQCSR_BUSY) == 0) + break; + DELAY(10); + } while (timeout--); + + if (timeout <= 0) { + device_printf(sc->dev, "could not enable command queue\n"); + return (-1); + } + + if ((reg & CQCSR_CQON) == 0) { + device_printf(sc->dev, "could not activate command queue\n"); + return (-1); + } + + /* RW1C interrupt pending bit. */ + WR4(sc, RISCV_IOMMU_IPSR, QUEUE_IPSR(q)); + + return (0); +} + +static int +riscv_iommu_init_queue(struct riscv_iommu_softc *sc, + struct riscv_iommu_queue *q, uint64_t base, uint32_t dwords) +{ + uint64_t reg; + int sz; + + q->entry_size = dwords * 8; + sz = (1 << q->size_log2) * q->entry_size; + + /* Set up the command circular buffer */ + q->vaddr = contigmalloc(sz, M_IOMMU, M_WAITOK | M_ZERO, 0, + (1ul << 48) - 1, QUEUE_ALIGN, 0); + if (q->vaddr == NULL) { + device_printf(sc->dev, "failed to allocate %d bytes\n", sz); + return (-1); + } + + q->mask = (1 << q->size_log2) - 1; + q->head_off = (uint32_t)base - RISCV_IOMMU_CQB + RISCV_IOMMU_CQH; + q->tail_off = (uint32_t)base - RISCV_IOMMU_CQB + RISCV_IOMMU_CQT; + q->paddr = vtophys(q->vaddr); + q->base = (sc->cq.size_log2 - 1) << CQB_LOG2SZ_1_S; + q->base |= PHYS_TO_PPN(q->paddr) << CQB_PPN_S; + WR8(sc, base, q->base); + + /* Verify it sticks. */ + reg = RD8(sc, base); + if (reg != q->base) { + device_printf(sc->dev, "could not init queue\n"); + return (ENXIO); + } + + return (0); +} + +static int +riscv_iommu_init_queues(struct riscv_iommu_softc *sc) +{ + int error; + + sc->cq.size_log2 = ilog2(CQ_ENTRY_COUNT); + sc->fq.size_log2 = ilog2(FQ_ENTRY_COUNT); + sc->pq.size_log2 = ilog2(PQ_ENTRY_COUNT); + + sc->cq.csr = RISCV_IOMMU_CQCSR; + sc->fq.csr = RISCV_IOMMU_FQCSR; + sc->pq.csr = RISCV_IOMMU_PQCSR; + + sc->cq.idx = 0; + sc->fq.idx = 1; + sc->pq.idx = 3; + + /* Command queue (CQ). */ + error = riscv_iommu_init_queue(sc, &sc->cq, RISCV_IOMMU_CQB, + CQ_ENTRY_DWORDS); + if (error) + return (error); + + /* Fault queue (FQ). */ + error = riscv_iommu_init_queue(sc, &sc->fq, RISCV_IOMMU_FQB, + FQ_ENTRY_DWORDS); + if (error) + return (error); + + /* Page request queue (PQ). */ + error = riscv_iommu_init_queue(sc, &sc->pq, RISCV_IOMMU_PQB, + PQ_ENTRY_DWORDS); + if (error) + return (error); + + error = riscv_iommu_enable_queue(sc, &sc->cq); + if (error) + return (error); + + error = riscv_iommu_enable_queue(sc, &sc->fq); + if (error) + return (error); + + error = riscv_iommu_enable_queue(sc, &sc->pq); + if (error) + return (error); + + return (0); +} + +static int +riscv_iommu_init_pagedir(struct riscv_iommu_softc *sc) +{ + + return (0); +} + +static void +riscv_iommu_print_fault(struct riscv_iommu_softc *sc, + struct riscv_iommu_fq_record *rec) +{ + struct riscv_iommu_fq_event *ev; + uint16_t cause_id; + uint16_t ttyp; + uint32_t did; + uint32_t pid; + bool pv, priv; + int i; + + cause_id = (rec->hdr & FQR_HDR_CAUSE_M) >> FQR_HDR_CAUSE_S; + ttyp = (rec->hdr & FQR_HDR_TTYP_M) >> FQR_HDR_TTYP_S; + did = (rec->hdr & FQR_HDR_DID_M) >> FQR_HDR_DID_S; + pid = (rec->hdr & FQR_HDR_PID_M) >> FQR_HDR_PID_S; + pv = (rec->hdr & FQR_HDR_PV) ? 1 : 0; + priv = (rec->hdr & FQR_HDR_PRIV) ? 1 : 0; + + ev = NULL; + for (i = 0; fq_events[i].cause_id != 0; i++) { + if (fq_events[i].cause_id == cause_id) { + ev = &fq_events[i]; + break; + } + } + + if (ev == NULL) { + device_printf(sc->dev, "Fault: unknown fault 0x%x received\n", + cause_id); + return; + } + + device_printf(sc->dev, "Fault: event 0x%x received: %s\n", + ev->cause_id, ev->descr); + device_printf(sc->dev, " hdr 0x%lx\n", rec->hdr); + device_printf(sc->dev, " iotval 0x%lx\n", rec->iotval); + device_printf(sc->dev, " iotval2 0x%lx\n", rec->iotval2); + device_printf(sc->dev, " ttyp 0x%x did 0x%x pid 0x%x pv %d priv %d" + "\n", ttyp, did, pid, pv, priv); +} + +static int +riscv_cq_intr(void *arg) +{ + struct riscv_iommu_softc *sc; + struct riscv_iommu_queue *q; + uint32_t reg; + + sc = arg; + q = &sc->cq; + + reg = RD4(sc, q->csr); + printf("%s: pending %x\n", __func__, reg); + + /* Clear pending bit. */ + WR4(sc, RISCV_IOMMU_IPSR, IPSR_CIP); + + return (FILTER_HANDLED); +} + +static int +riscv_fq_intr(void *arg) +{ + struct riscv_iommu_fq_record rec; + struct riscv_iommu_softc *sc; + struct riscv_iommu_queue *q; + uint32_t reg; + + sc = arg; + q = &sc->fq; + + reg = RD4(sc, q->csr); + printf("%s: pending %x\n", __func__, reg); + + /* Clear pending bit. */ + WR4(sc, RISCV_IOMMU_IPSR, IPSR_FIP); + + do { + riscv_iommu_dequeue(sc, q, &rec); + riscv_iommu_print_fault(sc, &rec); + } while (!riscv_iommu_q_empty(q)); + + return (FILTER_HANDLED); +} + +static int +riscv_pm_intr(void *arg) +{ + struct riscv_iommu_softc *sc; + + sc = arg; + + printf("%s\n", __func__); + + /* Clear pending bit. */ + WR4(sc, RISCV_IOMMU_IPSR, IPSR_PMIP); + + return (FILTER_HANDLED); +} + +static int +riscv_pq_intr(void *arg) +{ + struct riscv_iommu_softc *sc; + struct riscv_iommu_queue *q; + uint32_t reg; + + sc = arg; + q = &sc->pq; + + reg = RD4(sc, q->csr); + printf("%s: pending %x\n", __func__, reg); + + /* Clear pending bit. */ + WR4(sc, RISCV_IOMMU_IPSR, IPSR_PIP); + + return (FILTER_HANDLED); +} + +static int +riscv_iommu_init_ddt_linear(struct riscv_iommu_softc *sc) +{ + struct riscv_iommu_ddt *ddt; + uint64_t size; + uint64_t reg; + + ddt = &sc->ddt; + ddt->num_top_entries = (1 << sc->l0_did_bits); + + size = ddt->num_top_entries * (sc->dc_dwords << 3); + + if (bootverbose) + device_printf(sc->dev, "linear ddt size %ld, num_top_entries " + "%d\n", size, ddt->num_top_entries); + + ddt->vaddr = contigmalloc(size, M_IOMMU, + M_WAITOK | M_ZERO, /* flags */ + 0, /* low */ + (1ul << 48) - 1, /* high */ + size, /* alignment */ + 0); /* boundary */ + if (ddt->vaddr == NULL) { + device_printf(sc->dev, "failed to allocate ddt\n"); + return (ENXIO); + } + + reg = vtophys(ddt->vaddr); + if (bootverbose) + device_printf(sc->dev, "ddt base %p size %lx\n", ddt->vaddr, + size); + ddt->base = PHYS_TO_PPN(reg) << DDTP_PPN_S; + + return (0); +} + +static int +riscv_iommu_init_ddt_2lvl(struct riscv_iommu_softc *sc) +{ + struct riscv_iommu_ddt *ddt; + uint64_t size; + uint64_t reg; + uint64_t sz; + + ddt = &sc->ddt; + ddt->num_top_entries = (1 << DDT_L1_DID_BITS); + + size = ddt->num_top_entries * (DDT_NON_LEAF_DWORDS << 3); + + if (bootverbose) + device_printf(sc->dev, "%s: size %lu, l1 entries %d, size " + "%lu\n", __func__, size, ddt->num_top_entries, size); + + ddt->vaddr = contigmalloc(size, M_IOMMU, + M_WAITOK | M_ZERO, /* flags */ + 0, /* low */ + (1ul << 48) - 1, /* high */ + size, /* alignment */ + 0); /* boundary */ + if (ddt->vaddr == NULL) { + device_printf(sc->dev, "Failed to allocate 2lvl ddt.\n"); + return (ENOMEM); + } + + sz = ddt->num_top_entries * sizeof(struct l1_desc); + ddt->l1 = malloc(sz, M_IOMMU, M_WAITOK | M_ZERO); + + reg = vtophys(ddt->vaddr); + if (bootverbose) + device_printf(sc->dev, "ddt base %p size %lx\n", ddt->vaddr, + size); + ddt->base = PHYS_TO_PPN(reg) << DDTP_PPN_S; + + return (0); +} + +static int +riscv_iommu_init_l0_directory(struct riscv_iommu_softc *sc, int sid) +{ + struct riscv_iommu_ddt *ddt; + struct l1_desc *l1_desc; + uint64_t *l1e; + uint64_t val; + size_t size; + int i; + + ddt = &sc->ddt; + l1_desc = &ddt->l1[sid >> sc->l0_did_bits]; + if (l1_desc->va) { + /* Already allocated. */ + return (0); + } + + size = (1 << sc->l0_did_bits) * (sc->dc_dwords << 3); + + l1_desc->va = contigmalloc(size, M_IOMMU, + M_WAITOK | M_ZERO, /* flags */ + 0, /* low */ + (1ul << 48) - 1, /* high */ + size, /* alignment */ + 0); /* boundary */ + if (l1_desc->va == NULL) { + device_printf(sc->dev, "failed to allocate l0 directory\n"); + return (ENXIO); + } + + l1_desc->pa = vtophys(l1_desc->va); + + i = sid >> sc->l0_did_bits; + l1e = (void *)((uint64_t)ddt->vaddr + DDT_NON_LEAF_DWORDS * 8 * i); + + /* Install the L1 entry. */ + val = PHYS_TO_PPN(l1_desc->pa) << DC_NON_LEAF_ENTRY_PPN_S; + val |= DC_NON_LEAF_ENTRY_VALID; + *l1e = val; + + return (0); +} + +static void * +riscv_iommu_get_dc_addr(struct riscv_iommu_softc *sc, int did) +{ + struct riscv_iommu_ddt *ddt; + struct l1_desc *l1_desc; + uintptr_t l0_base; + void *addr; + int l0_offs; + int l1_idx; + + ddt = &sc->ddt; + + l0_offs = sc->dc_dwords * 8 * (did & ((1 << sc->l0_did_bits) - 1)); + + if (sc->iommu_mode == DDTP_IOMMU_MODE_2LVL) { + l1_idx = (did >> sc->l0_did_bits) & + ((1 << DDT_L1_DID_BITS) - 1); + l1_desc = &ddt->l1[l1_idx]; + l0_base = (uintptr_t)l1_desc->va; + } else + l0_base = (uintptr_t)ddt->vaddr; + + addr = (void *)(l0_base + l0_offs); + + dprintf("ddt vaddr %p addr %p\n", ddt->vaddr, addr); + + return (addr); +} + +static int +riscv_iommu_init_dc(struct riscv_iommu_softc *sc, + struct riscv_iommu_domain *domain, int did, bool bypass) +{ + struct riscv_iommu_dc_base *dc_base; + struct riscv_iommu_dc *dc; + struct riscv_iommu_pmap *p; + + dc = riscv_iommu_get_dc_addr(sc, did); + dc_base = &dc->base; + + device_printf(sc->dev, "address translation for device id" + " 0x%x is %s.\n", did, bypass ? "bypassed" : "enabled"); + + p = &domain->p; + + bzero(dc_base, sizeof(struct riscv_iommu_dc_base)); + if (bypass == false) + dc_base->fsc = p->pm_satp; + dc_base->ta = (domain->pscid << DC_TA_PSCID_S) | DC_TA_V; + + riscv_iommu_inval_ddt_did(sc, did); + riscv_iommu_sync(sc, &sc->cq); + dc_base->tc |= DC_TC_V; + riscv_iommu_inval_ddt_did(sc, did); + riscv_iommu_inval_vma(sc); + riscv_iommu_sync(sc, &sc->cq); + + return (0); +} + +static void +riscv_iommu_deinit_dc(struct riscv_iommu_softc *sc, int did) +{ + struct riscv_iommu_dc_base *dc_base; + struct riscv_iommu_dc *dc; + + dc = riscv_iommu_get_dc_addr(sc, did); + dc_base = &dc->base; + dc_base->tc &= ~DC_TC_V; + + riscv_iommu_inval_ddt_did(sc, did); + riscv_iommu_sync(sc, &sc->cq); +} + +static int +riscv_iommu_setup_interrupts(struct riscv_iommu_softc *sc) +{ + device_t dev; + int error; + + dev = sc->dev; + + if (sc->res[1] == NULL || sc->res[2] == NULL || + sc->res[3] == NULL || sc->res[4] == NULL) { + device_printf(dev, "Warning: no interrupt resources " + "provided.\n"); + return (ENXIO); + } + + error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC, + riscv_cq_intr, NULL, sc, &sc->intr_cookie[0]); + if (error) { + device_printf(dev, "Couldn't setup cq interrupt handler\n"); + return (ENXIO); + } + + error = bus_setup_intr(dev, sc->res[2], INTR_TYPE_MISC, + riscv_fq_intr, NULL, sc, &sc->intr_cookie[1]); + if (error) { + device_printf(dev, "Couldn't setup fq interrupt handler\n"); + return (ENXIO); + } + + error = bus_setup_intr(dev, sc->res[3], INTR_TYPE_MISC, + riscv_pm_intr, NULL, sc, &sc->intr_cookie[2]); + if (error) { + device_printf(dev, "Couldn't setup pm interrupt handler\n"); + return (ENXIO); + } + + error = bus_setup_intr(dev, sc->res[4], INTR_TYPE_MISC, + riscv_pq_intr, NULL, sc, &sc->intr_cookie[3]); + if (error) { + device_printf(dev, "Couldn't setup pq interrupt handler\n"); + return (ENXIO); + } + + WR8(sc, RISCV_IOMMU_ICVEC, 0 << 0 | 1 << 4 | 2 << 8 | 3 << 12); + + return (0); +} + +int +riscv_iommu_attach(device_t dev) +{ + struct riscv_iommu_softc *sc; + uint64_t caps; + int error; + + sc = device_get_softc(dev); + + caps = bus_read_8(sc->res[0], RISCV_IOMMU_CAPABILITIES); + if (bootverbose) + device_printf(sc->dev, "IOMMU Capabilities: %lx\n", caps); + + device_printf(sc->dev, "Device-Context structure is %s.\n", + caps & CAPABILITIES_MSI_FLAT ? + "64-bytes (ext format)" : "32-bytes (std format)"); + + if (caps & CAPABILITIES_MSI_FLAT) { + sc->dc_dwords = DDT_DC_EXT_DWORDS; + sc->l0_did_bits = 6; + } else { + sc->dc_dwords = DDT_DC_STD_DWORDS; + sc->l0_did_bits = 7; + } + + if (caps & CAPABILITIES_SV48) + sc->pm_mode = PMAP_MODE_SV48; + else if (caps & CAPABILITIES_SV39) + sc->pm_mode = PMAP_MODE_SV39; + else { + device_printf(sc->dev, "Unsupported virtual memory system\n"); + return (ENXIO); + } + + mtx_init(&sc->mtx, device_get_nameunit(sc->dev), "riscv_iommu", + MTX_DEF); + + WR4(sc, RISCV_IOMMU_FCTL, FCTL_WSI); + + error = riscv_iommu_setup_interrupts(sc); + if (error) { + device_printf(sc->dev, "Could not setup interrupts. " + "Continuing with no interrupts support."); + } + + error = riscv_iommu_init_pagedir(sc); + if (error) + return (error); + + error = riscv_iommu_init_queues(sc); + if (error) + return (error); + + sc->iommu_mode = DDTP_IOMMU_MODE_2LVL; + + switch (sc->iommu_mode) { + case DDTP_IOMMU_MODE_1LVL: + error = riscv_iommu_init_ddt_linear(sc); + break; + case DDTP_IOMMU_MODE_2LVL: + error = riscv_iommu_init_ddt_2lvl(sc); + break; + default: + error = ENXIO; + } + if (error) + return (error); + + sc->pscid_bits = 8; + + riscv_iommu_init_pscids(sc); + if (error) + return (error); + + error = riscv_iommu_set_mode(sc); + if (error) + return (error); + + return (0); +} + +static int +riscv_iommu_set_buswide(device_t dev, struct riscv_iommu_domain *domain, + struct riscv_iommu_ctx *ctx) +{ + struct riscv_iommu_softc *sc; + int i; + + sc = device_get_softc(dev); + + printf("%s\n", __func__); + + for (i = 0; i < PCI_SLOTMAX; i++) + riscv_iommu_init_dc(sc, domain, (ctx->did | i), + ctx->bypass); + + return (0); +} + +static int +riscv_iommu_pci_get_did(device_t child, uintptr_t *xref0, u_int *did0) +{ + struct pci_id_ofw_iommu pi; + int err; + + dprintf("%s\n", __func__); + + err = pci_get_id(child, PCI_ID_OFW_IOMMU, (uintptr_t *)&pi); + if (err == 0) { + if (did0) + *did0 = pi.id; + if (xref0) + *xref0 = pi.xref; + } + + return (err); +} + +static int +riscv_iommu_find(device_t dev, device_t child) +{ + struct riscv_iommu_softc *sc; + uintptr_t xref; + int err; + + dprintf("%s\n", __func__); + + sc = device_get_softc(dev); + + err = riscv_iommu_pci_get_did(child, &xref, NULL); + if (err) + return (ENOENT); + + /* Check if xref is ours. */ + dprintf("xref %lx sc->xref %lx\n", xref, sc->xref); + if (xref != sc->xref) + return (EFAULT); + + return (0); +} + +struct riscv_iommu_ctx * +riscv_iommu_ctx_lookup_by_did(device_t dev, u_int did) +{ + struct riscv_iommu_softc *sc; + struct riscv_iommu_domain *domain; + struct riscv_iommu_unit *unit; + struct riscv_iommu_ctx *ctx; + + dprintf("%s\n", __func__); + sc = device_get_softc(dev); + + unit = &sc->unit; + + LIST_FOREACH(domain, &unit->domain_list, next) { + LIST_FOREACH(ctx, &domain->ctx_list, next) { + if (ctx->did == did) { + refcount_acquire(&ctx->refcnt); + return (ctx); + } + } + } + + return (NULL); +} + +static struct iommu_ctx * +riscv_iommu_ctx_lookup(device_t dev, device_t child) +{ + struct iommu_unit *iommu __diagused; + struct riscv_iommu_softc *sc; + struct riscv_iommu_domain *domain; + struct riscv_iommu_unit *unit; + struct riscv_iommu_ctx *ctx; + + dprintf("%s\n", __func__); + sc = device_get_softc(dev); + + unit = &sc->unit; + iommu = &unit->iommu; + + IOMMU_ASSERT_LOCKED(iommu); + + LIST_FOREACH(domain, &unit->domain_list, next) { + IOMMU_DOMAIN_LOCK(&domain->iodom); + LIST_FOREACH(ctx, &domain->ctx_list, next) { + if (ctx->dev == child) { + refcount_acquire(&ctx->refcnt); + IOMMU_DOMAIN_UNLOCK(&domain->iodom); + return (&ctx->ioctx); + } + } + IOMMU_DOMAIN_UNLOCK(&domain->iodom); + } + + return (NULL); +} + +static int +riscv_iommu_unmap(device_t dev, struct iommu_domain *iodom, + vm_offset_t va, bus_size_t size) +{ + struct riscv_iommu_domain *domain; + struct riscv_iommu_softc *sc; + int err; + int i; + + sc = device_get_softc(dev); + + domain = (struct riscv_iommu_domain *)iodom; + + err = 0; + + dprintf("%s: %lx, %ld, domain %d\n", __func__, va, size, domain->pscid); + + for (i = 0; i < size; i += PAGE_SIZE) { + if (iommu_pmap_remove(&domain->p, va) == 0) { + /* pmap entry removed, invalidate TLB. */ + riscv_iommu_inval_vma_page(sc, va, domain->pscid); + } else { + err = ENOENT; + break; + } + va += PAGE_SIZE; + } + + riscv_iommu_sync(sc, &sc->cq); + + return (err); +} + +static int +riscv_iommu_map(device_t dev, struct iommu_domain *iodom, + vm_offset_t va, vm_page_t *ma, vm_size_t size, + vm_prot_t prot) +{ + struct riscv_iommu_domain *domain; + struct riscv_iommu_softc *sc; + vm_paddr_t pa; + int error; + int i; + + sc = device_get_softc(dev); + + domain = (struct riscv_iommu_domain *)iodom; + + for (i = 0; size > 0; size -= PAGE_SIZE) { + pa = VM_PAGE_TO_PHYS(ma[i++]); + dprintf("%s: %lx -> %lx, %ld, domain %d\n", __func__, va, pa, + size, domain->pscid); + error = iommu_pmap_enter(&domain->p, va, pa, prot, 0); + if (error) + return (error); + riscv_iommu_inval_vma_page(sc, va, domain->pscid); + va += PAGE_SIZE; + } + + riscv_iommu_sync(sc, &sc->cq); + + return (0); +} + +static struct iommu_domain * +riscv_iommu_domain_alloc(device_t dev, struct iommu_unit *iommu) +{ + struct iommu_domain *iodom; + struct riscv_iommu_domain *domain; + struct riscv_iommu_unit *unit; + struct riscv_iommu_softc *sc; + int new_pscid; + int va_bits; + int error; + + sc = device_get_softc(dev); + + dprintf("%s\n", __func__); + + unit = (struct riscv_iommu_unit *)iommu; + + error = riscv_iommu_pscid_alloc(sc, &new_pscid); + if (error) { + device_printf(sc->dev, + "Could not allocate PSCID for a new domain.\n"); + return (NULL); + } + + domain = malloc(sizeof(*domain), M_IOMMU, M_WAITOK | M_ZERO); + domain->pscid = (uint16_t)new_pscid; + + iommu_pmap_pinit(&domain->p, sc->pm_mode); + + riscv_iommu_inval_vma_pscid(sc, domain->pscid); + + LIST_INIT(&domain->ctx_list); + + IOMMU_LOCK(iommu); + LIST_INSERT_HEAD(&unit->domain_list, domain, next); + IOMMU_UNLOCK(iommu); + + iodom = &domain->iodom; + + va_bits = sc->pm_mode == PMAP_MODE_SV48 ? 48 : 39; + + /* Avoid sign-extension. */ + va_bits -= 1; + + iodom->end = (1ULL << va_bits) - 1; + + return (iodom); +} + +static void +riscv_iommu_domain_free(device_t dev, struct iommu_domain *iodom) +{ + struct riscv_iommu_domain *domain; + struct riscv_iommu_softc *sc; + + sc = device_get_softc(dev); + + dprintf("%s\n", __func__); + + domain = (struct riscv_iommu_domain *)iodom; + + LIST_REMOVE(domain, next); + + iommu_pmap_remove_pages(&domain->p); + iommu_pmap_release(&domain->p); + + riscv_iommu_inval_vma_pscid(sc, domain->pscid); + riscv_iommu_pscid_free(sc, domain->pscid); + + free(domain, M_IOMMU); +} + +static struct iommu_ctx * +riscv_iommu_ctx_alloc(device_t dev, struct iommu_domain *iodom, device_t child, + bool disabled) +{ + struct riscv_iommu_domain *domain; + struct riscv_iommu_ctx *ctx; + + dprintf("%s\n", __func__); + + domain = (struct riscv_iommu_domain *)iodom; + + ctx = malloc(sizeof(struct riscv_iommu_ctx), M_IOMMU, + M_WAITOK | M_ZERO); + ctx->dev = child; + ctx->domain = domain; + refcount_init(&ctx->refcnt, 1); + if (disabled) + ctx->bypass = true; + + IOMMU_DOMAIN_LOCK(iodom); + LIST_INSERT_HEAD(&domain->ctx_list, ctx, next); + IOMMU_DOMAIN_UNLOCK(iodom); + + return (&ctx->ioctx); +} + +static int +riscv_iommu_ctx_init(device_t dev, struct iommu_ctx *ioctx) +{ + struct riscv_iommu_domain *domain; + struct iommu_domain *iodom; + struct riscv_iommu_softc *sc; + struct riscv_iommu_ctx *ctx; + devclass_t pci_class; + u_int did; + int error; + + ctx = (struct riscv_iommu_ctx *)ioctx; + + dprintf("%s\n", __func__); + + sc = device_get_softc(dev); + + domain = ctx->domain; + iodom = (struct iommu_domain *)domain; + + pci_class = devclass_find("pci"); + if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) { + error = riscv_iommu_pci_get_did(ctx->dev, NULL, &did); + if (error) + return (error); + + ioctx->rid = pci_get_rid(dev); + ctx->did = did; + ctx->vendor = pci_get_vendor(ctx->dev); + ctx->device = pci_get_device(ctx->dev); + } + + if (sc->iommu_mode == DDTP_IOMMU_MODE_2LVL) { + error = riscv_iommu_init_l0_directory(sc, ctx->did); + if (error) + return (error); + } + riscv_iommu_init_dc(sc, domain, ctx->did, ctx->bypass); + + if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) + if (iommu_is_buswide_ctx(iodom->iommu, pci_get_bus(ctx->dev))) + riscv_iommu_set_buswide(dev, domain, ctx); + + return (0); +} + +static bool +riscv_iommu_ctx_free(device_t dev, struct iommu_ctx *ioctx) +{ + struct riscv_iommu_softc *sc; + struct riscv_iommu_ctx *ctx; + + dprintf("%s\n", __func__); + + IOMMU_ASSERT_LOCKED(ioctx->domain->iommu); + + sc = device_get_softc(dev); + + ctx = (struct riscv_iommu_ctx *)ioctx; + if (refcount_release(&ctx->refcnt)) { + riscv_iommu_deinit_dc(sc, ctx->did); + LIST_REMOVE(ctx, next); + free(ctx, M_IOMMU); + return (true); + } + + return (false); +} + +#ifdef FDT +static int +riscv_iommu_ofw_md_data(device_t dev, struct iommu_ctx *ioctx, pcell_t *cells, + int ncells) +{ + struct riscv_iommu_ctx *ctx; + + printf("%s\n", __func__); + ctx = (struct riscv_iommu_ctx *)ioctx; + + if (ncells != 1) + return (-1); + + ctx->did = cells[0]; + + return (0); +} +#endif + +static int +riscv_iommu_read_ivar(device_t dev, device_t child, int which, + uintptr_t *result) +{ + struct riscv_iommu_softc *sc; + + sc = device_get_softc(dev); + + device_printf(sc->dev, "%s\n", __func__); + + return (ENOENT); +} + +static device_method_t riscv_iommu_methods[] = { + /* IOMMU interface */ + DEVMETHOD(iommu_find, riscv_iommu_find), + DEVMETHOD(iommu_map, riscv_iommu_map), + DEVMETHOD(iommu_unmap, riscv_iommu_unmap), + DEVMETHOD(iommu_domain_alloc, riscv_iommu_domain_alloc), + DEVMETHOD(iommu_domain_free, riscv_iommu_domain_free), + DEVMETHOD(iommu_ctx_alloc, riscv_iommu_ctx_alloc), + DEVMETHOD(iommu_ctx_init, riscv_iommu_ctx_init), + DEVMETHOD(iommu_ctx_free, riscv_iommu_ctx_free), + DEVMETHOD(iommu_ctx_lookup, riscv_iommu_ctx_lookup), +#ifdef FDT + DEVMETHOD(iommu_ofw_md_data, riscv_iommu_ofw_md_data), +#endif + + /* Bus interface */ + DEVMETHOD(bus_read_ivar, riscv_iommu_read_ivar), + + /* End */ + DEVMETHOD_END +}; + +DEFINE_CLASS_0(riscv_iommu, riscv_iommu_driver, riscv_iommu_methods, + sizeof(struct riscv_iommu_softc)); diff --git a/sys/riscv/iommu/iommu.h b/sys/riscv/iommu/iommu.h new file mode 100644 index 000000000000..502a0e121bd1 --- /dev/null +++ b/sys/riscv/iommu/iommu.h @@ -0,0 +1,359 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RISCV_IOMMU_IOMMU_H_ +#define _RISCV_IOMMU_IOMMU_H_ + +#define RISCV_IOMMU_CAPABILITIES 0x0000 +#define CAPABILITIES_VERSION_S 0 +#define CAPABILITIES_VERSION_M (0xff << CAPABILITIES_VERSION_S) +#define CAPABILITIES_SV32 (1 << 8) +#define CAPABILITIES_SV39 (1 << 9) +#define CAPABILITIES_SV48 (1 << 10) +#define CAPABILITIES_SV57 (1 << 11) +#define CAPABILITIES_SVPBMT (1 << 15) +#define CAPABILITIES_SV32X4 (1 << 16) +#define CAPABILITIES_SV39X4 (1 << 17) +#define CAPABILITIES_SV48X4 (1 << 18) +#define CAPABILITIES_SV57X4 (1 << 19) +#define CAPABILITIES_AMO_MRIF (1 << 21) +#define CAPABILITIES_MSI_FLAT (1 << 22) +#define CAPABILITIES_MSI_MRIF (1 << 23) +#define CAPABILITIES_AMO_HWAD (1 << 24) +#define CAPABILITIES_ATS (1 << 25) +#define CAPABILITIES_T2GPA (1 << 26) +#define CAPABILITIES_END (1 << 27) +#define CAPABILITIES_IGS_S 28 +#define CAPABILITIES_IGS_M (0x3 << CAPABILITIES_IGS_S) +#define CAPABILITIES_HPM (1 << 30) +#define CAPABILITIES_DBG (1 << 31) +#define CAPABILITIES_PAS_S 32ULL +#define CAPABILITIES_PAS_M (0x3f << CAPABILITIES_PAS_S) +#define CAPABILITIES_PD8 (1ULL << 38) +#define CAPABILITIES_PD17 (1ULL << 39) +#define CAPABILITIES_PD20 (1ULL << 40) +#define RISCV_IOMMU_FCTL 0x0008 +#define FCTL_BE (1 << 0) /* Big-endian */ +#define FCTL_WSI (1 << 1) /* Wire-signalled Ints. */ +#define FCTL_GXL (1 << 2) /* Guest physical addresses */ +#define RISCV_IOMMU_DDTP 0x0010 +#define DDTP_IOMMU_MODE_S 0 +#define DDTP_IOMMU_MODE_OFF (0 << DDTP_IOMMU_MODE_S) +#define DDTP_IOMMU_MODE_BARE (1 << DDTP_IOMMU_MODE_S) +#define DDTP_IOMMU_MODE_1LVL (2 << DDTP_IOMMU_MODE_S) +#define DDTP_IOMMU_MODE_2LVL (3 << DDTP_IOMMU_MODE_S) +#define DDTP_IOMMU_MODE_3LVL (4 << DDTP_IOMMU_MODE_S) +#define DDTP_BUSY (1 << 4) +#define DDTP_PPN_S 10 +#define DDTP_PPN_M (0xfffffffffffULL << DDTP_PPN_S) +#define RISCV_IOMMU_CQB 0x18 /* Command queue base. */ +#define CQB_LOG2SZ_1_S 0 +#define CQB_LOG2SZ_1_M (0x3f << CQB_LOG2SZ_1_S) +#define CQB_PPN_S 10 +#define CQB_PPN_M (0xfffffffffffULL << CQB_PPN_S) +#define RISCV_IOMMU_CQH 0x20 +#define RISCV_IOMMU_CQT 0x24 +#define RISCV_IOMMU_FQB 0x28 /* Fault queue base. */ +#define RISCV_IOMMU_FQH 0x30 +#define RISCV_IOMMU_FQT 0x34 +#define RISCV_IOMMU_PQB 0x38 /* Page queue base. */ +#define RISCV_IOMMU_PQH 0x40 +#define RISCV_IOMMU_PQT 0x44 +#define RISCV_IOMMU_CQCSR 0x48 +#define CQCSR_BUSY (1 << 17) /* Write is observed */ +#define CQCSR_CQON (1 << 16) /* Active */ +#define CQCSR_FENCE_W_IP (1 << 11) /* iofence.c completed */ +#define CQCSR_CMD_ILL (1 << 10) /* Illegal command */ +#define CQCSR_CMD_TO (1 << 9) /* Timeout */ +#define CQCSR_CQMF (1 << 8) /* Memory Fault */ +#define CQCSR_CIE (1 << 1) /* Interrupt Enable */ +#define CQCSR_CQEN (1 << 0) /* Enable */ +#define RISCV_IOMMU_FQCSR 0x4C +#define FQCSR_BUSY (1 << 17) /* Write is observed */ +#define FQCSR_FQON (1 << 16) /* Active */ +#define FQCSR_FQOF (1 << 9) /* Overflow */ +#define FQCSR_FQMF (1 << 8) /* Memory Fault */ +#define FQCSR_FIE (1 << 1) /* Interrupt Enable */ +#define FQCSR_FQEN (1 << 0) /* Enable */ +#define RISCV_IOMMU_PQCSR 0x50 +#define PQCSR_BUSY (1 << 17) /* Write is observed */ +#define PQCSR_PQON (1 << 16) /* Active */ +#define PQCSR_PQOF (1 << 9) /* Overflow */ +#define PQCSR_PQMF (1 << 8) /* Memory Fault */ +#define PQCSR_PIE (1 << 1) /* Interrupt Enable */ +#define PQCSR_PQEN (1 << 0) /* Enable */ +#define RISCV_IOMMU_IPSR 0x54 +#define IPSR_CIP (1 << 0) /* Command queue interrupt pending */ +#define IPSR_FIP (1 << 1) /* Fault queue interrupt pending */ +#define IPSR_PMIP (1 << 2) /* Performance monitoring int pend */ +#define IPSR_PIP (1 << 3) /* Page queue interrupt pending */ + +#define RISCV_IOMMU_IOCOUNTOVF 0x0058 +#define RISCV_IOMMU_IOCOUNTINH 0x005C + +#define RISCV_IOMMU_IOHPMCYCLES 0x0060 +#define RISCV_IOMMU_IOHPMCTR_BASE 0x0068 +#define RISCV_IOMMU_IOHPMCTR(_n) (RISCV_IOMMU_IOHPMCTR_BASE + ((_n) * 0x8)) +#define RISCV_IOMMU_IOHPMEVT_BASE 0x0160 +#define RISCV_IOMMU_IOHPMEVT(_n) (RISCV_IOMMU_IOHPMEVT_BASE + ((_n) * 0x8)) +#define RISCV_IOMMU_TR_REQ_IOVA 0x0258 +#define RISCV_IOMMU_TR_REQ_CTL 0x0260 +#define RISCV_IOMMU_TR_RESPONSE 0x0268 +#define RISCV_IOMMU_ICVEC 0x02F8 + +#define RISCV_IOMMU_LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define RISCV_IOMMU_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) + +DECLARE_CLASS(riscv_iommu_driver); + +MALLOC_DECLARE(M_IOMMU); + +struct riscv_iommu_unit { + struct iommu_unit iommu; + LIST_HEAD(, riscv_iommu_domain) domain_list; + LIST_ENTRY(riscv_iommu_unit) next; + device_t dev; + intptr_t xref; +}; + +struct riscv_iommu_domain { + struct iommu_domain iodom; + LIST_HEAD(, riscv_iommu_ctx) ctx_list; + LIST_ENTRY(riscv_iommu_domain) next; + u_int entries_cnt; + struct riscv_iommu_cd *cd; + struct riscv_iommu_pmap p; + uint16_t pscid; +}; + +struct riscv_iommu_ctx { + struct iommu_ctx ioctx; + struct riscv_iommu_domain *domain; + LIST_ENTRY(riscv_iommu_ctx) next; + device_t dev; + bool bypass; + int did; + uint16_t vendor; + uint16_t device; + u_int refcnt; +}; + +struct riscv_iommu_queue_local_copy { + union { + uint64_t val; + struct { + uint32_t head; + uint32_t tail; + }; + }; +}; + +struct riscv_iommu_queue { + struct riscv_iommu_queue_local_copy lc; + vm_paddr_t paddr; + void *vaddr; + uint64_t mask; + uint32_t head_off; + uint32_t tail_off; + int size_log2; + uint64_t base; + uint64_t csr; + int idx; + uint8_t entry_size; +}; + +struct l1_desc { + uint8_t span; + void *va; + vm_paddr_t pa; +}; + +/* Base-format device-context. */ +struct riscv_iommu_dc_base { + uint64_t tc; /* Translation control */ +#define DC_TC_V (1 << 0) +#define DC_TC_EN_ATS (1 << 1) +#define DC_TC_EN_PRI (1 << 2) +#define DC_TC_T2GPA (1 << 3) +#define DC_TC_DTF (1 << 4) +#define DC_TC_PDTV (1 << 5) +#define DC_TC_PRPR (1 << 6) +#define DC_TC_GADE (1 << 7) +#define DC_TC_SADE (1 << 8) +#define DC_TC_DPE (1 << 9) +#define DC_TC_SBE (1 << 10) +#define DC_TC_SXL (1 << 11) + uint64_t iohgatp; /* IO Hyp guest address translation */ + uint64_t ta; /* Translation attributes */ +#define DC_TA_V (1 << 0) +#define DC_TA_ENS (1 << 1) +#define DC_TA_SUM (1 << 2) +#define DC_TA_PSCID_S 12 +#define DC_TA_PSCID_M (0xfffff << DC_TA_PSCID_S) + uint64_t fsc; /* First-stage-context */ +}; + +/* Extended-format device-context. */ +struct riscv_iommu_dc { + struct riscv_iommu_dc_base base; + uint64_t msiptp; /* MSI page table pointer */ + uint64_t msi_addr_mask; + uint64_t msi_addr_pattern; + uint64_t _reserved; +}; + +#define DC_NON_LEAF_ENTRY_PPN_S 10 +#define DC_NON_LEAF_ENTRY_VALID (1 << 0) + +struct riscv_iommu_ddt { + void *vaddr; + uint64_t base; + uint32_t base_cfg; + uint32_t num_top_entries; + struct l1_desc *l1; + struct riscv_iommu_dc *dc; +}; + +struct riscv_iommu_softc { + device_t dev; + intptr_t xref; + struct riscv_iommu_unit unit; + struct resource *res[5]; + void *intr_cookie[4]; + struct riscv_iommu_queue cq; + struct riscv_iommu_queue fq; + struct riscv_iommu_queue pq; + struct riscv_iommu_ddt ddt; + struct mtx mtx; + uint32_t l0_did_bits; + uint32_t dc_dwords; + + /* PSCID management. */ + bitstr_t *pscid_set; + int pscid_set_size; + struct mtx pscid_set_mutex; + uint32_t pscid_bits; + + enum pmap_mode pm_mode; + int iommu_mode; +}; + +/* + * Command queue request. + */ +struct riscv_iommu_command { + uint64_t dword0; + uint64_t dword1; +}; + +enum riscv_iommu_fq_causes { + FQ_CAUSE_INST_FAULT = 1, + FQ_CAUSE_RD_ADDR_MISALIGNED = 4, + FQ_CAUSE_RD_FAULT = 5, + FQ_CAUSE_WR_ADDR_MISALIGNED = 6, + FQ_CAUSE_WR_FAULT = 7, + FQ_CAUSE_INST_FAULT_S = 12, + FQ_CAUSE_RD_FAULT_S = 13, + FQ_CAUSE_WR_FAULT_S = 15, + FQ_CAUSE_INST_FAULT_VS = 20, + FQ_CAUSE_RD_FAULT_VS = 21, + FQ_CAUSE_WR_FAULT_VS = 23, + FQ_CAUSE_DMA_DISABLED = 256, + FQ_CAUSE_DDT_LOAD_FAULT = 257, + FQ_CAUSE_DDT_INVALID = 258, + FQ_CAUSE_DDT_MISCONFIGURED = 259, + FQ_CAUSE_TR_TYPE_DISALLOWED = 260, + FQ_CAUSE_MSI_LOAD_FAULT = 261, + FQ_CAUSE_MSI_INVALID = 262, + FQ_CAUSE_MSI_MISCONFIGURED = 263, + FQ_CAUSE_MRIF_FAULT = 264, + FQ_CAUSE_PDT_LOAD_FAULT = 265, + FQ_CAUSE_PDT_INVALID = 266, + FQ_CAUSE_PDT_MISCONFIGURED = 267, + FQ_CAUSE_DDT_CORRUPTED = 268, + FQ_CAUSE_PDT_CORRUPTED = 269, + FQ_CAUSE_MSI_PT_CORRUPTED = 270, + FQ_CAUSE_MRIF_CORRUPTED = 271, + FQ_CAUSE_INTERNAL_DP_ERROR = 272, + FQ_CAUSE_MSI_WR_FAULT = 273, + FQ_CAUSE_PT_CORRUPTED = 274, +}; + +/* + * Fault queue record. + */ +struct riscv_iommu_fq_record { + uint64_t hdr; +#define FQR_HDR_CAUSE_S 0 +#define FQR_HDR_CAUSE_M (0xfff << FQR_HDR_CAUSE_S) +#define FQR_HDR_PID_S 12 +#define FQR_HDR_PID_M (0xfffffULL << FQR_HDR_PID_S) +#define FQR_HDR_PV (1ULL << 32) +#define FQR_HDR_PRIV (1ULL << 33) +#define FQR_HDR_TTYP_S 34ULL +#define FQR_HDR_TTYP_M (0x3fULL << FQR_HDR_TTYP_S) +#define FQR_HDR_DID_S 40ULL +#define FQR_HDR_DID_M (0xffffffULL << FQR_HDR_DID_S) + uint32_t custom; + uint32_t reserved; + uint64_t iotval; + uint64_t iotval2; +}; + +#define COMMAND_OPCODE_S 0 +#define COMMAND_OPCODE_IOTINVAL (1 << COMMAND_OPCODE_S) +#define COMMAND_OPCODE_IOFENCE (2 << COMMAND_OPCODE_S) +#define COMMAND_OPCODE_IODIR (3 << COMMAND_OPCODE_S) +#define COMMAND_OPCODE_ATS (4 << COMMAND_OPCODE_S) +#define COMMAND_OPCODE_FUNC_S 7 +#define COMMAND_OPCODE_FUNC_M (0x3 << COMMAND_OPCODE_FUNC_S) +#define FUNC_IODIR_INVAL_DDT (0 << COMMAND_OPCODE_FUNC_S) +#define FUNC_IODIR_INVAL_PDT (1 << COMMAND_OPCODE_FUNC_S) +#define FUNC_IODIR_PID_S 12 +#define FUNC_IODIR_DV (1ULL << 33) /* DID Valid */ +#define FUNC_IODIR_DID_S 40ULL +/* dword0 */ +#define FUNC_IOTINVAL_VMA (0 << COMMAND_OPCODE_FUNC_S) +#define FUNC_IOTINVAL_GVMA (1 << COMMAND_OPCODE_FUNC_S) +#define FUNC_IOTINVAL_AV (1 << 10) /* Address Valid */ +#define FUNC_IOTINVAL_PSCID_S 12 /* Process-Soft-Context ID */ +#define FUNC_IOTINVAL_PSCV (1ULL << 32) /* PSCID Valid */ +#define FUNC_IOTINVAL_GV (1ULL << 33) /* GSCID Valid */ +#define FUNC_IOTINVAL_GSCID_S 44 /* Guest-Soft-Context ID */ +/* dword1 */ +#define FUNC_IOTINVAL_ADDR_S 10 +#define FUNC_IOFENCE_FUNC_C (0 << 7) +#define FUNC_IOFENCE_AV (1 << 10) +#define FUNC_IOFENCE_WSI (1 << 11) +#define FUNC_IOFENCE_PR (1 << 12) +#define FUNC_IOFENCE_PW (1 << 13) +#define FUNC_IOFENCE_DATA_S 32ULL + +int riscv_iommu_attach(device_t dev); +struct riscv_iommu_ctx *riscv_iommu_ctx_lookup_by_did(device_t dev, u_int did); + +#endif /* _RISCV_IOMMU_IOMMU_H_ */ diff --git a/sys/riscv/iommu/iommu_fdt.c b/sys/riscv/iommu/iommu_fdt.c new file mode 100644 index 000000000000..99fb41d55f8c --- /dev/null +++ b/sys/riscv/iommu/iommu_fdt.c @@ -0,0 +1,145 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/types.h> +#include <sys/systm.h> +#include <sys/bus.h> +#include <sys/bitstring.h> +#include <sys/kernel.h> +#include <sys/rman.h> +#include <sys/sysctl.h> +#include <sys/tree.h> +#include <sys/taskqueue.h> +#include <sys/malloc.h> +#include <sys/module.h> +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <sys/bus.h> +#include <sys/conf.h> +#include <sys/rman.h> + +#include <machine/bus.h> +#include <machine/resource.h> + +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> + +#include <dev/iommu/iommu.h> +#include <riscv/iommu/iommu_pmap.h> +#include <riscv/iommu/iommu.h> +#include <riscv/iommu/iommu_frontend.h> + +static struct ofw_compat_data compat_data[] = { + { "riscv,iommu", 1 }, + { NULL, 0 } +}; + +static struct resource_spec riscv_iommu_spec[] = { + { SYS_RES_MEMORY, 0, RF_ACTIVE }, + { SYS_RES_IRQ, 0, RF_ACTIVE }, /* CQ */ + { SYS_RES_IRQ, 1, RF_ACTIVE }, /* FQ */ + { SYS_RES_IRQ, 2, RF_ACTIVE }, /* PM */ + { SYS_RES_IRQ, 3, RF_ACTIVE }, /* PQ */ + RESOURCE_SPEC_END +}; + +static int +riscv_iommu_fdt_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "RISC-V IOMMU"); + + return (BUS_PROBE_DEFAULT); +} + +static int +riscv_iommu_fdt_attach(device_t dev) +{ + struct riscv_iommu_softc *sc; + struct riscv_iommu_unit *unit; + struct iommu_unit *iommu; + phandle_t node; + int error; + + sc = device_get_softc(dev); + sc->dev = dev; + + node = ofw_bus_get_node(dev); + + error = bus_alloc_resources(dev, riscv_iommu_spec, sc->res); + if (error) { + device_printf(dev, "could not allocate resources\n"); + goto error; + } + + error = riscv_iommu_attach(dev); + if (error != 0) { + device_printf(dev, "Failed to attach. Error %d\n", error); + goto error; + } + + unit = &sc->unit; + unit->dev = dev; + + iommu = &unit->iommu; + iommu->dev = dev; + + LIST_INIT(&unit->domain_list); + + sc->xref = OF_xref_from_node(node); + + error = iommu_register(iommu); + if (error) { + device_printf(dev, "Failed to register RISC-V IOMMU.\n"); + goto error; + } + + return (0); + +error: + bus_release_resources(dev, riscv_iommu_spec, sc->res); + + return (error); +} + +static device_method_t riscv_iommu_fdt_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, riscv_iommu_fdt_probe), + DEVMETHOD(device_attach, riscv_iommu_fdt_attach), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(riscv_iommu, riscv_iommu_fdt_driver, riscv_iommu_fdt_methods, + sizeof(struct riscv_iommu_softc), riscv_iommu_driver); +EARLY_DRIVER_MODULE(riscv_iommu, simplebus, riscv_iommu_fdt_driver, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE); diff --git a/sys/riscv/iommu/iommu_frontend.c b/sys/riscv/iommu/iommu_frontend.c new file mode 100644 index 000000000000..1de8b3623987 --- /dev/null +++ b/sys/riscv/iommu/iommu_frontend.c @@ -0,0 +1,505 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "opt_platform.h" + +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/memdesc.h> +#include <sys/tree.h> +#include <sys/taskqueue.h> +#include <sys/lock.h> +#include <sys/mutex.h> +#include <sys/sx.h> +#include <sys/sysctl.h> +#include <vm/vm.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> +#include <machine/bus.h> +#include <dev/iommu/busdma_iommu.h> +#include <machine/vmparam.h> + +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + +#include "iommu_frontend.h" +#include "iommu_if.h" + +static MALLOC_DEFINE(M_IOMMU, "IOMMU", "IOMMU framework"); + +#define IOMMU_LIST_LOCK() sx_xlock(&iommu_sx) +#define IOMMU_LIST_UNLOCK() sx_xunlock(&iommu_sx) +#define IOMMU_LIST_ASSERT_LOCKED() sx_assert(&iommu_sx, SA_XLOCKED) + +#define dprintf(fmt, ...) + +static struct sx iommu_sx; + +struct iommu_entry { + struct iommu_unit *iommu; + LIST_ENTRY(iommu_entry) next; +}; +static LIST_HEAD(, iommu_entry) iommu_list = LIST_HEAD_INITIALIZER(iommu_list); + +static int +iommu_domain_unmap_buf(struct iommu_domain *iodom, + struct iommu_map_entry *entry, int flags) +{ + struct iommu_unit *iommu; + int error; + + iommu = iodom->iommu; + error = IOMMU_UNMAP(iommu->dev, iodom, entry->start, entry->end - + entry->start); + return (error); +} + +static int +iommu_domain_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t eflags, int flags) +{ + struct iommu_unit *iommu; + vm_prot_t prot; + vm_offset_t va; + int error; + + dprintf("%s: base %lx, size %lx\n", __func__, base, size); + + prot = 0; + if (eflags & IOMMU_MAP_ENTRY_READ) + prot |= VM_PROT_READ; + if (eflags & IOMMU_MAP_ENTRY_WRITE) + prot |= VM_PROT_WRITE; + + va = entry->start; + iommu = iodom->iommu; + error = IOMMU_MAP(iommu->dev, iodom, va, ma, entry->end - + entry->start, prot); + return (error); +} + +static const struct iommu_domain_map_ops domain_map_ops = { + .map = iommu_domain_map_buf, + .unmap = iommu_domain_unmap_buf, +}; + +static struct iommu_domain * +iommu_domain_alloc(struct iommu_unit *iommu) +{ + struct iommu_domain *iodom; + + iodom = IOMMU_DOMAIN_ALLOC(iommu->dev, iommu); + if (iodom == NULL) + return (NULL); + + KASSERT(iodom->end != 0, ("domain end is not set")); + + iommu_domain_init(iommu, iodom, &domain_map_ops); + iodom->iommu = iommu; + iommu_gas_init_domain(iodom); + + return (iodom); +} + +static int +iommu_domain_free(struct iommu_domain *iodom) +{ + struct iommu_unit *iommu; + + iommu = iodom->iommu; + + IOMMU_LOCK(iommu); + + if ((iodom->flags & IOMMU_DOMAIN_GAS_INITED) != 0) { + IOMMU_DOMAIN_LOCK(iodom); + iommu_gas_fini_domain(iodom); + IOMMU_DOMAIN_UNLOCK(iodom); + } + + iommu_domain_fini(iodom); + + IOMMU_DOMAIN_FREE(iommu->dev, iodom); + IOMMU_UNLOCK(iommu); + + return (0); +} + +static void +iommu_tag_init(struct iommu_domain *iodom, struct bus_dma_tag_iommu *t) +{ + bus_addr_t maxaddr; + + maxaddr = MIN(iodom->end, BUS_SPACE_MAXADDR); + + t->common.impl = &bus_dma_iommu_impl; + t->common.alignment = 1; + t->common.boundary = 0; + t->common.lowaddr = maxaddr; + t->common.highaddr = maxaddr; + t->common.maxsize = maxaddr; + t->common.nsegments = BUS_SPACE_UNRESTRICTED; + t->common.maxsegsz = maxaddr; +} + +static struct iommu_ctx * +iommu_ctx_alloc(device_t requester, struct iommu_domain *iodom, bool disabled) +{ + struct iommu_unit *iommu; + struct iommu_ctx *ioctx; + + iommu = iodom->iommu; + + ioctx = IOMMU_CTX_ALLOC(iommu->dev, iodom, requester, disabled); + if (ioctx == NULL) + return (NULL); + + ioctx->domain = iodom; + + return (ioctx); +} + +static int +iommu_ctx_init(device_t requester, struct iommu_ctx *ioctx) +{ + struct bus_dma_tag_iommu *tag; + struct iommu_domain *iodom; + struct iommu_unit *iommu; + int error; + + iodom = ioctx->domain; + iommu = iodom->iommu; + + error = IOMMU_CTX_INIT(iommu->dev, ioctx); + if (error) + return (error); + + tag = ioctx->tag = malloc(sizeof(struct bus_dma_tag_iommu), + M_DEVBUF, M_WAITOK | M_ZERO); + tag->owner = requester; + tag->ctx = ioctx; + tag->ctx->domain = iodom; + + iommu_tag_init(iodom, tag); + + return (error); +} + +static struct iommu_unit * +iommu_lookup(device_t dev) +{ + struct iommu_entry *entry; + struct iommu_unit *iommu; + + IOMMU_LIST_LOCK(); + LIST_FOREACH(entry, &iommu_list, next) { + iommu = entry->iommu; + if (iommu->dev == dev) { + IOMMU_LIST_UNLOCK(); + return (iommu); + } + } + IOMMU_LIST_UNLOCK(); + + return (NULL); +} + +#ifdef FDT +struct iommu_ctx * +iommu_get_ctx_ofw(device_t dev, int channel) +{ + struct iommu_domain *iodom; + struct iommu_unit *iommu; + struct iommu_ctx *ioctx; + phandle_t node, parent; + device_t iommu_dev; + pcell_t *cells; + int niommus; + int ncells; + int error; + + node = ofw_bus_get_node(dev); + if (node <= 0) { + device_printf(dev, + "%s called on not ofw based device.\n", __func__); + return (NULL); + } + + error = ofw_bus_parse_xref_list_get_length(node, + "iommus", "#iommu-cells", &niommus); + if (error) { + device_printf(dev, "%s can't get iommu list.\n", __func__); + return (NULL); + } + + if (niommus == 0) { + device_printf(dev, "%s iommu list is empty.\n", __func__); + return (NULL); + } + + error = ofw_bus_parse_xref_list_alloc(node, "iommus", "#iommu-cells", + channel, &parent, &ncells, &cells); + if (error != 0) { + device_printf(dev, "%s can't get iommu device xref.\n", + __func__); + return (NULL); + } + + iommu_dev = OF_device_from_xref(parent); + if (iommu_dev == NULL) { + device_printf(dev, "%s can't get iommu device.\n", __func__); + return (NULL); + } + + iommu = iommu_lookup(iommu_dev); + if (iommu == NULL) { + device_printf(dev, "%s can't lookup iommu.\n", __func__); + return (NULL); + } + + /* + * In our current configuration we have a domain per each ctx, + * so allocate a domain first. + */ + iodom = iommu_domain_alloc(iommu); + if (iodom == NULL) { + device_printf(dev, "%s can't allocate domain.\n", __func__); + return (NULL); + } + + ioctx = iommu_ctx_alloc(dev, iodom, false); + if (ioctx == NULL) { + iommu_domain_free(iodom); + return (NULL); + } + + ioctx->domain = iodom; + + error = IOMMU_OFW_MD_DATA(iommu->dev, ioctx, cells, ncells); + if (error) { + device_printf(dev, "%s can't set MD data\n", __func__); + return (NULL); + } + + error = iommu_ctx_init(dev, ioctx); + if (error) { + IOMMU_CTX_FREE(iommu->dev, ioctx); + iommu_domain_free(iodom); + return (NULL); + } + + return (ioctx); +} +#endif + +struct iommu_ctx * +iommu_get_ctx(struct iommu_unit *iommu, device_t requester, + uint16_t rid, bool disabled, bool rmrr) +{ + struct iommu_domain *iodom; + struct iommu_ctx *ioctx; + int error; + + IOMMU_LOCK(iommu); + ioctx = IOMMU_CTX_LOOKUP(iommu->dev, requester); + if (ioctx) { + IOMMU_UNLOCK(iommu); + return (ioctx); + } + IOMMU_UNLOCK(iommu); + + /* + * In our current configuration we have a domain per each ctx. + * So allocate a domain first. + */ + iodom = iommu_domain_alloc(iommu); + if (iodom == NULL) + return (NULL); + + ioctx = iommu_ctx_alloc(requester, iodom, disabled); + if (ioctx == NULL) { + iommu_domain_free(iodom); + return (NULL); + } + + error = iommu_ctx_init(requester, ioctx); + if (error) { + IOMMU_CTX_FREE(iommu->dev, ioctx); + iommu_domain_free(iodom); + return (NULL); + } + + return (ioctx); +} + +void +iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ioctx) +{ + struct iommu_domain *domain; + bool released; + int error; + + IOMMU_ASSERT_LOCKED(iommu); + + domain = ioctx->domain; + + released = IOMMU_CTX_FREE(iommu->dev, ioctx); + IOMMU_UNLOCK(iommu); + + if (released) { + /* Since we have a domain per each ctx, remove it too. */ + error = iommu_domain_free(domain); + if (error) + device_printf(iommu->dev, "Could not free a domain\n"); + } +} + +static void +iommu_domain_free_entry(struct iommu_map_entry *entry, bool free) +{ + iommu_gas_free_space(entry); + + if (free) + iommu_gas_free_entry(entry); + else + entry->flags = 0; +} + +void +iommu_domain_unload(struct iommu_domain *iodom, + struct iommu_map_entries_tailq *entries, bool cansleep) +{ + struct iommu_map_entry *entry, *entry1; + int error __diagused; + + TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { + KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, + ("not mapped entry %p %p", iodom, entry)); + error = iodom->ops->unmap(iodom, entry, + cansleep ? IOMMU_PGF_WAITOK : 0); + KASSERT(error == 0, ("unmap %p error %d", iodom, error)); + TAILQ_REMOVE(entries, entry, dmamap_link); + iommu_domain_free_entry(entry, true); + } + + if (TAILQ_EMPTY(entries)) + return; + + panic("entries map is not empty"); +} + +int +iommu_register(struct iommu_unit *iommu) +{ + struct iommu_entry *entry; + + mtx_init(&iommu->lock, "IOMMU", NULL, MTX_DEF); + + entry = malloc(sizeof(struct iommu_entry), M_IOMMU, M_WAITOK | M_ZERO); + entry->iommu = iommu; + + IOMMU_LIST_LOCK(); + LIST_INSERT_HEAD(&iommu_list, entry, next); + IOMMU_LIST_UNLOCK(); + + sysctl_ctx_init(&iommu->sysctl_ctx); + iommu_init_busdma(iommu); + + return (0); +} + +int +iommu_unregister(struct iommu_unit *iommu) +{ + struct iommu_entry *entry, *tmp; + + IOMMU_LIST_LOCK(); + LIST_FOREACH_SAFE(entry, &iommu_list, next, tmp) { + if (entry->iommu == iommu) { + LIST_REMOVE(entry, next); + free(entry, M_IOMMU); + } + } + IOMMU_LIST_UNLOCK(); + + iommu_fini_busdma(iommu); + sysctl_ctx_free(&iommu->sysctl_ctx); + + mtx_destroy(&iommu->lock); + + return (0); +} + +struct iommu_unit * +iommu_find(device_t dev, bool verbose) +{ + struct iommu_entry *entry; + struct iommu_unit *iommu; + int error; + + IOMMU_LIST_LOCK(); + LIST_FOREACH(entry, &iommu_list, next) { + iommu = entry->iommu; + error = IOMMU_FIND(iommu->dev, dev); + if (error == 0) { + IOMMU_LIST_UNLOCK(); + return (entry->iommu); + } + } + IOMMU_LIST_UNLOCK(); + + return (NULL); +} + +void +iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ +} + +void +iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, + bool cansleep __unused) +{ + + dprintf("%s\n", __func__); + + iommu_domain_free_entry(entry, free); +} + +static void +iommu_init(void) +{ + + sx_init(&iommu_sx, "IOMMU list"); +} + +SYSINIT(iommu, SI_SUB_DRIVERS, SI_ORDER_FIRST, iommu_init, NULL); diff --git a/sys/riscv/iommu/iommu_frontend.h b/sys/riscv/iommu/iommu_frontend.h new file mode 100644 index 000000000000..f42856037383 --- /dev/null +++ b/sys/riscv/iommu/iommu_frontend.h @@ -0,0 +1,38 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _ARM64_IOMMU_IOMMU_H_ +#define _ARM64_IOMMU_IOMMU_H_ + +#define IOMMU_PAGE_SIZE 4096 +#define IOMMU_PAGE_MASK (IOMMU_PAGE_SIZE - 1) + +int iommu_unregister(struct iommu_unit *unit); +int iommu_register(struct iommu_unit *unit); +struct iommu_ctx * iommu_get_ctx_ofw(device_t dev, int channel); + +#endif /* _ARM64_IOMMU_IOMMU_H_ */ diff --git a/sys/riscv/iommu/iommu_if.m b/sys/riscv/iommu/iommu_if.m new file mode 100644 index 000000000000..56a04b7b8638 --- /dev/null +++ b/sys/riscv/iommu/iommu_if.m @@ -0,0 +1,147 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause +#: +# Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# + +#include "opt_platform.h" + +#include <sys/types.h> +#include <sys/taskqueue.h> +#include <sys/bus.h> +#include <sys/sysctl.h> +#include <sys/tree.h> +#include <vm/vm.h> +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> +#include <dev/iommu/iommu.h> + +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + +INTERFACE iommu; + +# +# Check if the iommu controller dev is responsible to serve traffic +# for a given child. +# +METHOD int find { + device_t dev; + device_t child; +}; + +# +# Map a virtual address VA to a physical address PA. +# +METHOD int map { + device_t dev; + struct iommu_domain *iodom; + vm_offset_t va; + vm_page_t *ma; + bus_size_t size; + vm_prot_t prot; +}; + +# +# Unmap a virtual address VA. +# +METHOD int unmap { + device_t dev; + struct iommu_domain *iodom; + vm_offset_t va; + bus_size_t size; +}; + +# +# Allocate an IOMMU domain. +# +METHOD struct iommu_domain * domain_alloc { + device_t dev; + struct iommu_unit *iommu; +}; + +# +# Release all the resources held by IOMMU domain. +# +METHOD void domain_free { + device_t dev; + struct iommu_domain *iodom; +}; + +# +# Find a domain allocated for a dev. +# +METHOD struct iommu_domain * domain_lookup { + device_t dev; +}; + +# +# Find an allocated context for a device. +# +METHOD struct iommu_ctx * ctx_lookup { + device_t dev; + device_t child; +}; + +# +# Allocate a new iommu context. +# +METHOD struct iommu_ctx * ctx_alloc { + device_t dev; + struct iommu_domain *iodom; + device_t child; + bool disabled; +}; + +# +# Initialize the new iommu context. +# +METHOD int ctx_init { + device_t dev; + struct iommu_ctx *ioctx; +}; + +# +# Free the iommu context. +# +METHOD bool ctx_free { + device_t dev; + struct iommu_ctx *ioctx; +}; + +#ifdef FDT +# +# Notify controller we have machine-dependent data. +# +METHOD int ofw_md_data { + device_t dev; + struct iommu_ctx *ioctx; + pcell_t *cells; + int ncells; +}; +#endif diff --git a/sys/riscv/iommu/iommu_pci.c b/sys/riscv/iommu/iommu_pci.c new file mode 100644 index 000000000000..2ec5b2dc95b5 --- /dev/null +++ b/sys/riscv/iommu/iommu_pci.c @@ -0,0 +1,172 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/types.h> +#include <sys/systm.h> +#include <sys/bus.h> +#include <sys/bitstring.h> +#include <sys/kernel.h> +#include <sys/rman.h> +#include <sys/sysctl.h> +#include <sys/tree.h> +#include <sys/taskqueue.h> +#include <sys/malloc.h> +#include <sys/module.h> +#include <vm/vm.h> +#include <vm/pmap.h> + +#include <machine/bus.h> +#include <machine/resource.h> + +#include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> + +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> + +#include <dev/iommu/iommu.h> +#include <riscv/iommu/iommu_pmap.h> +#include <riscv/iommu/iommu.h> +#include <riscv/iommu/iommu_frontend.h> + +#define PCI_DEVICE_ID_REDHAT_RISCV_IOMMU 0x0014 +#define PCI_VENDOR_ID_REDHAT 0x1b36 +#define PCI_DEVICE_ID_RIVOS_RISCV_IOMMU_GA 0x0008 +#define PCI_VENDOR_ID_RIVOS 0x1efd + +static int +iommu_pci_probe(device_t dev) +{ + uint16_t vendor_id, device_id; + + vendor_id = pci_get_vendor(dev); + device_id = pci_get_device(dev); + + if (vendor_id == PCI_VENDOR_ID_REDHAT && + device_id == PCI_DEVICE_ID_REDHAT_RISCV_IOMMU) { + device_set_desc(dev, "RedHat IOMMU"); + return (BUS_PROBE_DEFAULT); + } + + if (vendor_id == PCI_VENDOR_ID_RIVOS && + device_id == PCI_DEVICE_ID_RIVOS_RISCV_IOMMU_GA) { + device_set_desc(dev, "Rivos IOMMU"); + return (BUS_PROBE_DEFAULT); + } + + return (ENXIO); +} + +static int +iommu_pci_attach(device_t dev) +{ + struct riscv_iommu_unit *unit; + struct riscv_iommu_softc *sc; + struct iommu_unit *iommu; + phandle_t node; + int count; + int error; + int rid; + int i; + + sc = device_get_softc(dev); + sc->dev = dev; + + node = ofw_bus_get_node(dev); + + pci_enable_busmaster(dev); + + rid = PCIR_BAR(0); + sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->res[0] == NULL) { + device_printf(dev, "couldn't map memory\n"); + goto error; + } + + count = 4; + if (pci_alloc_msix(dev, &count) == 0) { + for (i = 0; i < 4; i++) { + rid = i; + sc->res[1 + i] = bus_alloc_resource_any(dev, + SYS_RES_IRQ, &rid, RF_ACTIVE); + if (sc->res[i + 1] == NULL) { + device_printf(dev, "Can't allocate IRQ " + " resource.\n"); + goto error; + } + } + } else + device_printf(dev, "Can't allocate MSI-X interrupts." + " Ignoring.\n"); + + error = riscv_iommu_attach(dev); + if (error) + goto error; + + unit = &sc->unit; + unit->dev = dev; + + iommu = &unit->iommu; + iommu->dev = dev; + + LIST_INIT(&unit->domain_list); + + sc->xref = OF_xref_from_node(node); + + error = iommu_register(iommu); + if (error) { + device_printf(dev, "Failed to register RISC-V IOMMU.\n"); + goto error; + } + + return (0); + +error: + if (sc->res[0]) + bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), + sc->res[0]); + + for (i = 0; i < 4; i++) + if (sc->res[i + 1]) + bus_release_resource(dev, SYS_RES_IRQ, i, + sc->res[i + 1]); + + return (error); +} + +static device_method_t riscv_iommu_pci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, iommu_pci_probe), + DEVMETHOD(device_attach, iommu_pci_attach), + DEVMETHOD_END +}; + +DEFINE_CLASS_1(riscv_iommu, riscv_iommu_pci_driver, + riscv_iommu_pci_methods, sizeof(struct riscv_iommu_softc), + riscv_iommu_driver); +DRIVER_MODULE(riscv_iommu, pci, riscv_iommu_pci_driver, NULL, NULL); diff --git a/sys/riscv/iommu/iommu_pmap.c b/sys/riscv/iommu/iommu_pmap.c new file mode 100644 index 000000000000..751ba4cf1ac3 --- /dev/null +++ b/sys/riscv/iommu/iommu_pmap.c @@ -0,0 +1,629 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/ktr.h> +#include <sys/lock.h> +#include <sys/mutex.h> + +#include <vm/vm.h> +#include <vm/vm_param.h> +#include <vm/vm_page.h> + +#include <riscv/iommu/iommu_pmap.h> + +/* + * Boundary values for the page table page index space: + * + * L3 pages: [0, NUL2E) + * L2 pages: [NUL2E, NUL2E + NUL1E) + * L1 pages: [NUL2E + NUL1E, NUL2E + NUL1E + NUL0E) + * + * Note that these ranges are used in both SV39 and SV48 mode. In SV39 mode the + * ranges are not fully populated since there are at most Ln_ENTRIES^2 L3 pages + * in a set of page tables. + */ +#define NUL0E Ln_ENTRIES +#define NUL1E (Ln_ENTRIES * NUL0E) +#define NUL2E (Ln_ENTRIES * NUL1E) + +#define pmap_l1_pindex(v) (NUL2E + ((v) >> L1_SHIFT)) +#define pmap_l2_pindex(v) ((v) >> L2_SHIFT) + +#define pmap_clear(pte) pmap_store(pte, 0) +#define pmap_clear_bits(pte, bits) atomic_clear_64(pte, bits) +#define pmap_load_store(pte, entry) atomic_swap_64(pte, entry) +#define pmap_load_clear(pte) pmap_load_store(pte, 0) +#define pmap_load(pte) atomic_load_64(pte) +#define pmap_store(pte, entry) atomic_store_64(pte, entry) +#define pmap_store_bits(pte, bits) atomic_set_64(pte, bits) + +#define pmap_l0_index(va) (((va) >> L0_SHIFT) & Ln_ADDR_MASK) +#define pmap_l1_index(va) (((va) >> L1_SHIFT) & Ln_ADDR_MASK) +#define pmap_l2_index(va) (((va) >> L2_SHIFT) & Ln_ADDR_MASK) +#define pmap_l3_index(va) (((va) >> L3_SHIFT) & Ln_ADDR_MASK) + +#define PTE_TO_PHYS(pte) \ + ((((pte) & ~PTE_HI_MASK) >> PTE_PPN0_S) * PAGE_SIZE) +#define L2PTE_TO_PHYS(l2) \ + ((((l2) & ~PTE_HI_MASK) >> PTE_PPN1_S) << L2_SHIFT) +#define L1PTE_TO_PHYS(l1) \ + ((((l1) & ~PTE_HI_MASK) >> PTE_PPN2_S) << L1_SHIFT) +#define PTE_TO_VM_PAGE(pte) PHYS_TO_VM_PAGE(PTE_TO_PHYS(pte)) + +/********************/ +/* Inline functions */ +/********************/ + +static __inline pd_entry_t * +pmap_l0(struct riscv_iommu_pmap *pmap, vm_offset_t va) +{ + KASSERT(pmap->pm_mode != PMAP_MODE_SV39, + ("%s: in SV39 mode", __func__)); + KASSERT(VIRT_IS_VALID(va), + ("%s: malformed virtual address %#lx", __func__, va)); + return (&pmap->pm_top[pmap_l0_index(va)]); +} + +static __inline pd_entry_t * +pmap_l0_to_l1(struct riscv_iommu_pmap *pmap, pd_entry_t *l0, vm_offset_t va) +{ + vm_paddr_t phys; + pd_entry_t *l1; + + KASSERT(pmap->pm_mode != PMAP_MODE_SV39, + ("%s: in SV39 mode", __func__)); + phys = PTE_TO_PHYS(pmap_load(l0)); + l1 = (pd_entry_t *)PHYS_TO_DMAP(phys); + + return (&l1[pmap_l1_index(va)]); +} + +static __inline pd_entry_t * +pmap_l1(struct riscv_iommu_pmap *pmap, vm_offset_t va) +{ + pd_entry_t *l0; + + KASSERT(VIRT_IS_VALID(va), + ("%s: malformed virtual address %#lx", __func__, va)); + if (pmap->pm_mode == PMAP_MODE_SV39) { + return (&pmap->pm_top[pmap_l1_index(va)]); + } else { + l0 = pmap_l0(pmap, va); + if ((pmap_load(l0) & PTE_V) == 0) + return (NULL); + if ((pmap_load(l0) & PTE_RX) != 0) + return (NULL); + return (pmap_l0_to_l1(pmap, l0, va)); + } +} + +static __inline pd_entry_t * +pmap_l1_to_l2(pd_entry_t *l1, vm_offset_t va) +{ + vm_paddr_t phys; + pd_entry_t *l2; + + phys = PTE_TO_PHYS(pmap_load(l1)); + l2 = (pd_entry_t *)PHYS_TO_DMAP(phys); + + return (&l2[pmap_l2_index(va)]); +} + +static __inline pd_entry_t * +pmap_l2(struct riscv_iommu_pmap *pmap, vm_offset_t va) +{ + pd_entry_t *l1; + + l1 = pmap_l1(pmap, va); + if (l1 == NULL) + return (NULL); + if ((pmap_load(l1) & PTE_V) == 0) + return (NULL); + if ((pmap_load(l1) & PTE_RX) != 0) + return (NULL); + + return (pmap_l1_to_l2(l1, va)); +} + +static __inline pt_entry_t * +pmap_l2_to_l3(pd_entry_t *l2, vm_offset_t va) +{ + vm_paddr_t phys; + pt_entry_t *l3; + + phys = PTE_TO_PHYS(pmap_load(l2)); + l3 = (pd_entry_t *)PHYS_TO_DMAP(phys); + + return (&l3[pmap_l3_index(va)]); +} + +static __inline pt_entry_t * +pmap_l3(struct riscv_iommu_pmap *pmap, vm_offset_t va) +{ + pd_entry_t *l2; + + l2 = pmap_l2(pmap, va); + if (l2 == NULL) + return (NULL); + if ((pmap_load(l2) & PTE_V) == 0) + return (NULL); + if ((pmap_load(l2) & PTE_RX) != 0) + return (NULL); + + return (pmap_l2_to_l3(l2, va)); +} + +static __inline void +pmap_resident_count_inc(struct riscv_iommu_pmap *pmap, int count) +{ + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + pmap->sp_resident_count += count; +} + +static __inline void +pmap_resident_count_dec(struct riscv_iommu_pmap *pmap, int count) +{ + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + KASSERT(pmap->sp_resident_count >= count, + ("pmap %p resident count underflow %ld %d", pmap, + pmap->sp_resident_count, count)); + pmap->sp_resident_count -= count; +} + +/*************************************************** + * Page table page management routines..... + ***************************************************/ + +int +iommu_pmap_pinit(struct riscv_iommu_pmap *pmap, enum pmap_mode pm_mode) +{ + vm_paddr_t topphys; + vm_page_t m; + + m = vm_page_alloc_noobj(VM_ALLOC_WIRED | VM_ALLOC_ZERO | + VM_ALLOC_WAITOK); + topphys = VM_PAGE_TO_PHYS(m); + pmap->pm_top = (pd_entry_t *)PHYS_TO_DMAP(topphys); + pmap->pm_mode = pm_mode; + + switch (pm_mode) { + case PMAP_MODE_SV39: + pmap->pm_satp = SATP_MODE_SV39; + break; + case PMAP_MODE_SV48: + pmap->pm_satp = SATP_MODE_SV48; + break; + default: + panic("Unknown virtual memory system"); + }; + + pmap->pm_satp |= (topphys >> PAGE_SHIFT); + +#ifdef INVARIANTS + pmap->sp_resident_count = 0; +#endif + + mtx_init(&pmap->pm_mtx, "iommu pmap", NULL, MTX_DEF); + + return (1); +} + +/* + * Release any resources held by the given physical map. + * Called when a pmap initialized by pmap_pinit is being released. + * Should only be called if the map contains no valid mappings. + */ +void +iommu_pmap_release(struct riscv_iommu_pmap *pmap) +{ + vm_page_t m; + + KASSERT(pmap->sp_resident_count == 0, + ("pmap_release: pmap resident count %ld != 0", + pmap->sp_resident_count)); + + m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_top)); + vm_page_unwire_noq(m); + vm_page_free_zero(m); + mtx_destroy(&pmap->pm_mtx); +} + +/* + * This routine is called if the desired page table page does not exist. + * + * If page table page allocation fails, this routine may sleep before + * returning NULL. It sleeps only if a lock pointer was given. + * + * Note: If a page allocation fails at page table level two or three, + * one or two pages may be held during the wait, only to be released + * afterwards. This conservative approach is easily argued to avoid + * race conditions. + */ +static vm_page_t +_pmap_alloc_l3(struct riscv_iommu_pmap *pmap, vm_pindex_t ptepindex) +{ + vm_page_t m, pdpg; + pt_entry_t entry; + vm_paddr_t phys; + pn_t pn; + + PMAP_LOCK_ASSERT(pmap, MA_OWNED); + + /* + * Allocate a page table page. + */ + m = vm_page_alloc_noobj(VM_ALLOC_WIRED | VM_ALLOC_ZERO); + if (m == NULL) { + /* + * Indicate the need to retry. While waiting, the page table + * page may have been allocated. + */ + return (NULL); + } + m->pindex = ptepindex; + + /* + * Map the pagetable page into the process address space, if + * it isn't already there. + */ + pn = VM_PAGE_TO_PHYS(m) >> PAGE_SHIFT; + if (ptepindex >= NUL2E + NUL1E) { + pd_entry_t *l0; + vm_pindex_t l0index; + + KASSERT(pmap->pm_mode != PMAP_MODE_SV39, + ("%s: pindex %#lx in SV39 mode", __func__, ptepindex)); + KASSERT(ptepindex < NUL2E + NUL1E + NUL0E, + ("%s: pindex %#lx out of range", __func__, ptepindex)); + + l0index = ptepindex - (NUL2E + NUL1E); + l0 = &pmap->pm_top[l0index]; + KASSERT((pmap_load(l0) & PTE_V) == 0, + ("%s: L0 entry %#lx is valid", __func__, pmap_load(l0))); + + entry = PTE_V | (pn << PTE_PPN0_S); + pmap_store(l0, entry); + } else if (ptepindex >= NUL2E) { + pd_entry_t *l0, *l1; + vm_pindex_t l0index, l1index; + + l1index = ptepindex - NUL2E; + if (pmap->pm_mode == PMAP_MODE_SV39) { + l1 = &pmap->pm_top[l1index]; + } else { + l0index = l1index >> Ln_ENTRIES_SHIFT; + l0 = &pmap->pm_top[l0index]; + if (pmap_load(l0) == 0) { + /* Recurse to allocate the L1 page. */ + if (_pmap_alloc_l3(pmap, + NUL2E + NUL1E + l0index) == NULL) + goto fail; + phys = PTE_TO_PHYS(pmap_load(l0)); + } else { + phys = PTE_TO_PHYS(pmap_load(l0)); + pdpg = PHYS_TO_VM_PAGE(phys); + pdpg->ref_count++; + } + l1 = (pd_entry_t *)PHYS_TO_DMAP(phys); + l1 = &l1[ptepindex & Ln_ADDR_MASK]; + } + KASSERT((pmap_load(l1) & PTE_V) == 0, + ("%s: L1 entry %#lx is valid", __func__, pmap_load(l1))); + + entry = PTE_V | (pn << PTE_PPN0_S); + pmap_store(l1, entry); + } else { + vm_pindex_t l0index, l1index; + pd_entry_t *l0, *l1, *l2; + + l1index = ptepindex >> (L1_SHIFT - L2_SHIFT); + if (pmap->pm_mode == PMAP_MODE_SV39) { + l1 = &pmap->pm_top[l1index]; + if (pmap_load(l1) == 0) { + /* recurse for allocating page dir */ + if (_pmap_alloc_l3(pmap, NUL2E + l1index) + == NULL) + goto fail; + } else { + pdpg = PTE_TO_VM_PAGE(pmap_load(l1)); + pdpg->ref_count++; + } + } else { + l0index = l1index >> Ln_ENTRIES_SHIFT; + l0 = &pmap->pm_top[l0index]; + if (pmap_load(l0) == 0) { + /* Recurse to allocate the L1 entry. */ + if (_pmap_alloc_l3(pmap, NUL2E + l1index) + == NULL) + goto fail; + phys = PTE_TO_PHYS(pmap_load(l0)); + l1 = (pd_entry_t *)PHYS_TO_DMAP(phys); + l1 = &l1[l1index & Ln_ADDR_MASK]; + } else { + phys = PTE_TO_PHYS(pmap_load(l0)); + l1 = (pd_entry_t *)PHYS_TO_DMAP(phys); + l1 = &l1[l1index & Ln_ADDR_MASK]; + if (pmap_load(l1) == 0) { + /* Recurse to allocate the L2 page. */ + if (_pmap_alloc_l3(pmap, + NUL2E + l1index) == NULL) + goto fail; + } else { + pdpg = PTE_TO_VM_PAGE(pmap_load(l1)); + pdpg->ref_count++; + } + } + } + + phys = PTE_TO_PHYS(pmap_load(l1)); + l2 = (pd_entry_t *)PHYS_TO_DMAP(phys); + l2 = &l2[ptepindex & Ln_ADDR_MASK]; + KASSERT((pmap_load(l2) & PTE_V) == 0, + ("%s: L2 entry %#lx is valid", __func__, pmap_load(l2))); + + entry = PTE_V | (pn << PTE_PPN0_S); + pmap_store(l2, entry); + } + + pmap_resident_count_inc(pmap, 1); + + return (m); + +fail: + vm_page_unwire_noq(m); + vm_page_free_zero(m); + return (NULL); +} + +/* + * Remove a single IOMMU entry. + */ +int +iommu_pmap_remove(struct riscv_iommu_pmap *pmap, vm_offset_t va) +{ + pt_entry_t *l3; + int rc; + + PMAP_LOCK(pmap); + + l3 = pmap_l3(pmap, va); + if (l3 != NULL) { + pmap_resident_count_dec(pmap, 1); + pmap_clear(l3); + rc = KERN_SUCCESS; + } else + rc = KERN_FAILURE; + + PMAP_UNLOCK(pmap); + + return (rc); +} + +/* Add a single IOMMU entry. This function does not sleep. */ +int +iommu_pmap_enter(struct riscv_iommu_pmap *pmap, vm_offset_t va, vm_paddr_t pa, + vm_prot_t prot, u_int flags) +{ + pd_entry_t *l2, l2e; + pt_entry_t new_l3; + pt_entry_t *l3; + vm_page_t mpte; + pn_t pn; + int rv; + + pn = (pa / PAGE_SIZE); + + new_l3 = PTE_V | PTE_R | PTE_A; + if (prot & VM_PROT_EXECUTE) + new_l3 |= PTE_X; + if (flags & VM_PROT_WRITE) + new_l3 |= PTE_D; + if (prot & VM_PROT_WRITE) + new_l3 |= PTE_W; + if (va < VM_MAX_USER_ADDRESS) + new_l3 |= PTE_U; + + new_l3 |= (pn << PTE_PPN0_S); + new_l3 |= PTE_MA_IO; + + /* + * Set modified bit gratuitously for writeable mappings if + * the page is unmanaged. We do not want to take a fault + * to do the dirty bit accounting for these mappings. + */ + if (prot & VM_PROT_WRITE) + new_l3 |= PTE_D; + + CTR2(KTR_PMAP, "pmap_enter: %.16lx -> %.16lx", va, pa); + + mpte = NULL; + PMAP_LOCK(pmap); + + l2 = pmap_l2(pmap, va); + if (l2 != NULL && ((l2e = pmap_load(l2)) & PTE_V) != 0 && + ((l2e & PTE_RWX) == 0)) { + l3 = pmap_l2_to_l3(l2, va); + } else if (va < VM_MAXUSER_ADDRESS) { + mpte = _pmap_alloc_l3(pmap, pmap_l2_pindex(va)); + if (mpte == NULL) { + CTR0(KTR_PMAP, "pmap_enter: mpte == NULL"); + rv = KERN_RESOURCE_SHORTAGE; + goto out; + } + l3 = pmap_l3(pmap, va); + } else + panic("pmap_enter: missing L3 table for kernel va %#lx", va); + + KASSERT((pmap_load(l3) & PTE_V) == 0, ("l3 is valid")); + + pmap_store(l3, new_l3); + pmap_resident_count_inc(pmap, 1); + + rv = KERN_SUCCESS; +out: + PMAP_UNLOCK(pmap); + + return (rv); +} + +static void +iommu_pmap_remove_pages_sv48(struct riscv_iommu_pmap *pmap) +{ + pd_entry_t l0e, *l1, l1e, *l2, l2e, *l3, l3e; + vm_paddr_t pa0, pa1, pa; + vm_page_t m0, m1, m; + int i, j, k, l; + + PMAP_LOCK(pmap); + + for (i = 0; i < Ln_ENTRIES; i++) { + l0e = pmap->pm_top[i]; + if ((l0e & PTE_V) == 0) + continue; + pa0 = PTE_TO_PHYS(l0e); + m0 = PHYS_TO_VM_PAGE(pa0); + l1 = (pd_entry_t *)PHYS_TO_DMAP(pa0); + + for (j = 0; j < Ln_ENTRIES; j++) { + l1e = l1[j]; + if ((l1e & PTE_V) == 0) + continue; + pa1 = PTE_TO_PHYS(l1e); + m1 = PHYS_TO_VM_PAGE(pa1); + l2 = (pd_entry_t *)PHYS_TO_DMAP(pa1); + + for (k = 0; k < Ln_ENTRIES; k++) { + l2e = l2[k]; + if ((l2e & PTE_V) == 0) + continue; + pa = PTE_TO_PHYS(l2e); + m = PHYS_TO_VM_PAGE(pa); + l3 = (pt_entry_t *)PHYS_TO_DMAP(pa); + + for (l = 0; l < Ln_ENTRIES; l++) { + l3e = l3[l]; + if ((l3e & PTE_V) == 0) + continue; + panic("%s: l3e found (idx %d %d %d %d)", + __func__, i, j, k, l); + } + + vm_page_unwire_noq(m1); + vm_page_unwire_noq(m); + pmap_resident_count_dec(pmap, 1); + vm_page_free(m); + pmap_clear(&l2[k]); + } + + vm_page_unwire_noq(m0); + pmap_resident_count_dec(pmap, 1); + vm_page_free(m1); + pmap_clear(&l1[j]); + } + + pmap_resident_count_dec(pmap, 1); + vm_page_free(m0); + pmap_clear(&pmap->pm_top[i]); + } + + KASSERT(pmap->sp_resident_count == 0, + ("Invalid resident count %jd", pmap->sp_resident_count)); + + PMAP_UNLOCK(pmap); +} + +static void +iommu_pmap_remove_pages_sv39(struct riscv_iommu_pmap *pmap) +{ + pd_entry_t l1e, *l2, l2e, *l3, l3e; + vm_paddr_t pa1, pa; + vm_page_t m1, m; + int j, k, l; + + PMAP_LOCK(pmap); + + for (j = 0; j < Ln_ENTRIES; j++) { + l1e = pmap->pm_top[j]; + if ((l1e & PTE_V) == 0) + continue; + pa1 = PTE_TO_PHYS(l1e); + m1 = PHYS_TO_VM_PAGE(pa1); + l2 = (pd_entry_t *)PHYS_TO_DMAP(pa1); + + for (k = 0; k < Ln_ENTRIES; k++) { + l2e = l2[k]; + if ((l2e & PTE_V) == 0) + continue; + pa = PTE_TO_PHYS(l2e); + m = PHYS_TO_VM_PAGE(pa); + l3 = (pt_entry_t *)PHYS_TO_DMAP(pa); + + for (l = 0; l < Ln_ENTRIES; l++) { + l3e = l3[l]; + if ((l3e & PTE_V) == 0) + continue; + panic("%s: l3e found (idx %d %d %d)", + __func__, j, k, l); + } + + vm_page_unwire_noq(m1); + vm_page_unwire_noq(m); + pmap_resident_count_dec(pmap, 1); + vm_page_free(m); + pmap_clear(&l2[k]); + } + + pmap_resident_count_dec(pmap, 1); + vm_page_free(m1); + pmap_clear(&pmap->pm_top[j]); + } + + KASSERT(pmap->sp_resident_count == 0, + ("Invalid resident count %jd", pmap->sp_resident_count)); + + PMAP_UNLOCK(pmap); +} + +void +iommu_pmap_remove_pages(struct riscv_iommu_pmap *pmap) +{ + + switch (pmap->pm_mode) { + case PMAP_MODE_SV39: + iommu_pmap_remove_pages_sv39(pmap); + break; + case PMAP_MODE_SV48: + iommu_pmap_remove_pages_sv48(pmap); + break; + default: + panic("Unknown virtual memory system"); + } +} diff --git a/sys/riscv/iommu/iommu_pmap.h b/sys/riscv/iommu/iommu_pmap.h new file mode 100644 index 000000000000..25347e239119 --- /dev/null +++ b/sys/riscv/iommu/iommu_pmap.h @@ -0,0 +1,49 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2026 Ruslan Bukin <br@bsdpad.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RISCV_IOMMU_IOMMU_PMAP_H_ +#define _RISCV_IOMMU_IOMMU_PMAP_H_ + +struct riscv_iommu_pmap { + pd_entry_t *pm_top; + enum pmap_mode pm_mode; + uint64_t pm_satp; + struct mtx pm_mtx; +#ifdef INVARIANTS + long sp_resident_count; +#endif +}; + +int iommu_pmap_enter(struct riscv_iommu_pmap *pmap, vm_offset_t va, + vm_paddr_t pa, vm_prot_t prot, u_int flags); +int iommu_pmap_remove(struct riscv_iommu_pmap *pmap, vm_offset_t va); +void iommu_pmap_remove_pages(struct riscv_iommu_pmap *pmap); +int iommu_pmap_pinit(struct riscv_iommu_pmap *pmap, enum pmap_mode pm_mode); +void iommu_pmap_release(struct riscv_iommu_pmap *pmap); +void iommu_pmap_remove_pages(struct riscv_iommu_pmap *pmap); + +#endif /* !_RISCV_IOMMU_IOMMU_PMAP_H_ */ diff --git a/sys/sys/_decls.h b/sys/sys/_decls.h new file mode 100644 index 000000000000..2ef61671dd70 --- /dev/null +++ b/sys/sys/_decls.h @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS__DECLS_H_ +#define _SYS__DECLS_H_ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +#endif diff --git a/sys/sys/_types.h b/sys/sys/_types.h index a2ee83a862da..bc438c17c8c0 100644 --- a/sys/sys/_types.h +++ b/sys/sys/_types.h @@ -40,18 +40,23 @@ */ typedef signed char __int8_t; typedef unsigned char __uint8_t; +#define __SIZEOF_INT8_T __SIZEOF_CHAR__ typedef short __int16_t; typedef unsigned short __uint16_t; +#define __SIZEOF_INT16_T __SIZEOF_SHORT__ typedef int __int32_t; typedef unsigned int __uint32_t; +#define __SIZEOF_INT32_T __SIZEOF_INT__ #if __SIZEOF_LONG__ == 8 typedef long __int64_t; typedef unsigned long __uint64_t; +#define __SIZEOF_INT64_T __SIZEOF_LONG__ #elif __SIZEOF_LONG__ == 4 __extension__ typedef long long __int64_t; __extension__ typedef unsigned long long __uint64_t; +#define __SIZEOF_INT64_T __SIZEOF_LONG_LONG__ #else #error unsupported long size #endif diff --git a/sys/sys/abi_types.h b/sys/sys/abi_types.h index 44d1bd733bbd..ddacd08ff011 100644 --- a/sys/sys/abi_types.h +++ b/sys/sys/abi_types.h @@ -27,8 +27,10 @@ typedef struct { #if defined(__amd64__) || defined(__i386__) typedef __int32_t time32_t; +#define __SIZEOF_TIME32_T __SIZEOF_INT32_T #else typedef __int64_t time32_t; +#define __SIZEOF_TIME32_T __SIZEOF_INT64_T #endif #define __HAVE_TIME32_T diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index a08c50c8439a..d0a34f1bdfc0 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -61,13 +61,7 @@ #define __has_builtin(x) 0 #endif -#if defined(__cplusplus) -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS } -#else -#define __BEGIN_DECLS -#define __END_DECLS -#endif +#include <sys/_decls.h> /* * This code has been put in place to help reduce the addition of diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 0b13241f0ee3..80cbca4ea753 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -142,6 +142,13 @@ typedef __pid_t pid_t; #define O_EMPTY_PATH 0x02000000 #define O_NAMEDATTR 0x04000000 /* NFSv4 named attributes */ #define O_XATTR O_NAMEDATTR /* Solaris compatibility */ + +/* + * Emulate MacOSX compatibility flag without consuming a flags bit. + * It is not fully correct since reads over regular files opened with + * this definition fail. + */ +#define O_SYMLINK (O_PATH | O_NOFOLLOW) #endif #if __POSIX_VISIBLE >= 202405 diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 1ca492929813..d6696bba0a4f 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -36,8 +36,10 @@ #include <sys/ucred.h> #include <sys/queue.h> #ifdef _KERNEL +#include <sys/systm.h> #include <sys/lock.h> #include <sys/lockmgr.h> +#include <sys/proc.h> #include <sys/tslog.h> #include <sys/_mutex.h> #include <sys/_sx.h> @@ -851,114 +853,134 @@ struct vfsops { vfs_statfs_t __vfs_statfs; -#define VFS_MOUNT(MP) ({ \ - int _rc; \ - \ - TSRAW(curthread, TS_ENTER, "VFS_MOUNT", (MP)->mnt_vfc->vfc_name);\ - _rc = (*(MP)->mnt_op->vfs_mount)(MP); \ - TSRAW(curthread, TS_EXIT, "VFS_MOUNT", (MP)->mnt_vfc->vfc_name);\ - _rc; }) +static inline int +VFS_MOUNT(struct mount *mp) +{ + int rc; -#define VFS_UNMOUNT(MP, FORCE) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_unmount)(MP, FORCE); \ - _rc; }) + TSRAW(curthread, TS_ENTER, "VFS_MOUNT", mp->mnt_vfc->vfc_name); + rc = mp->mnt_op->vfs_mount(mp); + TSRAW(curthread, TS_EXIT, "VFS_MOUNT", mp->mnt_vfc->vfc_name); + return (rc); +} -#define VFS_ROOT(MP, FLAGS, VPP) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_root)(MP, FLAGS, VPP); \ - _rc; }) +static inline int +VFS_UNMOUNT(struct mount *mp, int force) +{ + return (mp->mnt_op->vfs_unmount(mp, force)); +} -#define VFS_CACHEDROOT(MP, FLAGS, VPP) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_cachedroot)(MP, FLAGS, VPP); \ - _rc; }) +static inline int +VFS_ROOT(struct mount *mp, int flags, struct vnode **vpp) +{ + return (mp->mnt_op->vfs_root(mp, flags, vpp)); +} -#define VFS_QUOTACTL(MP, C, U, A, MP_BUSY) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, MP_BUSY); \ - _rc; }) +static inline int +VFS_CACHEDROOT(struct mount *mp, int flags, struct vnode **vpp) +{ + return (mp->mnt_op->vfs_cachedroot(mp, flags, vpp)); +} -#define VFS_STATFS(MP, SBP) ({ \ - int _rc; \ - \ - _rc = __vfs_statfs((MP), (SBP)); \ - _rc; }) +static inline int +VFS_QUOTACTL(struct mount *mp, int cmds, uid_t uid, void *arg, bool *mp_busy) +{ + return (mp->mnt_op->vfs_quotactl(mp, cmds, uid, arg, mp_busy)); +} -#define VFS_SYNC(MP, WAIT) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_sync)(MP, WAIT); \ - _rc; }) +static inline int +VFS_STATFS(struct mount *mp, struct statfs *sbp) +{ + return (__vfs_statfs(mp, sbp)); +} -#define VFS_VGET(MP, INO, FLAGS, VPP) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP); \ - _rc; }) +static inline int +VFS_SYNC(struct mount *mp, int waitfor) +{ + return (mp->mnt_op->vfs_sync(mp, waitfor)); +} -#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP); \ - _rc; }) +static inline int +VFS_VGET(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) +{ + return (mp->mnt_op->vfs_vget(mp, ino, flags, vpp)); +} -#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED, NUMSEC,\ - SEC); \ - _rc; }) +static inline int +VFS_FHTOVP(struct mount *mp, struct fid *fidp, int flags, struct vnode **vpp) +{ + return (mp->mnt_op->vfs_fhtovp(mp, fidp, flags, vpp)); +} -#define VFS_EXTATTRCTL(MP, C, FN, NS, N) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_extattrctl)(MP, C, FN, NS, N); \ - _rc; }) +static inline int +VFS_CHECKEXP(struct mount *mp, struct sockaddr *nam, uint64_t *extflagsp, + struct ucred **credanonp, int *numsecflavors, int *secflavors) +{ + return (mp->mnt_op->vfs_checkexp(mp, nam, extflagsp, credanonp, + numsecflavors, secflavors)); +} -#define VFS_SYSCTL(MP, OP, REQ) ({ \ - int _rc; \ - \ - _rc = (*(MP)->mnt_op->vfs_sysctl)(MP, OP, REQ); \ - _rc; }) +static inline int +VFS_EXTATTRCTL(struct mount *mp, int cmd, struct vnode *filename_vp, + int attrnamespace, const char *attrname) +{ + return (mp->mnt_op->vfs_extattrctl(mp, cmd, filename_vp, + attrnamespace, attrname)); +} -#define VFS_SUSP_CLEAN(MP) do { \ - if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \ - (*(MP)->mnt_op->vfs_susp_clean)(MP); \ - } \ -} while (0) +static inline int +VFS_SYSCTL(struct mount *mp, fsctlop_t op, struct sysctl_req *req) +{ + return (mp->mnt_op->vfs_sysctl(mp, op, req)); +} -#define VFS_RECLAIM_LOWERVP(MP, VP) do { \ - if (*(MP)->mnt_op->vfs_reclaim_lowervp != NULL) { \ - (*(MP)->mnt_op->vfs_reclaim_lowervp)((MP), (VP)); \ - } \ -} while (0) +static inline void +VFS_SUSP_CLEAN(struct mount *mp) +{ + if (mp->mnt_op->vfs_susp_clean != NULL) + mp->mnt_op->vfs_susp_clean(mp); +} -#define VFS_UNLINK_LOWERVP(MP, VP) do { \ - if (*(MP)->mnt_op->vfs_unlink_lowervp != NULL) { \ - (*(MP)->mnt_op->vfs_unlink_lowervp)((MP), (VP)); \ - } \ -} while (0) +static inline void +VFS_RECLAIM_LOWERVP(struct mount *mp, struct vnode *vp) +{ + if (mp->mnt_op->vfs_reclaim_lowervp != NULL) + mp->mnt_op->vfs_reclaim_lowervp(mp, vp); +} -#define VFS_PURGE(MP) do { \ - if (*(MP)->mnt_op->vfs_purge != NULL) { \ - (*(MP)->mnt_op->vfs_purge)(MP); \ - } \ -} while (0) +static inline void +VFS_UNLINK_LOWERVP(struct mount *mp, struct vnode *vp) +{ + if (mp->mnt_op->vfs_unlink_lowervp != NULL) + mp->mnt_op->vfs_unlink_lowervp(mp, vp); +} -#define VFS_KNOTE_LOCKED(vp, hint) do \ -{ \ - VN_KNOTE((vp), (hint), KNF_LISTLOCKED); \ -} while (0) +static inline void +VFS_PURGE(struct mount *mp) +{ + if (mp->mnt_op->vfs_purge != NULL) + mp->mnt_op->vfs_purge(mp); +} -#define VFS_KNOTE_UNLOCKED(vp, hint) do \ -{ \ - VN_KNOTE((vp), (hint), 0); \ -} while (0) +#include <sys/vnode.h> + +static inline void +VFS_KNOTE_LOCKED(struct vnode *vp, int hint) +{ + if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) { + KNOTE_LOCKED(&vp->v_pollinfo->vpi_selinfo.si_note, + hint); + } +} + +static inline void +VFS_KNOTE_UNLOCKED(struct vnode *vp, int hint) +{ + if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) { + KNOTE_UNLOCKED(&vp->v_pollinfo->vpi_selinfo.si_note, + hint); + } +} #include <sys/module.h> @@ -1137,47 +1159,64 @@ void resume_all_fs(void); */ #define vfs_mount_pcpu(mp) zpcpu_get(mp->mnt_pcpu) #define vfs_mount_pcpu_remote(mp, cpu) zpcpu_get_cpu(mp->mnt_pcpu, cpu) +static void vfs_op_thread_exit_crit(struct mount *mp, struct mount_pcpu *mpcpu); -#define vfs_op_thread_entered(mp) ({ \ - MPASS(curthread->td_critnest > 0); \ - struct mount_pcpu *_mpcpu = vfs_mount_pcpu(mp); \ - _mpcpu->mntp_thread_in_ops == 1; \ -}) +static inline bool +vfs_op_thread_entered(struct mount *mp) +{ + struct mount_pcpu *mpcpu = vfs_mount_pcpu(mp); -#define vfs_op_thread_enter_crit(mp, _mpcpu) ({ \ - bool _retval_crit = true; \ - MPASS(curthread->td_critnest > 0); \ - _mpcpu = vfs_mount_pcpu(mp); \ - MPASS(mpcpu->mntp_thread_in_ops == 0); \ - _mpcpu->mntp_thread_in_ops = 1; \ - atomic_interrupt_fence(); \ - if (__predict_false(mp->mnt_vfs_ops > 0)) { \ - vfs_op_thread_exit_crit(mp, _mpcpu); \ - _retval_crit = false; \ - } \ - _retval_crit; \ -}) + MPASS(curthread->td_critnest > 0); + return (mpcpu->mntp_thread_in_ops == 1); +} -#define vfs_op_thread_enter(mp, _mpcpu) ({ \ - bool _retval; \ - critical_enter(); \ - _retval = vfs_op_thread_enter_crit(mp, _mpcpu); \ - if (__predict_false(!_retval)) \ - critical_exit(); \ - _retval; \ -}) +static inline bool +vfs_op_thread_enter_crit(struct mount *mp, struct mount_pcpu **mpcpup) +{ + struct mount_pcpu *mpcpu; + bool retval_crit = true; -#define vfs_op_thread_exit_crit(mp, _mpcpu) do { \ - MPASS(_mpcpu == vfs_mount_pcpu(mp)); \ - MPASS(_mpcpu->mntp_thread_in_ops == 1); \ - atomic_interrupt_fence(); \ - _mpcpu->mntp_thread_in_ops = 0; \ -} while (0) + MPASS(curthread->td_critnest > 0); + mpcpu = vfs_mount_pcpu(mp); + MPASS(mpcpu->mntp_thread_in_ops == 0); + mpcpu->mntp_thread_in_ops = 1; + atomic_interrupt_fence(); + if (__predict_false(mp->mnt_vfs_ops > 0)) { + vfs_op_thread_exit_crit(mp, mpcpu); + retval_crit = false; + } + *mpcpup = mpcpu; + return (retval_crit); +} -#define vfs_op_thread_exit(mp, _mpcpu) do { \ - vfs_op_thread_exit_crit(mp, _mpcpu); \ - critical_exit(); \ -} while (0) +static inline bool +vfs_op_thread_enter(struct mount *mp, struct mount_pcpu **mpcpup) +{ + bool retval; + + critical_enter(); + retval = vfs_op_thread_enter_crit(mp, mpcpup); + if (__predict_false(!retval)) + critical_exit(); + return (retval); +} + +static inline void +vfs_op_thread_exit_crit(struct mount *mp, struct mount_pcpu *mpcpu) +{ + MPASS(mpcpu == vfs_mount_pcpu(mp)); + MPASS(mpcpu->mntp_thread_in_ops == 1); + + atomic_interrupt_fence(); + mpcpu->mntp_thread_in_ops = 0; +} + +static inline void +vfs_op_thread_exit(struct mount *mp, struct mount_pcpu *mpcpu) +{ + vfs_op_thread_exit_crit(mp, mpcpu); + critical_exit(); +} #define vfs_mp_count_add_pcpu(_mpcpu, count, val) do { \ MPASS(_mpcpu->mntp_thread_in_ops == 1); \ diff --git a/sys/sys/power.h b/sys/sys/power.h index d34af0ddb86a..e420717e1aa7 100644 --- a/sys/sys/power.h +++ b/sys/sys/power.h @@ -48,28 +48,29 @@ * Sleep state transition requests. * * These are high-level sleep states that the system can enter. They map to - * a specific generic sleep type (enum power_stype). + * a specific generic sleep type (enum power_stype), depending on the + * kern.power.* sysctls. */ -enum power_sstate_transition { - POWER_SSTATE_TRANSITION_STANDBY, - POWER_SSTATE_TRANSITION_SUSPEND, - POWER_SSTATE_TRANSITION_HIBERNATE, +enum power_transition { + POWER_TRANSITION_STANDBY, + POWER_TRANSITION_SUSPEND, + POWER_TRANSITION_HIBERNATE, }; /* * Sleep type. * * These are the specific generic methods of entering a sleep state. E.g. - * POWER_SSTATE_TRANSITION_SUSPEND could be set to enter either suspend-to-RAM - * (which is S3 on ACPI systems), or suspend-to-idle (S0ix on ACPI systems). - * This would be done through the kern.power.suspend sysctl. + * POWER_TRANSITION_SUSPEND could be set to enter either firmware suspend (which + * is suspend-to-RAM or S3 on ACPI systems), or suspend-to-idle (S0ix on ACPI + * platforms). This would be done through the kern.power.suspend sysctl. */ enum power_stype { POWER_STYPE_AWAKE, POWER_STYPE_STANDBY, - POWER_STYPE_SUSPEND_TO_MEM, + POWER_STYPE_FW_SUSPEND, POWER_STYPE_SUSPEND_TO_IDLE, - POWER_STYPE_HIBERNATE, + POWER_STYPE_FW_HIBERNATE, POWER_STYPE_POWEROFF, POWER_STYPE_COUNT, POWER_STYPE_UNKNOWN, @@ -78,9 +79,9 @@ enum power_stype { static const char * const power_stype_names[POWER_STYPE_COUNT] = { [POWER_STYPE_AWAKE] = "awake", [POWER_STYPE_STANDBY] = "standby", - [POWER_STYPE_SUSPEND_TO_MEM] = "s2mem", - [POWER_STYPE_SUSPEND_TO_IDLE] = "s2idle", - [POWER_STYPE_HIBERNATE] = "hibernate", + [POWER_STYPE_FW_SUSPEND] = "fw_suspend", + [POWER_STYPE_SUSPEND_TO_IDLE] = "suspend_to_idle", + [POWER_STYPE_FW_HIBERNATE] = "fw_hibernate", [POWER_STYPE_POWEROFF] = "poweroff", }; @@ -96,7 +97,7 @@ extern int power_pm_register(u_int _pm_type, power_pm_fn_t _pm_fn, void *_pm_arg, bool _pm_supported[static POWER_STYPE_COUNT]); extern u_int power_pm_get_type(void); -extern void power_pm_suspend(enum power_sstate_transition _trans); +extern void power_pm_suspend(enum power_transition _trans); /* * System power API. diff --git a/sys/sys/time.h b/sys/sys/time.h index 6f18d8bd844d..5255d3bc9c7e 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -355,7 +355,7 @@ tstosbt(struct timespec _ts) static __inline sbintime_t tstosbt_sat(struct timespec _ts) { -#ifndef __i386__ +#if __SIZEOF_TIME_T > 4 if (_ts.tv_sec > SBT_MAX >> 32) return (SBT_MAX); if (_ts.tv_sec < -(SBT_MAX >> 32) - 1) @@ -384,7 +384,7 @@ tvtosbt(struct timeval _tv) static __inline sbintime_t tvtosbt_sat(struct timeval _tv) { -#ifndef __i386__ +#if __SIZEOF_TIME_T > 4 if (_tv.tv_sec > SBT_MAX >> 32) return (SBT_MAX); if (_tv.tv_sec < -(SBT_MAX >> 32) - 1) diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index ba241cf9ff3a..4bf48a5e4b87 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -193,6 +193,17 @@ struct setcred32 { uint32_t sc_label; /* struct mac32 [*] */ }; +#ifdef COMPAT_FREEBSD32 +/* 32-bit compatible version of xucred */ +struct xucred32 { + u_int cr_version; /* structure layout version */ + uid_t cr_uid; /* effective user id */ + short cr_ngroups; /* number of groups (incl. cr_gid). */ + gid_t cr_groups[XU_NGROUPS]; /* groups */ + pid_t cr_pid; +}; +#endif + struct thread; /* Common native and 32-bit compatibility entry point. */ diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 3fd2c770cda1..4fee025a93ea 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -221,21 +221,16 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); #define bo2vnode(bo) __containerof((bo), struct vnode, v_bufobj) -/* XXX: These are temporary to avoid a source sweep at this time */ #define v_object v_bufobj.bo_object -/* We don't need to lock the knlist */ -#define VN_KNLIST_EMPTY(vp) ((vp)->v_pollinfo == NULL || \ - KNLIST_EMPTY(&(vp)->v_pollinfo->vpi_selinfo.si_note)) - -#define VN_KNOTE(vp, b, a) \ - do { \ - if (!VN_KNLIST_EMPTY(vp)) \ - KNOTE(&vp->v_pollinfo->vpi_selinfo.si_note, (b), \ - (a) | KNF_NOKQLOCK); \ - } while (0) -#define VN_KNOTE_LOCKED(vp, b) VN_KNOTE(vp, b, KNF_LISTLOCKED) -#define VN_KNOTE_UNLOCKED(vp, b) VN_KNOTE(vp, b, 0) +#define VN_KNOTE(vp, b, a) do { \ + if ((vn_irflag_read(vp) & VIRF_KNOTE) != 0) { \ + KNOTE(&vp->v_pollinfo->vpi_selinfo.si_note, (b), \ + (a) | KNF_NOKQLOCK); \ + } \ +} while (0) +#define VN_KNOTE_LOCKED(vp, b) VN_KNOTE(vp, b, KNF_LISTLOCKED) +#define VN_KNOTE_UNLOCKED(vp, b) VN_KNOTE(vp, b, 0) /* * Vnode flags. @@ -260,6 +255,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes"); #define VIRF_INOTIFY 0x0080 /* This vnode is being watched */ #define VIRF_INOTIFY_PARENT 0x0100 /* A parent of this vnode may be being watched */ +#define VIRF_KNOTE 0x0200 /* Has knlist */ #define VI_UNUSED0 0x0001 /* unused */ #define VI_MOUNT 0x0002 /* Mount in progress */ @@ -1052,7 +1048,7 @@ void vop_rename_fail(struct vop_rename_args *ap); off_t osize, ooffset, noffset; \ \ osize = ooffset = noffset = 0; \ - if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ + if ((vn_irflag_read((ap)->a_vp) & VIRF_KNOTE) != 0) { \ error = VOP_GETATTR((ap)->a_vp, &va, (ap)->a_cred); \ if (error) \ return (error); \ @@ -1063,10 +1059,8 @@ void vop_rename_fail(struct vop_rename_args *ap); #define vop_write_post(ap, ret) \ noffset = (ap)->a_uio->uio_offset; \ if (noffset > ooffset) { \ - if (!VN_KNLIST_EMPTY((ap)->a_vp)) { \ - VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \ - (noffset > osize ? NOTE_EXTEND : 0)); \ - } \ + VFS_KNOTE_LOCKED((ap)->a_vp, NOTE_WRITE | \ + (noffset > osize ? NOTE_EXTEND : 0)); \ INOTIFY((ap)->a_vp, IN_MODIFY); \ } diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 63bdce9d60f8..94dd7d3a19bc 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -4723,6 +4723,11 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, return (rv); } +static bool report_stackoverflow = true; +SYSCTL_BOOL(_vm, OID_AUTO, report_stackoverflow, CTLFLAG_RWTUN, + &report_stackoverflow, 0, + "uprintf() on stack overflow"); + /* * Attempts to grow a vm stack entry. Returns KERN_SUCCESS if we * successfully grow the stack. @@ -4731,6 +4736,7 @@ static int vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry) { vm_map_entry_t stack_entry; + struct thread *td; struct proc *p; struct vmspace *vm; vm_offset_t gap_end, gap_start, grow_start; @@ -4746,7 +4752,8 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry) int error __diagused; #endif - p = curproc; + td = curthread; + p = td->td_proc; vm = p->p_vmspace; /* @@ -4754,15 +4761,14 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_map_entry_t gap_entry) * debugger or AIO daemon. The reason is that the wrong * resource limits are applied. */ - if (p != initproc && (map != &p->p_vmspace->vm_map || - p->p_textvp == NULL)) + if (p != initproc && (map != &vm->vm_map || p->p_textvp == NULL)) return (KERN_FAILURE); MPASS(!vm_map_is_system(map)); - lmemlim = lim_cur(curthread, RLIMIT_MEMLOCK); - stacklim = lim_cur(curthread, RLIMIT_STACK); - vmemlim = lim_cur(curthread, RLIMIT_VMEM); + lmemlim = lim_cur(td, RLIMIT_MEMLOCK); + stacklim = lim_cur(td, RLIMIT_STACK); + vmemlim = lim_cur(td, RLIMIT_VMEM); retry: /* If addr is not in a hole for a stack grow area, no need to grow. */ if (gap_entry == NULL && !vm_map_lookup_entry(map, addr, &gap_entry)) @@ -4778,15 +4784,19 @@ retry: } else { return (KERN_FAILURE); } - guard = ((curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 || - (curproc->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 : + guard = ((p->p_flag2 & P2_STKGAP_DISABLE) != 0 || + (p->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 : gap_entry->next_read; max_grow = gap_entry->end - gap_entry->start; if (guard > max_grow) return (KERN_NO_SPACE); max_grow -= guard; - if (grow_amount > max_grow) + if (grow_amount > max_grow) { + if (report_stackoverflow) + uprintf("pid %d comm %s tid %d stack overflow\n", + p->p_pid, p->p_comm, td->td_tid); return (KERN_NO_SPACE); + } /* * If this is the main process stack, see if we're over the stack @@ -4794,8 +4804,12 @@ retry: */ is_procstack = addr >= (vm_offset_t)vm->vm_maxsaddr && addr < (vm_offset_t)vm->vm_stacktop; - if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim)) + if (is_procstack && (ctob(vm->vm_ssize) + grow_amount > stacklim)) { + if (report_stackoverflow) + uprintf("pid %d comm %s tid %d stack overflow\n", + p->p_pid, p->p_comm, td->td_tid); return (KERN_NO_SPACE); + } #ifdef RACCT if (racct_enable) { diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c index 5e075a26a57b..bbc6592579e3 100644 --- a/sys/x86/cpufreq/hwpstate_amd.c +++ b/sys/x86/cpufreq/hwpstate_amd.c @@ -745,7 +745,7 @@ hwpstate_settings(device_t dev, struct cf_setting *sets, int *count) static int hwpstate_type_cppc(device_t dev, int *type) { - *type |= CPUFREQ_TYPE_ABSOLUTE | CPUFREQ_FLAG_INFO_ONLY | + *type = CPUFREQ_TYPE_ABSOLUTE | CPUFREQ_FLAG_INFO_ONLY | CPUFREQ_FLAG_UNCACHED; return (0); } diff --git a/sys/x86/include/_types.h b/sys/x86/include/_types.h index b33dc0bfc7af..2630af1257c7 100644 --- a/sys/x86/include/_types.h +++ b/sys/x86/include/_types.h @@ -71,10 +71,12 @@ typedef __int64_t __int_fast64_t; typedef __int64_t __register_t; typedef __int64_t __segsz_t; /* segment size (in pages) */ typedef __int64_t __time_t; /* time()... */ +#define __SIZEOF_TIME_T __SIZEOF_INT64_T #else typedef __int32_t __register_t; typedef __int32_t __segsz_t; typedef __int32_t __time_t; +#define __SIZEOF_TIME_T __SIZEOF_INT32_T #endif typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; |
