From ddf4e10d7b1469ffa7ef4c792375ab7feb7bd88c Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Mon, 18 Apr 2022 16:06:12 +0300 Subject: [PATCH] plugins/flashrom: enable for 2 Tuxedo laptops Their ME region in flash can be unlocked manually, give user instructions on how to do it. Signed-off-by: Sergii Dmytruk --- plugins/flashrom/flashrom.quirk | 12 ++++++++++ plugins/flashrom/fu-flashrom-device.c | 32 +++++++++++++++++++++++++++ plugins/flashrom/fu-flashrom-device.h | 3 +++ plugins/flashrom/fu-plugin-flashrom.c | 7 ++++++ 4 files changed, 54 insertions(+) diff --git a/plugins/flashrom/flashrom.quirk b/plugins/flashrom/flashrom.quirk index 4c8ea826a..ffcbb1e1b 100644 --- a/plugins/flashrom/flashrom.quirk +++ b/plugins/flashrom/flashrom.quirk @@ -99,3 +99,15 @@ Plugin = flashrom [43455705-4c7d-5440-b285-8362b67a5743] Branch = dasharo VersionFormat = triplet + +# Tuxedo InifinityBook S14 Gen6 (HwId) +[6c80d85b-d0b6-5ee2-99d4-ec28dd32febd] +Plugin = flashrom +[FLASHROM\GUID_6c80d85b-d0b6-5ee2-99d4-ec28dd32febd] +Flags = fn-m-me-unlock + +# Tuxedo InifinityBook S15 Gen6 (HwId) +[60f53465-e8fc-5122-b79b-f7b03f063037] +Plugin = flashrom +[FLASHROM\GUID_60f53465-e8fc-5122-b79b-f7b03f063037] +Flags = fn-m-me-unlock diff --git a/plugins/flashrom/fu-flashrom-device.c b/plugins/flashrom/fu-flashrom-device.c index a59b151e0..10bd8a8a5 100644 --- a/plugins/flashrom/fu-flashrom-device.c +++ b/plugins/flashrom/fu-flashrom-device.c @@ -19,6 +19,11 @@ */ #define FU_FLASHROM_DEVICE_FLAG_RESET_CMOS (1 << 0) +/* + * Flag to determine if manual ME unlocking by pressing Fn + M is supported. + */ +#define FU_FLASHROM_DEVICE_FLAG_FN_M_ME_UNLOCK (1 << 1) + struct _FuFlashromDevice { FuUdevDevice parent_instance; FuIfdRegion region; @@ -304,6 +309,9 @@ fu_flashrom_device_init(FuFlashromDevice *self) fu_device_register_private_flag(FU_DEVICE(self), FU_FLASHROM_DEVICE_FLAG_RESET_CMOS, "reset-cmos"); + fu_device_register_private_flag(FU_DEVICE(self), + FU_FLASHROM_DEVICE_FLAG_FN_M_ME_UNLOCK, + "fn-m-me-unlock"); } static void @@ -398,3 +406,27 @@ fu_flashrom_device_get_region(FuFlashromDevice *self) { return self->region; } + +gboolean +fu_flashrom_device_unlock(FuFlashromDevice *self, GError **error) +{ + if (fu_flashrom_device_get_region(self) == FU_IFD_REGION_ME && + fu_device_has_private_flag(FU_DEVICE(self), FU_FLASHROM_DEVICE_FLAG_FN_M_ME_UNLOCK)) { + g_set_error_literal(error, + FWUPD_ERROR, + FWUPD_ERROR_NOTHING_TO_DO, + "\n" + "ME region should be unlocked manually the following way:\n" + " 1. Power off your device\n" + " 2. Press and keep holding Fn + M during the next step\n" + " 3. Press power on button"); + return FALSE; + } + + g_set_error(error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Unlocking of device %s is not supported", + fu_device_get_name(FU_DEVICE(self))); + return FALSE; +} diff --git a/plugins/flashrom/fu-flashrom-device.h b/plugins/flashrom/fu-flashrom-device.h index fc4f9bb1e..9984a64f9 100644 --- a/plugins/flashrom/fu-flashrom-device.h +++ b/plugins/flashrom/fu-flashrom-device.h @@ -17,3 +17,6 @@ fu_flashrom_device_new(FuContext *ctx, FuIfdRegion region); FuIfdRegion fu_flashrom_device_get_region(FuFlashromDevice *self); + +gboolean +fu_flashrom_device_unlock(FuFlashromDevice *self, GError **error); diff --git a/plugins/flashrom/fu-plugin-flashrom.c b/plugins/flashrom/fu-plugin-flashrom.c index aebb5f249..adaa5fa02 100644 --- a/plugins/flashrom/fu-plugin-flashrom.c +++ b/plugins/flashrom/fu-plugin-flashrom.c @@ -281,6 +281,12 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, GError **error) return TRUE; } +static gboolean +fu_plugin_flashrom_unlock(FuPlugin *self, FuDevice *device, GError **error) +{ + return fu_flashrom_device_unlock(FU_FLASHROM_DEVICE(device), error); +} + void fu_plugin_init_vfuncs(FuPluginVfuncs *vfuncs) { @@ -290,4 +296,5 @@ fu_plugin_init_vfuncs(FuPluginVfuncs *vfuncs) vfuncs->device_registered = fu_plugin_flashrom_device_registered; vfuncs->startup = fu_plugin_flashrom_startup; vfuncs->coldplug = fu_plugin_flashrom_coldplug; + vfuncs->unlock = fu_plugin_flashrom_unlock; }