From patchwork Tue Nov 26 16:19:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jorge Ramirez-Ortiz, Foundries" X-Patchwork-Id: 1201121 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="CyQvTrrk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47Mpyh45hYz9sQy for ; Wed, 27 Nov 2019 03:19:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 82665C21F0F; Tue, 26 Nov 2019 16:19:43 +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 F2939C21EC2; Tue, 26 Nov 2019 16:19:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CEB96C21EC2; Tue, 26 Nov 2019 16:19:39 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 7D4C7C21E44 for ; Tue, 26 Nov 2019 16:19:39 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id i12so23247342wro.5 for ; Tue, 26 Nov 2019 08:19: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; bh=JjEJuSqgVsZEEyGwue5KkGznki/55fNHNk2s6ELNt4M=; b=CyQvTrrk0zzLzlnVrbZAoN85fEeOlA6X6GEWI0RCX/LsVpDxHrjpqa9LV7qYaDfHVd y5ilhV0snLpDf0epKDg/odKmu0YpV9kffjvKor7Jke7hNv6dGc0E8wOb9HJAx9pF6TWk 90nRadB5e/+zHOljyTtFcLocBJk9nzJXJEONFDH9ef+4mES5ed5SXPDoaMOVbaC18Fa5 rcZtPBgzQ29iXzujXqwYHYPZsym6aWoyJtJVruKTD8CLPuBG1yQSx3syBXt6GG+r+Mhe YUmpDYuBZle1sVxot8CqA8qtTpy0uctAMb02vs7KCZOolSmyAyn+oYn7lVyqjwi40Q1K D5aA== 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; bh=JjEJuSqgVsZEEyGwue5KkGznki/55fNHNk2s6ELNt4M=; b=nXju/ujsf0u49TUp9U9zP5OMRVgfXMXI8CkYdN7TBl7WRdsDAGx21XtgqLO7TuE0gm LR6Jafad0TYmJ1i9mygBorInNBLQ++NCzy2Js3ETmRfo6LSpDHbGkf4WNlEIE158B8iD 4g5HznhRsQNnKrjG5s1BIi6Mv+6kDzn8O3bxcGnH3WNxj0vcBfzMH67U5Lgnd3hAJqOf cT+FmGv2IbB/LIxnCboWPLYXrXqroQgf5m/5uYg3KZep1cNUy+3Zcq832r8TI+ttWVSQ PaTUdE1+T0TcnxSQu4UV227D5TV5++yFFpu/AwvQZCenot5wVg8p6bVMuNLvPzGr6jIs NXmg== X-Gm-Message-State: APjAAAUeHpSWfnDQoCw72Zv5SChKWxpv4Ak3X79mQpYQW5/5rdiCHafr xC8fH1pHJvwAIyy2NLcq70WDNA== X-Google-Smtp-Source: APXvYqwwHZcSK3ZK0R1wOu4NMrxYZWA2sxQba+oguFVLhXgjytkI1K8kwdQMPckNQ17eVkJ+Cs36lA== X-Received: by 2002:adf:b193:: with SMTP id q19mr37160772wra.78.1574785179137; Tue, 26 Nov 2019 08:19:39 -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 f6sm15694432wrr.15.2019.11.26.08.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 08:19:38 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, jens.wiklander@linaro.org, sjg@chromium.org Date: Tue, 26 Nov 2019 17:19:34 +0100 Message-Id: <20191126161934.7826-1-jorge@foundries.io> X-Mailer: git-send-email 2.17.1 Cc: u-boot@lists.denx.de, mike@foundries.io 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The mmc CID value is one of the input parameters used to provision the RPMB key. The trusted execution environment expects this value to be specified in big endian format. Before this fix, on little endian systems, the value returned by the linux kernel mmc driver differed from the one returned by u-boot. This meant that if linux provisioned the RPMB key, u-boot would not have access to the partition (and the other way around). Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Jens Wiklander --- 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..cf1ce77e6e 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] = cpu_to_be32(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;