Commit 32742e61 authored by Inaky Perez-Gonzalez's avatar Inaky Perez-Gonzalez

wimax/i2400m: decide properly if using signed vs non-signed firmware loading

The i2400m based devices can boot two main types of firmware images:
signed and non-signed. Signed images have signature data included that
must match that of a certificate stored in the device.

Currently the code is making the decission on what type of firmware
load (signed vs non-signed) is going to be loaded based on a hardcoded
decission in __i2400m_ack_verify(), based on the barker the device
sent upon boot.

This is not flexible enough as future hardware will emit more barkers;
thus the bit has to be set in a place where there is better knowledge
of what is going on. This will be done in follow-up commits -- however
this patch paves the way for it.

So the querying of the mode is packed into i2400m_boot_is_signed();
the main changes are just using i2400m_boot_is_signed() to determine
the method to follow and setting i2400m->sboot in
i2400m_is_boot_barker(). The modifications in i2400m_dnload_init() and
i2400m_dnload_finalize() are just reorganizing the order of the if
blocks and thus look larger than they really are.
Signed-off-by: default avatarInaky Perez-Gonzalez <inaky@linux.intel.com>
parent 59bdc4be
...@@ -508,6 +508,17 @@ error_send: ...@@ -508,6 +508,17 @@ error_send:
} }
/*
* Indicate if the device emitted a reboot barker that indicates
* "signed boot"
*/
static
unsigned i2400m_boot_is_signed(struct i2400m *i2400m)
{
return likely(i2400m->sboot);
}
/* /*
* Do the final steps of uploading firmware * Do the final steps of uploading firmware
* *
...@@ -529,7 +540,7 @@ int i2400m_dnload_finalize(struct i2400m *i2400m, ...@@ -529,7 +540,7 @@ int i2400m_dnload_finalize(struct i2400m *i2400m,
d_fnstart(3, dev, "offset %zu\n", offset); d_fnstart(3, dev, "offset %zu\n", offset);
cmd = (void *) bcf + offset; cmd = (void *) bcf + offset;
if (i2400m->sboot == 0) { if (i2400m_boot_is_signed(i2400m) == 0) {
struct i2400m_bootrom_header jump_ack; struct i2400m_bootrom_header jump_ack;
d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n", d_printf(1, dev, "unsecure boot, jumping to 0x%08x\n",
le32_to_cpu(cmd->target_addr)); le32_to_cpu(cmd->target_addr));
...@@ -846,28 +857,24 @@ int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf) ...@@ -846,28 +857,24 @@ int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf)
{ {
int result; int result;
struct device *dev = i2400m_dev(i2400m); struct device *dev = i2400m_dev(i2400m);
u32 module_id = le32_to_cpu(bcf->module_id);
if (i2400m->sboot == 0 if (i2400m_boot_is_signed(i2400m)) {
&& (module_id & I2400M_BCF_MOD_ID_POKES) == 0) { d_printf(1, dev, "signed boot\n");
/* non-signed boot process without pokes */ result = i2400m_dnload_init_signed(i2400m, bcf);
result = i2400m_dnload_init_nonsigned(i2400m);
if (result == -ERESTARTSYS) if (result == -ERESTARTSYS)
return result; return result;
if (result < 0) if (result < 0)
dev_err(dev, "fw %s: non-signed download " dev_err(dev, "firmware %s: signed boot download "
"initialization failed: %d\n", "initialization failed: %d\n",
i2400m->fw_name, result); i2400m->fw_name, result);
} else if (i2400m->sboot == 0 } else {
&& (module_id & I2400M_BCF_MOD_ID_POKES)) { /* non-signed boot process without pokes */
/* non-signed boot process with pokes, nothing to do */ d_printf(1, dev, "non-signed boot\n");
result = 0; result = i2400m_dnload_init_nonsigned(i2400m);
} else { /* signed boot process */
result = i2400m_dnload_init_signed(i2400m, bcf);
if (result == -ERESTARTSYS) if (result == -ERESTARTSYS)
return result; return result;
if (result < 0) if (result < 0)
dev_err(dev, "fw %s: signed boot download " dev_err(dev, "firmware %s: non-signed download "
"initialization failed: %d\n", "initialization failed: %d\n",
i2400m->fw_name, result); i2400m->fw_name, result);
} }
......
...@@ -168,16 +168,6 @@ enum i2400m_brh { ...@@ -168,16 +168,6 @@ enum i2400m_brh {
}; };
/* Constants for bcf->module_id */
enum i2400m_bcf_mod_id {
/* Firmware file carries its own pokes -- pokes are a set of
* magical values that have to be written in certain memory
* addresses to get the device up and ready for firmware
* download when it is in non-signed boot mode. */
I2400M_BCF_MOD_ID_POKES = 0x000000001,
};
/** /**
* i2400m_bootrom_header - Header for a boot-mode command * i2400m_bootrom_header - Header for a boot-mode command
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment