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 E4380C636D4 for ; Tue, 7 Feb 2023 16:21:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1817885E39; Tue, 7 Feb 2023 17:20:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="vhmyS8o8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BAF6F85D9E; Tue, 7 Feb 2023 17:20:34 +0100 (CET) Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 B1A5485E34 for ; Tue, 7 Feb 2023 17:20:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=paul.liu@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id n2so11126028pfo.3 for ; Tue, 07 Feb 2023 08:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BmrN5jXMiSepa2dbMHxu2cuzXVQqppRip1SBhY7bF5A=; b=vhmyS8o8kmCQglhJczDBY6NIm6h7X4yWIt4slXmJDJEJgPoKUki31HrleCvPbmc/XO Ahwdm++I4EMC90JOCFwdJGpnkeQms4rKZrGXz7HmExbllGzaxrX2Sdi/pR2hOldpApTY j2rywetSUdHdX2C2v7K1a8uzFIzsihSPvF40kCvcwzxLdxjy39A/ZhB8mi9CVbX4W122 QMrXIlpIGspevOGDGhXO381GshwtIfMwYqg1EvFvjRpHHS/O/S6E3PooyMN/y+KcTPwj 0IPW/HQaMAEw1Ap2iqcrpj1TflMc3yGVXk28kM9gxht4m8Bt5Kr8PTZVx8Sq5eXF2xjr 4XJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BmrN5jXMiSepa2dbMHxu2cuzXVQqppRip1SBhY7bF5A=; b=l/tOCe1sQZU1MzWDX1AE/nV5pbOSswq8nDnqp1ACgrmABNFcslqAy3sLaVBCQTv9Nb fM/c+tx1BfORFWULwFIoMm1hPWGMGDtHjepzFZbHPVuO5vw6/1HFlcIu8boa/nrlk5B/ o+oAK1/MKFVnBL/EOUnHgYK5AaT4obH+nADkNt3w8ErMR+6OWdepNfFQPw12ZQ3aRVA/ DacvG2hJtcXkKZbsb/lgZhfzT6nEWCWLo8d2ocAaR7qJ9Un+2lh5AmXlQy38JhjLKttT rqQ2GJM4oFQzmv93Tzh1Wx2Xpx+E1QNIddCvWnJJhQ+KOEa9gEsW84S8F79rCsWNVF6d jUZQ== X-Gm-Message-State: AO0yUKX1kHFA7CYWWW1MGtGu9wbHQdx3L3KJOi7IuLqRnJF98W4mK5ET rif6agf95yjkJj8eP19Y8q6cFbOwox7U7dgP X-Google-Smtp-Source: AK7set/exaVp/YdajZWtwKvuNWGePZt4ARjCHxth+e4ret0GXiCiAL/DkI8kuywI9pLXalho4CmTlg== X-Received: by 2002:aa7:9aef:0:b0:594:251f:ffe1 with SMTP id y15-20020aa79aef000000b00594251fffe1mr4067450pfp.19.1675786828692; Tue, 07 Feb 2023 08:20:28 -0800 (PST) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id e16-20020a62ee10000000b0058bca264253sm1973185pfi.126.2023.02.07.08.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 08:20:28 -0800 (PST) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , =?UTF-8?q?Pierre-Cl=C3=A9ment=20Tosi?= , Tom Rini Subject: [PATCH 2/2] arm64: Initialize TLB memory if CMO_BY_VA_ONLY Date: Wed, 8 Feb 2023 00:20:14 +0800 Message-Id: <20230207162014.58664-3-paul.liu@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207162014.58664-1-paul.liu@linaro.org> References: <20230207162014.58664-1-paul.liu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 Memory used to hold the page tables is allocated from the top of RAM with no prior initialization and could therefore hold invalid data. As invalidate_dcache_all() will be called before the MMU has been initialized and as that function relies indirectly on the page tables when using CMO_BY_VA_ONLY, these must be in a valid state from their allocation. Signed-off-by: Ying-Chun Liu (PaulLiu) Signed-off-by: Pierre-Clément Tosi Cc: Tom Rini --- arch/arm/lib/cache.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index 1a589c7e2a..7a16015867 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -159,6 +159,15 @@ __weak int arm_reserve_mmu(void) */ gd->arch.tlb_allocated = gd->arch.tlb_addr; #endif + + if (IS_ENABLED(CONFIG_CMO_BY_VA_ONLY)) { + /* + * As invalidate_dcache_all() will be called before + * mmu_setup(), we should make sure that the PTs are + * already in a valid state. + */ + memset((void *)gd->arch.tlb_addr, 0, gd->arch.tlb_size); + } #endif return 0; -- 2.39.1