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 317BAC352A1 for ; Wed, 7 Dec 2022 19:24:52 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93CD183600; Wed, 7 Dec 2022 20:24:50 +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=1670441090; bh=7b5OXGb2fSWalwMdCnoq0Bq6KtfN3plqsin3ximspbA=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=MAWlhAGVg4ZQtR9lnnlh949CQwSOC2sfEB3trEneJSqVxMdHv5fSWdR2sSVFJUkuv 9UliCIDk0M0oYG52GOd0uODmRG+YEU1KEuNIoaQCitiTYNthOLnb5xRthIfwyCLCE0 dP9lZnkgHOsGYaJuOaa9HxdjKI3F7coXHlQZJwcQWzaOPPlPVRq7I9zegRAfyY8qfR 4fsfPlCKFFBHASa8aFlMAArc+wolWWhAxQ5Y9kZApKa1nCXvpP6+Zn7OIdKOoRjAb8 w6hjrWiHi620934e7kOcU2GemE3U9AOUM216zadMlGqur4gVR7RmqJpJ0D7J90TTYN PS/0w41jjA0RA== 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 9C21482BCD; Wed, 7 Dec 2022 20:24:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1670441088; bh=7b5OXGb2fSWalwMdCnoq0Bq6KtfN3plqsin3ximspbA=; h=From:To:Cc:Subject:Date:From; b=TTev7R6oGVrz22OsfadsSc0P92TLidXCiAt6t2PbjZi7HP6uaNe4EMh8qd+dqJ+P7 rV4suuEMZJG1QhnO2D2ErD3Ew16PpecfTeowDTWxWNeics5vY1i5pzvgaZTxWVUaZa DMZLgnDQonwOMF/3Vzdme9yiUlGQ+S/Vj0air2Ha70UR99j4mf7fG5Bz/BRXdOyIWJ sOzDz5DtOdv3A5/8hlPQlMBeEDIBeNXWyJZtFORurU7NocUCSYHnN0Vs1Pu/h/aZHz 7S5Zo9Va+fPprA4qcNICeaMxuT96WWLbi+Zr7JUiVEf8MQljATOkJWtx1qQWRtEbfW gObnlZqHVVZrQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Alexandru Gagniuc , Patrice Chotard , Patrick Delaunay Subject: [PATCH v3 1/4] ARM: stm32: Fix ECDSA authentication with Dcache enabled Date: Wed, 7 Dec 2022 20:24:23 +0100 Message-Id: <20221207192426.45591-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 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. 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 --- 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.35.1