Hi all,
We found the problem with FPU S16-S31 registers if FPU is enabled and compiler uses S16-S31 FPU registers on CM33 non-secure code with TZ agent. SPM doesn't save/restore S16-S31 registers properly nor by PendSV neither by FLIH SVC handler. I created a patch for this problem:
https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/34202
The second problem I found is related to lazy stacking. It's possible that float point context will be stacked by MCU when FLIH is switching to/from background thread after a new boundary is applied. As result it's possible that the non-privileged code will no have access to PSP stack of suspended partition because a new MPU settings are applied. Please review a patch for this problem:
https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/34203
Regards,
Roman.
Hello,
We are facing the same compatibility break issues, during a TF-M 1.7.0 -> 2.1.0 migration.
- About the problem [1] (commit ffd13c3)
Is there any plan to implement a mechanism, to migrate old Protected Storage objects, to the new format?
- About the problem [2] (client id).
There is also a compatibility break, on keys stored in Internal Trusted Storage (ITS). A key generated from NS, with TF-M 1.7.0, can not be read anymore after TF-M 2.1.0 migration (psa_key_attributes returns PSA_ERROR_INVALID_HANDLE).
Changing client_id_limit from value -0x3c000000 to -1 makes old keys available.
Is there a cleaner option, to support backward compatibility with keys created with client id = -1?
Best regards,
T. FLOC'H
________________________________
This electronic message and its attachments are confidential and transmitted for the exclusive use of their addressee. Should you receive this message by mistake, you are not authorized to use it for any purpose whatsoever; please delete it and notify the sender at once. LACROIX reserves the right to initiate any legal proceedings against any individual and organization in case of unauthorized use, without prejudice to possible criminal sanctions.
________________________________
Ce message et ses pièces jointes sont confidentiels et exclusivement transmis à l'usage de leur destinataire. Si vous recevez ce message par erreur, vous n’êtes pas autorisés à en faire une quelconque utilisation ; merci de le détruire et d'en avertir immédiatement l'expéditeur. LACROIX se réserve le droit de poursuivre toute entité, personne physique ou morale qui en ferait un usage non autorisé, sans préjudice d'éventuelles sanctions pénales.
Hi,
I am trying to use connection-based (instead of SFN) Crypto service with MMIOVEC, but I noticed that iovec_status is not automatically cleared so the second psa_call causes a TFM panic due to detection of a previously mapped IOVEC.
FF spec says:
[cid:image001.png@01DB3B6B.1D4E93F0]
In tfm_crypto_call_srv(), I see the output vecs are unmapped but not the input vectors. Should the inputs be unmapped here as well? (psa_attest_get_token also does not unmap input vecs)
status = tfm_crypto_init_iovecs(msg, in_vec, in_len, out_vec, out_len);
if (status != PSA_SUCCESS) {
return status;
}
tfm_crypto_set_caller_id(msg->client_id);
/* Call the dispatcher to the functions that implement the PSA Crypto API */
status = tfm_crypto_api_dispatcher(in_vec, in_len, out_vec, out_len);
#if PSA_FRAMEWORK_HAS_MM_IOVEC == 1
for (i = 0; i < out_len; i++) {
if (out_vec[i].base != NULL) {
psa_unmap_outvec(msg->handle, i, out_vec[i].len);
}
}
#else
/* Write into the IPC framework outputs from the scratch */
for (i = 0; i < out_len; i++) {
psa_write(msg->handle, i, out_vec[i].base, out_vec[i].len);
}
Currently, to clear the connection's iovec_status, I have to call psa_close() after every psa_call() and reconnect with psa_connect() before the next psa_call() which adds overhead. Is this behavior of not automatically clearing iovec_status for connection-based services by design?
As an alternative to calling psa_unmap_invecs(), I was wondering if spm_get_connection()/spm_get_idle_connection() could be modified with the following workaround to avoid needing to close/connect:
#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
connection = handle_to_connection(handle);
if (!connection) {
return PSA_ERROR_PROGRAMMER_ERROR;
}
if (spm_validate_connection(connection) != PSA_SUCCESS) {
return PSA_ERROR_PROGRAMMER_ERROR;
}
/* WORKAROUND */
#if PSA_FRAMEWORK_HAS_MM_IOVEC
connection->iovec_status &= 0xFFFF0000; // Clear status of input vecs
#endif
/* Validate the caller id in the connection handle equals client_id. */
if (connection->msg.client_id != client_id) {
return PSA_ERROR_PROGRAMMER_ERROR;
}
/*
* It is a PROGRAMMER ERROR if the connection is currently
* handling a request.
*/
if (connection->status != TFM_HANDLE_STATUS_IDLE) {
return PSA_ERROR_PROGRAMMER_ERROR;
}
if (!(connection->service)) {
/* FixMe: Need to implement a mechanism to resolve this failure. */
return PSA_ERROR_PROGRAMMER_ERROR;
}
#else
Regards,
Brian Quach
SimpleLink MCU
Texas Instruments Inc.
12500 TI Blvd, MS F-4000
Dallas, TX 75243
214-479-4076
Hi Anton and Chris,
Thank you for your replies.
I have TFM_NS_MANAGE_NSID set to off. That does not prevent client_id
translation to happen. `tfm_nspm_get_current_client_id` seems to do
translation unconditionally here:
https://git.trustedfirmware.org/plugins/gitiles/TF-M/trusted-firmware-m.git….
But as said, setting client_id_limit in code to -1 helps. Maybe there could
be additional configuration #define whether to do translation
when TFM_NS_MANAGE_NSID is off.
Transition approach to convert the old PS data format to new one on the
flash when reading data in new format fails sounds reasonable assuming
there's no security problems involved in retrying to read the objects using
the old format after a failure. Probably not. It anyways sounds better than
supporting the old one "forever". At least to me, being able to do that
transition would require a bit of learning what exactly was the old and
what is the new layout. If there's some material in addition to source
code, I'd be happy to check that.
-Miika
ke 27.11.2024 klo 23.01 Chris.Brand--- via TF-M (
tf-m(a)lists.trustedfirmware.org) kirjoitti:
> Hi Miika,
>
>
>
> Unfortunately there have been a couple of changes to the way that PS data
> is stored in flash. I hope that we are getting better at considering
> backwards compatibility. In general I think that whenever we do introduce a
> change like this, we need to ensure that data stored with the old layout
> can still be read by newer code.
>
>
>
> I believe the patch that you’ve identified was part of the work to make PS
> encryption optional. Looking at it now, I don’t see that the layout was a
> necessary part of that work. Unfortunately, we’re now in a position where
> there could be PS data stored on devices in this new format, so just
> reverting that part of that patch would cause other problems.
>
>
>
> The bad news is that there’s another stored format change post-v2.1.1. The
> good news is that we did think about existing data and introduced a build
> option to read the old format.
>
>
>
> One solution to your problem would be similar to
> https://github.com/TrustedFirmware-M/trusted-firmware-m/commit/e8d48d78c166…
> - a build option to support reading the old format, with stores then using
> the new format. Another option would be to introduce the 1.8.1 format as an
> alternative implementation i.e. a second struct inside union ps_crypto_t
> and provide the 1.8.1 code as well as the current code (this would mean
> picking a storage format at build time and using it forever).
>
>
>
> Regarding the client_id. You’re correct that the client_id is used as a
> kind of access control (the client_id and UID together identify the stored
> object). Yes, there was a major change to the way that client_ids are used,
> with the mapping being added. Do you have TFM_NS_MANAGE_NSID set to ON? I
> believe that if it is set to OFF then -1 is used inside TF-M to represent
> all non-secure clients, which sounds like it may be what you need.
>
>
>
> Chris
>
Hi all,
just to point out that the coding guidelines are being updated to reflect feedback received over the years about the point of variable declaration. The majority of the code already follows this style, changing the guidelines to avoid further confusion.
…/coding_guide.rst · Gerrit Code Review<https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/33807/1/docs…>
Please let us know if any feedback.
Thanks,
Antonio
Hello,
The next Technical Forum is planned on Thursday, Sep 12 at 7:00-8:00 UTC (East time zone).
Please reply on this email with your proposals for agenda topics.
Recording and slides of previous meetings are here:
https://www.trustedfirmware.org/meetings/tf-m-technical-forum/
Best regards,
Anton
Hi Team
I am investigating the move from MbedTLS 2.25 to 3.6, however, our client uses the 2.25 currently (looks like they prefer to stay with it) and I need to provide convincing proof to move to 3.6 considering the upgrade issues that might arise. Any suggestions here that is convincing proof to do the migration to 3.6? I would appreciate your comments. Thanks
Michael