[RFC] make sof_abi_hdr optional in binary configs#2002
[RFC] make sof_abi_hdr optional in binary configs#2002juimonen wants to merge 2 commits intothesofproject:topic/sof-devfrom
Conversation
|
absolutely not tested thoroughly... |
SOF users want sometimes to use legacy binary blobs compatible with other DSP systems. These blobs are not wrapped inside sof_abi_hdr and trying to send those to firmware will stop at SOF driver in abi checks. So make the usage of sof_abi_hdr in bytes set/get optional thus moving the responsibility of possible abi checks to firmware. Blobs coming from user space are still wrapped inside snd_ctl_tlv and size checks are made in SOF driver. Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
…topology SOF users want sometimes to use legacy binary blobs compatible with other DSP systems. These blobs are not wrapped inside sof_abi_hdr and trying to send those to firmware will stop at SOF driver in abi checks. So make the usage of sof_abi_hdr in bytes inside topology optional thus moving the responsibility of possible abi checks to firmware. Blobs coming from user space are still wrapped inside snd_ctl_tlv and size checks are made in SOF driver. Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
2ef5bcc to
8cbd306
Compare
|
@cujomalainey @dgreid can you comment on this? Is it really a problem to have an ABI header information in binary blobs? |
Are the ABI headers useful for ensuring the blob being loaded is compatible with the running firmware? Or, are there other constraints on config blob format? Are blobs containing code considered in the same paths? Sorry for silly questions, just paging in some context... |
personally I think it might be worth keeping the header for anyone who doesn't have the forethought to put something like versioning system into their blob. Also the magic prevents anyone from stuffing random bytes down the control by accident. What do we gain by removing these checks other than the space the header occupies? |
|
@juimonen can you clarify which group was asking for this removal? I thought it was related to hotwording and EQ blobs but now it's unclear to me given the answers from @dgreid and @cujomalainey |
|
Let me add some information about this.
magic: sof-ctl tool:
(snd_ctl_tlv) [sof_abi_hdr] (blob raw data) Where the sof_abi_hdr is optional, but the snd_ctl_tlv is mandatory and should be included in the blob binary files. So it should be fine for @singalsu, it won't affect his EQ use case. Hi @cujomalainey @dgreid @bzhg, looks some of Google's blob files don't have the snd_ctl_tlv prefix, so it is still an open to me that how can we make them works without sof-ctl tool. @xiulipan is also working on this. @juimonen @xiulipan please correct me if I am wrong. |
These are some of the examples of cset-tlv we have from previous platforms in UCM: So, to get cset-tlv working on current blobs, we need to add header like below and probably for Intel platforms blobs can be updated by Google like below: @keyonjie , is this right understanding? |
Yes, to get cset-tlv work, without @juimonen 's change here, we should make the blobs to be in the format of "(snd_ctl_tlv) (sof_abi_hdr) (original blob)", all are mandatory, with this PR applied, it should be "(snd_ctl_tlv) [sof_abi_hdr] (original blob)", the sof_abi_hdr is optional. (I made a typo previously, the sof_abi_hdr should be put after the snd_ctl_tlv). |
|
@sathya-nujella Yes it should be like @keyonjie said, to make cset-tlv working we need I think this PR is can make the cset-tlv to work with |
|
I am not in the sync meeting with Google, it came from @sathyap-chrome so I guess it eventually from @bzhg ? @sathyap-chrome correct me if I am wrong. |
|
my request is based on how it is working for dsm param and wov works through UCM in KBL platforms. |
| dev_err_ratelimited(scomp->dev, "error: Mismatch in ABI data size (truncated?).\n"); | ||
| return -EINVAL; | ||
| /* copy the whole data blob */ | ||
| if (copy_from_user(cdata->data, tlvd->tlv, header.length)) |
There was a problem hiding this comment.
this looks like a bug to me and it was there in the original code. tlvd is a __user pointer, so, it shouldn't be dereferenced. You have a copy of tlvd->tlv now in header.tlv i.e. in kernel memory.
| return -EINVAL; | ||
| } | ||
| /* check if this blob actually uses sof_abi_hdr */ | ||
| if (cdata->data->magic == SOF_ABI_MAGIC) { |
There was a problem hiding this comment.
This doesn't look particularly robust to me, sorry. We check for a magic number, and if we don't find one, we still use the data. I understand that we want to rely on the firmware in such cases to check whether the data is valid. Maybe we should then give the firmware an explicit indication that this data isn't known to the kernel? How about cdata->data->magic = ~SOF_ABI_MAGIC;? Or cdata->data->magic = SOF_ABI_BINARY_LEGACY; or something?
| } else { | ||
| dev_dbg(scomp->dev, "no sof_abi_hdr in binary blob\n"); | ||
|
|
||
| if (copy_from_user(cdata->data->data, tlvd->tlv, header.length)) |
|
Is there a reason to avoid using the sof-ctl tool? It seems like a fine solution to me. It could be used at load time or at build time so the image on the board already has the headers. |
|
@dgreid my plan was to bypass the tool and use the controls directly in CRAS to avoid having to run code via the command line and incorporating another package. |
Hi @cujomalainey , @dgreid ,
|
@bzhg i feel like you are probably a good person to comment on this. @chiang831 FYI |
|
Hi @sathya-nujella I think your understanding is correct. I agree with @cujomalainey that we can modify the existing blobs using sof-ctl at build time as we move each older platform to SOF. The modified blobs with the two headers will also live in the ChromeOS localmirror and get installed to DUT image. No change to CRAS or SOF driver is needed. For development, sof-ctl can be used to test new blobs quickly. For production, we'll have an extra step to append the headers when updating the blobs. I feel the extra step is worth it to keep the basic sanity check and to be consistent across old and new platforms. @chiang831 What do you think? |
|
@bzhg @cujomalainey @dgreid @sathya-nujella Currently sof-ctl tool packages the blob inside snd_ctl_tlv before sending. So the blob that you are giving to sof-ctl doesn't have the snd_ctl_tlv in it. Like we have sof examples currently with eq's and demux. But sof blobs require also the sof_abi_hdr. So when sof-ctl sends the blob it looks like OTH "old" chrome blobs have this snd_ctl_tlv already around it. So the UCM is not wrapping anything at runtime, just sending the blob as it is. And they don't have sof_abi_hdr. So when old ucm chrome sends the blob it looks like (snd-ctl-tlv -> blob). So it is a question which approach is better.
|
|
@juimonen I checked with @lgirdwood he thinks sof_abi_hdr should be mandatory. So when sof-ctl sends the blob it looks like (snd-ctl-tlv -> sof_abi_hdr -> blob). He commented the parameters can change for different ABI versions of a component. A version mismatch can cause unexpected results. |
|
@mengdonglin ok this means then that "old" chrome blobs should be modified to have sof_abi_hdr after sof_ctl_tlv. There's still a question should we modify the "old" sof blobs to use also sof_ctl_tlv and remove the wrapping from sof-ctl? This would then "unify" the blobs in ucm and sof topology. |
|
chrome folks, if you want to experiment blob generation with the above suggestion, you could try thesofproject/sof#2536. With an option it should be able to generate a blob containing snd_ctl_tlv -> sof_abi_hdr -> blob |
|
We can modify the old chrome blobs from (snd-ctl-tlv)(blob) to (snd-ctl-tlv)(sof_abi_hdr)(blob). For the sof-ctl cmdline tool, is it possible to keep the -r option to allow wrap/unwrap of both headers? It'll make development/testing easier when experimenting new blobs. |
|
@bzhg yes no problem. If you change the "old" blobs to include sof_abi_hdr for ucm, I think we don't have to do do any changes for the driver (so this PR is obsolete). The driver strips the snd_ctl_tlv away and checks after that for sof_abi_hdr. I'm little bit now uncertain if the alsatplg will also wrap the topology blob with snd_ctl_tlv, but that can be changed later. It is just little bit inconsistent if the binary hex blobs in topology and ucm files look different, well you can't do diffs etc. @bzhg I haven't used sof-ctl that much myself, but if there are any issues, it is easy to modify/update for your needs... |
|
@juimonen so can we close this PR? |
|
@mengdonglin yes let's close it. We can revisit later if needed. The sof_abi_hdr chrome issue was cleared and @lyakh found&fixed a bug in the control copy, so it was not for nothing :) |
|
The sof-ctl tool has a switch -r to work without headers. I'm not using it since I really prefer to have the header there in my own generated configuration files to ensure compatibility. The EQ tool creates the header automatically so there's no extra effort for user. |
Currently we require SOF blobs to be wrapped inside sof_abi_hdr, thus other blobs that you try to send to firmware will stop at abi checks etc. in SOF driver. So make this optional.