News: 0001600816

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

WMI Marshalling Support For Linux Aims To Match Windows' ACPI/WMI Handling

([Hardware] 6 Hours Ago WMI Marshalling)


Open-source developer Armin Wolf has been working most recently on marshalling support for the Windows Management Instrumentation (WMI) platform code within the Linux kernel. This WMI marshalling support is to better match the behavior of Microsoft Windows' WMI ACPI driver and ultimately to allow for better compatibility with some ACPI firmware and enhancing some WMI drivers.

The WMI marshalling support is up to its second post-RFC revision for this effort to better match the handling of Windows' WMI ACPI driver. Wolf explained in this weekend's [1]v2 patch series about the work:

"The Windows WMI-ACPI driver likely uses wmilib to interact with the WMI service in userspace. Said library uses plain byte buffers for exchanging data, so the WMI-ACPI driver has to convert between those byte buffers and ACPI objects returned by the ACPI firmware.

The format of the byte buffer is publicly documented, and after some reverse [engineering] of the WMI-ACPI driver using a set of custom ACPI tables, the following conversion rules have been discovered:

- ACPI integers are always converted into a uint32

- ACPI strings are converted into special WMI strings

- ACPI buffers are copied as-is

- ACPI packages are unpacked

Extending the ACPI-WMI to perform this kind of marshalling for WMI data blocks, methods and events would give us a number of benefits:

- WMI drivers are not restricted to a fixed set of supported ACPI data types anymore, see dell-wmi-aio (integer vs buffer) and hp-wmi-sensors (string vs buffer)

- correct marshalling of WMI strings when data blocks are marked as requiring ACPI strings instead of ACPI buffers

- development of WMI drivers without having to understand ACPI

This eventually should result in better compatibility with some ACPI firmware implementations and in simpler WMI drivers.

The first patch extends the WMI driver core to perform said marshalling as well as a new API not based on ACPI objects. The next patch adds a KUnit test for testing the marshalling code. The following two patches then add a set of helper functions for dealing

with WMI string data together with another KUnit test.

The remaining patches then convert some simple WMI drivers to use the new WMI API and update the driver development guide so that new WMI drivers stop using the ACPI-based API.

The series has been tested on multiple machines, with the xiaomi-wmi and intel-wmi-sbl-fw-update being tested using a set of custom ACPI tables loaded over configFS."

By better mirroring the Microsoft Windows behavior should ultimately help out with the WMI drivers in better supporting newer hardware, particularly laptops, on Linux. The code remains under review and testing on the kernel mailing list.



[1] https://lore.kernel.org/platform-driver-x86/20251220204622.3541-1-W_Armin@gmx.de/



Long ago, in a finite state far away, there lived a JOVIAL
character named Jack. Jack and his relations were poor. Often their
hash table was bare. One day Jack's parent said to him, "Our matrices
are sparse. You must go to the market to exchange our RAM for some
BASICs." She compiled a linked list of items to retrieve and passed it
to him.
So Jack set out. But as he was walking along a Hamilton path,
he met the traveling salesman.
"Whither dost thy flow chart take thou?" prompted the salesman
in high-level language.
"I'm going to the market to exchange this RAM for some chips
and Apples," commented Jack.
"I have a much better algorithm. You needn't join a queue
there; I will swap your RAM for these magic kernels now."
Jack made the trade, then backtracked to his house. But when
he told his busy-waiting parent of the deal, she became so angry she
started thrashing.
"Don't you even have any artificial intelligence? All these
kernels together hardly make up one byte," and she popped them out the
window...
-- Mark Isaak, "Jack and the Beanstack"