[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] optee: enable OPTEE_SMC_SEC_CAP_MEMREF_NULL capability


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Fri, 7 May 2021 01:39:47 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7wuDkXPIYyz+us8xX2jgYYjsbG6TmWiFvdgkn5m+tMs=; b=AfVNo3NLNuBUjsHMlsUhI7BGqX3f4cq3HLjJS59Gwp9k/0VF0uonaI/NT6hUkZhyCPb5qOrFC/y3H3c1TCFwrDIhKa7pvTHzVCY3ckI19qDNq1RvosRwyLtpmlQplCzkJu+GGV8JTcewjueXDbyeAjbFB+wiikJF1A2PtZ8Xv/DMAPlRdItmZtvlWuXPzciOtpfFYoI3thQIxt4lSzP8WmuFJvKKznhDXZ8ttPuw3aMNhl644LLao27JsXTAJi45KsVoTDeMy5EwUz8VJfRNz2v57qQQxUVp6WykRmIEG7GSr9FDccUiJx2MmRpDCuoRP8V9F+0Pf9H7v4avVbWvyg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nfAAxvj2k9zxJrIMqKh5MLLAw7C1npJ3BLFG2zAX4jAUi5kVxG+LWDTWY6aSP259DUkOBkxJoru9fN0RhdRtIfYrEFfm33zzTAeAoOsm7dBfl3d7C4LwvuilRHTqeIYSH1O7/Nit/VWUTOIo3HjTs+7WyzVNLFsMawBjSw9u5DolezzTr+TIAeEX0F9AopA8r+SugSxRpmWesbIIS6Jo7FgdB61DTP5XsliW39VdzIKFSdDBomdaoVJ+JCMOqf8sqUXAxSWVwdne7YQZ0SeJPcZ7z+mzi4K5kr/34u8kwcxAAhet2mtOJvWQYNwOJqLxnjEQc2b/EN3mj8CkHNjARQ==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=epam.com;
  • Cc: "tee-dev@xxxxxxxxxxxxxxxx" <tee-dev@xxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 07 May 2021 01:40:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXQuHcC5ITAI62gUKYhtJEOCBguA==
  • Thread-topic: [PATCH] optee: enable OPTEE_SMC_SEC_CAP_MEMREF_NULL capability

OP-TEE mediator already have support for NULL memory references. It
was added in patch 0dbed3ad336 ("optee: allow plain TMEM buffers with
NULL address"). But it does not propagate
OPTEE_SMC_SEC_CAP_MEMREF_NULL capability flag to a guest, so well
behaving guest can't use this feature.

Note: linux optee driver honors this capability flag when handling
buffers from userspace clients, but ignores it when working with
internal calls. For instance, __optee_enumerate_devices() function
uses NULL argument to get buffer size hint from OP-TEE. This was the
reason, why "optee: allow plain TMEM buffers with NULL address" was
introduced in the first place.

This patch adds the mentioned capability to list of known
capabilities. From Linux point of view it means that userspace clients
can use this feature, which is confirmed by OP-TEE test suite:

* regression_1025 Test memref NULL and/or 0 bytes size
o regression_1025.1 Invalid NULL buffer memref registration
  regression_1025.1 OK
o regression_1025.2 Input/Output MEMREF Buffer NULL - Size 0 bytes
  regression_1025.2 OK
o regression_1025.3 Input MEMREF Buffer NULL - Size non 0 bytes
  regression_1025.3 OK
o regression_1025.4 Input MEMREF Buffer NULL over PTA invocation
  regression_1025.4 OK
  regression_1025 OK

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
---
 xen/arch/arm/tee/optee.c            | 3 ++-
 xen/include/asm-arm/tee/optee_smc.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index 9570dc6771..6b59027964 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -96,7 +96,8 @@
 #define OPTEE_KNOWN_NSEC_CAPS OPTEE_SMC_NSEC_CAP_UNIPROCESSOR
 #define OPTEE_KNOWN_SEC_CAPS (OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM | \
                               OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM | \
-                              OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
+                              OPTEE_SMC_SEC_CAP_DYNAMIC_SHM | \
+                              OPTEE_SMC_SEC_CAP_MEMREF_NULL)
 
 enum optee_call_state {
     OPTEE_CALL_NORMAL,
diff --git a/xen/include/asm-arm/tee/optee_smc.h 
b/xen/include/asm-arm/tee/optee_smc.h
index d568bb2fe1..2f5c702326 100644
--- a/xen/include/asm-arm/tee/optee_smc.h
+++ b/xen/include/asm-arm/tee/optee_smc.h
@@ -244,6 +244,9 @@
  */
 #define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM          (1 << 2)
 
+/* Secure world supports Shared Memory with a NULL reference */
+#define OPTEE_SMC_SEC_CAP_MEMREF_NULL          (1 << 4)
+
 #define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9
 #define OPTEE_SMC_EXCHANGE_CAPABILITIES \
        OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES)
-- 
2.31.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.