linux/drivers/platform/x86/think-lmi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Think LMI BIOS configuration driver
 *
 * Copyright(C) 2019-2021 Lenovo
 *
 * Original code from Thinkpad-wmi project https://github.com/iksaif/thinkpad-wmi
 * Copyright(C) 2017 Corentin Chary <[email protected]>
 * Distributed under the GPL-2.0 license
 */

#define pr_fmt(fmt)

#include <linux/acpi.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/mutex.h>
#include <linux/string_helpers.h>
#include <linux/types.h>
#include <linux/dmi.h>
#include <linux/wmi.h>
#include "firmware_attributes_class.h"
#include "think-lmi.h"

static bool debug_support;
module_param(debug_support, bool, 0444);
MODULE_PARM_DESC();

/*
 * Name: BiosSetting
 * Description: Get item name and settings for current LMI instance.
 * Type: Query
 * Returns: "Item,Value"
 * Example: "WakeOnLAN,Enable"
 */
#define LENOVO_BIOS_SETTING_GUID

/*
 * Name: SetBiosSetting
 * Description: Change the BIOS setting to the desired value using the SetBiosSetting
 *  class. To save the settings, use the SaveBiosSetting class.
 *  BIOS settings and values are case sensitive.
 *  After making changes to the BIOS settings, you must reboot the computer
 *  before the changes will take effect.
 * Type: Method
 * Arguments: "Item,Value,Password,Encoding,KbdLang;"
 * Example: "WakeOnLAN,Disable,pa55w0rd,ascii,us;"
 */
#define LENOVO_SET_BIOS_SETTINGS_GUID

/*
 * Name: SaveBiosSettings
 * Description: Save any pending changes in settings.
 * Type: Method
 * Arguments: "Password,Encoding,KbdLang;"
 * Example: "pa55w0rd,ascii,us;"
 */
#define LENOVO_SAVE_BIOS_SETTINGS_GUID

/*
 * Name: BiosPasswordSettings
 * Description: Return BIOS Password settings
 * Type: Query
 * Returns: PasswordMode, PasswordState, MinLength, MaxLength,
 *  SupportedEncoding, SupportedKeyboard
 */
#define LENOVO_BIOS_PASSWORD_SETTINGS_GUID

/*
 * Name: SetBiosPassword
 * Description: Change a specific password.
 *  - BIOS settings cannot be changed at the same boot as power-on
 *    passwords (POP) and hard disk passwords (HDP). If you want to change
 *    BIOS settings and POP or HDP, you must reboot the system after changing
 *    one of them.
 *  - A password cannot be set using this method when one does not already
 *    exist. Passwords can only be updated or cleared.
 * Type: Method
 * Arguments: "PasswordType,CurrentPassword,NewPassword,Encoding,KbdLang;"
 * Example: "pop,pa55w0rd,newpa55w0rd,ascii,us;”
 */
#define LENOVO_SET_BIOS_PASSWORD_GUID

/*
 * Name: GetBiosSelections
 * Description: Return a list of valid settings for a given item.
 * Type: Method
 * Arguments: "Item"
 * Returns: "Value1,Value2,Value3,..."
 * Example:
 *  -> "FlashOverLAN"
 *  <- "Enabled,Disabled"
 */
#define LENOVO_GET_BIOS_SELECTIONS_GUID

/*
 * Name: DebugCmd
 * Description: Debug entry method for entering debug commands to the BIOS
 */
#define LENOVO_DEBUG_CMD_GUID

/*
 * Name: OpcodeIF
 * Description: Opcode interface which provides the ability to set multiple
 *  parameters and then trigger an action with a final command.
 *  This is particularly useful for simplifying setting passwords.
 *  With this support comes the ability to set System, HDD and NVMe
 *  passwords.
 *  This is currently available on ThinkCenter and ThinkStations platforms
 */
#define LENOVO_OPCODE_IF_GUID

/*
 * Name: SetBiosCert
 * Description: Install BIOS certificate.
 * Type: Method
 * Arguments: "Certificate,Password"
 * You must reboot the computer before the changes will take effect.
 */
#define LENOVO_SET_BIOS_CERT_GUID

/*
 * Name: UpdateBiosCert
 * Description: Update BIOS certificate.
 * Type: Method
 * Format: "Certificate,Signature"
 * You must reboot the computer before the changes will take effect.
 */
#define LENOVO_UPDATE_BIOS_CERT_GUID

/*
 * Name: ClearBiosCert
 * Description: Uninstall BIOS certificate.
 * Type: Method
 * Format: "Serial,Signature"
 * You must reboot the computer before the changes will take effect.
 */
#define LENOVO_CLEAR_BIOS_CERT_GUID
/*
 * Name: CertToPassword
 * Description: Switch from certificate to password authentication.
 * Type: Method
 * Format: "Password,Signature"
 * You must reboot the computer before the changes will take effect.
 */
#define LENOVO_CERT_TO_PASSWORD_GUID

/*
 * Name: SetBiosSettingCert
 * Description: Set attribute using certificate authentication.
 * Type: Method
 * Format: "Item,Value,Signature"
 */
#define LENOVO_SET_BIOS_SETTING_CERT_GUID

/*
 * Name: SaveBiosSettingCert
 * Description: Save any pending changes in settings.
 * Type: Method
 * Format: "Signature"
 */
#define LENOVO_SAVE_BIOS_SETTING_CERT_GUID

/*
 * Name: CertThumbprint
 * Description: Display Certificate thumbprints
 * Type: Query
 * Returns: MD5, SHA1 & SHA256 thumbprints
 */
#define LENOVO_CERT_THUMBPRINT_GUID

