Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: think-lmi: Add certificate GUID structure

Add a certificate GUID structure to make it easier to add different
options for other platforms that need different GUIDs.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20250903173824.1472244-2-mpearson-lenovo@squebb.ca
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Mark Pearson and committed by
Ilpo Järvinen
c778f7ac ee1cb9b0

+33 -9
+20 -9
drivers/platform/x86/lenovo/think-lmi.c
··· 177 177 #define TLMI_CERT_SVC BIT(7) /* Admin Certificate Based */ 178 178 #define TLMI_CERT_SMC BIT(8) /* System Certificate Based */ 179 179 180 + static const struct tlmi_cert_guids thinkpad_cert_guid = { 181 + .thumbprint = LENOVO_CERT_THUMBPRINT_GUID, 182 + .set_bios_setting = LENOVO_SET_BIOS_SETTING_CERT_GUID, 183 + .save_bios_setting = LENOVO_SAVE_BIOS_SETTING_CERT_GUID, 184 + .cert_to_password = LENOVO_CERT_TO_PASSWORD_GUID, 185 + .clear_bios_cert = LENOVO_CLEAR_BIOS_CERT_GUID, 186 + .update_bios_cert = LENOVO_UPDATE_BIOS_CERT_GUID, 187 + .set_bios_cert = LENOVO_SET_BIOS_CERT_GUID, 188 + }; 189 + 180 190 static const struct tlmi_err_codes tlmi_errs[] = { 181 191 {"Success", 0}, 182 192 {"Not Supported", -EOPNOTSUPP}, ··· 678 668 const union acpi_object *obj; 679 669 acpi_status status; 680 670 681 - status = wmi_evaluate_method(LENOVO_CERT_THUMBPRINT_GUID, 0, 0, &input, &output); 671 + status = wmi_evaluate_method(tlmi_priv.cert_guid->thumbprint, 0, 0, &input, &output); 682 672 if (ACPI_FAILURE(status)) { 683 673 kfree(output.pointer); 684 674 return -EIO; ··· 761 751 kfree_sensitive(passwd); 762 752 return -ENOMEM; 763 753 } 764 - ret = tlmi_simple_call(LENOVO_CERT_TO_PASSWORD_GUID, auth_str); 754 + ret = tlmi_simple_call(tlmi_priv.cert_guid->cert_to_password, auth_str); 765 755 kfree(auth_str); 766 756 kfree_sensitive(passwd); 767 757 ··· 784 774 char *auth_str, *new_cert; 785 775 const char *serial; 786 776 char *signature; 787 - char *guid; 777 + const char *guid; 788 778 int ret; 789 779 790 780 if (!capable(CAP_SYS_ADMIN)) ··· 807 797 if (!auth_str) 808 798 return -ENOMEM; 809 799 810 - ret = tlmi_simple_call(LENOVO_CLEAR_BIOS_CERT_GUID, auth_str); 800 + ret = tlmi_simple_call(tlmi_priv.cert_guid->clear_bios_cert, auth_str); 811 801 kfree(auth_str); 812 802 813 803 return ret ?: count; ··· 844 834 kfree(new_cert); 845 835 return -EACCES; 846 836 } 847 - guid = LENOVO_UPDATE_BIOS_CERT_GUID; 837 + guid = tlmi_priv.cert_guid->update_bios_cert; 848 838 /* Format: 'Certificate,Signature' */ 849 839 auth_str = cert_command(setting, new_cert, signature); 850 840 } else { ··· 855 845 kfree(new_cert); 856 846 return -EACCES; 857 847 } 858 - guid = LENOVO_SET_BIOS_CERT_GUID; 848 + guid = tlmi_priv.cert_guid->set_bios_cert; 859 849 /* Format: 'Certificate, password' */ 860 850 auth_str = cert_command(setting, new_cert, setting->password); 861 851 } ··· 1081 1071 goto out; 1082 1072 } 1083 1073 1084 - ret = tlmi_simple_call(LENOVO_SET_BIOS_SETTING_CERT_GUID, set_str); 1074 + ret = tlmi_simple_call(tlmi_priv.cert_guid->set_bios_setting, set_str); 1085 1075 if (ret) 1086 1076 goto out; 1087 1077 if (tlmi_priv.save_mode == TLMI_SAVE_BULK) 1088 1078 tlmi_priv.save_required = true; 1089 1079 else 1090 - ret = tlmi_simple_call(LENOVO_SAVE_BIOS_SETTING_CERT_GUID, 1080 + ret = tlmi_simple_call(tlmi_priv.cert_guid->save_bios_setting, 1091 1081 tlmi_priv.pwd_admin->save_signature); 1092 1082 } else if (tlmi_priv.opcode_support) { 1093 1083 /* ··· 1292 1282 ret = -EINVAL; 1293 1283 goto out; 1294 1284 } 1295 - ret = tlmi_simple_call(LENOVO_SAVE_BIOS_SETTING_CERT_GUID, 1285 + ret = tlmi_simple_call(tlmi_priv.cert_guid->save_bios_setting, 1296 1286 tlmi_priv.pwd_admin->save_signature); 1297 1287 if (ret) 1298 1288 goto out; ··· 1738 1728 } 1739 1729 1740 1730 if (tlmi_priv.certificate_support) { 1731 + tlmi_priv.cert_guid = &thinkpad_cert_guid; 1741 1732 tlmi_priv.pwd_admin->cert_installed = 1742 1733 tlmi_priv.pwdcfg.core.password_state & TLMI_CERT_SVC; 1743 1734 tlmi_priv.pwd_system->cert_installed =
+13
drivers/platform/x86/lenovo/think-lmi.h
··· 41 41 TLMI_SAVE_SAVE, 42 42 }; 43 43 44 + /* GUIDs can differ between platforms */ 45 + struct tlmi_cert_guids { 46 + const char *thumbprint; 47 + const char *set_bios_setting; 48 + const char *save_bios_setting; 49 + const char *cert_to_password; 50 + const char *clear_bios_cert; 51 + const char *update_bios_cert; 52 + const char *set_bios_cert; 53 + }; 54 + 44 55 /* password configuration details */ 45 56 #define TLMI_PWDCFG_MODE_LEGACY 0 46 57 #define TLMI_PWDCFG_MODE_PASSWORD 1 ··· 132 121 struct tlmi_pwd_setting *pwd_system; 133 122 struct tlmi_pwd_setting *pwd_hdd; 134 123 struct tlmi_pwd_setting *pwd_nvme; 124 + 125 + const struct tlmi_cert_guids *cert_guid; 135 126 }; 136 127 137 128 #endif /* !_THINK_LMI_H_ */