We're storing a persistent pointer to an ephemeral local variable
which technically is a dangling pointer and the compiler is correct.
However, since we never indirect the pointer, this is a safe
operation and we can suppress the warning.
Also, some C run-times (like MUSL) aren't including <stdint.h>
indirectly so we must include it explicitly or we won't have the
type definition for uintptr_t.
Fixes issue #867.
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
The acpica will be integrated as module into Zephyr project for
enable acpi bus driver. This patch is for enable os specific
support layer for Zephyr.
Signed-off-by: Najumon <najumon.ba@intel.com>
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3). Note that the spec requires there be at least
one interrupt, so use a union to keep space allocated for this.
The only binary change in .text and .data sections is some rearrangement
by the compiler of AcpiDmAddressCommon(), but appears to be harmless.
Use ACPI_FLEX_ARRAY() helper to define flexible array member alone in a
struct. Fixes issue #812.
No binary changes appear in the .text nor .data sections.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
The handling of ACPI_DMAR_ANDD by AcpiDmDumpDmar() appears to expect a
single trailing char for calculating table offsets. Keep a char in the
union to avoid any code changes appearing in the .text or .data
sections.
Signed-off-by: Kees Cook <kees@outflux.net>
The "Source" array is actually a dynamically sized array, but it
is defined as a fixed-size 4 byte array. This results in tripping
both compile-time and run-time bounds checkers (e.g. via either
__builtin_object_size() or -fsanitize=bounds).
To retain the padding, create a union with an unused Pad variable of
size 4, and redefine Source as a proper flexible array member.
No binary changes appear in the .text nor .data sections.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper flexible array
member as defined by C99, but without changing the structure size. This
allows the code to operate without tripping compile-time and run-time
bounds checkers (e.g. via __builtin_object_size(), -fsanitize=bounds,
and/or -fstrict-flex-arrays=3). As with IRQs, leave a single element in
a union.
No binary changes appear in the .text nor .data sections.
In order to enable using -fstrict-flex-arrays with GCC and Clang in the
Linux kernel, each trailing dynamically sized array must be defined as
proper C99 "flexible array members" (FAM). Unfortunately, ACPICA has a
bunch of technical debt, dating back to before even the GNU extension of
0-length arrays, meaning the code base has many 1-element and 0-length
arrays defined at the end of structures that should actually be FAMs.
One limitation of the C99 FAM specification is the accidental requirement
that they cannot be in unions or alone in structs. There is no real-world
reason for this, though, and, actually, the existing GNU extension
permits this for 0-length arrays (which get treated as FAMs).
Add the ACPI_FLEX_ARRAY() helper macro to work around this requirement
so that FAMs can be defined in unions or alone in structs. Since this
behavior still depends on GNU extensions, keep the macro specific to GCC
(and Clang) builds. In this way, MSVC will continue to use 0-length
arrays (since it does not support the union work-around). When MSVC
grows support for this in the future, the macro can be updated.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
Unlike ACPI_NFIT_FLUSH_ADDRESS and ACPI_NFIT_SMBIOS, which had their
sizeof() uses adjusted in code, ACPI_NFIT_INTERLEAVE did not. This appears
to have been a bug. After this change, there is a binary difference in
AcpiDmDumpNfit() since the size of the structure now has the correct size,
as the prior result was including the trailing U32:
- mov $0x14,%ebp
+ mov $0x10,%ebp
Signed-off-by: Kees Cook <kees@outflux.net>
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
The sizeof() uses with ACPI_NFIT_FLUSH_ADDRESS and ACPI_NFIT_SMBIOS have
been adjusted to drop the open-coded subtraction of the trailing single
element. The result is no binary differences in .text nor .data sections.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
No .text nor .data differences result from this change.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
No binary changes appear in the .text nor .data sections.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).
No binary changes appear in the .text nor .data sections.
84449c1eef fixed this for Linux kernel
builds, but not Linux userspace builds.
Before this change we see the following UBSAN stack trace in Fuchsia:
../../third_party/acpica/source/components/tables/tbfadt.c:536:39: runtime error: member access within null pointer of type 'ACPI_TABLE_FADT' (aka 'struct acpi_table_fadt')
#0 0x564860b5ee9b in AcpiTbConvertFadt ../../third_party/acpica/source/components/tables/tbfadt.c:536:39
#1 0x564860b5edb4 in AcpiTbCreateLocalFadt ../../third_party/acpica/source/components/tables/tbfadt.c:461:5
#2 0x564860b5e5c6 in AcpiTbParseFadt ../../third_party/acpica/source/components/tables/tbfadt.c:371:5
#3 0x564860b5c485 in AcpiTbParseRootTable ../../third_party/acpica/source/components/tables/tbutils.c:407:13
#4 0x564860b6401a in AcpiInitializeTables ../../third_party/acpica/source/components/tables/tbxface.c:160:14
#5 0x5648608fb417 in acpi_host_test::AcpiHostTest::InitAcpiWithTables(char const*) ../../src/devices/board/tests/acpi-host-tests/acpi-host-test.cc:36:5
#6 0x5648608f9095 in acpi_host_test::AcpiHostTest_DeviceIsChildOfScopeTest_Test::TestBody() ../../src/devices/board/tests/acpi-host-tests/acpi-host-test.cc:85:3
#7 0x564860c6007e in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../../third_party/googletest/src/googletest/src/gtest.cc:2609:10
#8 0x564860bbd5df in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../../third_party/googletest/src/googletest/src/gtest.cc:2664:12 #9 0x564860bbd141 in testing::Test::Run() ../../third_party/googletest/src/googletest/src/gtest.cc:2684:5 #10 0x564860bbff0a in testing::TestInfo::Run() ../../third_party/googletest/src/googletest/src/gtest.cc:2864:11 #11 0x564860bc40f1 in testing::TestSuite::Run() ../../third_party/googletest/src/googletest/src/gtest.cc:3023:30 #12 0x564860beba40 in testing::internal::UnitTestImpl::RunAllTests() ../../third_party/googletest/src/googletest/src/gtest.cc:5882:44
#13 0x564860c7db6e in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../../third_party/googletest/src/googletest/src/gtest.cc:2609:10
#14 0x564860bea71f in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../../third_party/googletest/src/googletest/src/gtest.cc:2664:12 #15 0x564860bea1c5 in testing::UnitTest::Run() ../../third_party/googletest/src/googletest/src/gtest.cc:5456:10 #16 0x5648608fccc0 in RUN_ALL_TESTS() ../../third_party/googletest/src/googletest/include/gtest/gtest.h:2304:73 #17 0x5648608fcb7e in main ../../src/devices/board/tests/acpi-host-tests/acpi-host-test.cc:121:10 #18 0x7f6defa2d189 (/lib/x86_64-linux-gnu/libc.so.6+0x27189) (BuildId: c4f6727c560b1c33527ff9e0ca0cef13a7db64d2)
#19 0x7f6defa2d244 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27244) (BuildId: c4f6727c560b1c33527ff9e0ca0cef13a7db64d2)
#20 0x56486082e598 (/usr/local/google/home/tamird/src/fuchsia/out/core.x64/host_x64/acpi-host-test-bin+0x359598) (BuildId: 851423b0e664df6a)
RISC-V Hart Capabilities Table (RHCT) is a new static table.
The ECR to add RHCT is approved by the UEFI forum and will be
available in the next version of the ACPI spec.
Reference: Mantis: 2349
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
The ECR to add RISC-V INTC interrupt controller is approved by
the UEFI forum and will be available in the next revision of
the ACPI specification.
Reference: Mantis ID: 2348
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Complies with ACPI for Memory System Resource Partitioning and
Monitoring 2.0 [1]. Document number: DEN0065, as of December 2022.
Support for all types of MPAM resources. No support yet for:
1) MPAM PCC Interface Type
2) The optional Resource-specific data per MSC node, introduced in v2 of the
MPAM ACPI spec.
[1] https://developer.arm.com/documentation/den0065/latest
Signed-off-by: Hesham Almatary <hesham.almatary@huawei.com>
ASPT is the AMD Secure Processor table, found in Hyper-V VMs when SNP
isolation is exposed to the VM and in some high-end AMD servers. This
commit adds support for rev 1 of the ASPT spec in the disassembler.
Add 64 bit LoongArch architecture by defining ACPI_MACHINE_WIDTH to 64.
Useful for acpica tools and incorporating ACPICA into the Firmware Test
Suite.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Also renames ACPI_DATA_TABLE_MAPPING's struct to
acpi_data_table_mapping, just so conversion goes smoothly.
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
The "Source" array is actually a dynamically sized array, but it
is defined as a fixed-size 4 byte array. This results in tripping
both compile-time and run-time bounds checkers (e.g. via either
__builtin_object_size() or -fsanitize=bounds).
To retain the padding, create a union with an unused Pad variable of
size 4, and redefine Source as a proper flexible array member.
Similar to commit 7ba2f3d91a ("Replace one-element array with
flexible-array"), replace the 1-element array with a proper
flexible array member as defined by C99. This allows the code to
operate without tripping compile-time and run-time bounds checkers
(e.g. via __builtin_object_size(), -fsanitize=bounds, and/or
-fstrict-flex-arrays=3).