#define TLMI_POP_PWD
#define TLMI_PAP_PWD
#define TLMI_HDD_PWD
#define TLMI_SMP_PWD
#define TLMI_CERT

static const struct tlmi_err_codes tlmi_errs[] =;

static const char * const encoding_options[] =;
static const char * const level_options[] =;
static struct think_lmi tlmi_priv;
static const struct class *fw_attr_class;
static DEFINE_MUTEX(tlmi_mutex);

static inline struct tlmi_pwd_setting *to_tlmi_pwd_setting(struct kobject *kobj)
{}

static inline struct tlmi_attr_setting *to_tlmi_attr_setting(struct kobject *kobj)
{}

/* Convert BIOS WMI error string to suitable error code */
static int tlmi_errstr_to_err(const char *errstr)
{}

/* Extract error string from WMI return buffer */
static int tlmi_extract_error(const struct acpi_buffer *output)
{}

/* Utility function to execute WMI call to BIOS */
static int tlmi_simple_call(const char *guid, const char *arg)
{}

/* Extract output string from WMI return buffer */
static int tlmi_extract_output_string(const struct acpi_buffer *output,
				      char **string)
{}

/* ------ Core interface functions ------------*/

/* Get password settings from BIOS */
static int tlmi_get_pwd_settings(struct tlmi_pwdcfg *pwdcfg)
{}

static int tlmi_save_bios_settings(const char *password)
{}

static int tlmi_opcode_setting(char *setting, const char *value)
{}

static int tlmi_setting(int item, char **value, const char *guid_string)
{}

static int tlmi_get_bios_selections(const char *item, char **value)
{}

/* ---- Authentication sysfs --------------------------------------------------------- */
static ssize_t is_enabled_show(struct kobject *kobj, struct kobj_attribute *attr,
					  char *buf)
{}

static struct kobj_attribute auth_is_pass_set =;

static ssize_t current_password_store(struct kobject *kobj,
				      struct kobj_attribute *attr,
				      const char *buf, size_t count)
{}

static struct kobj_attribute auth_current_password =;

static ssize_t new_password_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_new_password =;

static ssize_t min_password_length_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static struct kobj_attribute auth_min_pass_length =;

static ssize_t max_password_length_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}
static struct kobj_attribute auth_max_pass_length =;

static ssize_t mechanism_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}
static struct kobj_attribute auth_mechanism =;

static ssize_t encoding_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static ssize_t encoding_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_encoding =;

static ssize_t kbdlang_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static ssize_t kbdlang_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_kbdlang =;

static ssize_t role_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}
static struct kobj_attribute auth_role =;

static ssize_t index_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static ssize_t index_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_index =;

static ssize_t level_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static ssize_t level_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_level =;

static ssize_t cert_thumbprint(char *buf, const char *arg, int count)
{}

static ssize_t certificate_thumbprint_show(struct kobject *kobj, struct kobj_attribute *attr,
			 char *buf)
{}

static struct kobj_attribute auth_cert_thumb =;

static ssize_t cert_to_password_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_cert_to_password =;

static ssize_t certificate_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_certificate =;

static ssize_t signature_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_signature =;

static ssize_t save_signature_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{}

static struct kobj_attribute auth_save_signature =;

static umode_t auth_attr_is_visible(struct kobject *kobj,
					     struct attribute *attr, int n)
{}

static struct attribute *auth_attrs[] =;

static const struct attribute_group auth_attr_group =;

/* ---- Attributes sysfs --------------------------------------------------------- */
static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *attr,
		char *buf)
{}

static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{}

static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{}

static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr,
		char *buf)
{}

static ssize_t current_value_store(struct kobject *kobj,
		struct kobj_attribute *attr,
		const char *buf, size_t count)
{}

static struct kobj_attribute attr_displ_name =;

static struct kobj_attribute attr_possible_values =;

static struct kobj_attribute attr_current_val =;

static struct kobj_attribute attr_type =;

static umode_t attr_is_visible(struct kobject *kobj,
					     struct attribute *attr, int n)
{}

static struct attribute *tlmi_attrs[] =;

static const struct attribute_group tlmi_attr_group =;

static void tlmi_attr_setting_release(struct kobject *kobj)
{}

static void tlmi_pwd_setting_release(struct kobject *kobj)
{}

static const struct kobj_type tlmi_attr_setting_ktype =;

static const struct kobj_type tlmi_pwd_setting_ktype =;

static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
				   char *buf)
{}

static struct kobj_attribute pending_reboot =;

static const char * const save_mode_strings[] =;

static ssize_t save_settings_show(struct kobject *kobj, struct kobj_attribute *attr,
				  char *buf)
{}

static ssize_t save_settings_store(struct kobject *kobj, struct kobj_attribute *attr,
				   const char *buf, size_t count)
{}

static struct kobj_attribute save_settings =;

/* ---- Debug interface--------------------------------------------------------- */
static ssize_t debug_cmd_store(struct kobject *kobj, struct kobj_attribute *attr,
				const char *buf, size_t count)
{}

static struct kobj_attribute debug_cmd =;

/* ---- Initialisation --------------------------------------------------------- */
static void tlmi_release_attr(void)
{}

static int tlmi_validate_setting_name(struct kset *attribute_kset, char *name)
{}

static int tlmi_sysfs_init(void)
{}

/* ---- Base Driver -------------------------------------------------------- */
static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
			    const char *pwd_role)
{}

static int tlmi_analyze(void)
{}

static void tlmi_remove(struct wmi_device *wdev)
{}

static int tlmi_probe(struct wmi_device *wdev, const void *context)
{}

static const struct wmi_device_id tlmi_id_table[] =;
MODULE_DEVICE_TABLE(wmi, tlmi_id_table);

static struct wmi_driver tlmi_driver =;

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

module_wmi_driver();