From patchwork Wed Apr 5 12:30:57 2023 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: 1765392 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=JnWUF9/1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ps3s359tlz1yY8 for ; Wed, 5 Apr 2023 22:31:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A3EBD85F7D; Wed, 5 Apr 2023 14:31:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="JnWUF9/1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C34685F7A; Wed, 5 Apr 2023 14:31:05 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 64E3285DC9 for ; Wed, 5 Apr 2023 14:31:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wm1-x333.google.com with SMTP id l10-20020a05600c1d0a00b003f04bd3691eso6982283wms.5 for ; Wed, 05 Apr 2023 05:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; t=1680697862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dBoEHbvT8eNY1rl5Cm+gWjsl/wHCeu3mgT9ROyxGfoQ=; b=JnWUF9/1PhZnKTyvFeU48fumLraQ9PURG/1t2ELjwUopQ7dyMXmGaamy6IFFf8t0WX TF1com8WpcdihA0HYHBb5tkuDBVrbCf21BU6YhxyJSVi+R4+U6HlfGCAYGTbuupUIHgS lHiPCX0kWm98GiqGmtDbY9/EqzD9dTjQx+sBuzzL2xUnUILFsyLwnZrJ8QYWy64B7zIt JoUqY/FRwHtk7ApZ7VrZbZ6zy3o/cH+NJqLB8Ej4z3ycz4EJVEvEMagmx/OQX5faHjSv KRJFfzkbTDk/jEndL01SEL9nqNj8fo6uPinoPP9bKS0/XzD9bsUk2toKreTQmNQdNRgs f/FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680697862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dBoEHbvT8eNY1rl5Cm+gWjsl/wHCeu3mgT9ROyxGfoQ=; b=R8pnR4/Z8WguUUApwin8cjIszb8VyBOccSIsc5mL90DsfgwlMj1ph6D1QMT3DD7oVg DQBNNQpv8df7drThlbe65Kg19i48plB5/OSwPjAmQLQTaOXbuOkJYqK0YQ5bZC6Z9pIv npd/pHV8TT7A/NFBdqqWe4ucmvftfW957xOejqJMalFb1ERJWPFjf5BERUhiBWK3suHz WkeYBwViT9aRy3RNNa8jhBNmXF6Tkngc0IaT3aUrOOj/23M4ZX2O80o1vpC3+aTJgFoo faKrDOEZo8V2srRaVC/xDM+uC3dsmL6Jxr6MHTJGv2dAeM3MilyUvyP6+Mm3aQ3ONE5V RM3Q== X-Gm-Message-State: AAQBX9fb32tpg8bBkTaJYJlOdCzYSu1/xAJPptXnE4wa3pWu8//S3vLp v+sK0YJ1f0sNAgFa4NcuCmr+Ag== X-Google-Smtp-Source: AKy350aLsgLqYKVCbOOb3M2DYZJwySwrwTicroU51dNcN4B2fFgfFDkb83hyqiWY5WDMLPqS1jLFDA== X-Received: by 2002:a7b:c852:0:b0:3eb:5ab3:b6d0 with SMTP id c18-20020a7bc852000000b003eb5ab3b6d0mr4388685wml.6.1680697861770; Wed, 05 Apr 2023 05:31:01 -0700 (PDT) Received: from localhost.localdomain (119.red-79-144-185.dynamicip.rima-tde.net. [79.144.185.119]) by smtp.gmail.com with ESMTPSA id h7-20020a05600c350700b003ee9f396dcesm2082786wmq.30.2023.04.05.05.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 05:31:00 -0700 (PDT) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, sjg@chromium.org, jens.wiklander@linaro.org, ilias.apalodimas@linaro.org Cc: u-boot@lists.denx.de Subject: [PATCH] drivers: tee: sandbox: Fix SCP03 control emulator Date: Wed, 5 Apr 2023 14:30:57 +0200 Message-Id: <20230405123057.258685-1-jorge@foundries.io> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Fix and document the Secure Channel Protocol03 emulator. Fixes: 5a8783c80c39 ("drivers: tee: sandbox: SCP03 control emulator") Signed-off-by: Jorge Ramirez-Ortiz --- drivers/tee/sandbox.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/tee/sandbox.c b/drivers/tee/sandbox.c index 35e8542fa3..8e32b69f5b 100644 --- a/drivers/tee/sandbox.c +++ b/drivers/tee/sandbox.c @@ -119,6 +119,7 @@ static u32 pta_scp03_invoke_func(struct udevice *dev, u32 func, uint num_params, { u32 res; static bool enabled; + static bool provision; switch (func) { case PTA_CMD_ENABLE_SCP03: @@ -130,12 +131,18 @@ static u32 pta_scp03_invoke_func(struct udevice *dev, u32 func, uint num_params, if (res) return res; - if (!enabled) { + /* If SCP03 was not enabled, enable it */ + if (!enabled) enabled = true; - } else { - } + /* If SCP03 was not provisioned, provision new keys */ if (params[0].u.value.a) + provision = true; + + /* + * Either way, we asume both operations succeeded and that + * the communication channel has now been stablished + */ return TEE_SUCCESS; default: