mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 00:59:39 +07:00
44b6b76611
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>
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/*
|
|
* wmi.h - ACPI WMI interface
|
|
*
|
|
* Copyright (c) 2015 Andrew Lutomirski
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _LINUX_WMI_H
|
|
#define _LINUX_WMI_H
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/acpi.h>
|
|
#include <uapi/linux/wmi.h>
|
|
|
|
struct wmi_device {
|
|
struct device dev;
|
|
|
|
/* True for data blocks implementing the Set Control Method */
|
|
bool setable;
|
|
};
|
|
|
|
/* evaluate the ACPI method associated with this device */
|
|
extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev,
|
|
u8 instance, u32 method_id,
|
|
const struct acpi_buffer *in,
|
|
struct acpi_buffer *out);
|
|
|
|
/* Caller must kfree the result. */
|
|
extern union acpi_object *wmidev_block_query(struct wmi_device *wdev,
|
|
u8 instance);
|
|
|
|
extern int set_required_buffer_size(struct wmi_device *wdev, u64 length);
|
|
|
|
struct wmi_device_id {
|
|
const char *guid_string;
|
|
};
|
|
|
|
struct wmi_driver {
|
|
struct device_driver driver;
|
|
const struct wmi_device_id *id_table;
|
|
|
|
int (*probe)(struct wmi_device *wdev);
|
|
int (*remove)(struct wmi_device *wdev);
|
|
void (*notify)(struct wmi_device *device, union acpi_object *data);
|
|
long (*filter_callback)(struct wmi_device *wdev, unsigned int cmd,
|
|
struct wmi_ioctl_buffer *arg);
|
|
};
|
|
|
|
extern int __must_check __wmi_driver_register(struct wmi_driver *driver,
|
|
struct module *owner);
|
|
extern void wmi_driver_unregister(struct wmi_driver *driver);
|
|
#define wmi_driver_register(driver) __wmi_driver_register((driver), THIS_MODULE)
|
|
|
|
#define module_wmi_driver(__wmi_driver) \
|
|
module_driver(__wmi_driver, wmi_driver_register, \
|
|
wmi_driver_unregister)
|
|
|
|
#endif
|