firmware: fix race conditions in control out transfers (-3 bytes XRAM).#703
Conversation
a628e16 to
b1e7539
Compare
b1e7539 to
cf672e2
Compare
|
I think you might need to update the submodule. |
Yes, but PR18 in libfx2 isn't merged yet, only approved. I'll do that as soon as it's merged. |
cf672e2 to
8591432
Compare
8591432 to
1091d3d
Compare
|
Alright,
Should be ready to merge. |
|
Thanks! |
|
(I think deploying the firmware may have to happen in a separate PR.) |
1091d3d to
be634a5
Compare
|
Okay, re-pushed without the deploy |
Before this change, the EP0BUF buffer used by control out transfers could be overwritten by new control transfers before the firmware is finished processing the previous control transfer. The easiest way to illustrate this problem would be to run in a different terminal the following: ```bash while true; do lsusb -v -d 20b7:9db1 > /dev/null; done ``` While this is running, glasglow is completely unusable. Presumably even a single lsusb run could cause corruption, if it happens to be issued at the wrong time. With this change glasgow is now usable, even if the above loop is running. Please see GlasgowEmbedded/libfx2#18 for more details.
be634a5 to
7bbbd25
Compare
|
Aand pushed again, rebased |
|
(You have write access now, so I think it automatically replaces your PR in the queue if you push to it, or something like that?) |
Not sure, I definitely didn't add it to the queue |
|
I did. But if you don't have write access, then it kicks you out of the queue after a (force-/normal-)push. |
…tes XRAM) These were missed by PR GlasgowEmbedded#703, because they used `SETUP_EP0_BUF(2)` with a non-zero argument for Control OUT transfers. Even though these didn't follow libfx2's (old) rule, of setting length to 0 when using Control OUT transfers, they did mostly work, because the FX2 actually ignores the length on OUT transfers. PR GlasgowEmbedded#703 assumed that all non-zero `SETUP_EP0_BUF` calls were IN transfer, which was wrong, so these instances remained vulnerable to the race condition. This change fixes those too.
…tes XRAM). These were missed by PR GlasgowEmbedded#703, because they used `SETUP_EP0_BUF(2)` with a non-zero argument for Control OUT transfers. Even though these didn't follow libfx2's (old) rule, of setting length to 0 when using Control OUT transfers, they did mostly work, because the FX2 actually ignores the length on OUT transfers. PR GlasgowEmbedded#703 assumed that all non-zero `SETUP_EP0_BUF` calls were IN transfer, which was wrong, so these instances remained vulnerable to the race condition. This change fixes those too.
These were missed by PR #703, because they used `SETUP_EP0_BUF(2)` with a non-zero argument for Control OUT transfers. Even though these didn't follow libfx2's (old) rule, of setting length to 0 when using Control OUT transfers, they did mostly work, because the FX2 actually ignores the length on OUT transfers. PR #703 assumed that all non-zero `SETUP_EP0_BUF` calls were IN transfer, which was wrong, so these instances remained vulnerable to the race condition. This change fixes those too.
This PR depends on GlasgowEmbedded/libfx2#18
This PR is ready for review but it should only be merged after the libfx2 PR is merged,
and then this PR should also include an update to the submodule reference.
Before this change, the EP0BUF buffer used by control out transfers could be overwritten by new control transfers before the firmware is finished processing the previous control transfer.
The easiest way to illustrate this problem would be to run in a different terminal the following:
While this is running, glasglow is completely unusable. Presumably even a single lsusb run could cause corruption, if it happens to be issued at the wrong time.
With this change glasgow is now usable, even if the above loop is running.