From patchwork Mon May 31 17:43:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1485748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oAsNki6n; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fv2hS44Rmz9sRN for ; Tue, 1 Jun 2021 03:43:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3728B82E8D; Mon, 31 May 2021 19:43:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="oAsNki6n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C51482E9A; Mon, 31 May 2021 19:43:25 +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,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) (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 9737982D73 for ; Mon, 31 May 2021 19:43:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-oo1-xc35.google.com with SMTP id v13-20020a4aa40d0000b02902052145a469so2931708ool.3 for ; Mon, 31 May 2021 10:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=scwKAEDWCWS6XSzkzF+foL5NGZLMJ1lxkiHH/e3JfzE=; b=oAsNki6nI28BgIptVpGqRk1wtU0HNleTCmPR2IAQjfMPSRYhtwLa/epav5w00GKG8Y +3oQVoSTjBaeS+0QTByf/yDyDBXf0xP+yYZPVBiFmj5Z5tCS/Hwkjr+rOJcQCbd/t6Ry K8raN3zxM1RKxrrn8pdOHUQ0gdnjmBRQEo1zkMrKtfs4kQC6XFQb0aQCGg60nBykklMb tmjAFzW3rCaaUTlMuMPK5OUcJ+0Zp0hhnC5IdWrtQxaUIiDJv1IiAC9H0cZ6+KG9Ke3q iCfJ+CW29fe6tKiUoTk0f0dmoDNnB7fKlO0Ylz5DzJdtjia6/sMcvkfCH1tTWOHx1eze wqHA== 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=scwKAEDWCWS6XSzkzF+foL5NGZLMJ1lxkiHH/e3JfzE=; b=dsDswaK0lhWQ1HN9RDWwq4oWUbwYJMoXBwyOzQ3Pr5F13ksg2fcl7HDHpUTpNVLDz1 0nI7auIPOaRVkGWU7YKaRBmkWYm5KWEEOgz6jB4Ppyk7C0yfdT8YMNkh+EVcCDn3Qj63 WvV46gJqK/p5JGrOG88ULblagAurjTPEohS2du4ihjE65UkIXiEbHBypmF+OsjRnvi+M PziOu52PbNucUhhxJDQ18F6gIzrpwbMof+X2NC7kTBHoutjdZryiQJey8fKOi8umoC66 EfZ2k2SMqZXtxSpayggqLhDIqnVuc3kv+dMPe4PqFqzBmbYVo4JPii0HgMa7Xl0UJVxg VICg== X-Gm-Message-State: AOAM5303UBWjcwz/pf948CSusgb8Yk5eeUYyHai5yJh0OOB1gTq4FOry cHFmA7ob+JexQeWA/Db66ewZ8hyVSaM= X-Google-Smtp-Source: ABdhPJytCqz33oNt9lUUSeff6IhcJLOgKS0HIryILLa6fzlw7OE1iALf4cPnrywrIm+3zAc8YswZWg== X-Received: by 2002:a4a:a9c8:: with SMTP id h8mr1883318oon.1.1622483001005; Mon, 31 May 2021 10:43:21 -0700 (PDT) Received: from nuclearis3.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id 12sm825048ooy.0.2021.05.31.10.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 10:43:20 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, trini@konsulko.com, patrick.delaunay@foss.st.com Cc: Alexandru Gagniuc , sjg@chromium.org, etienne.carriere@linaro.org Subject: [PATCH v4 0/5] stm32mp: Enable OP-TEE and TZC support in SPL Date: Mon, 31 May 2021 12:43:09 -0500 Message-Id: <20210531174314.1395666-1-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 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 The purpose of this series is to allow booting an OP-TEE image from SPL, by corectly configuring the TrustZone (TZC) memory regions. Although TZC400 is a generic silicon logic that could apply to other mach- families, support is currently restricted to stm32mp. I have neither a feasible way nor interest in validating this for other chips. It's fairly trivial to move the code from mach- to arch/, should another use case arise. The configuration of the memory regions is devicetree-driven, so there isn't much to hardcode, However the delineation between OP-TEE secure memory and shared memory is not given in the devicetree. This is the one thing that has to be hardcoded. Changes since v3: - Pass a "phys_size_t *" to ofnode_get_addr_size() to resolve warning - s/u-boot,dm-pre-reloc/u-boot,dm-spl/ in devicetree for clarity Changes since v2: - Use ram_get_info() instead of ofnode_read("st,mem-size") - Only hardcode shared memory size instead of TZDRAM size - Use log_info() instead of pr_info() Changes since v1: - Removed "Weak functions are stupid" comment - Addressed blank line complaints from checkpatch Alexandru Gagniuc (5): spl: mmc: Support OP-TEE payloads in Falcon mode spl: Introduce spl_board_prepare_for_optee() hook arm: stm32mp: Implement support for TZC 400 controller stm32mp1: spl: Configure TrustZone controller for OP-TEE ARM: dts: stm32mp: Add OP-TEE reserved memory to SPL dtb arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 3 + arch/arm/mach-stm32mp/Makefile | 1 + arch/arm/mach-stm32mp/include/mach/tzc.h | 33 ++++++ arch/arm/mach-stm32mp/spl.c | 92 +++++++++++++++ arch/arm/mach-stm32mp/tzc400.c | 136 +++++++++++++++++++++++ common/spl/spl.c | 5 + common/spl/spl_mmc.c | 6 +- include/spl.h | 14 +++ 8 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 arch/arm/mach-stm32mp/include/mach/tzc.h create mode 100644 arch/arm/mach-stm32mp/tzc400.c