]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
platform/x86: wmi: create userspace interface for drivers
authorMario Limonciello <mario.limonciello@dell.com>
Wed, 1 Nov 2017 19:25:35 +0000 (14:25 -0500)
committerDarren Hart (VMware) <dvhart@infradead.org>
Fri, 3 Nov 2017 23:34:00 +0000 (16:34 -0700)
commit44b6b7661132b1b0e5fd3147ded66f1e4a817ca9
treeaa54778be562e5b60b8cde0034fb1bfc276870e3
parent1f8543a5d602b816b9b64a62cafd6caae2af4ca6
platform/x86: wmi: create userspace interface for drivers

For WMI operations that are only Set or Query readable and writable sysfs
attributes created by WMI vendor drivers or the bus driver makes sense.

For other WMI operations that are run on Method, there needs to be a
way to guarantee to userspace that the results from the method call
belong to the data request to the method call.  Sysfs attributes don't
work well in this scenario because two userspace processes may be
competing at reading/writing an attribute and step on each other's
data.

When a WMI vendor driver declares a callback method in the wmi_driver
the WMI bus driver will create a character device that maps to that
function.  This callback method will be responsible for filtering
invalid requests and performing the actual call.

That character device will correspond to this path:
/dev/wmi/$driver

Performing read() on this character device will provide the size
of the buffer that the character device needs to perform calls.
This buffer size can be set by vendor drivers through a new symbol
or when MOF parsing is available by the MOF.

Performing ioctl() on this character device will be interpretd
by the WMI bus driver. It will perform sanity tests for size of
data, test them for a valid instance, copy the data from userspace
and pass iton to the vendor driver to further process and run.

This creates an implicit policy that each driver will only be allowed
a single character device.  If a module matches multiple GUID's,
the wmi_devices will need to be all handled by the same wmi_driver.

The WMI vendor drivers will be responsible for managing inappropriate
access to this character device and proper locking on data used by
it.

When a WMI vendor driver is unloaded the WMI bus driver will clean
up the character device and any memory allocated for the call.

Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Reviewed-by: Edward O'Callaghan <quasisec@google.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
MAINTAINERS
drivers/platform/x86/wmi.c
include/linux/wmi.h
include/uapi/linux/wmi.h [new file with mode: 0644]