Changes in v2: 1. Separate patch for MdePkg/Include/IndustryStandard/GlobalPlatform.h. 2. Correct comments style for struct members. 3. Update commit message.
Sumit Garg (2): MdePkg/IndustryStandard: Add Global Plaform header file ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE
ArmPkg/Include/Library/OpteeLib.h | 87 ++++++ ArmPkg/Library/OpteeLib/Optee.c | 358 +++++++++++++++++++++++ ArmPkg/Library/OpteeLib/OpteeLib.inf | 2 + ArmPkg/Library/OpteeLib/OpteeSmc.h | 43 +++ MdePkg/Include/IndustryStandard/GlobalPlatform.h | 27 ++ 5 files changed, 517 insertions(+) create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h create mode 100644 MdePkg/Include/IndustryStandard/GlobalPlatform.h
Add Global Plaform header file specific to TEE Client API Specification v1 http://www.globalplatform.org/specificationsdevice.asp.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg sumit.garg@linaro.org --- MdePkg/Include/IndustryStandard/GlobalPlatform.h | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++ b/MdePkg/Include/IndustryStandard/GlobalPlatform.h @@ -0,0 +1,27 @@ +/** @file + Standardized Global Platform header file. GlobalPlatform TEE Client API + Specification v1.0: http://www.globalplatform.org/specificationsdevice.asp + + Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR> + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_ + +#define TEEC_ORIGIN_COMMS 0x00000002 + +#define TEEC_SUCCESS 0x00000000 +#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 +#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C +#define TEEC_ERROR_COMMUNICATION 0xFFFF000E + +#endif
On 27 August 2018 at 04:50, Sumit Garg sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE Client API Specification v1 http://www.globalplatform.org/specificationsdevice.asp.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg sumit.garg@linaro.org
Acked-by: Ard Biesheuvel ard.biesheuvel@linaro.org
Mike,
The header file is a bit light on content at introduction, but as discussed online, we can add stuff as we go for other use cases.
MdePkg/Include/IndustryStandard/GlobalPlatform.h | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++ b/MdePkg/Include/IndustryStandard/GlobalPlatform.h @@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file. GlobalPlatform TEE Client API
- Specification v1.0: http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS 0x00000002
+#define TEEC_SUCCESS 0x00000000 +#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 +#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C +#define TEEC_ERROR_COMMUNICATION 0xFFFF000E
+#endif
2.7.4
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE Client API Specification v1 http://www.globalplatform.org/specificationsdevice.asp.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg sumit.garg@linaro.org
Acked-by: Ard Biesheuvel ard.biesheuvel@linaro.org
Mike,
The header file is a bit light on content at introduction, but as discussed online, we can add stuff as we go for other use cases.
... as discussed *offline*
MdePkg/Include/IndustryStandard/GlobalPlatform.h | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++ b/MdePkg/Include/IndustryStandard/GlobalPlatform.h @@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file. GlobalPlatform TEE Client API
- Specification v1.0: http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS 0x00000002
+#define TEEC_SUCCESS 0x00000000 +#define TEEC_ERROR_BAD_PARAMETERS 0xFFFF0006 +#define TEEC_ERROR_OUT_OF_MEMORY 0xFFFF000C +#define TEEC_ERROR_COMMUNICATION 0xFFFF000E
+#endif
2.7.4
Hi Ard,
The initial content is only from the TEE Client API Specification. I noticed that there is an errata to that spec as well. Does this content follow the errata?
I also noticed that the specifications require the acceptance of an additional license to view the contents. Is there a version of the content for this include file available that does not require the acceptance of an additional license?
Thanks,
Mike
-----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Monday, September 24, 2018 1:26 AM To: Sumit Garg sumit.garg@linaro.org Cc: edk2-devel@lists.01.org; tee-dev@lists.linaro.org; Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo Carlini Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar udit.kumar@nxp.com; Kinney, Michael D michael.d.kinney@intel.com; Gao, Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg
sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE
Client API Specification v1
<http://www.globalplatform.org/specificationsdevice.asp
.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement
1.1
Signed-off-by: Sumit Garg sumit.garg@linaro.org
Acked-by: Ard Biesheuvel ard.biesheuvel@linaro.org
Mike,
The header file is a bit light on content at
introduction, but as
discussed online, we can add stuff as we go for other
use cases.
... as discussed *offline*
MdePkg/Include/IndustryStandard/GlobalPlatform.h |
27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+) create mode 100644
MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git
a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++
b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
@@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file.
GlobalPlatform TEE Client API
- Specification v1.0:
<http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights
reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms
and conditions of the BSD License
- which accompanies this distribution. The full
text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE
ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS
0x00000002
+#define TEEC_SUCCESS
0x00000000
+#define TEEC_ERROR_BAD_PARAMETERS
0xFFFF0006
+#define TEEC_ERROR_OUT_OF_MEMORY
0xFFFF000C
+#define TEEC_ERROR_COMMUNICATION
0xFFFF000E
+#endif
2.7.4
Thanks Mike for your comments.
On Mon, 24 Sep 2018 at 22:20, Kinney, Michael D michael.d.kinney@intel.com wrote:
Hi Ard,
The initial content is only from the TEE Client API Specification. I noticed that there is an errata to that spec as well. Does this content follow the errata?
Yes.
I also noticed that the specifications require the acceptance of an additional license to view the contents. Is there a version of the content for this include file available that does not require the acceptance of an additional license?
Yes, following is another version of the content for this include file:
https://github.com/OP-TEE/optee_client/blob/master/public/tee_client_api.h#L...
-Sumit
Thanks,
Mike
-----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Monday, September 24, 2018 1:26 AM To: Sumit Garg sumit.garg@linaro.org Cc: edk2-devel@lists.01.org; tee-dev@lists.linaro.org; Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo Carlini Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar udit.kumar@nxp.com; Kinney, Michael D michael.d.kinney@intel.com; Gao, Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg
sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE
Client API Specification v1
<http://www.globalplatform.org/specificationsdevice.asp
.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement
1.1
Signed-off-by: Sumit Garg sumit.garg@linaro.org
Acked-by: Ard Biesheuvel ard.biesheuvel@linaro.org
Mike,
The header file is a bit light on content at
introduction, but as
discussed online, we can add stuff as we go for other
use cases.
... as discussed *offline*
MdePkg/Include/IndustryStandard/GlobalPlatform.h |
27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+) create mode 100644
MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git
a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++
b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
@@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file.
GlobalPlatform TEE Client API
- Specification v1.0:
<http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights
reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms
and conditions of the BSD License
- which accompanies this distribution. The full
text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE
ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS
0x00000002
+#define TEEC_SUCCESS
0x00000000
+#define TEEC_ERROR_BAD_PARAMETERS
0xFFFF0006
+#define TEEC_ERROR_OUT_OF_MEMORY
0xFFFF000C
+#define TEEC_ERROR_COMMUNICATION
0xFFFF000E
+#endif
2.7.4
On Tue, 25 Sep 2018 at 10:27, Sumit Garg sumit.garg@linaro.org wrote:
Thanks Mike for your comments.
On Mon, 24 Sep 2018 at 22:20, Kinney, Michael D michael.d.kinney@intel.com wrote:
Hi Ard,
The initial content is only from the TEE Client API Specification. I noticed that there is an errata to that spec as well. Does this content follow the errata?
Yes.
I also noticed that the specifications require the acceptance of an additional license to view the contents. Is there a version of the content for this include file available that does not require the acceptance of an additional license?
Yes, following is another version of the content for this include file:
https://github.com/OP-TEE/optee_client/blob/master/public/tee_client_api.h#L...
Thanks Sumit.
Mike,
are you saying this content should not be [click through] license encumbered if we want to put it into MdePkg as an industry standard?
-----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Monday, September 24, 2018 1:26 AM To: Sumit Garg sumit.garg@linaro.org Cc: edk2-devel@lists.01.org; tee-dev@lists.linaro.org; Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo Carlini Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar udit.kumar@nxp.com; Kinney, Michael D michael.d.kinney@intel.com; Gao, Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg
sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE
Client API Specification v1
<http://www.globalplatform.org/specificationsdevice.asp
.
Cc: Michael D Kinney michael.d.kinney@intel.com Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement
1.1
Signed-off-by: Sumit Garg sumit.garg@linaro.org
Acked-by: Ard Biesheuvel ard.biesheuvel@linaro.org
Mike,
The header file is a bit light on content at
introduction, but as
discussed online, we can add stuff as we go for other
use cases.
... as discussed *offline*
MdePkg/Include/IndustryStandard/GlobalPlatform.h |
27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+) create mode 100644
MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git
a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++
b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
@@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file.
GlobalPlatform TEE Client API
- Specification v1.0:
<http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights
reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms
and conditions of the BSD License
- which accompanies this distribution. The full
text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE
ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS
0x00000002
+#define TEEC_SUCCESS
0x00000000
+#define TEEC_ERROR_BAD_PARAMETERS
0xFFFF0006
+#define TEEC_ERROR_OUT_OF_MEMORY
0xFFFF000C
+#define TEEC_ERROR_COMMUNICATION
0xFFFF000E
+#endif
2.7.4
Ard,
I think it depends on the license behind the click through.
The fact that there is another .h file with the same content under a BSD license is good data point. However, that other .h file does not reference the spec with the click through license, so it is not clear where the define values come from. I looked at the root of that tree, and it has a Readme.md that has a link to a Notice.md that has a link to a Notice.md in another repository that then has a link to the same specs that require the click through.
https://github.com/OP-TEE/optee_client/blob/master/README.md https://github.com/OP-TEE/optee_client/blob/master/Notice.md https://github.com/OP-TEE/optee_os/blob/master/Notice.md https://globalplatform.org/specs-library/
Can you explain how this other project is using spec content that requires a click through license.
Thanks,
Mike
-----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Tuesday, September 25, 2018 1:32 AM To: Sumit Garg sumit.garg@linaro.org Cc: Kinney, Michael D michael.d.kinney@intel.com; edk2-devel@lists.01.org; tee-dev@lists.linaro.org; Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo Carlini Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar udit.kumar@nxp.com; Gao, Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file
On Tue, 25 Sep 2018 at 10:27, Sumit Garg sumit.garg@linaro.org wrote:
Thanks Mike for your comments.
On Mon, 24 Sep 2018 at 22:20, Kinney, Michael D michael.d.kinney@intel.com wrote:
Hi Ard,
The initial content is only from the TEE Client API
Specification.
I noticed that there is an errata to that spec as
well. Does this
content follow the errata?
Yes.
I also noticed that the specifications require the
acceptance of
an additional license to view the contents. Is
there a version of
the content for this include file available that
does not require
the acceptance of an additional license?
Yes, following is another version of the content for
this include file:
TEE/optee_client/blob/master/public/tee_client_api.h#L16 3
Thanks Sumit.
Mike,
are you saying this content should not be [click through] license encumbered if we want to put it into MdePkg as an industry standard?
-----Original Message----- From: Ard Biesheuvel
[mailto:ard.biesheuvel@linaro.org]
Sent: Monday, September 24, 2018 1:26 AM To: Sumit Garg sumit.garg@linaro.org Cc: edk2-devel@lists.01.org; tee-
dev@lists.linaro.org;
Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo
Carlini
Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar
Kinney, Michael D michael.d.kinney@intel.com;
Gao,
Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header
file
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg
sumit.garg@linaro.org wrote:
Add Global Plaform header file specific to TEE
Client API Specification v1
<http://www.globalplatform.org/specificationsdevice.asp
.
Cc: Michael D Kinney
Cc: Liming Gao liming.gao@intel.com Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution
Agreement
1.1
Signed-off-by: Sumit Garg
Acked-by: Ard Biesheuvel
Mike,
The header file is a bit light on content at
introduction, but as
discussed online, we can add stuff as we go for
other
use cases.
... as discussed *offline*
MdePkg/Include/IndustryStandard/GlobalPlatform.h |
27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+) create mode 100644
MdePkg/Include/IndustryStandard/GlobalPlatform.h
diff --git
a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
new file mode 100644 index 000000000000..72c5af4ef588 --- /dev/null +++
b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
@@ -0,0 +1,27 @@ +/** @file
- Standardized Global Platform header file.
GlobalPlatform TEE Client API
- Specification v1.0:
<http://www.globalplatform.org/specificationsdevice.asp
- Copyright (c) 2018, Linaro Ltd. All rights
reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the
terms
and conditions of the BSD License
- which accompanies this distribution. The
full
text of the license may be found at
license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD
LICENSE
ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF
ANY
KIND, EITHER EXPRESS OR IMPLIED.
+**/
+#ifndef _GLOBAL_PLATFORM_H_ +#define _GLOBAL_PLATFORM_H_
+#define TEEC_ORIGIN_COMMS
0x00000002
+#define TEEC_SUCCESS
0x00000000
+#define TEEC_ERROR_BAD_PARAMETERS
0xFFFF0006
+#define TEEC_ERROR_OUT_OF_MEMORY
0xFFFF000C
+#define TEEC_ERROR_COMMUNICATION
0xFFFF000E
+#endif
2.7.4
+Joakim
Joakim,
Please help to answer below query from Michael regarding licensing concerns for using Global Platform specs content in OP-TEE.
Regards, Sumit
On Wed, 26 Sep 2018 at 23:32, Kinney, Michael D michael.d.kinney@intel.com wrote:
Ard,
I think it depends on the license behind the click through.
The fact that there is another .h file with the same content under a BSD license is good data point. However, that other .h file does not reference the spec with the click through license, so it is not clear where the define values come from. I looked at the root of that tree, and it has a Readme.md that has a link to a Notice.md that has a link to a Notice.md in another repository that then has a link to the same specs that require the click through.
https://github.com/OP-TEE/optee_client/blob/master/README.md https://github.com/OP-TEE/optee_client/blob/master/Notice.md https://github.com/OP-TEE/optee_os/blob/master/Notice.md https://globalplatform.org/specs-library/
Can you explain how this other project is using spec content that requires a click through license.
Thanks,
Mike
-----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] Sent: Tuesday, September 25, 2018 1:32 AM To: Sumit Garg sumit.garg@linaro.org Cc: Kinney, Michael D michael.d.kinney@intel.com; edk2-devel@lists.01.org; tee-dev@lists.linaro.org; Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo Carlini Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar udit.kumar@nxp.com; Gao, Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header file
On Tue, 25 Sep 2018 at 10:27, Sumit Garg sumit.garg@linaro.org wrote:
Thanks Mike for your comments.
On Mon, 24 Sep 2018 at 22:20, Kinney, Michael D michael.d.kinney@intel.com wrote:
Hi Ard,
The initial content is only from the TEE Client API
Specification.
I noticed that there is an errata to that spec as
well. Does this
content follow the errata?
Yes.
I also noticed that the specifications require the
acceptance of
an additional license to view the contents. Is
there a version of
the content for this include file available that
does not require
the acceptance of an additional license?
Yes, following is another version of the content for
this include file:
TEE/optee_client/blob/master/public/tee_client_api.h#L16 3
Thanks Sumit.
Mike,
are you saying this content should not be [click through] license encumbered if we want to put it into MdePkg as an industry standard?
-----Original Message----- From: Ard Biesheuvel
[mailto:ard.biesheuvel@linaro.org]
Sent: Monday, September 24, 2018 1:26 AM To: Sumit Garg sumit.garg@linaro.org Cc: edk2-devel@lists.01.org; tee-
dev@lists.linaro.org;
Leif Lindholm leif.lindholm@linaro.org; Daniel Thompson daniel.thompson@linaro.org; Matteo
Carlini
Matteo.Carlini@arm.com; Achin Gupta Achin.Gupta@arm.com; Udit Kumar
Kinney, Michael D michael.d.kinney@intel.com;
Gao,
Liming liming.gao@intel.com Subject: Re: [edk2][PATCH v2 1/2] MdePkg/IndustryStandard: Add Global Plaform header
file
On Sat, 22 Sep 2018 at 01:15, Ard Biesheuvel ard.biesheuvel@linaro.org wrote:
On 27 August 2018 at 04:50, Sumit Garg
sumit.garg@linaro.org wrote:
> Add Global Plaform header file specific to TEE
Client API Specification v1
>
<http://www.globalplatform.org/specificationsdevice.asp
. > > Cc: Michael D Kinney
> Cc: Liming Gao liming.gao@intel.com > Cc: Ard Biesheuvel ard.biesheuvel@linaro.org > Cc: Leif Lindholm leif.lindholm@linaro.org > Contributed-under: TianoCore Contribution
Agreement
1.1
> Signed-off-by: Sumit Garg
Acked-by: Ard Biesheuvel
Mike,
The header file is a bit light on content at
introduction, but as
discussed online, we can add stuff as we go for
other
use cases.
... as discussed *offline*
> --- >
MdePkg/Include/IndustryStandard/GlobalPlatform.h |
27 ++++++++++++++++++++++++
> 1 file changed, 27 insertions(+) > create mode 100644
MdePkg/Include/IndustryStandard/GlobalPlatform.h
> > diff --git
a/MdePkg/Include/IndustryStandard/GlobalPlatform.h b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
> new file mode 100644 > index 000000000000..72c5af4ef588 > --- /dev/null > +++
b/MdePkg/Include/IndustryStandard/GlobalPlatform.h
> @@ -0,0 +1,27 @@ > +/** @file > + Standardized Global Platform header file.
GlobalPlatform TEE Client API
> + Specification v1.0:
<http://www.globalplatform.org/specificationsdevice.asp
> + > + Copyright (c) 2018, Linaro Ltd. All rights
reserved.<BR>
> + > + This program and the accompanying materials > + are licensed and made available under the
terms
and conditions of the BSD License
> + which accompanies this distribution. The
full
text of the license may be found at
license.php
> + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD
LICENSE
ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF
ANY
KIND, EITHER EXPRESS OR IMPLIED.
> + > +**/ > + > +#ifndef _GLOBAL_PLATFORM_H_ > +#define _GLOBAL_PLATFORM_H_ > + > +#define TEEC_ORIGIN_COMMS
0x00000002
> + > +#define TEEC_SUCCESS
0x00000000
> +#define TEEC_ERROR_BAD_PARAMETERS
0xFFFF0006
> +#define TEEC_ERROR_OUT_OF_MEMORY
0xFFFF000C
> +#define TEEC_ERROR_COMMUNICATION
0xFFFF000E
> + > +#endif > -- > 2.7.4 >
Hi,
On Thu, Sep 27, 2018 at 05:40:49PM +0530, Sumit Garg wrote:
+Joakim
Joakim,
Please help to answer below query from Michael regarding licensing concerns for using Global Platform specs content in OP-TEE.
This dates back to ~2014 before OP-TEE had been pushed as an open source project and indeed the click-through license was one thing that was discussed before we decided to publish this. Having that said, the legal people at ST (back then the project was owned by ST) concluded that we could use the GP click-through license for the APIs, this is a copy/paste from an email discussion with ST (in 2014).
"On the legal side, one week ago our legal dedicated to this matter wrote “Progress! Finally, having discussed with colleagues, we have concluded that we can use the GP click-through license for the APIs. Therefore I just need to tidy up the following points and we will be able to provide both the CLA and the license terms for the distribution quite quickly […].”
I don't know how the discussion went inside ST nor who the legal person was, but since ST had people on GlobalPlatform boards back then, I suppose that the ST legal people went that way. The only way to find out more about this is to talk directly to ST legal people who were involved in this back in the days.
On Thu, 27 Sep 2018 at 18:21, Joakim Bech joakim.bech@linaro.org wrote:
Hi,
On Thu, Sep 27, 2018 at 05:40:49PM +0530, Sumit Garg wrote:
+Joakim
Joakim,
Please help to answer below query from Michael regarding licensing concerns for using Global Platform specs content in OP-TEE.
This dates back to ~2014 before OP-TEE had been pushed as an open source project and indeed the click-through license was one thing that was discussed before we decided to publish this. Having that said, the legal people at ST (back then the project was owned by ST) concluded that we could use the GP click-through license for the APIs, this is a copy/paste from an email discussion with ST (in 2014).
"On the legal side, one week ago our legal dedicated to this matter wrote “Progress! Finally, having discussed with colleagues, we have concluded that we can use the GP click-through license for the APIs. Therefore I just need to tidy up the following points and we will be able to provide both the CLA and the license terms for the distribution quite quickly […].”
I don't know how the discussion went inside ST nor who the legal person was, but since ST had people on GlobalPlatform boards back then, I suppose that the ST legal people went that way. The only way to find out more about this is to talk directly to ST legal people who were involved in this back in the days.
Thanks Joakim for this info.
Mike,
Please share your views on this and if we could include content from Global Platform spec into MdePkg as an industry standard.
-Sumit
Hi Sumit,
On Fri, Sep 28, 2018 at 11:59:33AM +0530, Sumit Garg wrote:
Please help to answer below query from Michael regarding licensing concerns for using Global Platform specs content in OP-TEE.
This dates back to ~2014 before OP-TEE had been pushed as an open source project and indeed the click-through license was one thing that was discussed before we decided to publish this. Having that said, the legal people at ST (back then the project was owned by ST) concluded that we could use the GP click-through license for the APIs, this is a copy/paste from an email discussion with ST (in 2014).
"On the legal side, one week ago our legal dedicated to this matter wrote “Progress! Finally, having discussed with colleagues, we have concluded that we can use the GP click-through license for the APIs. Therefore I just need to tidy up the following points and we will be able to provide both the CLA and the license terms for the distribution quite quickly […].”
I don't know how the discussion went inside ST nor who the legal person was, but since ST had people on GlobalPlatform boards back then, I suppose that the ST legal people went that way. The only way to find out more about this is to talk directly to ST legal people who were involved in this back in the days.
Thanks Joakim for this info.
Mike,
Please share your views on this and if we could include content from Global Platform spec into MdePkg as an industry standard.
Having had a discussion about this, the bit that concerns us the most is the export restrictions clause of the click-through license which contains the very unfortunate part "or any product complying with the Specification.".
Someone must have thought this interface defines cryptography, rather than an API through which to call cryptography functions.
I don't like it, but without a change in that license I don't see how we can include this interface in edk2. One workaround would be to publish this in a separate repository on https://github.com/OP-TEE/ which could be included in builds using PACKAGES_PATH (like we do with edk2-platforms and edk2-non-osi).
/ Leif
Add following APIs to communicate with OP-TEE pseudo/early TAs: 1. OpteeInit 2. OpteeOpenSession 3. OpteeCloseSession 4. OpteeInvokeFunc
Cc: Ard Biesheuvel ard.biesheuvel@linaro.org Cc: Leif Lindholm leif.lindholm@linaro.org Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sumit Garg sumit.garg@linaro.org --- ArmPkg/Include/Library/OpteeLib.h | 87 +++++++++ ArmPkg/Library/OpteeLib/Optee.c | 358 +++++++++++++++++++++++++++++++++++ ArmPkg/Library/OpteeLib/OpteeLib.inf | 2 + ArmPkg/Library/OpteeLib/OpteeSmc.h | 43 +++++ 4 files changed, 490 insertions(+) create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h
diff --git a/ArmPkg/Include/Library/OpteeLib.h b/ArmPkg/Include/Library/OpteeLib.h index f65d8674d9b8..89d6b5a7b34f 100644 --- a/ArmPkg/Include/Library/OpteeLib.h +++ b/ArmPkg/Include/Library/OpteeLib.h @@ -25,10 +25,97 @@ #define OPTEE_OS_UID2 0xaf630002 #define OPTEE_OS_UID3 0xa5d5c51b
+#define OPTEE_MSG_ATTR_TYPE_NONE 0x0 +#define OPTEE_MSG_ATTR_TYPE_VALUE_INPUT 0x1 +#define OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT 0x2 +#define OPTEE_MSG_ATTR_TYPE_VALUE_INOUT 0x3 +#define OPTEE_MSG_ATTR_TYPE_MEM_INPUT 0x9 +#define OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT 0xa +#define OPTEE_MSG_ATTR_TYPE_MEM_INOUT 0xb + +#define OPTEE_MSG_ATTR_TYPE_MASK 0xff + +typedef struct { + UINT64 BufPtr; + UINT64 Size; + UINT64 ShmRef; +} OPTEE_MSG_PARAM_MEM; + +typedef struct { + UINT64 A; + UINT64 B; + UINT64 C; +} OPTEE_MSG_PARAM_VALUE; + +typedef struct { + UINT64 Attr; + union { + OPTEE_MSG_PARAM_MEM Mem; + OPTEE_MSG_PARAM_VALUE Value; + } U; +} OPTEE_MSG_PARAM; + +#define MAX_PARAMS 4 + +typedef struct { + UINT32 Cmd; + UINT32 Func; + UINT32 Session; + UINT32 CancelId; + UINT32 Pad; + UINT32 Ret; + UINT32 RetOrigin; + UINT32 NumParams; + + // NumParams tells the actual number of element in Params + OPTEE_MSG_PARAM Params[MAX_PARAMS]; +} OPTEE_MSG_ARG; + +#define OPTEE_UUID_LEN 16 + +typedef struct { + UINT8 Uuid[OPTEE_UUID_LEN]; // [in] UUID of the Trusted Application + UINT32 Session; // [out] Session id + UINT32 Ret; // [out] Return value + UINT32 RetOrigin; // [out] Origin of the return value +} OPTEE_OPEN_SESSION_ARG; + +typedef struct { + UINT32 Func; // [in] Trusted App func, specific to the TA + UINT32 Session; // [in] Session id + UINT32 Ret; // [out] Return value + UINT32 RetOrigin; // [out] Origin of the return value + OPTEE_MSG_PARAM Params[MAX_PARAMS]; // Params for func to be invoked +} OPTEE_INVOKE_FUNC_ARG; + BOOLEAN EFIAPI IsOpteePresent ( VOID );
+EFI_STATUS +EFIAPI +OpteeInit ( + VOID + ); + +EFI_STATUS +EFIAPI +OpteeOpenSession ( + IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg + ); + +EFI_STATUS +EFIAPI +OpteeCloseSession ( + IN UINT32 Session + ); + +EFI_STATUS +EFIAPI +OpteeInvokeFunc ( + IN OUT OPTEE_INVOKE_FUNC_ARG *InvokeFuncArg + ); + #endif diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c index 574527f8b5ea..2111022d3662 100644 --- a/ArmPkg/Library/OpteeLib/Optee.c +++ b/ArmPkg/Library/OpteeLib/Optee.c @@ -14,11 +14,19 @@
**/
+#include <Library/ArmMmuLib.h> #include <Library/ArmSmcLib.h> +#include <Library/BaseMemoryLib.h> #include <Library/BaseLib.h> +#include <Library/DebugLib.h> #include <Library/OpteeLib.h>
#include <IndustryStandard/ArmStdSmc.h> +#include <IndustryStandard/GlobalPlatform.h> +#include <OpteeSmc.h> +#include <Uefi.h> + +STATIC OPTEE_SHARED_MEMORY_INFO OpteeShmInfo = { 0 };
/** Check for OP-TEE presence. @@ -31,6 +39,7 @@ IsOpteePresent ( { ARM_SMC_ARGS ArmSmcArgs;
+ ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS)); // Send a Trusted OS Calls UID command ArmSmcArgs.Arg0 = ARM_SMC_ID_TOS_UID; ArmCallSmc (&ArmSmcArgs); @@ -44,3 +53,352 @@ IsOpteePresent ( return FALSE; } } + +STATIC +EFI_STATUS +OpteeShmMemRemap ( + VOID + ) +{ + ARM_SMC_ARGS ArmSmcArgs; + EFI_PHYSICAL_ADDRESS Paddr; + EFI_PHYSICAL_ADDRESS Start; + EFI_PHYSICAL_ADDRESS End; + EFI_STATUS Status; + UINTN Size; + + ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS)); + ArmSmcArgs.Arg0 = OPTEE_SMC_GET_SHM_CONFIG; + + ArmCallSmc (&ArmSmcArgs); + if (ArmSmcArgs.Arg0 != OPTEE_SMC_RETURN_OK) { + DEBUG ((DEBUG_WARN, "OP-TEE shared memory not supported\n")); + return EFI_UNSUPPORTED; + } + + if (ArmSmcArgs.Arg3 != OPTEE_SMC_SHM_CACHED) { + DEBUG ((DEBUG_WARN, "OP-TEE: Only normal cached shared memory supported\n")); + return EFI_UNSUPPORTED; + } + + Start = (ArmSmcArgs.Arg1 + SIZE_4KB - 1) & ~(SIZE_4KB - 1); + End = (ArmSmcArgs.Arg1 + ArmSmcArgs.Arg2) & ~(SIZE_4KB - 1); + Paddr = Start; + Size = End - Start; + + if (Size < SIZE_4KB) { + DEBUG ((DEBUG_WARN, "OP-TEE shared memory too small\n")); + return EFI_BUFFER_TOO_SMALL; + } + + Status = ArmSetMemoryAttributes (Paddr, Size, EFI_MEMORY_WB); + if (EFI_ERROR (Status)) { + return Status; + } + + OpteeShmInfo.Base = (UINTN)Paddr; + OpteeShmInfo.Size = Size; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +OpteeInit ( + VOID + ) +{ + EFI_STATUS Status; + + if (!IsOpteePresent ()) { + DEBUG ((DEBUG_WARN, "OP-TEE not present\n")); + return EFI_UNSUPPORTED; + } + + Status = OpteeShmMemRemap (); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "OP-TEE shared memory remap failed\n")); + return Status; + } + + return EFI_SUCCESS; +} + +/** + Does Standard SMC to OP-TEE in secure world. + + @param[in] Parg Physical address of message to pass to secure world + + @return 0 on success, secure world return code otherwise + +**/ +STATIC +UINT32 +OpteeCallWithArg ( + IN EFI_PHYSICAL_ADDRESS Parg + ) +{ + ARM_SMC_ARGS ArmSmcArgs; + + ZeroMem (&ArmSmcArgs, sizeof (ARM_SMC_ARGS)); + ArmSmcArgs.Arg0 = OPTEE_SMC_CALL_WITH_ARG; + ArmSmcArgs.Arg1 = (UINT32)(Parg >> 32); + ArmSmcArgs.Arg2 = (UINT32)Parg; + + while (TRUE) { + ArmCallSmc (&ArmSmcArgs); + + if (ArmSmcArgs.Arg0 == OPTEE_SMC_RETURN_RPC_FOREIGN_INTR) { + // + // A foreign interrupt was raised while secure world was + // executing, since they are handled in UEFI a dummy RPC is + // performed to let UEFI take the interrupt through the normal + // vector. + // + ArmSmcArgs.Arg0 = OPTEE_SMC_RETURN_FROM_RPC; + } else { + break; + } + } + + return ArmSmcArgs.Arg0; +} + +EFI_STATUS +EFIAPI +OpteeOpenSession ( + IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg + ) +{ + OPTEE_MSG_ARG *MsgArg; + + MsgArg = NULL; + + if (OpteeShmInfo.Base == 0) { + DEBUG ((DEBUG_WARN, "OP-TEE not initialized\n")); + return EFI_NOT_STARTED; + } + + MsgArg = (OPTEE_MSG_ARG *)OpteeShmInfo.Base; + ZeroMem (MsgArg, sizeof (OPTEE_MSG_ARG)); + + MsgArg->Cmd = OPTEE_MSG_CMD_OPEN_SESSION; + + // + // Initialize and add the meta parameters needed when opening a + // session. + // + MsgArg->Params[0].Attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | + OPTEE_MSG_ATTR_META; + MsgArg->Params[1].Attr = OPTEE_MSG_ATTR_TYPE_VALUE_INPUT | + OPTEE_MSG_ATTR_META; + CopyMem (&MsgArg->Params[0].U.Value, OpenSessionArg->Uuid, OPTEE_UUID_LEN); + ZeroMem (&MsgArg->Params[1].U.Value, OPTEE_UUID_LEN); + MsgArg->Params[1].U.Value.C = TEE_LOGIN_PUBLIC; + + MsgArg->NumParams = 2; + + if (OpteeCallWithArg ((EFI_PHYSICAL_ADDRESS)MsgArg)) { + MsgArg->Ret = TEEC_ERROR_COMMUNICATION; + MsgArg->RetOrigin = TEEC_ORIGIN_COMMS; + } + + OpenSessionArg->Session = MsgArg->Session; + OpenSessionArg->Ret = MsgArg->Ret; + OpenSessionArg->RetOrigin = MsgArg->RetOrigin; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +OpteeCloseSession ( + IN UINT32 Session + ) +{ + OPTEE_MSG_ARG *MsgArg; + + MsgArg = NULL; + + if (OpteeShmInfo.Base == 0) { + DEBUG ((DEBUG_WARN, "OP-TEE not initialized\n")); + return EFI_NOT_STARTED; + } + + MsgArg = (OPTEE_MSG_ARG *)OpteeShmInfo.Base; + ZeroMem (MsgArg, sizeof (OPTEE_MSG_ARG)); + + MsgArg->Cmd = OPTEE_MSG_CMD_CLOSE_SESSION; + MsgArg->Session = Session; + + OpteeCallWithArg ((EFI_PHYSICAL_ADDRESS)MsgArg); + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +OpteeToMsgParam ( + OUT OPTEE_MSG_PARAM *MsgParams, + IN UINT32 NumParams, + IN OPTEE_MSG_PARAM *InParams + ) +{ + UINT32 Idx; + UINTN ParamShmAddr; + UINTN ShmSize; + UINTN Size; + + Size = (sizeof (OPTEE_MSG_ARG) + sizeof (UINT64) - 1) & ~(sizeof (UINT64) - 1); + ParamShmAddr = OpteeShmInfo.Base + Size; + ShmSize = OpteeShmInfo.Size - Size; + + for (Idx = 0; Idx < NumParams; Idx++) { + CONST OPTEE_MSG_PARAM *Ip; + OPTEE_MSG_PARAM *Mp; + UINT32 Attr; + + Ip = InParams + Idx; + Mp = MsgParams + Idx; + Attr = Ip->Attr & OPTEE_MSG_ATTR_TYPE_MASK; + + switch (Attr) { + case OPTEE_MSG_ATTR_TYPE_NONE: + Mp->Attr = OPTEE_MSG_ATTR_TYPE_NONE; + ZeroMem (&Mp->U, sizeof (Mp->U)); + break; + + case OPTEE_MSG_ATTR_TYPE_VALUE_INPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_INOUT: + Mp->Attr = Attr; + Mp->U.Value.A = Ip->U.Value.A; + Mp->U.Value.B = Ip->U.Value.B; + Mp->U.Value.C = Ip->U.Value.C; + break; + + case OPTEE_MSG_ATTR_TYPE_MEM_INPUT: + case OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_MEM_INOUT: + Mp->Attr = Attr; + + if (Ip->U.Mem.Size > ShmSize) { + return EFI_OUT_OF_RESOURCES; + } + + CopyMem ((VOID *)ParamShmAddr, (VOID *)Ip->U.Mem.BufPtr, Ip->U.Mem.Size); + Mp->U.Mem.BufPtr = (UINT64)ParamShmAddr; + Mp->U.Mem.Size = Ip->U.Mem.Size; + + Size = (Ip->U.Mem.Size + sizeof (UINT64) - 1) & ~(sizeof (UINT64) - 1); + ParamShmAddr += Size; + ShmSize -= Size; + break; + + default: + return EFI_INVALID_PARAMETER; + } + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +OpteeFromMsgParam ( + OUT OPTEE_MSG_PARAM *OutParams, + IN UINT32 NumParams, + IN OPTEE_MSG_PARAM *MsgParams + ) +{ + UINT32 Idx; + + for (Idx = 0; Idx < NumParams; Idx++) { + OPTEE_MSG_PARAM *Op; + CONST OPTEE_MSG_PARAM *Mp; + UINT32 Attr; + + Op = OutParams + Idx; + Mp = MsgParams + Idx; + Attr = Mp->Attr & OPTEE_MSG_ATTR_TYPE_MASK; + + switch (Attr) { + case OPTEE_MSG_ATTR_TYPE_NONE: + Op->Attr = OPTEE_MSG_ATTR_TYPE_NONE; + ZeroMem (&Op->U, sizeof (Op->U)); + break; + + case OPTEE_MSG_ATTR_TYPE_VALUE_INPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_VALUE_INOUT: + Op->Attr = Attr; + Op->U.Value.A = Mp->U.Value.A; + Op->U.Value.B = Mp->U.Value.B; + Op->U.Value.C = Mp->U.Value.C; + break; + + case OPTEE_MSG_ATTR_TYPE_MEM_INPUT: + case OPTEE_MSG_ATTR_TYPE_MEM_OUTPUT: + case OPTEE_MSG_ATTR_TYPE_MEM_INOUT: + Op->Attr = Attr; + + if (Mp->U.Mem.Size > Op->U.Mem.Size) { + return EFI_BAD_BUFFER_SIZE; + } + + CopyMem ((VOID *)Op->U.Mem.BufPtr, (VOID *)Mp->U.Mem.BufPtr, Mp->U.Mem.Size); + Op->U.Mem.Size = Mp->U.Mem.Size; + break; + + default: + return EFI_INVALID_PARAMETER; + } + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +OpteeInvokeFunc ( + IN OUT OPTEE_INVOKE_FUNC_ARG *InvokeFuncArg + ) +{ + EFI_STATUS Status; + OPTEE_MSG_ARG *MsgArg; + + MsgArg = NULL; + + if (OpteeShmInfo.Base == 0) { + DEBUG ((DEBUG_WARN, "OP-TEE not initialized\n")); + return EFI_NOT_STARTED; + } + + MsgArg = (OPTEE_MSG_ARG *)OpteeShmInfo.Base; + ZeroMem (MsgArg, sizeof (OPTEE_MSG_ARG)); + + MsgArg->Cmd = OPTEE_MSG_CMD_INVOKE_COMMAND; + MsgArg->Func = InvokeFuncArg->Func; + MsgArg->Session = InvokeFuncArg->Session; + + Status = OpteeToMsgParam (MsgArg->Params, MAX_PARAMS, InvokeFuncArg->Params); + if (Status) + return Status; + + MsgArg->NumParams = MAX_PARAMS; + + if (OpteeCallWithArg ((EFI_PHYSICAL_ADDRESS)MsgArg)) { + MsgArg->Ret = TEEC_ERROR_COMMUNICATION; + MsgArg->RetOrigin = TEEC_ORIGIN_COMMS; + } + + if (OpteeFromMsgParam (InvokeFuncArg->Params, MAX_PARAMS, MsgArg->Params)) { + MsgArg->Ret = TEEC_ERROR_COMMUNICATION; + MsgArg->RetOrigin = TEEC_ORIGIN_COMMS; + } + + InvokeFuncArg->Ret = MsgArg->Ret; + InvokeFuncArg->RetOrigin = MsgArg->RetOrigin; + + return EFI_SUCCESS; +} diff --git a/ArmPkg/Library/OpteeLib/OpteeLib.inf b/ArmPkg/Library/OpteeLib/OpteeLib.inf index 5abd427379cc..e03054a7167d 100644 --- a/ArmPkg/Library/OpteeLib/OpteeLib.inf +++ b/ArmPkg/Library/OpteeLib/OpteeLib.inf @@ -23,11 +23,13 @@ [Defines]
[Sources] Optee.c + OpteeSmc.h
[Packages] ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec
[LibraryClasses] + ArmMmuLib ArmSmcLib BaseLib diff --git a/ArmPkg/Library/OpteeLib/OpteeSmc.h b/ArmPkg/Library/OpteeLib/OpteeSmc.h new file mode 100644 index 000000000000..e2ea35784a0a --- /dev/null +++ b/ArmPkg/Library/OpteeLib/OpteeSmc.h @@ -0,0 +1,43 @@ +/** @file + OP-TEE SMC header file. + + Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR> + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef _OPTEE_SMC_H_ +#define _OPTEE_SMC_H_ + +/* Returned in Arg0 only from Trusted OS functions */ +#define OPTEE_SMC_RETURN_OK 0x0 + +#define OPTEE_SMC_RETURN_FROM_RPC 0x32000003 +#define OPTEE_SMC_CALL_WITH_ARG 0x32000004 +#define OPTEE_SMC_GET_SHM_CONFIG 0xb2000007 + +#define OPTEE_SMC_SHM_CACHED 1 + +#define OPTEE_SMC_RETURN_RPC_FOREIGN_INTR 0xffff0004 + +#define OPTEE_MSG_CMD_OPEN_SESSION 0 +#define OPTEE_MSG_CMD_INVOKE_COMMAND 1 +#define OPTEE_MSG_CMD_CLOSE_SESSION 2 + +#define OPTEE_MSG_ATTR_META 0x100 + +#define TEE_LOGIN_PUBLIC 0x0 + +typedef struct { + UINTN Base; + UINTN Size; +} OPTEE_SHARED_MEMORY_INFO; + +#endif
On Mon, 27 Aug 2018 at 17:20, Sumit Garg sumit.garg@linaro.org wrote:
Changes in v2:
- Separate patch for MdePkg/Include/IndustryStandard/GlobalPlatform.h.
- Correct comments style for struct members.
- Update commit message.
Sumit Garg (2): MdePkg/IndustryStandard: Add Global Plaform header file ArmPkg/OpteeLib: Add APIs to communicate with OP-TEE
I hope you have reviewed this patch-set.
Please let me know if you have any more review comments.
-Sumit
ArmPkg/Include/Library/OpteeLib.h | 87 ++++++ ArmPkg/Library/OpteeLib/Optee.c | 358 +++++++++++++++++++++++ ArmPkg/Library/OpteeLib/OpteeLib.inf | 2 + ArmPkg/Library/OpteeLib/OpteeSmc.h | 43 +++ MdePkg/Include/IndustryStandard/GlobalPlatform.h | 27 ++ 5 files changed, 517 insertions(+) create mode 100644 ArmPkg/Library/OpteeLib/OpteeSmc.h create mode 100644 MdePkg/Include/IndustryStandard/GlobalPlatform.h
-- 2.7.4