Skip to content

Default psa headers implementation #9661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion components/TARGET_PSA/inc/psa/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,43 @@

#if defined(TARGET_TFM)
#include "interface/include/psa_client.h"
#else
#elif defined(TARGET_MBED_SPM)
#include "TARGET_MBED_SPM/psa_defs.h"
#include "TARGET_MBED_SPM/spm_client.h"
#else

#ifndef __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
#define __MBED_OS_DEFAULT_PSA_CLIENT_API_H__

#if !defined(UINT32_MAX)
#define UINT32_MAX ((uint32_t)-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we duplicating the header file?
Please consider moving spm_client.h and psa_defs.h to this folder instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spm_client.h and psa_defs.h contains more defines and definitions that are not relevant for non-PSA builds (example K64F)

this "default" implementation holds only what the spec requires.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see this default implementation gets removed from the original files. Thus it is a duplication.
Please keep in mind that our divergence from TF-M sources ( spec version) is temporal while single core API compliance is not. Eventually I would not want to duplicate the header files and would prefer adopting TF-M's version.
Please consider moving these files to a common place instead of simbols cherry picking.

#endif

#if !defined(INT32_MIN)
#define INT32_MIN (-0x7fffffff - 1)
#endif

#define PSA_FRAMEWORK_VERSION (0x0100) /**< Version of the PSA Framework API. */
#define PSA_VERSION_NONE (0L) /**< Identifier for an unimplemented Root of Trust (RoT) Service. */
#define PSA_SUCCESS (0L) /**< A general result code for calls to psa_call() indicating success.*/
#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) /**< The return value from psa_connect() if the RoT Service or SPM was unable to establish a connection.*/
#define PSA_CONNECTION_BUSY (INT32_MIN + 2) /**< The return value from psa_connect() if the RoT Service rejects the connection for a transient reason.*/
#define PSA_DROP_CONNECTION (INT32_MIN) /**< The result code in a call to psa_reply() to indicate a nonrecoverable error in the client.*/
#define PSA_NULL_HANDLE ((psa_handle_t)0) /**< Denotes an invalid handle.*/

typedef int32_t psa_status_t;
typedef int32_t psa_handle_t;

typedef struct psa_invec {
const void *base; /**< Starting address of the buffer.*/
size_t len; /**< Length in bytes of the buffer.*/
} psa_invec;


typedef struct psa_outvec {
void *base; /**< Starting address of the buffer.*/
size_t len; /**< Length in bytes of the buffer.*/
} psa_outvec;

#endif // __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
#endif
4 changes: 3 additions & 1 deletion components/TARGET_PSA/inc/psa/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

#if defined(TARGET_TFM)
#include "interface/include/psa_service.h"
#else
#elif defined(TARGET_MBED_SPM)
#include "TARGET_MBED_SPM/psa_defs.h"
#include "TARGET_MBED_SPM/COMPONENT_SPE/spm_server.h"
#include "TARGET_MBED_SPM/COMPONENT_SPE/spm_panic.h"
#else
#error "Compiling psa service header on non-secure target is not allowed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not allowed? Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because you are not supposed to use psa/service/h in NSPE builds and non-PSA builds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call it not expected instead of not allowed. There are no rules about what symbols can be used where.

#endif