Introduce support for Dell SMBIOS over WMI
Subsystems (3)
PATCH v10 2/15 platform/x86: dell-wmi: increase severity of some failures
In reply to Mario LimoncielloThere is a lot of error checking in place for the format of the WMI descriptor buffer, but some of the potentially raised issues should be considered critical failures.
If the buffer size or header don't match, this is a good indication that the buffer format changed in a way that the rest of the data should not be relied upon.
For the remaining data set vectors, continue to notate a warning in undefined results, but as those are fields that the descriptor intended to refer to other applications, don't fail if they're new values.
--- drivers/platform/x86/dell-wmi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/platform/x86/dell-wmi.c +7 -6
@@ -657,17 +657,18 @@ static int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev)dev_err (&wdev->dev,"Dell descriptor buffer has invalid length (%d)\n" , obj->buffer.length); -if (obj->buffer.length <16 ) { - ret = -EINVAL ; - goto out; - } + ret = -EINVAL ; + goto out; } buffer = (u32 *)obj->buffer.pointer; -if (buffer[0 ] !=0x4C4C4544 && buffer[1 ] !=0x494D5720 ) -dev_warn (&wdev->dev,"Dell descriptor buffer has invalid signature (%*ph)\n" , +if (buffer[0 ] !=0x4C4C4544 && buffer[1 ] !=0x494D5720 ) { +dev_err (&wdev->dev,"Dell descriptor buffer has invalid signature (%*ph)\n" ,8 , buffer); + ret = -EINVAL ; + goto out; + }if (buffer[2 ] !=0 && buffer[2 ] !=1 ) dev_warn(&wdev->dev, "Dell descriptor buffer has unknown version (%d)\n",
Signature · 1 line
2.14.1
PATCH v10 4/15 platform/x86: dell-wmi: don't check length returned
In reply to Mario LimoncielloThis is intended to be variable and provided by the platform. Some platforms this year will be adopting a 32k WMI buffer, so don't complain when encountering those platforms or any other future changes.
--- drivers/platform/x86/dell-wmi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/platform/x86/dell-wmi.c +1 -5
@@ -624,7 +624,7 @@ static void dell_wmi_input_destroy(struct wmi_device *wdev)* Vendor Signature 0 4 "DELL" * Object Signature 4 4 " WMI" * WMI Interface Version 8 4 <version> -* WMI buffer length 12 4 4096 +* WMI buffer length 12 4 <length> */ static int dell_wmi_check_descriptor_buffer (struct wmi_device *wdev) {
@@ -674,10 +674,6 @@ static int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev)dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%lu)\n" , (unsigned long ) buffer[2 ]); -if (buffer[3 ] !=4096 ) -dev_warn (&wdev->dev,"Dell descriptor buffer has invalid buffer length (%d)\n" , - buffer[3 ]); - priv->interface_version = buffer[2 ]; ret =0 ;
Signature · 1 line
2.14.1
PATCH v10 5/15 platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own driver
In reply to Mario LimoncielloAll communication on individual GUIDs should occur in separate drivers. Allowing a driver to communicate with the bus to another GUID is just a hack that discourages drivers to adopt the bus model.
The information found from the WMI descriptor driver is now exported for use by other drivers.
--- MAINTAINERS | 5 + drivers/platform/x86/Kconfig | 5 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/dell-wmi-descriptor.c | 168 +++++++++++++++++++++++++++++ drivers/platform/x86/dell-wmi-descriptor.h | 21 ++++ drivers/platform/x86/dell-wmi.c | 80 ++------------ 6 files changed, 206 insertions(+), 74 deletions(-) create mode 100644 drivers/platform/x86/dell-wmi-descriptor.c create mode 100644 drivers/platform/x86/dell-wmi-descriptor.h
MAINTAINERS +5 -0
@@ -4013,6 +4013,11 @@ M: Pali Rohár <[email protected]> S: Maintained F: drivers/platform/x86/dell-wmi.c +DELL WMI DESCRIPTOR DRIVER +M: Mario Limonciello <[email protected]> +S: Maintained +F: drivers/platform/x86/dell-wmi-descriptor.c + DELTA ST MEDIA DRIVER M: Hugues Fruchet <[email protected]> L: [email protected]
drivers/platform/x86/Kconfig +5 -0
@@ -121,6 +121,7 @@ config DELL_WMI depends on DMI depends on INPUT depends on ACPI_VIDEO || ACPI_VIDEO = n + select DELL_WMI_DESCRIPTOR select DELL_SMBIOS select INPUT_SPARSEKMAP ---help---
@@ -129,6 +130,10 @@ config DELL_WMI To compile this driver as a module, choose M here: the module will be called dell-wmi. +config DELL_WMI_DESCRIPTOR + tristate + depends on ACPI_WMI + config DELL_WMI_AIO tristate "WMI Hotkeys for Dell All-In-One series" depends on ACPI_WMI
drivers/platform/x86/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o +obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o obj-$(CONFIG_DELL_WMI_AIO) += dell-wmi-aio.o obj-$(CONFIG_DELL_WMI_LED) += dell-wmi-led.o obj-$(CONFIG_DELL_SMO8800) += dell-smo8800.o
drivers/platform/x86/dell-wmi-descriptor.c new file +168 -0
168 lines not on this page · raw message
drivers/platform/x86/dell-wmi-descriptor.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Dell WMI descriptor driver +* +* Copyright (c) 2017 Dell Inc. +* +* 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. +*/ + +#ifndef _DELL_WMI_DESCRIPTOR_H_ +#define _DELL_WMI_DESCRIPTOR_H_ + +#include <linux/wmi.h> + +#define DELL_WMI_DESCRIPTOR_GUID "8D9DDCBC-A997-11DA-B012-B622A1EF5492" + +bool dell_wmi_get_interface_version (u32 *version); +bool dell_wmi_get_size (u32 *size); + +#endif
drivers/platform/x86/dell-wmi.c +6 -74
110 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v10 7/15 platform/x86: dell-smbios: only run if proper oem string is detected
In reply to Mario LimoncielloThe proper way to indicate that a system is a 'supported' Dell System is by the presence of this string in OEM strings.
Allowing the driver to load on non-Dell systems will have undefined results.
--- drivers/platform/x86/dell-smbios.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/dell-smbios.c +7 -0
@@ -172,8 +172,15 @@ static void __init find_tokens(const struct dmi_header *dm, void *dummy)static int __init dell_smbios_init (void ) { +const struct dmi_device *valid;int ret; + valid =dmi_find_device (DMI_DEV_TYPE_OEM_STRING ,"Dell System" ,NULL ); +if (!valid) { +pr_err ("Unable to run on non-Dell system\n" ); +return -ENODEV ; + } +dmi_walk (find_tokens,NULL );if (!da_tokens) {
Signature · 1 line
2.14.1
PATCH v10 8/15 platform/x86: dell-smbios: Add a sysfs interface for SMBIOS tokens
In reply to Mario LimoncielloCurrently userspace tools can access system tokens via the dcdbas kernel module and a SMI call that will cause the platform to execute SMM code.
With a goal in mind of deprecating the dcdbas kernel module a different method for accessing these tokens from userspace needs to be created.
This is intentionally marked to only be readable as a process with CAP_SYS_ADMIN as it can contain sensitive information about the platform's configuration.
While adding this interface I found that some tokens are duplicated. These need to be ignored from sysfs to avoid duplicate files.
MAINTAINERS was missing for this driver. Add myself and Pali to maintainers list for it.
--- .../ABI/testing/sysfs-platform-dell-smbios | 21 ++ MAINTAINERS | 7 + drivers/platform/x86/dell-smbios.c | 212 ++++++++++++++++++++- 3 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-dell-smbios
Documentation/ABI/testing/sysfs-platform-dell-smbios new file +21 -0
@@ -0,0 +1,21 @@ +What: /sys/devices/platform/<platform>/tokens/* +Date: November 2017 +KernelVersion: 4.15 +Contact: "Mario Limonciello" <[email protected]> +Description: + A read-only description of Dell platform tokens + available on the machine. + + Each token attribute is available as a pair of + sysfs attributes readable by a process with + CAP_SYS_ADMIN. + + For example the token ID "5" would be available + as the following attributes: + + 0005_location + 0005_value + + Tokens will vary from machine to machine, and + only tokens available on that machine will be + displayed.
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ M: "Maciej W. Rozycki" <[email protected]> S: Maintained F: drivers/net/fddi/defxx.* +DELL SMBIOS DRIVER +M: Pali Rohár <[email protected]> +M: Mario Limonciello <[email protected]> +L: [email protected] +S: Maintained +F: drivers/platform/x86/dell-smbios.* + DELL LAPTOP DRIVER M: Matthew Garrett <[email protected]> M: Pali Rohár <[email protected]>
drivers/platform/x86/dell-smbios.c +211 -1
257 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v10 11/15 platform/x86: dell-smbios-smm: test for WSMT
In reply to Mario LimoncielloWSMT is as an attestation to the OS that the platform won't modify memory outside of pre-defined areas.
If a platform has WSMT enabled in BIOS setup, SMM calls through dcdbas will fail. The only way to access platform data in these instances is through the WMI SMBIOS calling interface.
--- drivers/platform/x86/dell-smbios-smm.c | 33 +++++++++++++++++++++++++++++++++ drivers/platform/x86/dell-smbios.h | 2 ++ 2 files changed, 35 insertions(+)
drivers/platform/x86/dell-smbios-smm.c +33 -0
@@ -102,6 +102,31 @@ int dell_smbios_smm_call(struct calling_interface_buffer *input)return 0 ; } +/* When enabled this indicates that SMM won't work */ +static bool test_wsmt_enabled (void ) +{ +struct calling_interface_token *token; + +/* if token doesn't exist, SMM will work */ + token =dell_smbios_find_token (WSMT_EN_TOKEN ); +if (!token) +return false; + +/* if token exists, try to access over SMM */ + buffer->class =CLASS_TOKEN_READ ; + buffer->select =SELECT_TOKEN_STD ; +memset (buffer,0 ,sizeof (struct calling_interface_buffer )); + buffer->input[0 ] = token->location; +dell_smbios_smm_call (buffer); + +/* if lookup failed, we know WSMT was enabled */ +if (buffer->output[0 ] !=0 ) +return true; + +/* query token status if it didn't fail */ +return (buffer->output[1 ] == token->value); +} +static int __init dell_smbios_smm_init (void ) {int ret;
@@ -115,6 +140,13 @@ static int __init dell_smbios_smm_init(void)dmi_walk (find_cmd_address,NULL ); + ret =test_wsmt_enabled (); +pr_debug ("WSMT enable test: %d\n" , ret); +if (ret) { + ret = -ENODEV ; + goto fail_wsmt; + } + platform_device =platform_device_alloc ("dell-smbios" ,1 );if (!platform_device) { ret = -ENOMEM ;
@@ -138,6 +170,7 @@ static int __init dell_smbios_smm_init(void) fail_platform_device_add:platform_device_put (platform_device); +fail_wsmt: fail_platform_device_alloc:free_page ((unsigned long )buffer);return ret;
drivers/platform/x86/dell-smbios.h +2 -0
@@ -44,6 +44,8 @@#define KBD_LED_AUTO_100_TOKEN 0x02F6#define GLOBAL_MIC_MUTE_ENABLE 0x0364#define GLOBAL_MIC_MUTE_DISABLE 0x0365 +#define WSMT_EN_TOKEN 0x04EC +#define WSMT_DIS_TOKEN 0x04EDstruct notifier_block ;
Signature · 1 line
2.14.1
PATCH v10 13/15 platform/x86: wmi: create userspace interface for drivers
In reply to Mario LimoncielloFor 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.
--- MAINTAINERS | 1 + drivers/platform/x86/wmi.c | 206 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/wmi.h | 6 ++ include/uapi/linux/wmi.h | 26 ++++++ 4 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 include/uapi/linux/wmi.h
MAINTAINERS +1 -0
@@ -384,6 +384,7 @@ ACPI WMI DRIVER L: [email protected] S: Orphan F: drivers/platform/x86/wmi.c +F: include/uapi/linux/wmi.h AD1889 ALSA SOUND DRIVER M: Thibaut Varene <[email protected]>
drivers/platform/x86/wmi.c +204 -2
265 lines not on this page · raw message
include/linux/wmi.h +6 -0
@@ -18,6 +18,7 @@#include <linux/device.h> #include <linux/acpi.h> +#include <uapi/linux/wmi.h> struct wmi_device {struct device dev;
@@ -36,6 +37,9 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev,extern union acpi_object *wmidev_block_query (struct wmi_device *wdev,u8 instance); +extern int set_required_buffer_size (struct wmi_device *wdev,u8 instance, +u64 length); +struct wmi_device_id {const char *guid_string; };
@@ -47,6 +51,8 @@ struct wmi_driver {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,
include/uapi/linux/wmi.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* User API methods for ACPI-WMI mapping driver +* +* Copyright (C) 2017 Dell, Inc. +* +* 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. +*/ +#ifndef _UAPI_LINUX_WMI_H +#define _UAPI_LINUX_WMI_H + +#include <linux/types.h> + +/* WMI bus will filter all WMI vendor driver requests through this IOC */ +#define WMI_IOC 'W' + +/* All ioctl requests through WMI should declare their size followed by +* relevant data objects +*/ +struct wmi_ioctl_buffer { +__u64 length; +__u8 data[]; +}; + +#endif
Signature · 1 line
2.14.1
PATCH v10 14/15 platform/x86: dell-smbios-wmi: introduce userspace interface
In reply to Mario LimoncielloIt's important for the driver to provide a R/W ioctl to ensure that two competing userspace processes don't race to provide or read each others data.
This userspace character device will be used to perform SMBIOS calls from any applications.
It provides an ioctl that will allow passing the WMI calling interface buffer between userspace and kernel space.
This character device is intended to deprecate the dcdbas kernel module and the interface that it provides to userspace.
To perform an SMBIOS IOCTL call using the character device userspace will perform a read() on the the character device. The WMI bus will provide a u64 variable containing the necessary size of the IOCTL buffer.
The API for interacting with this interface is defined in documentation as well as the WMI uapi header provides the format of the structures.
Not all userspace requests will be accepted. The dell-smbios filtering functionality will be used to prevent access to certain tokens and calls.
All whitelisted commands and tokens are now shared out to userspace so applications don't need to define them in their own headers.
--- Documentation/ABI/testing/dell-smbios-wmi | 41 +++++++++++++++++++ drivers/platform/x86/dell-smbios-wmi.c | 67 ++++++++++++++++++++++++++----- drivers/platform/x86/dell-smbios.h | 32 +-------------- include/uapi/linux/wmi.h | 47 ++++++++++++++++++++++ 4 files changed, 146 insertions(+), 41 deletions(-) create mode 100644 Documentation/ABI/testing/dell-smbios-wmi
Documentation/ABI/testing/dell-smbios-wmi new file +41 -0
@@ -0,0 +1,41 @@ +What: /dev/wmi/dell-smbios +Date: November 2017 +KernelVersion: 4.15 +Contact: "Mario Limonciello" <[email protected]> +Description: + Perform SMBIOS calls on supported Dell machines. + through the Dell ACPI-WMI interface. + + IOCTL's and buffer formats are defined in: + <uapi/linux/wmi.h> + + 1) To perform an SMBIOS call from userspace, you'll need to + first determine the minimum size of the calling interface + buffer for your machine. + Platforms that contain larger buffers can return larger + objects from the system firmware. + Commonly this size is either 4k or 32k. + + To determine the size of the buffer read() a u64 dword from + the WMI character device /dev/wmi/dell-smbios. + + 2) After you've determined the minimum size of the calling + interface buffer, you can allocate a structure that represents + the structure documented above. + + 3) In the 'length' object store the size of the buffer you + determined above and allocated. + + 4) In this buffer object, prepare as necessary for the SMBIOS + call you're interested in. Typically SMBIOS buffers have + "class", "select", and "input" defined to values that coincide + with the data you are interested in. + Documenting class/select/input values is outside of the scope + of this documentation. Check with the libsmbios project for + further documentation on these values. + + 6) Run the call by using ioctl() as described in the header. + + 7) The output will be returned in the buffer object. + + 8) Be sure to free up your allocated object.
drivers/platform/x86/dell-smbios-wmi.c +56 -11
91 lines not on this page · raw message
drivers/platform/x86/dell-smbios.h +2 -30
@@ -17,23 +17,11 @@#define _DELL_SMBIOS_H_#include <linux/device.h> +#include <uapi/linux/wmi.h> -/* Classes and selects used in kernel drivers */ -#define CLASS_TOKEN_READ 0 -#define CLASS_TOKEN_WRITE 1 -#define SELECT_TOKEN_STD 0 -#define SELECT_TOKEN_BAT 1 -#define SELECT_TOKEN_AC 2 +/* Classes and selects used only in kernel drivers */ #define CLASS_KBD_BACKLIGHT 4#define SELECT_KBD_BACKLIGHT 11 -#define CLASS_FLASH_INTERFACE 7 -#define SELECT_FLASH_INTERFACE 3 -#define CLASS_ADMIN_PROP 10 -#define SELECT_ADMIN_PROP 3 -#define CLASS_INFO 17 -#define SELECT_RFKILL 11 -#define SELECT_APP_REGISTRATION 3 -#define SELECT_DOCK 22/* Tokens used in kernel drivers, any of these * should be filtered from userspace access
@@ -50,24 +38,8 @@#define GLOBAL_MIC_MUTE_ENABLE 0x0364#define GLOBAL_MIC_MUTE_DISABLE 0x0365 -/* tokens whitelisted to userspace use */ -#define CAPSULE_EN_TOKEN 0x0461 -#define CAPSULE_DIS_TOKEN 0x0462 -#define WSMT_EN_TOKEN 0x04EC -#define WSMT_DIS_TOKEN 0x04ED -struct notifier_block ; -/* This structure will be modified by the firmware when we enter -* system management mode, hence the volatiles */ - -struct calling_interface_buffer { -u16 class; -u16 select; -volatile u32 input[4 ]; -volatile u32 output[4 ]; -} __packed; -struct calling_interface_token {u16 tokenID;u16 location;
include/uapi/linux/wmi.h +47 -0
57 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v10 15/15 tools/wmi: add a sample for dell smbios communication over WMI
In reply to Mario LimoncielloThis application uses the character device /dev/wmi/dell-smbios to perform SMBIOS communications from userspace.
It offers demonstrations of a few simple tasks:
- Running a class/select command
- Querying a token value
- Activating a token
--- MAINTAINERS | 1 + tools/Makefile | 14 +-- tools/wmi/Makefile | 18 ++++ tools/wmi/dell-smbios-example.c | 210 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 tools/wmi/Makefile create mode 100644 tools/wmi/dell-smbios-example.c
MAINTAINERS +1 -0
@@ -3997,6 +3997,7 @@ M: Mario Limonciello <[email protected]> L: [email protected] S: Maintained F: drivers/platform/x86/dell-smbios-wmi.c +F: tools/wmi/dell-smbios-example.c DELL LAPTOP DRIVER M: Matthew Garrett <[email protected]>
tools/Makefile +8 -6
@@ -29,6 +29,7 @@ help: @echo ' usb - USB testing tools' @echo ' virtio - vhost test module' @echo ' vm - misc vm tools' + @echo ' wmi - WMI interface examples' @echo ' x86_energy_perf_policy - Intel energy policy tool' @echo '' @echo 'You can do:'
@@ -57,7 +58,7 @@ acpi: FORCE cpupower: FORCE $(call descend,power/$@) -cgroup firewire hv guest spi usb virtio vm net iio gpio objtool leds: FORCE +cgroup firewire hv guest spi usb virtio vm net iio gpio objtool leds wmi: FORCE $(call descend,$@) liblockdep: FORCE
@@ -92,7 +93,7 @@ kvm_stat: FORCE all: acpi cgroup cpupower gpio hv firewire liblockdep \ perf selftests spi turbostat usb \ virtio vm net x86_energy_perf_policy \ - tmon freefall iio objtool kvm_stat + tmon freefall iio objtool kvm_stat wmi acpi_install: $(call descend,power/$(@:_install=),install)
@@ -100,7 +101,7 @@ acpi_install: cpupower_install: $(call descend,power/$(@:_install=),install) -cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install: +cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install wmi_install: $(call descend,$(@:_install=),install) liblockdep_install:
@@ -125,7 +126,8 @@ install: acpi_install cgroup_install cpupower_install gpio_install \ hv_install firewire_install iio_install liblockdep_install \ perf_install selftests_install turbostat_install usb_install \ virtio_install vm_install net_install x86_energy_perf_policy_install \ - tmon_install freefall_install objtool_install kvm_stat_install + tmon_install freefall_install objtool_install kvm_stat_install \ + wmi_install acpi_clean: $(call descend,power/acpi,clean)
@@ -133,7 +135,7 @@ acpi_clean: cpupower_clean: $(call descend,power/cpupower,clean) -cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean net_clean iio_clean gpio_clean objtool_clean leds_clean: +cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean net_clean iio_clean gpio_clean objtool_clean leds_clean: $(call descend,$(@:_clean=),clean) liblockdep_clean:
@@ -171,6 +173,6 @@ clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \ perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \ vm_clean net_clean iio_clean x86_energy_perf_policy_clean tmon_clean \ freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \ - gpio_clean objtool_clean leds_clean + gpio_clean objtool_clean leds_clean wmi_clean .PHONY: FORCE
tools/wmi/Makefile new file +18 -0
@@ -0,0 +1,18 @@ +PREFIX ?= /usr +SBINDIR ?= sbin +INSTALL ?= install +CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include +CC = $(CROSS_COMPILE)gcc + +TARGET = dell-smbios-example + +all: $(TARGET) + +%: %.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +clean: + $(RM) $(TARGET) + +install: dell-smbios-example + $(INSTALL) -D -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/$(SBINDIR)/$(TARGET)
tools/wmi/dell-smbios-example.c new file +210 -0
210 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v10 3/15 platform/x86: dell-wmi: clean up wmi descriptor check
In reply to Mario LimoncielloSome cases the wrong type was used for errors and checks can be done more cleanly.
--- drivers/platform/x86/dell-wmi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/platform/x86/dell-wmi.c +5 -5
@@ -663,16 +663,16 @@ static int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev) buffer = (u32 *)obj->buffer.pointer; -if (buffer[0 ] !=0x4C4C4544 && buffer[1 ] !=0x494D5720 ) { -dev_err (&wdev->dev,"Dell descriptor buffer has invalid signature (%*ph)\n" , -8 , buffer); +if (strncmp (obj->string.pointer,"DELL WMI" ,8 ) !=0 ) { +dev_err (&wdev->dev,"Dell descriptor buffer has invalid signature (%8ph)\n" , + buffer); ret = -EINVAL ; goto out; }if (buffer[2 ] !=0 && buffer[2 ] !=1 ) -dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%d)\n" , - buffer[2 ]); +dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%lu)\n" , + (unsigned long ) buffer[2 ]);if (buffer[3 ] !=4096 ) dev_warn(&wdev->dev, "Dell descriptor buffer has invalid buffer length (%d)\n",
Signature · 1 line
2.14.1
PATCH v10 1/15 platform/x86: wmi: Add new method wmidev_evaluate_method
In reply to Mario LimoncielloDrivers properly using the wmibus can pass their wmi_device pointer rather than the GUID back to the WMI bus to evaluate the proper methods.
Any "new" drivers added that use the WMI bus should use this rather than the old wmi_evaluate_method that would take the GUID.
--- drivers/platform/x86/wmi.c | 28 ++++++++++++++++++++++++---- include/linux/wmi.h | 6 ++++++ 2 files changed, 30 insertions(+), 4 deletions(-)
drivers/platform/x86/wmi.c +24 -4
@@ -200,6 +200,28 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)*/ acpi_status wmi_evaluate_method (const char *guid_string,u8 instance,u32 method_id,const struct acpi_buffer *in,struct acpi_buffer *out) +{ +struct wmi_block *wblock =NULL ; + +if (!find_guid (guid_string, &wblock)) +return AE_ERROR ; +return wmidev_evaluate_method (&wblock->dev, instance, method_id, + in, out); +} +EXPORT_SYMBOL_GPL (wmi_evaluate_method); + +/** +* wmidev_evaluate_method - Evaluate a WMI method +* @wdev: A wmi bus device from a driver +* @instance: Instance index +* @method_id: Method ID to call +* &in: Buffer containing input for the method call +* &out: Empty buffer to return the method results +* +* Call an ACPI-WMI method +*/ +acpi_status wmidev_evaluate_method (struct wmi_device *wdev,u8 instance, +u32 method_id,const struct acpi_buffer *in,struct acpi_buffer *out) {struct guid_block *block =NULL ;struct wmi_block *wblock =NULL ;
@@ -209,9 +231,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)union acpi_object params[3 ];char method[5 ] ="WM" ; -if (!find_guid (guid_string, &wblock)) -return AE_ERROR ; - + wblock = container_of(wdev, struct wmi_block, dev); block = &wblock->gblock; handle = wblock->acpi_device->handle;
@@ -246,7 +266,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)return status; } -EXPORT_SYMBOL_GPL (wmi_evaluate_method); +EXPORT_SYMBOL_GPL (wmidev_evaluate_method);static acpi_status __query_block (struct wmi_block *wblock,u8 instance,struct acpi_buffer *out)
include/linux/wmi.h +6 -0
@@ -26,6 +26,12 @@ struct wmi_device {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);
Signature · 1 line
2.14.1
PATCH v10 6/15 platform/x86: wmi: Don't allow drivers to get each other's GUIDs
In reply to Mario LimoncielloThe only driver using this was dell-wmi, and it really was a hack. The driver was getting a data attribute from another driver and this type of action should not be encouraged.
Rather drivers that need to interact with one another should pass data back and forth via exported functions.
--- drivers/platform/x86/wmi.c | 17 ----------------- include/linux/wmi.h | 4 ---- 2 files changed, 21 deletions(-)
drivers/platform/x86/wmi.c +0 -17
@@ -368,23 +368,6 @@ union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance) }EXPORT_SYMBOL_GPL (wmidev_block_query); -struct wmi_device *wmidev_get_other_guid (struct wmi_device *wdev, -const char *guid_string) -{ - struct wmi_block *this_wb = container_of(wdev, struct wmi_block, dev); -struct wmi_block *other_wb; - -if (!find_guid (guid_string, &other_wb)) -return NULL ; - -if (other_wb->acpi_device != this_wb->acpi_device) -return NULL ; - -get_device (&other_wb->dev.dev); -return &other_wb->dev; -} -EXPORT_SYMBOL_GPL (wmidev_get_other_guid); -/** * wmi_set_block - Write to a WMI block * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
include/linux/wmi.h +0 -4
@@ -36,10 +36,6 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev,extern union acpi_object *wmidev_block_query (struct wmi_device *wdev,u8 instance); -/* Gets another device on the same bus. Caller must put_device the result. */ -extern struct wmi_device *wmidev_get_other_guid (struct wmi_device *wdev, -const char *guid_string); -struct wmi_device_id {const char *guid_string; };
Signature · 1 line
2.14.1
v10 cover Introduce support for Dell SMBIOS over WMI
The existing way that the dell-smbios helper module and associated other drivers (dell-laptop, dell-wmi) communicate with the platform really isn't secure. It requires creating a buffer in physical DMA32 memory space and passing that to the platform via SMM.
Since the platform got a physical memory pointer, you've just got to trust that the platform has only modified (and accessed) memory within that buffer.
Dell Platform designers recognize this security risk and offer a safer way to communicate with the platform over ACPI. This is in turn exposed via a WMI interface to the OS.
When communicating over WMI-ACPI the communication doesn't occur with physical memory pointers. When the ASL is invoked, the fixed length ACPI buffer is copied to a small operating region. The ASL will invoke the SMI, and SMM will only have access to this operating region. When the ASL returns the buffer is copied back for the OS to process.
This method of communication should also deprecate the usage of the dcdbas kernel module and software dependent upon it's interface. Instead offer a character device interface for communicating with this ASL method to allow userspace to use instead.
To faciliate that this patch series introduces a generic way for WMI drivers to be able to create discoverable character devices with a predictable IOCTL interface through the WMI bus when desired. Requiring WMI drivers to explicitly ask for this functionality will act as an effective vendor whitelist to character device creation.
Some of this work is the basis for what will be a proper interpreter of MOF in the kernel and controls for what drivers will be able to do with that MOF.
NOTE: This patch series is intended to go on top of platform-drivers-x86 linux-next.
For convenience the entire series including those is also available here:
https://github.com/dell/linux/tree/wmi-smbios
changes between v9 and v10:
* Add reviewed by from Pali & Edward to applicable patches
* Patch 3/7 (cleanup descriptor check)
- Cast u32 to unsigned long when displaying error
* Patch 4/7 (allow 32k return size)
- Adjust not to show warnings when return size is unexpected
* Patch 5/7 (split dell-wmi in two)
- Use wmi_has_guid to make sure DELL_WMI_DESCRIPTOR_GUID is on the WMI bus during probing.
Prevents situations that firmware doesn't have descriptor GUID available.
- Use a mutex to prevent race conditions.
* Patch 10/17 (Add new WMI dispatcher)
- Grab mutex earlier to avoid race condition
- Use wmi_has_guid to make sure DELL_WMI_DESCRIPTOR_GUID is on the WMI bus during probing.
Prevents situations that firmware doesn't have descriptor GUID available.
* Patch 11/17 (WSMT patch):
- Return boolean instead of int
* Patch 13/17 (required_buffer_size patch)
- Merge with patch 14/17
* Patch 14/17 (WMI character device patch)
- Don't offer required_buffer_size over sysfs. Offer the data provided when read() from character device instead.
- Switch from offering an ioctl callback method to a filter callback method. The copying to/from userspace is now handled by the bus driver and generic for all vendor drivers. This simplifies the amount of code needed in a vendor driver callback.
- Allocate memory for the ioctl call when creating character device
- Add locking to the ioctl function
- Remove existing Reviewed by as this has changed significantly
* Patch 15/17 (Offer dell character device patch)
- Update documentation for changes in 14/17
- Update callback method for changes in 14/17
* Patch 16/17 (shuffle header content)
- Merge into patch 15/17
* Patch 17/17 (sample tool)
- Use the new read() interface from 14/17
changes between v8 and v9:
* Add Reviewed by from Edward to relevant patches
* Add a new patch that introduces an example tool for using character device API.
- Recommended by Pali
* wmi bus character patch
- Add a missing #ifdef CONFIG_COMPAT caught by kbuild bot
* dell smbios tokens patch:
- Add missing #include <linux/compatability.h> caught by kbuild bot.
* dell smbios smm patch:
- Remove unnecessary semicolons caught by kbuild bot.
- Add missing header caught by kbuild bot.
changes between v7 and v8:
* fix typo s/desc_buffer/buffer/ in 32k split commit
* Add missing include for <linux/types.h> in uapi
* dell-smbios: initialize correct attribute files
* Output class/select in debug messages in base 10.
* Don't send the u64 length argument to ACPI call length
* Only filter calls that originate from userspace
* Filter kernel calls from userspace
* Add more blacklisting/whitelisting logic per Alan Cox's recommendations
* Adjust tokens attributes to only be accessible to CAP_SYS_ADMIN
* Set default permissions on character device.
* Move token, class, select definitions for items used in drivers to dells-smios.h.
changes between v6 and v7:
* Use deferred probing in any function results needed from dell-wmi-descriptor
* Protect against a list entry disappearing when running an ioctl from WMI bus
* Move ioctl uapi declaration into a common header file for all WMI drivers.
* New patch: create required_buffer_size for method type WMI objects in WMI core rather than vendor driver.
* WSMT patch: Add comment explaining WSMT
* Filtering patch: Add comments explaining what I can about blacklists.
* WMI, dell-smbios-wmi: Add back in compat ioctl, it is needed. My previous test was erroneous in forgetting to copy an updated header into the chroot.
* dell-laptop, dell-wmi: allocate less memory for buffer, page no longer needed
* dell-laptop make the changes (hopefully) more amenable to pali style wise.
* read SMM cmd address in dell-smbios-smm rather than dell-smbios
* shuffle structure definitions for this
changes between v5 and v6:
* Adjust Kconfig for dell-smbios to not depend on anything.
- SMM and WMI drivers will both select dell-smbios
- Technically the module can run on it's own (it's just not useful)
* Add a new tokens sysfs interface
* Rework blacklisting into easily expandable structures
* Lock modules during ioctl call from WMI bus
* drop references to compat ioctl in both WMI and dell-smbios-wmi drivers. (Made sure ioctl worked in both 32 and 64 userspace though)
* dell-smbios-wmi
- s/buffer_size/req_buf_size/ to make it clearer that userspace doesn't get to set this, it's set internally.
- read just buffer length before reading whole structure from userspace
- if buffer length is too big, show a warning
- I tried to rename argument for unlocked_ioctl, but this caused problems in matching initialization lists, so still casting.
- Add comments clarifying everything happening in ioctl
changes between v4 and v5:
* Remove Andy's S suggested by in sysfs tokens patch
* Make some output in dell-wmi-descriptor debug only
* Adjust various Kconfig dependencies as recommended by Darren
* Drop patch to set dell-smbios to default on ACPI_WMI,
it's not needed after the Kconfig dependencies rework
* Move WSMT check patch to after WMI driver is introduced.
* Make common smbios call return value int as there could be errors now with drivers not being loaded.
* Make SMBIOS call methods for all drivers return status
* Reorder patches 2 and 4.
* Don't export symbols for calling functions on dispatchers
* wmi patch:
- use sprintf instead of strcpy
- remove needless bool for tracking found
- adjust logic to look for instance_count - 1, it's zero based not 1 based.
- Pass a callback to unlocked_ioctl instead of full file operations object
- ioctl: Don't fail on no bound WMI driver
- Add missing header for uapi
- Make helper macros include data types
- add compat ioctl
* dell-smbios:
- Add filtering functionality for SMBIOS calling interface
- Use dev_dbg rather than pr_debug where possible
* dell-smbios-wmi:
- test for handle on b1 table
- correct misc flags comment
- drop access checks
- use dev_dbg instead of pr_* calls
- use filtering functionality
- add mutexes around list add/remove
- switch from get_first_device to get_first_priv and inline
- add mutex locking to prevent unloading mid-call.
- update to new ioctl passing
- fix userspace uapi to use __u32 instead of u32
- Don't use a header file for internal only use
- make sure it works with compat ioctl
* dell-laptop: make dell_smbios_send_request local function for boilerplate calls.
* ioctl patch
- Change API to have a simpler structure to pass back and forth
- Rename header file
- Export to sysfs properly
- Add the size of the length variable into the requested buffersize to sysfs, do math in the driver when copying data around.
changes between v3 and v4:
* Make Dell WMI notifications driver fail notifications fail when WMI descriptor driver is unavailable.
* Add a patch to check for Dell OEM string to stop dell-smbios module from being loaded in unsupported systems manually.
* Split Dell WMI descriptor into it's own driver for others to query.
* Test the misc BIOS flags table to decide whether to run in WMI or SMI mode.
* s/dell-wmi-smbios/dell-smbios/ in a few patch titles
* Add missing Suggested-by to a patch from v2 (Sorry Andy S!)
* Adjust cleanup order of wmi character device.
* Fix a remaining reference to /dev/wmi-$driver
* Use get_order to get size for pages
* Split up dell-smbios into 3 drivers:
dell-smbios
-> dell-smbios-smm
-> dell-smbios-wmi
If either of the two dispatcher drivers is unloaded but the other still works, gracefully fall back to that driver
* Remove unneded open and release on file operations in WMI driver
* Switch to misc character device in WMI bus.
* Query the size of the calling interface buffer from WMI descriptor driver.
* Require userspace to use this information to build an appropriately sized buffer.
* Verify the size of buffer passed from userspace matches expectation of buffer processed in kernel.
* Add more documentation about the IOCTL API.
* Add in a recommendation from Andy S about outputing tokens
* Add a patch to test for non-functional SMM due to WSMT
* Define macros for IOCTL's through the WMI bus.
* Pass all IOCTL calls for WMI drivers through WMI bus
WMI bus will guarantee instance count matches and prevent creating too many more IOCTLs.
changes between v2 and v3:
* Drop patches 1-7, they're in Darren's review tree now
* Add missing newline on new Documentation
* Add Reviewed by from Edward O'Callaghan
* Adjust path of character device from /dev/wmi-$driver to /dev/wmi/$driver
* Store wmi_device pointer rather than using a boolean has_wmi to indicate driver is running in WMI mode
* Don't guard free_page from freeing NULL (this is OK)
* New patch: add wmidev_evaluate_method to wmi bus as recommended by Andy L
* Adjust ACPI-WMI interface for this patch change ^
* Add back in sysfs token patch, drop 2nd and 3rd ioctls per discussion on mailing list.
* On sysfs interface: adjust the delimiter to be tabs
* Drop the rename dell-smbios -> dell-wmi-smbios patch
* Remove/move some unnecessary tests for CONFIG_DCDBAS
* Reword s/platform/SMM/ in the WMI-ACPI patch.
* Update Kconfig to recommend using CONFIG_DCDBAS on old machines.
* Allocate buffer to the same pointer regardless of the struct assigned to it. Keep track of the buffer size for cleaning up.
* Explain policy around character device creation in commit message
changes between v1 and v2:
* Introduce another patch to sort the includes in wmi.c
* Introduce another patch to cleanup dell_wmi_check_descriptor_buffer checks.
* Add a commit message to the pr_fmt commit
* Introduce includes to wmi.c in proper location
* Add Reviewed-by to relevant patches from Pali
* Make the WMI introduction patch fallback to legacy SMI
if compiled with CONFIG_DCDBAS
* Separate format of WMI and SMI buffers. WMI buffer supports more arguments and data.
* Adjust the rename patch for changes to fallback
* Drop sysfs token creation patch
* Adjust WMI descriptor check patch for changes to fallback
* introduce another patch to remove needless includes in dell-smbios.c
* Add token ioctl interface to character device.
- Can query number of tokens
- Can query values in all tokens
* Expose format of all buffers and IOCTL commands to uapi header
* Drop the read interface from character device. It doesn't make sense with multiple different ioctl methods.
* Default WMI interface to 32k (This would normally be queried via MOF, but that's not possible yet)
* Create separate buffers for WMI and SMI. If WMI is available, free the SMI buffer.
* Reorder patches so all fixups come first in the series.
Mario Limonciello (15):
platform/x86: wmi: Add new method wmidev_evaluate_method platform/x86: dell-wmi: increase severity of some failures platform/x86: dell-wmi: clean up wmi descriptor check platform/x86: dell-wmi: don't check length returned platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own
driver
platform/x86: wmi: Don't allow drivers to get each other's GUIDs platform/x86: dell-smbios: only run if proper oem string is detected platform/x86: dell-smbios: Add a sysfs interface for SMBIOS tokens platform/x86: dell-smbios: Introduce dispatcher for SMM calls platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver platform/x86: dell-smbios-smm: test for WSMT
platform/x86: dell-smbios: Add filtering support platform/x86: wmi: create userspace interface for drivers platform/x86: dell-smbios-wmi: introduce userspace interface tools/wmi: add a sample for dell smbios communication over WMI
Documentation/ABI/testing/dell-smbios-wmi | 41 ++ .../ABI/testing/sysfs-platform-dell-smbios | 21 + MAINTAINERS | 26 ++ drivers/platform/x86/Kconfig | 34 +- drivers/platform/x86/Makefile | 3 + drivers/platform/x86/dell-laptop.c | 283 +++++------- drivers/platform/x86/dell-smbios-smm.c | 196 ++++++++ drivers/platform/x86/dell-smbios-wmi.c | 281 +++++++++++ drivers/platform/x86/dell-smbios.c | 512 +++++++++++++++++++-- drivers/platform/x86/dell-smbios.h | 49 +- drivers/platform/x86/dell-wmi-descriptor.c | 168 +++++++ drivers/platform/x86/dell-wmi-descriptor.h | 21 + drivers/platform/x86/dell-wmi.c | 94 +--- drivers/platform/x86/wmi.c | 251 +++++++++- include/linux/wmi.h | 14 +- include/uapi/linux/wmi.h | 73 +++ tools/Makefile | 14 +- tools/wmi/Makefile | 18 + tools/wmi/dell-smbios-example.c | 210 +++++++++ 19 files changed, 1951 insertions(+), 358 deletions(-) create mode 100644 Documentation/ABI/testing/dell-smbios-wmi create mode 100644 Documentation/ABI/testing/sysfs-platform-dell-smbios create mode 100644 drivers/platform/x86/dell-smbios-smm.c create mode 100644 drivers/platform/x86/dell-smbios-wmi.c create mode 100644 drivers/platform/x86/dell-wmi-descriptor.c create mode 100644 drivers/platform/x86/dell-wmi-descriptor.h create mode 100644 include/uapi/linux/wmi.h create mode 100644 tools/wmi/Makefile create mode 100644 tools/wmi/dell-smbios-example.c
Signature · 1 line
2.14.1
PATCH v10 10/15 platform/x86: dell-smbios-wmi: Add new WMI dispatcher driver
The dell-smbios stack only currently uses an SMI interface which grants direct access to physical memory to the firmware SMM methods via a pointer.
This dispatcher driver adds a WMI-ACPI interface that is detected by WMI probe and preferred over the SMI interface in dell-smbios.
Changing this to operate over WMI-ACPI will use an ACPI OperationRegion for a buffer of data storage when SMM calls are performed.
This is a safer approach to use in kernel drivers as the SMM will only have access to that OperationRegion.
--- MAINTAINERS | 6 + drivers/platform/x86/Kconfig | 14 ++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/dell-smbios-wmi.c | 236 +++++++++++++++++++++++++++++++++ 4 files changed, 257 insertions(+) create mode 100644 drivers/platform/x86/dell-smbios-wmi.c
MAINTAINERS +6 -0
@@ -3991,6 +3991,12 @@ L: [email protected] S: Maintained F: drivers/platform/x86/dell-smbios-smm.c +DELL SMBIOS WMI DRIVER +M: Mario Limonciello <[email protected]> +L: [email protected] +S: Maintained +F: drivers/platform/x86/dell-smbios-wmi.c + DELL LAPTOP DRIVER M: Matthew Garrett <[email protected]> M: Pali Rohár <[email protected]>
drivers/platform/x86/Kconfig +14 -0
@@ -94,6 +94,20 @@ config ASUS_LAPTOP config DELL_SMBIOS tristate +config DELL_SMBIOS_WMI + tristate "Dell SMBIOS calling interface (WMI implementation)" + depends on ACPI_WMI + select DELL_WMI_DESCRIPTOR + default ACPI_WMI + select DELL_SMBIOS + ---help--- + This provides an implementation for the Dell SMBIOS calling interface + communicated over ACPI-WMI. + + If you have a Dell computer from >2007 you should say Y or M here. + If you aren't sure and this module doesn't work for your computer + it just won't load. + config DELL_SMBIOS_SMM tristate "Dell SMBIOS calling interface (SMM implementation)" depends on DCDBAS
drivers/platform/x86/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o +obj-$(CONFIG_DELL_SMBIOS_WMI) += dell-smbios-wmi.o obj-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o
drivers/platform/x86/dell-smbios-wmi.c new file +236 -0
236 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v10 9/15 platform/x86: dell-smbios: Introduce dispatcher for SMM calls
In reply to Mario LimoncielloThis splits up the dell-smbios driver into two drivers:
* dell-smbios
* dell-smbios-smm
dell-smbios can operate with multiple different dispatcher drivers to perform SMBIOS operations.
Also modify the interface that dell-laptop and dell-wmi use align to this model more closely. Rather than a single global buffer being allocated for all drivers, each driver will allocate and be responsible for it's own buffer. The pointer will be passed to the calling function and each dispatcher driver will then internally copy it to the proper location to perform it's call.
Add defines for calls used by these methods in the dell-smbios.h header for tracking purposes.
--- MAINTAINERS | 6 + drivers/platform/x86/Kconfig | 15 +- drivers/platform/x86/Makefile | 1 + drivers/platform/x86/dell-laptop.c | 283 ++++++++++++--------------------- drivers/platform/x86/dell-smbios-smm.c | 163 +++++++++++++++++++ drivers/platform/x86/dell-smbios.c | 121 +++++++------- drivers/platform/x86/dell-smbios.h | 46 +++++- drivers/platform/x86/dell-wmi.c | 11 +- 8 files changed, 398 insertions(+), 248 deletions(-) create mode 100644 drivers/platform/x86/dell-smbios-smm.c
MAINTAINERS +6 -0
@@ -3985,6 +3985,12 @@ L: [email protected] S: Maintained F: drivers/platform/x86/dell-smbios.* +DELL SMBIOS SMM DRIVER +M: Mario Limonciello <[email protected]> +L: [email protected] +S: Maintained +F: drivers/platform/x86/dell-smbios-smm.c + DELL LAPTOP DRIVER M: Matthew Garrett <[email protected]> M: Pali Rohár <[email protected]>
drivers/platform/x86/Kconfig +11 -4
@@ -93,12 +93,19 @@ config ASUS_LAPTOP config DELL_SMBIOS tristate - select DCDBAS + +config DELL_SMBIOS_SMM + tristate "Dell SMBIOS calling interface (SMM implementation)" + depends on DCDBAS + default DCDBAS + select DELL_SMBIOS ---help--- - This module provides common functions for kernel modules using - Dell SMBIOS. + This provides an implementation for the Dell SMBIOS calling interface + communicated over SMI/SMM. - If you have a Dell laptop, say Y or M here. + If you have a Dell computer from <=2017 you should say Y or M here. + If you aren't sure and this module doesn't work for your computer + it just won't load. config DELL_LAPTOP tristate "Dell Laptop Extras"
drivers/platform/x86/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o obj-$(CONFIG_DELL_SMBIOS) += dell-smbios.o +obj-$(CONFIG_DELL_SMBIOS_SMM) += dell-smbios-smm.o obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o obj-$(CONFIG_DELL_WMI) += dell-wmi.o obj-$(CONFIG_DELL_WMI_DESCRIPTOR) += dell-wmi-descriptor.o
drivers/platform/x86/dell-laptop.c +105 -178
538 lines not on this page · raw message
drivers/platform/x86/dell-smbios-smm.c new file +163 -0
163 lines not on this page · raw message
drivers/platform/x86/dell-smbios.c +64 -57
192 lines not on this page · raw message
drivers/platform/x86/dell-smbios.h +41 -5
59 lines not on this page · raw message
drivers/platform/x86/dell-wmi.c +7 -4
@@ -638,13 +638,16 @@ static int dell_wmi_events_set_enabled(bool enable)struct calling_interface_buffer *buffer;int ret; - buffer =dell_smbios_get_buffer (); + buffer =kzalloc (sizeof (struct calling_interface_buffer ),GFP_KERNEL ); + buffer->class =CLASS_INFO ; + buffer->select =SELECT_APP_REGISTRATION ; buffer->input[0 ] =0x10000 ; buffer->input[1 ] =0x51534554 ; buffer->input[3 ] = enable; -dell_smbios_send_request (17 ,3 ); - ret = buffer->output[0 ]; -dell_smbios_release_buffer (); + ret =dell_smbios_call (buffer); +if (ret ==0 ) + ret = buffer->output[0 ]; +kfree (buffer);return dell_smbios_error (ret); }
Signature · 1 line
2.14.1
PATCH v10 12/15 platform/x86: dell-smbios: Add filtering support
In reply to Mario LimoncielloWhen a userspace interface is introduced to dell-smbios filtering support will be used to make sure that userspace doesn't make calls deemed unsafe or that can cause the kernel drivers to get out of sync.
A blacklist is provided for the following:
- Items that are in use by other kernel drivers
- Items that are deemed unsafe (diagnostics, write-once, etc)
- Any items in the blacklist will be rejected.
Following that a whitelist is provided as follows:
- Each item has an associated capability. If a userspace interface accesses this item, that capability will be tested to filter the request.
- If the process provides CAP_SYS_RAWIO the whitelist will be overridden.
When an item is not in the blacklist, or whitelist and the process is run with insufficient capabilities the call will be rejected.
--- drivers/platform/x86/dell-smbios.c | 190 +++++++++++++++++++++++++++++++++++++ drivers/platform/x86/dell-smbios.h | 11 +++ 2 files changed, 201 insertions(+)
drivers/platform/x86/dell-smbios.c +190 -0
@@ -24,6 +24,7 @@#include <linux/slab.h> #include "dell-smbios.h" +static u32 da_supported_commands;static int da_num_tokens;static struct platform_device *platform_device;static struct calling_interface_token *da_tokens;
@@ -38,6 +39,91 @@ struct smbios_device {int (*call_fn)(struct calling_interface_buffer *); }; +struct smbios_call { +u32 need_capability; +int class; +int select; +}; + +/* calls that are whitelisted for given capabilities */ +static struct smbios_call call_whitelist[] = { +/* generally tokens are allowed, but may be further filtered or +* restricted by token blacklist or whitelist +*/ + {CAP_SYS_ADMIN ,CLASS_TOKEN_READ ,SELECT_TOKEN_STD }, + {CAP_SYS_ADMIN ,CLASS_TOKEN_READ ,SELECT_TOKEN_AC }, + {CAP_SYS_ADMIN ,CLASS_TOKEN_READ ,SELECT_TOKEN_BAT }, + {CAP_SYS_ADMIN ,CLASS_TOKEN_WRITE ,SELECT_TOKEN_STD }, + {CAP_SYS_ADMIN ,CLASS_TOKEN_WRITE ,SELECT_TOKEN_AC }, + {CAP_SYS_ADMIN ,CLASS_TOKEN_WRITE ,SELECT_TOKEN_BAT }, +/* used by userspace: fwupdate */ + {CAP_SYS_ADMIN ,CLASS_ADMIN_PROP ,SELECT_ADMIN_PROP }, +/* used by userspace: fwupd */ + {CAP_SYS_ADMIN ,CLASS_INFO ,SELECT_DOCK }, + {CAP_SYS_ADMIN ,CLASS_FLASH_INTERFACE ,SELECT_FLASH_INTERFACE }, +}; + +/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ + {0x0000 ,11 ,11 },/* write once */ + {0x0000 ,19 ,-1 },/* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000 ,CLASS_INFO ,SELECT_RFKILL }, + {0x0000 ,CLASS_KBD_BACKLIGHT ,SELECT_KBD_BACKLIGHT }, +}; + +struct token_range { +u32 need_capability; +u16 min; +u16 max; +}; + +/* tokens that are whitelisted for given capabilities */ +static struct token_range token_whitelist[] = { +/* used by userspace: fwupdate */ + {CAP_SYS_ADMIN ,CAPSULE_EN_TOKEN ,CAPSULE_DIS_TOKEN }, +/* can indicate to userspace that WMI is needed */ + {0x0000 ,WSMT_EN_TOKEN ,WSMT_DIS_TOKEN } +}; + +/* tokens that are explicitly blacklisted */ +static struct token_range token_blacklist[] = { + {0x0000 ,0x0058 ,0x0059 },/* ME use */ + {0x0000 ,0x00CD ,0x00D0 },/* raid shadow copy */ + {0x0000 ,0x013A ,0x01FF },/* sata shadow copy */ + {0x0000 ,0x0175 ,0x0176 },/* write once */ + {0x0000 ,0x0195 ,0x0197 },/* diagnostics */ + {0x0000 ,0x01DC ,0x01DD },/* manufacturing use */ + {0x0000 ,0x027D ,0x0284 },/* diagnostics */ + {0x0000 ,0x02E3 ,0x02E3 },/* manufacturing use */ + {0x0000 ,0x02FF ,0x02FF },/* manufacturing use */ + {0x0000 ,0x0300 ,0x0302 },/* manufacturing use */ + {0x0000 ,0x0325 ,0x0326 },/* manufacturing use */ + {0x0000 ,0x0332 ,0x0335 },/* fan control */ + {0x0000 ,0x0350 ,0x0350 },/* manufacturing use */ + {0x0000 ,0x0363 ,0x0363 },/* manufacturing use */ + {0x0000 ,0x0368 ,0x0368 },/* manufacturing use */ + {0x0000 ,0x03F6 ,0x03F7 },/* manufacturing use */ + {0x0000 ,0x049E ,0x049F },/* manufacturing use */ + {0x0000 ,0x04A0 ,0x04A3 },/* disagnostics */ + {0x0000 ,0x04E6 ,0x04E7 },/* manufacturing use */ + {0x0000 ,0x4000 ,0x7FFF },/* internal BIOS use */ + {0x0000 ,0x9000 ,0x9001 },/* internal BIOS use */ + {0x0000 ,0xA000 ,0xBFFF },/* write only */ + {0x0000 ,0xEFF0 ,0xEFFF },/* internal BIOS use */ +/* handled by kernel: dell-laptop */ + {0x0000 ,BRIGHTNESS_TOKEN ,BRIGHTNESS_TOKEN }, + {0x0000 ,KBD_LED_OFF_TOKEN ,KBD_LED_AUTO_TOKEN }, + {0x0000 ,KBD_LED_AC_TOKEN ,KBD_LED_AC_TOKEN }, + {0x0000 ,KBD_LED_AUTO_25_TOKEN ,KBD_LED_AUTO_75_TOKEN }, + {0x0000 ,KBD_LED_AUTO_100_TOKEN ,KBD_LED_AUTO_100_TOKEN }, + {0x0000 ,GLOBAL_MIC_MUTE_ENABLE ,GLOBAL_MIC_MUTE_DISABLE }, +}; +static LIST_HEAD (smbios_device_list);int dell_smbios_error (int value)
@@ -90,6 +176,108 @@ void dell_smbios_unregister_device(struct device *d) }EXPORT_SYMBOL_GPL (dell_smbios_unregister_device); +int dell_smbios_call_filter (struct device *d, +struct calling_interface_buffer *buffer) +{ +u16 t =0 ; +int i; + +/* can't make calls over 30 */ +if (buffer->class >30 ) { +dev_dbg (d,"class too big: %u\n" , buffer->class); +return -EINVAL ; + } + +/* supported calls on the particular system */ +if (!(da_supported_commands & (1 << buffer->class))) { +dev_dbg (d,"invalid command, supported commands: 0x%8x\n" , + da_supported_commands); +return -EINVAL ; + } + +/* match against call blacklist */ +for (i =0 ; i <ARRAY_SIZE (call_blacklist); i++) { +if (buffer->class != call_blacklist[i].class) +continue ; +if (buffer->select != call_blacklist[i].select && + call_blacklist[i].select !=-1 ) +continue ; +dev_dbg (d,"blacklisted command: %u/%u\n" , + buffer->class, buffer->select); +return -EINVAL ; + } + +/* if a token call, find token ID */ +if ((buffer->class ==CLASS_TOKEN_READ && buffer->select <3 ) || + (buffer->class ==CLASS_TOKEN_WRITE && buffer->select <3 )) { +/* find the matching token ID */ +for (i =0 ; i < da_num_tokens; i++) { +if (da_tokens[i].location != buffer->input[0 ]) +continue ; + t = da_tokens[i].tokenID; +break ; + } + +/* token call; but token didn't exist */ +if (!t) { +dev_dbg (d,"token at location %04x doesn't exist\n" , + buffer->input[0 ]); +return -EINVAL ; + } + +/* match against token blacklist */ +for (i =0 ; i <ARRAY_SIZE (token_blacklist); i++) { +if (!token_blacklist[i].min || !token_blacklist[i].max) +continue ; +if (t >= token_blacklist[i].min && + t <= token_blacklist[i].max) +return -EINVAL ; + } + +/* match against token whitelist */ +for (i =0 ; i <ARRAY_SIZE (token_whitelist); i++) { +if (!token_whitelist[i].min || !token_whitelist[i].max) +continue ; +if (t < token_whitelist[i].min || + t > token_whitelist[i].max) +continue ; +if (!token_whitelist[i].need_capability || +capable (token_whitelist[i].need_capability)) { +dev_dbg (d,"whitelisted token: %x\n" , t); +return 0 ; + } + + } + } +/* match against call whitelist */ +for (i =0 ; i <ARRAY_SIZE (call_whitelist); i++) { +if (buffer->class != call_whitelist[i].class) +continue ; +if (buffer->select != call_whitelist[i].select) +continue ; +if (!call_whitelist[i].need_capability || +capable (call_whitelist[i].need_capability)) { +dev_dbg (d,"whitelisted capable command: %u/%u\n" , + buffer->class, buffer->select); +return 0 ; + } +dev_dbg (d,"missing capability %d for %u/%u\n" , + call_whitelist[i].need_capability, + buffer->class, buffer->select); + + } + +/* not in a whitelist, only allow processes with capabilities */ +if (capable (CAP_SYS_RAWIO )) { +dev_dbg (d,"Allowing %u/%u due to CAP_SYS_RAWIO\n" , + buffer->class, buffer->select); +return 0 ; + } + +return -EACCES ; +} +EXPORT_SYMBOL_GPL (dell_smbios_call_filter); +int dell_smbios_call (struct calling_interface_buffer *buffer) {int (*call_fn)(struct calling_interface_buffer *) =NULL ;
@@ -168,6 +356,8 @@ static void __init parse_da_table(const struct dmi_header *dm)if (dm->length <17 )return ; + da_supported_commands = table->supportedCmds; + new_da_tokens =krealloc (da_tokens, (da_num_tokens + tokens) *sizeof (struct calling_interface_token ),GFP_KERNEL );
drivers/platform/x86/dell-smbios.h +11 -0
@@ -26,9 +26,14 @@#define SELECT_TOKEN_AC 2#define CLASS_KBD_BACKLIGHT 4#define SELECT_KBD_BACKLIGHT 11 +#define CLASS_FLASH_INTERFACE 7 +#define SELECT_FLASH_INTERFACE 3 +#define CLASS_ADMIN_PROP 10 +#define SELECT_ADMIN_PROP 3#define CLASS_INFO 17#define SELECT_RFKILL 11#define SELECT_APP_REGISTRATION 3 +#define SELECT_DOCK 22/* Tokens used in kernel drivers, any of these * should be filtered from userspace access
@@ -44,6 +49,10 @@#define KBD_LED_AUTO_100_TOKEN 0x02F6#define GLOBAL_MIC_MUTE_ENABLE 0x0364#define GLOBAL_MIC_MUTE_DISABLE 0x0365 + +/* tokens whitelisted to userspace use */ +#define CAPSULE_EN_TOKEN 0x0461 +#define CAPSULE_DIS_TOKEN 0x0462#define WSMT_EN_TOKEN 0x04EC#define WSMT_DIS_TOKEN 0x04ED
@@ -80,6 +89,8 @@ int dell_smbios_register_device(struct device *d, void *call_fn);void dell_smbios_unregister_device (struct device *d);int dell_smbios_error (int value); +int dell_smbios_call_filter (struct device *d, +struct calling_interface_buffer *buffer);int dell_smbios_call (struct calling_interface_buffer *buffer);struct calling_interface_token *dell_smbios_find_token (int tokenid);
Signature · 1 line
2.14.1
Re: [PATCH v10 03/15] platform/x86: dell-wmi: clean up wmi descriptor check
In reply to Mario LimoncielloQuoted 6 lines · On Thursday 19 October 2017 12:50:06 Mario Limonciello wrote:
Some cases the wrong type was used for errors and checks can be done more cleanly.
Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Edward O'Callaghan <[email protected]>Suggested-by Andy Shevchenko <[email protected]>
Quoted 30 lines
--- drivers/platform/x86/dell-wmi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/platform/x86/dell-wmi.c +5
-5@@ -663,16 +663,16 @@ static int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev) buffer = (u32 *)obj->buffer.pointer; -if (buffer[0 ] !=0x4C4C4544 && buffer[1 ] !=0x494D5720 ) { -dev_err (&wdev->dev,"Dell descriptor buffer has invalid signature (%*ph)\n" , -8 , buffer); +if (strncmp (obj->string.pointer,"DELL WMI" ,8 ) !=0 ) { +dev_err (&wdev->dev,"Dell descriptor buffer has invalid signature (%8ph)\n" , + buffer); ret = -EINVAL ; goto out; }if (buffer[2 ] !=0 && buffer[2 ] !=1 ) -dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%d)\n" , - buffer[2 ]); +dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%lu)\n" , + (unsigned long ) buffer[2 ]);if (buffer[3 ] !=4096 ) dev_warn(&wdev->dev, "Dell descriptor buffer has invalid buffer length (%d)\n",
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v10 04/15] platform/x86: dell-wmi: don't check length returned
In reply to Mario LimoncielloQuoted 6 lines · On Thursday 19 October 2017 12:50:07 Mario Limonciello wrote:
This is intended to be variable and provided by the platform. Some platforms this year will be adopting a 32k WMI buffer, so don't complain when encountering those platforms or any other future changes.
Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Edward O'Callaghan <[email protected]>
Quoted 28 lines
--- drivers/platform/x86/dell-wmi.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/platform/x86/dell-wmi.c +1
-5@@ -624,7 +624,7 @@ static void dell_wmi_input_destroy(struct wmi_device *wdev)* Vendor Signature 0 4 "DELL" * Object Signature 4 4 " WMI" * WMI Interface Version 8 4 <version> -* WMI buffer length 12 4 4096 +* WMI buffer length 12 4 <length> */ static int dell_wmi_check_descriptor_buffer (struct wmi_device *wdev) {@@ -674,10 +674,6 @@ static int dell_wmi_check_descriptor_buffer(struct wmi_device *wdev)dev_warn (&wdev->dev,"Dell descriptor buffer has unknown version (%lu)\n" , (unsigned long ) buffer[2 ]); -if (buffer[3 ] !=4096 ) -dev_warn (&wdev->dev,"Dell descriptor buffer has invalid buffer length (%d)\n" , - buffer[3 ]); - priv->interface_version = buffer[2 ]; ret =0 ;
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v10 05/15] platform/x86: dell-wmi-descriptor: split WMI descriptor into it's own driver
In reply to Mario Limonciellodrivers/platform/x86/dell-wmi-descriptor.c line 128
Quoted 5 lines · On Thursday 19 October 2017 12:50:08 Mario Limonciello wrote:
drivers/platform/x86/dell-wmi-descriptor.c new file +5
-0+ priv->interface_version = buffer[2 ]; + priv->size = buffer[3 ]; + ret =0 ; +dev_set_drvdata (&wdev->dev, priv); +list_add_tail (&priv->list, &wmi_list);
Still missing lock when changing wmi_list.
Quoted 9 lines
drivers/platform/x86/dell-wmi-descriptor.c new file +9
-0+ +dev_dbg (&wdev->dev,"Detected Dell WMI interface version %lu and buffer size %lu\n" , + (unsigned long ) priv->interface_version, + (unsigned long ) priv->size); + +out: +kfree (obj); +return ret; +}
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v10 11/15] platform/x86: dell-smbios-smm: test for WSMT
In reply to Mario LimoncielloQuoted 29 lines · On Thursday 19 October 2017 12:50:14 Mario Limonciello wrote:
drivers/platform/x86/dell-smbios-smm.c +25
-0+/* When enabled this indicates that SMM won't work */ +static bool test_wsmt_enabled (void ) +{ +struct calling_interface_token *token; + +/* if token doesn't exist, SMM will work */ + token =dell_smbios_find_token (WSMT_EN_TOKEN ); +if (!token) +return false; + +/* if token exists, try to access over SMM */ + buffer->class =CLASS_TOKEN_READ ; + buffer->select =SELECT_TOKEN_STD ; +memset (buffer,0 ,sizeof (struct calling_interface_buffer )); + buffer->input[0 ] = token->location; +dell_smbios_smm_call (buffer); + +/* if lookup failed, we know WSMT was enabled */ +if (buffer->output[0 ] !=0 ) +return true; + +/* query token status if it didn't fail */ +return (buffer->output[1 ] == token->value); +} +static int __init dell_smbios_smm_init (void ) {int ret;
drivers/platform/x86/dell-smbios-smm.c static int __init dell_smbios_smm_init(void) · line 143
Quoted 4 lines
drivers/platform/x86/dell-smbios-smm.c +1
-0@@ -115,6 +140,13 @@ static int __init dell_smbios_smm_init(void)dmi_walk (find_cmd_address,NULL ); + ret =test_wsmt_enabled ();
ret is int, but test_wsmt_enabled() returns bool.
Signature · 2 lines
Pali Rohár [email protected]
RE: [PATCH v10 11/15] platform/x86: dell-smbios-smm: test for WSMT
Quoted 42 lines
-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Thursday, October 19, 2017 1:09 PM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 11/15] platform/x86: dell-smbios-smm: test for WSMTQuoted 30 lines · On Thursday 19 October 2017 12:50:14 Mario Limonciello wrote:
drivers/platform/x86/dell-smbios-smm.c +25
-0+/* When enabled this indicates that SMM won't work */ +static bool test_wsmt_enabled (void ) +{ +struct calling_interface_token *token; + +/* if token doesn't exist, SMM will work */ + token =dell_smbios_find_token (WSMT_EN_TOKEN ); +if (!token) +return false; + +/* if token exists, try to access over SMM */ + buffer->class =CLASS_TOKEN_READ ; + buffer->select =SELECT_TOKEN_STD ; +memset (buffer,0 ,sizeof (struct calling_interface_buffer )); + buffer->input[0 ] = token->location; +dell_smbios_smm_call (buffer); + +/* if lookup failed, we know WSMT was enabled */ +if (buffer->output[0 ] !=0 ) +return true; + +/* query token status if it didn't fail */ +return (buffer->output[1 ] == token->value); +} +static int __init dell_smbios_smm_init (void ) {int ret;@@ -115,6 +140,13 @@ static int __init dell_smbios_smm_init(void)
Quoted 5 lines
drivers/platform/x86/dell-smbios-smm.c static int __init dell_smbios_smm_init(void) · line 143
Quoted 3 lines
drivers/platform/x86/dell-smbios-smm.c +1
-0dmi_walk (find_cmd_address,NULL ); + ret =test_wsmt_enabled ();ret is int, but
test_wsmt_enabled()returns bool.
Yes, ret is re-used within this method.
0, 1 enum is a subset of int, so this seemed like a logical thing to me to do.
Re: [PATCH v10 11/15] platform/x86: dell-smbios-smm: test for WSMT
Quoted 42 lines · On Thu, Oct 19, 2017 at 06:12:09PM +0000, [email protected] wrote:
Quoted 42 lines
-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Thursday, October 19, 2017 1:09 PM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 11/15] platform/x86: dell-smbios-smm: test for WSMTQuoted 30 lines · On Thursday 19 October 2017 12:50:14 Mario Limonciello wrote:
drivers/platform/x86/dell-smbios-smm.c +25
-0+/* When enabled this indicates that SMM won't work */ +static bool test_wsmt_enabled (void ) +{ +struct calling_interface_token *token; + +/* if token doesn't exist, SMM will work */ + token =dell_smbios_find_token (WSMT_EN_TOKEN ); +if (!token) +return false; + +/* if token exists, try to access over SMM */ + buffer->class =CLASS_TOKEN_READ ; + buffer->select =SELECT_TOKEN_STD ; +memset (buffer,0 ,sizeof (struct calling_interface_buffer )); + buffer->input[0 ] = token->location; +dell_smbios_smm_call (buffer); + +/* if lookup failed, we know WSMT was enabled */ +if (buffer->output[0 ] !=0 ) +return true; + +/* query token status if it didn't fail */ +return (buffer->output[1 ] == token->value); +} +static int __init dell_smbios_smm_init (void ) {int ret;@@ -115,6 +140,13 @@ static int __init dell_smbios_smm_init(void)
Quoted 8 lines
Quoted 5 lines
drivers/platform/x86/dell-smbios-smm.c static int __init dell_smbios_smm_init(void) · line 143
Quoted 3 lines
drivers/platform/x86/dell-smbios-smm.c +1
-0dmi_walk (find_cmd_address,NULL ); + ret =test_wsmt_enabled ();ret is int, but
test_wsmt_enabled()returns bool.Yes, ret is re-used within this method.
0, 1 enum is a subset of int, so this seemed like a logical thing to me to do.
Agreed, the conversion is automatic and he tests for it and returns an appropriate error code. I don't see a real problem with this.
Signature · 2 lines
Darren Hart VMware Open Source Technology Center
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Mario Limonciellodrivers/platform/x86/wmi.c static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) · line 211
Quoted 3 lines · Mario Limonciello
drivers/platform/x86/wmi.c +3
-0+ wblock = container_of(wdev, struct wmi_block, dev); +if (!wblock) +return -ENODEV ;
How can container_of() ever return NULL? If so, you have a very odd memory layout...
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 804
Quoted 5 lines
drivers/platform/x86/wmi.c +5
-0+list_for_each_entry_safe (wblock, next, &wmi_block_list, list) { + wdriver =container_of (wblock->dev.dev.driver, + struct wmi_driver, driver); +if (!wdriver) +continue ;
Same here. And other places in this file.
thanks,
greg k-h
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Mario LimoncielloQuoted 7 lines · Mario Limonciello
drivers/platform/x86/wmi.c +7
-0+static ssize_t wmi_char_read (struct file *filp,char __user *buffer, +size_t length,loff_t *offset) +{ +struct wmi_block *wblock = filp->private_data; +size_t count; + +if (*offset !=0 )
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 832
Quoted 10 lines
drivers/platform/x86/wmi.c +10
-0+return 0 ; + + count =sizeof (wblock->req_buf_size); + count = length < count ? length : count; + +if (copy_to_user (buffer, &wblock->req_buf_size, count)) +return -EFAULT ; + + *offset = count; +return count;
simple_read_from_buffer()? Library functions are your friend :)
thanks,
greg k-h
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Mario Limonciellodrivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 911
Quoted 2 lines · Mario Limonciello
drivers/platform/x86/wmi.c +2
-0+#ifdef CONFIG_COMPAT + .compat_ioctl = wmi_ioctl,
Why do you still need a compat ioctl?
RE: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Greg KHQuoted 12 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:22 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
Quoted 8 lines
drivers/platform/x86/wmi.c static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) · line 211
Quoted 3 lines · Mario Limonciello
drivers/platform/x86/wmi.c +3
-0+ wblock = container_of(wdev, struct wmi_block, dev); +if (!wblock) +return -ENODEV ;How can
container_of()ever return NULL? If so, you have a very odd memory layout...
I'm assuming this is from set_required_buffer_size right?
The symbol is exported out for other drivers to use. It's possible for another driver to allocate a wmi_device structure that's not part of a wblock.
Quoted 8 lines
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 804
Quoted 5 lines
drivers/platform/x86/wmi.c +5
-0+list_for_each_entry_safe (wblock, next, &wmi_block_list, list) { + wdriver =container_of (wblock->dev.dev.driver, + struct wmi_driver, driver); +if (!wdriver) +continue ;Same here. And other places in this file.
This one it's possible that a driver isn't bound to a device, and when that happens wdriver is NULL.
RE: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Greg KHQuoted 24 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:23 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for driversQuoted 11 lines · Mario Limonciello
drivers/platform/x86/wmi.c +11
-0+static ssize_t wmi_char_read (struct file *filp,char __user *buffer, +size_t length,loff_t *offset) +{ +struct wmi_block *wblock = filp->private_data; +size_t count; + +if (*offset !=0 ) +return 0 ; + + count =sizeof (wblock->req_buf_size); + count = length < count ? length : count;
Quoted 9 lines
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 832
Quoted 6 lines
drivers/platform/x86/wmi.c +6
-0+ +if (copy_to_user (buffer, &wblock->req_buf_size, count)) +return -EFAULT ; + + *offset = count; +return count;
simple_read_from_buffer()? Library functions are your friend :)
Thanks, wasn't aware of it.
RE: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Greg KHQuoted 12 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:24 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
Quoted 5 lines
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 911
Quoted 2 lines · Mario Limonciello
drivers/platform/x86/wmi.c +2
-0+#ifdef CONFIG_COMPAT + .compat_ioctl = wmi_ioctl,Why do you still need a compat ioctl?
Being able to run 32 bit app on 64 bit kernel. Removing the .compat_ioctl definition and they fail.
So do you mean specifically the #ifdef CONFIG_COMPAT?
I do see that compat_ioctl is declared without it in linux/fs.h, but I'll admit I'm unsure what happens if the kernel is compiled without CONFIG_COMPAT and you try to run 32 bit apps. _Should_ that work?
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to [email protected]Quoted 21 lines · On Fri, Oct 20, 2017 at 01:54:36PM +0000, [email protected] wrote:
Quoted 12 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:22 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for driversQuoted 8 lines
drivers/platform/x86/wmi.c static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) · line 211
Quoted 3 lines · Mario Limonciello
drivers/platform/x86/wmi.c +3
-0+ wblock = container_of(wdev, struct wmi_block, dev); +if (!wblock) +return -ENODEV ;How can
container_of()ever return NULL? If so, you have a very odd memory layout...
Quoted 4 lines
I'm assuming this is from
set_required_buffer_sizeright?The symbol is exported out for other drivers to use. It's possible for another driver to allocate a
wmi_devicestructure that's not part of a wblock.
container_of can never return NULL, it does arithmetics on a pointer based on the type it is embedded into.
You better don't register a wmi_device that's not part of the block with your driver. Which others drivers are those, btw?
Quoted 11 lines
Quoted 8 lines
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 804
Quoted 5 lines
drivers/platform/x86/wmi.c +5
-0+list_for_each_entry_safe (wblock, next, &wmi_block_list, list) { + wdriver =container_of (wblock->dev.dev.driver, + struct wmi_driver, driver); +if (!wdriver) +continue ;Same here. And other places in this file.
This one it's possible that a driver isn't bound to a device, and when that happens wdriver is NULL.
See above, no it can't. Maybe wblock->dev.dev.driver can be NULL, but in that case you must not call container_of on it.
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to [email protected]Quoted 21 lines · On Fri, Oct 20, 2017 at 01:54:36PM +0000, [email protected] wrote:
Quoted 12 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:22 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for driversQuoted 8 lines
drivers/platform/x86/wmi.c static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) · line 211
Quoted 3 lines · Mario Limonciello
drivers/platform/x86/wmi.c +3
-0+ wblock = container_of(wdev, struct wmi_block, dev); +if (!wblock) +return -ENODEV ;How can
container_of()ever return NULL? If so, you have a very odd memory layout...
Quoted 4 lines
I'm assuming this is from
set_required_buffer_sizeright?The symbol is exported out for other drivers to use. It's possible for another driver to allocate a
wmi_devicestructure that's not part of a wblock.
Fine, but your test does not do anything at all.
Quoted 11 lines
Quoted 8 lines
drivers/platform/x86/wmi.c static int wmi_dev_match(struct device *dev, struct device_driver *driver) · line 804
Quoted 5 lines
drivers/platform/x86/wmi.c +5
-0+list_for_each_entry_safe (wblock, next, &wmi_block_list, list) { + wdriver =container_of (wblock->dev.dev.driver, + struct wmi_driver, driver); +if (!wdriver) +continue ;Same here. And other places in this file.
This one it's possible that a driver isn't bound to a device, and when that happens wdriver is NULL.
Again, that's not what you are testing at all.
container_of() is just pointer math. If you pass in NULL, you will get a non-NULL value (incremented or decremented). If you pass in a very tiny number, you might get NULL, but that's still really wrong.
In other words, these tests will _NEVER_ fail. Go ahead, try it :)
thanks,
greg k-h
RE: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
In reply to Christoph HellwigQuoted 37 lines
-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Friday, October 20, 2017 9:49 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for driversQuoted 6 lines · On Fri, Oct 20, 2017 at 01:54:36PM +0000, [email protected] wrote:
Quoted 6 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Friday, October 20, 2017 8:22 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected];Andy
Quoted 4 lines
Quoted 4 lines
Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interfacefor
Quoted 13 lines
Quoted 10 lines
drivers
drivers/platform/x86/wmi.c static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) · line 211
Quoted 3 lines · Mario Limonciello
drivers/platform/x86/wmi.c +3
-0+ wblock = container_of(wdev, struct wmi_block, dev); +if (!wblock) +return -ENODEV ;How can
container_of()ever return NULL? If so, you have a very odd memory layout...I'm assuming this is from
set_required_buffer_sizeright?
Quoted 8 lines
Quoted 2 lines
The symbol is exported out for other drivers to use. It's possible for another driver to allocate a
wmi_devicestructure that's not part of a wblock.
container_ofcan never return NULL, it does arithmetics on a pointer based on the type it is embedded into.You better don't register a
wmi_devicethat's not part of the block with your driver. Which others drivers are those, btw?
No drivers do this today, it's obviously not a good idea. I was just saying it's hypothetical.
I see that the other methods exported (wmi_evaluate_method and such) to drivers require that it's part of a wblock, so this seems like a reasonable expectation from other drivers. I'll remove this invalid check.
Quoted 4 lines
Quoted 2 lines
This one it's possible that a driver isn't bound to a device, and when that happens wdriver is NULL.
Quoted 8 lines
See above, no it can't. Maybe
wblock->dev.dev.drivercan be NULL, but in that case you must not callcontainer_ofon it.
container_of()is just pointer math. If you pass in NULL, you will get a non-NULL value (incremented or decremented). If you pass in a very tiny number, you might get NULL, but that's still really wrong.In other words, these tests will _NEVER_ fail. Go ahead, try it :)
I was seeing failures (with NULL) when I tested with some drivers unbound, but I now understand my check is definitely wrong. I'll adjust the check and make sure it's valid.
Thank you both for your feedback here.
Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
Quoted 2 lines · On Fri, Oct 20, 2017 at 03:07:27PM +0000, [email protected] wrote:
No drivers do this today, it's obviously not a good idea. I was just saying it's hypothetical.
If there is no one using the exported methods don't export them.
RE: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
Quoted 12 lines
-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Friday, October 20, 2017 10:09 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; platform-driver- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 13/15] platform/x86: wmi: create userspace interface for drivers
Quoted 5 lines
Quoted 2 lines · On Fri, Oct 20, 2017 at 03:07:27PM +0000, [email protected] wrote:
No drivers do this today, it's obviously not a good idea. I was just saying it's hypothetical.
If there is no one using the exported methods don't export them.
This particular one is used by patch 14/15 in this series.
Quoted 13 lines · Mario Limonciello
The existing way that the dell-smbios helper module and associated other drivers (dell-laptop, dell-wmi) communicate with the platform really isn't secure. It requires creating a buffer in physical DMA32 memory space and passing that to the platform via SMM.
Since the platform got a physical memory pointer, you've just got to trust that the platform has only modified (and accessed) memory within that buffer.
Dell Platform designers recognize this security risk and offer a safer way to communicate with the platform over ACPI. This is in turn exposed via a WMI interface to the OS.
Quoted 6 lines
When communicating over WMI-ACPI the communication doesn't occur with physical memory pointers. When the ASL is invoked, the fixed length ACPI buffer is copied to a small operating region. The ASL will invoke the SMI, and SMM will only have access to this operating region. When the ASL returns the buffer is copied back for the OS to process.
SMM has access anywhere it wants. This may be good idea, but definitely not for "security" reasons.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
In reply to Mario LimoncielloI know that this patch is already applied and merged, but I spotted this problem:
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines · On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */
Numbers prefixed by zero means that they are in octal notation, right? This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};
Signature · 2 lines
Pali Rohár [email protected]
RE: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
Quoted 18 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportI know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Is that how the kernel interprets an integer prefix by zero?
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is? Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */
{0x0000, 6, 5}, /* manufacturing use */
{0x0000, 11, 3}, /* write once */
{0x0000, 11, 7}, /* write once */That seems less readable to me but should interpret the same way.
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 77
Quoted 7 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]
Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
Quoted 26 lines · On Friday 05 January 2018 14:32:54 [email protected] wrote:
Quoted 18 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected]; Andy Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportI know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, this is how C language define it. See e.g. C11 standard, section 6.4.4.1 Integer constants:
decimal-constant:
nonzero-digit
decimal-constant digit
octal-constant:
0 octal-constant octal-digit
So in C decimal number cannot start with digit zero.
I think the place where octal numbers are used are in permissions (0777)
Quoted 7 lines
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Currently it is not problem as 7 is same number in octal (07) and decimal (7). representation. But e.g. octal 077 is 63 in decimal.
Quoted 5 lines
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */
Yes, this is better. If you need to achieve alignment then use spaces. Really, not leading zeros.
Quoted 1 line
That seems less readable to me but should interpret the same way.
Example:
{0x000, 077, 7},
{0x000, 007, 7},
is **not** same as
{0x000, 77, 7},
{0x000, 7, 7},
As first number in first section is (decimal) 63, not (decimal) 77.
Quoted 14 lines
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 77
Quoted 7 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]
Signature · 2 lines
Pali Rohár [email protected]
Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
In reply to [email protected]Quoted 12 lines · On Fri, Jan 5, 2018 at 4:32 PM, <[email protected]> wrote:
Quoted 4 lines
I know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, compiler.
Quoted 1 line
I prefixed by zero for readability, they're supposed to be decimal.
...which make a confusion. Luckily you don't have 8 and 9 there, otherwise I even don't know if it would be a compilation warning.
Quoted 11 lines
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */
I think something like that. You might use white space for indentation.
Quoted 5 lines
That seems less readable to me but should interpret the same way.
Perhaps it would be better if you submit a patch with what is clearer to you.
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
In reply to Pali RohárQuoted 107 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 8:44 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 9 lines · On Friday 05 January 2018 14:32:54 [email protected] wrote:
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected];Andy
Quoted 17 lines
Quoted 9 lines
Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportI know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, this is how C language define it. See e.g. C11 standard, section 6.4.4.1 Integer constants:
decimal-constant:
nonzero-digit
decimal-constant digitoctal-constant:
0 octal-constant octal-digitSo in C decimal number cannot start with digit zero.
I think the place where octal numbers are used are in permissions (0777)
Quoted 7 lines
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Currently it is not problem as 7 is same number in octal (07) and decimal (7). representation. But e.g. octal 077 is 63 in decimal.
Quoted 5 lines
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */Yes, this is better. If you need to achieve alignment then use spaces. Really, not leading zeros.
Quoted 1 line
That seems less readable to me but should interpret the same way.
Example:
{
0x000, 077, 7},
{0x000, 007, 7},is **not** same as
{
0x000, 77, 7},
{0x000, 7, 7},As first number in first section is (decimal) 63, not (decimal) 77.
Quoted 14 lines
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 77
Quoted 7 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]
Quoted 3 lines
--
Pali Rohár
[email protected]
Thanks very much for sharing. I wasn't aware of this. I'll send a patch.
Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
Quoted 107 lines · On Friday 05 January 2018 14:48:39 [email protected] wrote:
Quoted 107 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 8:44 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 9 lines · On Friday 05 January 2018 14:32:54 [email protected] wrote:
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy Shevchenko <[email protected]>; LKML <[email protected]>; [email protected];Andy
Quoted 17 lines
Quoted 9 lines
Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportI know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, this is how C language define it. See e.g. C11 standard, section 6.4.4.1 Integer constants:
decimal-constant:
nonzero-digit
decimal-constant digitoctal-constant:
0 octal-constant octal-digitSo in C decimal number cannot start with digit zero.
I think the place where octal numbers are used are in permissions (0777)
Quoted 7 lines
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Currently it is not problem as 7 is same number in octal (07) and decimal (7). representation. But e.g. octal 077 is 63 in decimal.
Quoted 5 lines
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */Yes, this is better. If you need to achieve alignment then use spaces. Really, not leading zeros.
Quoted 1 line
That seems less readable to me but should interpret the same way.
Example:
{
0x000, 077, 7},
{0x000, 007, 7},is **not** same as
{
0x000, 77, 7},
{0x000, 7, 7},As first number in first section is (decimal) 63, not (decimal) 77.
Quoted 14 lines
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 77
Quoted 7 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]
Quoted 5 lines
Quoted 3 lines
--
Pali Rohár
[email protected]Thanks very much for sharing. I wasn't aware of this. I'll send a patch.
Hi! Do you have a patch for it?
Signature · 2 lines
Pali Rohár [email protected]
RE: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
Quoted 123 lines
-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Saturday, January 27, 2018 8:51 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 9 lines · On Friday 05 January 2018 14:48:39 [email protected] wrote:
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 8:44 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected];Quoted 9 lines
Quoted 9 lines
[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 4 lines · On Friday 05 January 2018 14:32:54 [email protected] wrote:
Quoted 4 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy ShevchenkoQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
LKML <[email protected]>; platform-driver-
Quoted 5 lines
Quoted 5 lines
Andy
Quoted 4 lines
Quoted 4 lines
Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filteringsupport
Quoted 79 lines
Quoted 79 lines
Quoted 13 lines
Quoted 5 lines
I know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 71
Quoted 6 lines
drivers/platform/x86/dell-smbios.c +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000 ,01 ,07 },/* manufacturing use */ + {0x0000 ,06 ,05 },/* manufacturing use */ + {0x0000 ,11 ,03 },/* write once */ + {0x0000 ,11 ,07 },/* write once */ Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, this is how C language define it. See e.g. C11 standard, section 6.4.4.1 Integer constants:
decimal-constant:
nonzero-digit
decimal-constant digitoctal-constant:
0 octal-constant octal-digitSo in C decimal number cannot start with digit zero.
I think the place where octal numbers are used are in permissions (0777)
Quoted 7 lines
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Currently it is not problem as 7 is same number in octal (07) and decimal (7). representation. But e.g. octal 077 is 63 in decimal.
Quoted 5 lines
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */Yes, this is better. If you need to achieve alignment then use spaces. Really, not leading zeros.
Quoted 1 line
That seems less readable to me but should interpret the same way.
Example:
{
0x000, 077, 7},
{0x000, 007, 7},is **not** same as
{
0x000, 77, 7},
{0x000, 7, 7},As first number in first section is (decimal) 63, not (decimal) 77.
Quoted 14 lines
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
drivers/platform/x86/dell-smbios.c struct smbios_device { · line 77
Quoted 7 lines
drivers/platform/x86/dell-smbios.c +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ +/* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
--
Pali Rohár
[email protected]Thanks very much for sharing. I wasn't aware of this. I'll send a patch.
Hi! Do you have a patch for it?
I used the wrong tag so it didn't automatically CC you. Sorry about that. It's here:
Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering support
Quoted 127 lines · On Monday 29 January 2018 16:22:07 [email protected] wrote:
Quoted 127 lines
-----Original Message-----
From: Pali Rohár [mailto:[email protected]]
Sent: Saturday, January 27, 2018 8:51 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 9 lines · On Friday 05 January 2018 14:48:39 [email protected] wrote:
Quoted 9 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86- [email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 8:44 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected];Quoted 9 lines
Quoted 9 lines
[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filtering supportQuoted 4 lines · On Friday 05 January 2018 14:32:54 [email protected] wrote:
Quoted 4 lines
-----Original Message-----
From: [email protected] [mailto:platform-driver-x86-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
[email protected]] On Behalf Of Pali Rohár
Sent: Friday, January 5, 2018 5:13 AM
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; Andy ShevchenkoQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
LKML <[email protected]>; platform-driver-
Quoted 5 lines
Quoted 5 lines
Andy
Quoted 4 lines
Quoted 4 lines
Lutomirski <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Greg KH <[email protected]>; Alan Cox <[email protected]>
Subject: Re: [PATCH v10 12/15] platform/x86: dell-smbios: Add filteringsupport
Quoted 83 lines
Quoted 82 lines
Quoted 13 lines
Quoted 5 lines
I know that this patch is already applied and merged, but I spotted this problem:
On Thursday 19 October 2017 12:50:15 Mario Limonciello wrote:
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+/* calls that are explicitly blacklisted */ +static struct smbios_call call_blacklist[] = { + {0x0000, 01, 07}, /* manufacturing use */ + {0x0000, 06, 05}, /* manufacturing use */ + {0x0000, 11, 03}, /* write once */ + {0x0000, 11, 07}, /* write once */Numbers prefixed by zero means that they are in octal notation, right?
Quoted 1 line
Is that how the kernel interprets an integer prefix by zero?
No, this is how C language define it. See e.g. C11 standard, section 6.4.4.1 Integer constants:
decimal-constant:
nonzero-digit
decimal-constant digitoctal-constant:
0 octal-constant octal-digitSo in C decimal number cannot start with digit zero.
I think the place where octal numbers are used are in permissions (0777)
Quoted 7 lines
I prefixed by zero for readability, they're supposed to be decimal.
Quoted 3 lines
This can lead to misunderstanding, confusion or problems in future...
Can we have all numbers either in hexadecimal or decimal notation?
Could you elaborate more why this is problematic the way it is?
Currently it is not problem as 7 is same number in octal (07) and decimal (7). representation. But e.g. octal 077 is 63 in decimal.
Quoted 5 lines
Are you meaning you would rather see this?
{0x0000, 1, 7}, /* manufacturing use */ {0x0000, 6, 5}, /* manufacturing use */ {0x0000, 11, 3}, /* write once */ {0x0000, 11, 7}, /* write once */Yes, this is better. If you need to achieve alignment then use spaces. Really, not leading zeros.
Quoted 1 line
That seems less readable to me but should interpret the same way.
Example:
{
0x000, 077, 7},
{0x000, 007, 7},is **not** same as
{
0x000, 77, 7},
{0x000, 7, 7},As first number in first section is (decimal) 63, not (decimal) 77.
Quoted 14 lines
Perhaps it would be better if you submit a patch with what is clearer to you.
Quoted 11 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+ {0x0000, 11, 11}, /* write once */ + {0x0000, 19, -1}, /* diagnostics */ + /* handled by kernel: dell-laptop */ + {0x0000, CLASS_INFO, SELECT_RFKILL}, + {0x0000, CLASS_KBD_BACKLIGHT, SELECT_KBD_BACKLIGHT}, +};--
Pali Rohár
[email protected]--
Pali Rohár
[email protected]
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Thanks very much for sharing. I wasn't aware of this. I'll send a patch.
Hi! Do you have a patch for it?
I used the wrong tag so it didn't automatically CC you. Sorry about that. It's here:
Ok, looks good for me.
Signature · 2 lines
Pali Rohár [email protected]