trivial: dell: TPM switching blacklist->whitelist

It's been decided that TPM mode switching won't be supported
on any other new platforms.  Instead of blacklisting the outliers
whitelist the (smaller) list of platforms that do support the
feature.
This commit is contained in:
Mario Limonciello 2017-08-29 15:28:50 -05:00 committed by Mario Limonciello
parent f30a1cbaa1
commit f1cc61d2f0
3 changed files with 40 additions and 23 deletions

View File

@ -103,11 +103,18 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (FuDellSmiObj, _dell_smi_obj_free);
#define TBT_CBL_DESC "Thunderbolt Cable"
/**
* Devices that should explicitly disable modeswitching
* Devices that should allow modeswitching
*/
static guint16 tpm_switch_blacklist[] = {0x06D6, 0x06E6, 0x06E7, 0x06EB, 0x06EA,
0x0702};
static guint16 tpm_switch_whitelist[] = {0x06F2, 0x06F3, 0x06DD, 0x06DE, 0x06DF,
0x06DB, 0x06DC, 0x06BB, 0x06C6, 0x06BA,
0x06B9, 0x05CA, 0x06C7, 0x06B7, 0x06E0,
0x06E5, 0x06D9, 0x06DA, 0x06E4, 0x0704,
0x0720, 0x0730, 0x0758, 0x0759, 0x075B,
0x07A0, 0x079F, 0x07A4, 0x07A5, 0x07A6,
0x07A7, 0x07A8, 0x07A9, 0x07AA, 0x07AB,
0x07B0, 0x07B1, 0x07B2, 0x07B4, 0x07B7,
0x07B8, 0x07B9, 0x07BE, 0x07BF, 0x077A,
0x07CF};
static void
_fwup_resource_iter_free (fwup_resource_iter *iter)
{
@ -146,7 +153,7 @@ fu_plugin_dell_match_dock_component (const gchar *query_str,
void
fu_plugin_dell_inject_fake_data (FuPlugin *plugin,
guint32 *output, guint16 vid, guint16 pid,
guint8 *buf)
guint8 *buf, gboolean can_switch_modes)
{
FuPluginData *data = fu_plugin_get_data (plugin);
@ -157,6 +164,7 @@ fu_plugin_dell_inject_fake_data (FuPlugin *plugin,
data->fake_vid = vid;
data->fake_pid = pid;
data->smi_obj->fake_buffer = buf;
data->can_switch_modes = TRUE;
}
static AsVersionParseFlag
@ -506,7 +514,7 @@ fu_plugin_dell_detect_tpm (FuPlugin *plugin, GError **error)
const gchar *tpm_mode;
const gchar *tpm_mode_alt;
guint16 system_id = 0;
gboolean can_switch_modes = TRUE;
gboolean can_switch_modes = FALSE;
g_autofree gchar *pretty_tpm_name_alt = NULL;
g_autofree gchar *pretty_tpm_name = NULL;
g_autofree gchar *product_name = NULL;
@ -562,10 +570,12 @@ fu_plugin_dell_detect_tpm (FuPlugin *plugin, GError **error)
if (!data->smi_obj->fake_smbios)
system_id = (guint16) sysinfo_get_dell_system_id ();
else
can_switch_modes = data->can_switch_modes;
for (guint i = 0; i < G_N_ELEMENTS (tpm_switch_blacklist); i++) {
if (tpm_switch_blacklist[i] == system_id) {
can_switch_modes = FALSE;
for (guint i = 0; i < G_N_ELEMENTS (tpm_switch_whitelist); i++) {
if (tpm_switch_whitelist[i] == system_id) {
can_switch_modes = TRUE;
}
}
@ -640,7 +650,7 @@ fu_plugin_dell_detect_tpm (FuPlugin *plugin, GError **error)
fu_plugin_device_add (plugin, dev_alt);
}
else
g_debug ("System %04x is on blacklist, disabling TPM modeswitch",
g_debug ("System %04x does not offer TPM modeswitching",
system_id);
return TRUE;

View File

@ -30,12 +30,13 @@ struct FuPluginData {
FuDellSmiObj *smi_obj;
guint16 fake_vid;
guint16 fake_pid;
gboolean can_switch_modes;
};
void
fu_plugin_dell_inject_fake_data (FuPlugin *plugin,
guint32 *output, guint16 vid, guint16 pid,
guint8 *buf);
guint8 *buf, gboolean can_switch_modes);
gboolean
fu_plugin_dell_detect_tpm (FuPlugin *plugin, GError **error);

View File

@ -75,7 +75,8 @@ fu_plugin_dell_tpm_func (void)
/* inject fake data (no TPM) */
tpm_out.ret = -2;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &tpm_out, 0, 0, NULL);
(guint32 *) &tpm_out, 0, 0,
NULL, FALSE);
ret = fu_plugin_dell_detect_tpm (plugin, &error);
g_assert_no_error (error);
g_assert (!ret);
@ -91,7 +92,8 @@ fu_plugin_dell_tpm_func (void)
tpm_out.status = TPM_EN_MASK | (TPM_1_2_MODE << 8);
tpm_out.flashes_left = 0;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &tpm_out, 0, 0, NULL);
(guint32 *) &tpm_out, 0, 0,
NULL, TRUE);
ret = fu_plugin_dell_detect_tpm (plugin, &error);
device_alt = fu_device_get_alternate (device);
g_assert_no_error (error);
@ -125,7 +127,8 @@ fu_plugin_dell_tpm_func (void)
tpm_out.status = TPM_EN_MASK | TPM_OWN_MASK | (TPM_1_2_MODE << 8);
tpm_out.flashes_left = 125;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &tpm_out, 0, 0, NULL);
(guint32 *) &tpm_out, 0, 0,
NULL, TRUE);
ret = fu_plugin_dell_detect_tpm (plugin, &error);
device_alt = fu_device_get_alternate (device);
g_assert_no_error (error);
@ -156,7 +159,8 @@ fu_plugin_dell_tpm_func (void)
tpm_out.status = TPM_EN_MASK | (TPM_1_2_MODE << 8);
tpm_out.flashes_left = 125;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &tpm_out, 0, 0, NULL);
(guint32 *) &tpm_out, 0, 0,
NULL, TRUE);
ret = fu_plugin_dell_detect_tpm (plugin, &error);
device_alt = fu_device_get_alternate (device);
g_assert_no_error (error);
@ -191,7 +195,8 @@ fu_plugin_dell_tpm_func (void)
tpm_out.status = TPM_EN_MASK | (TPM_2_0_MODE << 8);
tpm_out.flashes_left = 1;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &tpm_out, 0, 0, NULL);
(guint32 *) &tpm_out, 0, 0,
NULL, TRUE);
ret = fu_plugin_dell_detect_tpm (plugin, &error);
device_alt = fu_device_get_alternate (device);
g_assert_no_error (error);
@ -255,7 +260,7 @@ fu_plugin_dell_dock_func (void)
/* make sure bad device doesn't trigger this */
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
0x1234, 0x4321, NULL);
0x1234, 0x4321, NULL, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL, plugin);
g_assert (device == NULL);
@ -264,7 +269,8 @@ fu_plugin_dell_dock_func (void)
out[1] = 0;
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID, NULL);
DOCK_NIC_VID, DOCK_NIC_PID,
NULL, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL, plugin);
g_assert (device == NULL);
@ -296,7 +302,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID,
buf.buf);
buf.buf, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL,
plugin);
g_assert (device != NULL);
@ -333,7 +339,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID,
buf.buf);
buf.buf, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL,
plugin);
g_assert (device != NULL);
@ -368,7 +374,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID,
buf.buf);
buf.buf, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL,
plugin);
g_assert (device != NULL);
@ -403,7 +409,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID,
buf.buf);
buf.buf, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL,
plugin);
g_assert (device != NULL);
@ -431,7 +437,7 @@ fu_plugin_dell_dock_func (void)
fu_plugin_dell_inject_fake_data (plugin,
(guint32 *) &out,
DOCK_NIC_VID, DOCK_NIC_PID,
buf.buf);
buf.buf, FALSE);
fu_plugin_dell_device_added_cb (NULL, NULL,
plugin);
g_assert (device == NULL);