From patchwork Fri Nov 15 21:37:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 1195909 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=foundries-io.20150623.gappssmtp.com header.i=@foundries-io.20150623.gappssmtp.com header.b="OlCfD76P"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47FDcg737Yz9sPF for ; Sat, 16 Nov 2019 10:11:31 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9E2DCC21DFD; Fri, 15 Nov 2019 23:10:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 101E9C21E12; Fri, 15 Nov 2019 23:07:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A2D17C21C3F; Fri, 15 Nov 2019 21:37:39 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by lists.denx.de (Postfix) with ESMTPS id 46E18C21C2F for ; Fri, 15 Nov 2019 21:37:39 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id f2so12470161wrs.11 for ; Fri, 15 Nov 2019 13:37:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/asijXTildUZxTZV8mtVS7mjYrWE7tN7NXO8Extp3fA=; b=OlCfD76PLYdOHjRlQ6rjdEPDAkd4lkI/IKADiHq3dNahNiQosO9VGcbbXg0i1CB12J uhq0nFnfTAX85yq7lVa1nRyLyrgMbxPtvkZZOXPv2yCnny8yGqW6p7LWimt3fgPD8zpo kcasbI+vH7QuizBOWHId+Q8Tm+dzjaEQywwVY6jyf5G11sdjI1aCJaIHXcDdrbJ3OC/o qZJb0wlmMLSmYup7RIZNiXMulw0iJBGGktU5SlzHmxYooe1QnOOLKJi/bleThDlOENT0 ri1L7CCzAWYZXPu1faw46FFa+/+C5UVM/MIP1qdbU7ypBqiz7vgFYAENH3x0H2gKfkVv imqA== 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:mime-version :content-transfer-encoding; bh=/asijXTildUZxTZV8mtVS7mjYrWE7tN7NXO8Extp3fA=; b=gBE9rFmO65YOXgkU9uCyvU6JIUMhLx4UrUajdBHSMrMmCgJDptda84in1xMtkWwRjQ KsXKRhyu5YVtFcNw02OP329MDBGulWUzDlEPk8taHaDg4sbnoAtGO/R4rupS8LgWP+bo Oi1QcsU6gWkuNoZXiG2AYc3xT+XZMSp09fsuCWBZCthwu4FvMqnk2PW2mi/ppm3nbFPe OTi52CnGdlf1xxaMeMedQmoT1JxYQ+7KdTEK/SENpZO6GIai0pZTqEb5GnyZj9Q/nZOV qT+z+OhbwgMOx5NVDuvS2nbigPWflu9QOzXcSzAFi7GCCpzytWmL4ix6i6RUy8f9mlg2 KjPw== X-Gm-Message-State: APjAAAXpsPqqDrsE+BAQiK3JTcm12e/tKSwvoizsX8eQy3ctZpAI5dzJ WjX0H+TsSNKvDkeKFsa9DrgC4Q== X-Google-Smtp-Source: APXvYqwpF2/gtfpbOn0XJvCCFSys1OmptSVaUraSzLhjVed4BInIMFCriUAigZghaFzRliy5eG2tuA== X-Received: by 2002:adf:c00a:: with SMTP id z10mr17615409wre.81.1573853858911; Fri, 15 Nov 2019 13:37:38 -0800 (PST) Received: from localhost.localdomain (210.red-83-34-201.dynamicip.rima-tde.net. [83.34.201.210]) by smtp.gmail.com with ESMTPSA id x8sm10600039wmi.10.2019.11.15.13.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 13:37:38 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, jens.wiklander@linaro.org, sjg@chromium.org Date: Fri, 15 Nov 2019 22:37:35 +0100 Message-Id: <20191115213735.25711-1-jorge@foundries.io> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 15 Nov 2019 23:07:24 +0000 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] drivers: optee: rpmb: fix returning CID to TEE X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" The MMC CID value is one of the input parameters to unequivocally provision the the RPMB key. Before this patch, the value returned by the mmc driver in the Linux kernel differs from the one returned by uboot to optee. This means that if Linux provisions the RPMB key, uboot wont be able to access it (and the other way around). Fix it so both uboot and linux can access the RPMB partition independently of who provisions the key. Signed-off-by: Jorge Ramirez-Ortiz --- drivers/tee/optee/rpmb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c index 955155b3f8..5dbb1eae4a 100644 --- a/drivers/tee/optee/rpmb.c +++ b/drivers/tee/optee/rpmb.c @@ -98,6 +98,7 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id) static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info) { struct mmc *mmc = find_mmc_device(dev_id); + int i; if (!mmc) return TEE_ERROR_ITEM_NOT_FOUND; @@ -105,7 +106,9 @@ static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info) if (!mmc->ext_csd) return TEE_ERROR_GENERIC; - memcpy(info->cid, mmc->cid, sizeof(info->cid)); + for (i = 0; i < ARRAY_SIZE(mmc->cid); i++) + ((u32 *) info->cid)[i] = be32_to_cpu(mmc->cid[i]); + info->rel_wr_sec_c = mmc->ext_csd[222]; info->rpmb_size_mult = mmc->ext_csd[168]; info->ret_code = RPMB_CMD_GET_DEV_INFO_RET_OK;