From patchwork Wed May 19 14:26:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 442437 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1376886jac; Wed, 19 May 2021 07:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdec0FEMb7Ob91jsuJER8wrpGC1cVSBGoJHSJDgTmLNIaZhPlVJIj78tmFkf44whFjE+Hx X-Received: by 2002:a17:907:c13:: with SMTP id ga19mr12887216ejc.163.1621434444489; Wed, 19 May 2021 07:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621434444; cv=none; d=google.com; s=arc-20160816; b=iUaIiHrYa+8OnROm/RcCR7ntW33KTmTdpjstFkqKuq/CcSHa6p5fWUlj/ywitKPvbe Hkuk686kxL6FJvxeA4+Jcei236tiLdk4PLudJ66EB53aAz4vcF3v9mknA4zme1CBI5s0 UWe1YwdATpUnOGRH82wtY+/WzBATmtqiktfW8jAslWkVDPuJ46dnJEInjWm9zFSRIElW wl09agcgGlxjQ9eAB28jKmv0fQ6EEFBMYvfrrlrAz+1O67qV/+IyC+TqNSJpFXxf7Ktz 0or+zLNbira1zq7FlhAfz6AokQCoAndfmSIIDAxCwhYxAEr1Ud6RjA7e4Lahh7I4b81Z oTKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=V0mRH4iNEk9fCg0k/pfX8rBiJ0f4icHxAH+F1ZqxKJs=; b=rdu6D/yUewRF9HjVQjGFNnsFUxuFG+eGOu4EC+2BgeIP16miVPMfgLNBN0j5pohr0e nfJN8LRD+9Xs9r+l8UBGwmzNNGAc7iWFR3XKhf+5Q3ge/n3ohK8+lZ0SjwhNvVumXK9C I2nbwOS65pASL6D7jNlRzf2B1gBYgLOklgfIiBWEc8tdXa+bwbs1/O+d726i7/iaMKUw wx0GuLqwLUY1GawMO21FDhmsiItI+BKPkpQFEKmaDQtbbZTbiG1eY+NE0NvinkNTvdyQ sqf9CcEeyZ4jPW2dGV7IBGOeQDYv9HSL/WjGr1eAhzw8msauSjxErZaYaGolW7NrdW24 fjAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v3vs6z0y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id c16si447175ede.83.2021.05.19.07.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 07:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v3vs6z0y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 346F882AA0; Wed, 19 May 2021 16:27:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="v3vs6z0y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2758181DC8; Wed, 19 May 2021 16:27:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AAF2281D3B for ; Wed, 19 May 2021 16:27:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wm1-x32a.google.com with SMTP id s5-20020a7bc0c50000b0290147d0c21c51so3449602wmh.4 for ; Wed, 19 May 2021 07:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V0mRH4iNEk9fCg0k/pfX8rBiJ0f4icHxAH+F1ZqxKJs=; b=v3vs6z0ynrXmnXR2B74sLGtjm+S4Qa3KzE4tqjNJgpDLNubg5cKjIwCzjxWTSqa0mL Cfo7eanMX9D6qG3Xym9XNupbnYqCXZtXLC1okRYfhWa7/qsmvNqcRm7C6IW9T1qaOSzk EB/WkpLQ7JruhRfXd05ufGOMSBOP1vIfTB0Wd05ubQ0aNgelVo3Cjo1LQIM5PjIBVg+q 4ww0a0vyYXB9AlmsUPr9Fk40tTedH585uMGNSXmL4fa+9IoQ0UzQBl3TJnkIkygcueW+ 55nS9Rh0pA7N3dm21GsWbun1+07s7Bwz9gzENNhuHlnvqYrXc0kdsaSV8slPUmwKOVQ9 ztNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V0mRH4iNEk9fCg0k/pfX8rBiJ0f4icHxAH+F1ZqxKJs=; b=W8Maz4vJ0j/GTCfvXqno6f+WXqk6xsHca8/RFR4pOv+tdxkWZVLuDhMqR6SHVlxHPP YUo0iloWCIBZb5wY91pxixVjETSPV1iWVagtK7tM33sXGtPY6NFIW20YzabRmzArKMyk dXFrOdtoB8lJumOfWFdDabBqJTTnD0tDHN1LvskVSz1Tuouy3guMKHlm7bjDvT/HvjK6 maHna5UqKbeYlME8RY2wvKeD5sa4kCaXVrMMyuFql5gLvZQSbfPcbH7W+sCrHEvbjDND oMP0YKRRNNkip1PKKsrhpQoKMaBuI/HrGoL+BcyFrUPFB5a2S/ZrMO+Y7xhmPKtFKCJn fiUA== X-Gm-Message-State: AOAM531SYOhZjIv+JWCtFds3CdwSNc/HoYw+Ax3Yod41hcOBY/UPbsVz WTxENt/UOtHQRrTZ2zegWnhtO7SGW8/E2MDH X-Received: by 2002:a1c:48e:: with SMTP id 136mr11720776wme.166.1621434425048; Wed, 19 May 2021 07:27:05 -0700 (PDT) Received: from lmecxl0524.lme.st.com (2a01cb058b850800452ff0effb46d5f4.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:452f:f0ef:fb46:d5f4]) by smtp.gmail.com with ESMTPSA id h15sm6752456wmq.1.2021.05.19.07.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 07:27:04 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Jens Wiklander , Simon Glass , Etienne Carriere Subject: [PATCH v2 2/2] tee: optee: support session login as REE kernel Date: Wed, 19 May 2021 16:26:13 +0200 Message-Id: <20210519142613.7668-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210519142613.7668-1-etienne.carriere@linaro.org> References: <20210519142613.7668-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Remove unused OPTEE_MSG_LOGIN_* IDs and rely on the ones introduced in tee.h. Change optee core to treat invalid client IDs as public login. Signed-off-by: Etienne Carriere --- Changes since v1: - Remove ID conversion. I kept the sanitation of login ID for optee. --- drivers/tee/optee/core.c | 19 ++++++++++++++++++- drivers/tee/optee/optee_msg.h | 10 ---------- 2 files changed, 18 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 73dbb22ba0..14f9cce5f8 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -349,6 +349,23 @@ static int optee_close_session(struct udevice *dev, u32 session) return 0; } +static u32 optee_login_id(u32 login_id) +{ + /* Treat invalid IDs as public login */ + switch (login_id) { + case TEE_LOGIN_USER: + case TEE_LOGIN_GROUP: + case TEE_LOGIN_APPLICATION: + case TEE_LOGIN_APPLICATION_USER: + case TEE_LOGIN_APPLICATION_GROUP: + case TEE_LOGIN_REE_KERNEL: + return login_id; + case TEE_LOGIN_PUBLIC: + default: + return TEE_LOGIN_PUBLIC; + } +} + static int optee_open_session(struct udevice *dev, struct tee_open_session_arg *arg, uint num_params, struct tee_param *params) @@ -372,7 +389,7 @@ static int optee_open_session(struct udevice *dev, OPTEE_MSG_ATTR_META; memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); memcpy(&msg_arg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid)); - msg_arg->params[1].u.value.c = arg->clnt_login; + msg_arg->params[1].u.value.c = optee_login_id(arg->clnt_login); rc = to_msg_param(msg_arg->params + 2, num_params, params); if (rc) diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h index 8d40ce60c2..9490592a8e 100644 --- a/drivers/tee/optee/optee_msg.h +++ b/drivers/tee/optee/optee_msg.h @@ -86,16 +86,6 @@ #define OPTEE_MSG_ATTR_CACHE_MASK GENMASK(2, 0) #define OPTEE_MSG_ATTR_CACHE_PREDEFINED 0 -/* - * Same values as TEE_LOGIN_* from TEE Internal API - */ -#define OPTEE_MSG_LOGIN_PUBLIC 0x00000000 -#define OPTEE_MSG_LOGIN_USER 0x00000001 -#define OPTEE_MSG_LOGIN_GROUP 0x00000002 -#define OPTEE_MSG_LOGIN_APPLICATION 0x00000004 -#define OPTEE_MSG_LOGIN_APPLICATION_USER 0x00000005 -#define OPTEE_MSG_LOGIN_APPLICATION_GROUP 0x00000006 - /* * Page size used in non-contiguous buffer entries */