Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31960C61DB3 for ; Thu, 12 Jan 2023 17:59:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC64E85408; Thu, 12 Jan 2023 18:59:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1673546341; bh=r7SE9QdaXH8REZzpgKQ529urb4/JK+TjdYwyBPWaMrs=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=N19bLKzBCqpdxRcaBCdtmkD8JDxchjde+QIV4uAtQ9KGUpYDSpZuJGBcEeYzD9GPI GjvGQlIycrLTAmQGjAX71EYeVkBHt1OBVuOu6xqcBpmG/kGdLulhK5VfJf7Ah/SP+9 1uOzSUbHSTzGmxqOXvFsP2dyO49KixaSCcV2+4ac/+5B73cDF86JU19kjr0Vl+KsW8 ofdNBNUAI+J1KnQda80st2orICNkOAn09bPDhTQwarQrkZ9P3/Zb856JS+y45zozTv s9nB4UBIcJlzjafsQXcrq9YcZH7kX355derixoU7cyoW7wPpEpnce/hbOEnYS1L97l d4vRmY+Pku5MA== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6ECB885351; Thu, 12 Jan 2023 18:58:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1673546338; bh=r7SE9QdaXH8REZzpgKQ529urb4/JK+TjdYwyBPWaMrs=; h=From:To:Cc:Subject:Date:From; b=cdabyXsrbaMpHpNmhDUSbxUjUPGT8qw2Jfn+i7t8DeRmVgL2i0v06jL6QrQU2o38e TGNQ3EUPH2gLHT3wgPL/h1E1uWaUucYxVIKgO5xgHNHUy/eamtDOw6I9vqVZgku7SB tZzwIQ1jO2HDDMOsQe+2+f5df8T4Y7YZ8/w3LwnXcKQiz0xOl5ROOMMO9W8t0ngWKs 3z/60WqvPDOWofW1AXQfK0CUmtNZde+r33KBXEH08G5oDpuYaxJ4Ayjzpctm/sck5P 7HrJAYQWb8NfWgjQmyYdVJqRrRHfzGV/GRL9csJhP5xhPXIFRxnuK6ND8U1ZoyHLwl zBKVp1QoW7EMg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrice Chotard , Patrick Delaunay , Alexandru Gagniuc Subject: [PATCH v4 1/4] ARM: stm32: Fix ECDSA authentication with Dcache enabled Date: Thu, 12 Jan 2023 18:58:39 +0100 Message-Id: <20230112175842.25032-1-marex@denx.de> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean In case Dcache is enabled while the ECDSA authentication function is called via BootROM ROM API, the MMU tables are set up and the BootROM region is not marked as executable, so an attempt to run code from it results in a hang. Mark the BootROM region as executable as suggested by Patrick to prevent the hang. Reviewed-by: Patrice Chotard Reviewed-by: Patrick Delaunay Signed-off-by: Marek Vasut --- Cc: Alexandru Gagniuc Cc: Patrice Chotard Cc: Patrick Delaunay --- V2: - Initialize reenable_dcache variable V3: - Mark BootROM as executable instead V4: - Add RB from Patrick --- arch/arm/mach-stm32mp/ecdsa_romapi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-stm32mp/ecdsa_romapi.c b/arch/arm/mach-stm32mp/ecdsa_romapi.c index a2f63ff879f..6156526253c 100644 --- a/arch/arm/mach-stm32mp/ecdsa_romapi.c +++ b/arch/arm/mach-stm32mp/ecdsa_romapi.c @@ -81,6 +81,10 @@ static int romapi_ecdsa_verify(struct udevice *dev, memcpy(raw_key + 32, pubkey->y, 32); stm32mp_rom_get_ecdsa_functions(&rom); + + /* Mark BootROM region as executable. */ + mmu_set_region_dcache_behaviour(0, SZ_2M, DCACHE_DEFAULT_OPTION); + rom_ret = rom.ecdsa_verify_signature(hash, raw_key, signature, algo); return rom_ret == ROM_API_SUCCESS ? 0 : -EPERM; -- 2.39.0