From patchwork Wed Feb 8 20:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 651708 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp3722575wrr; Wed, 8 Feb 2023 12:55:17 -0800 (PST) X-Google-Smtp-Source: AK7set8esfgTUocv5HKJUKb9RfLse+9Pzyo0WBDw83N56GklIH0VAodE7Le6X0Ml/SggLCm964E4 X-Received: by 2002:a05:6870:c111:b0:163:83b1:4061 with SMTP id f17-20020a056870c11100b0016383b14061mr4598227oad.0.1675889717358; Wed, 08 Feb 2023 12:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675889717; cv=none; d=google.com; s=arc-20160816; b=XQJe5UqhXLhmmSGub9IkyC9/iNUxSCyhKsmalGyWyImSKGxlJHMC9s7c0njZcrKppV 2axdxYBEznx33XnDxNhvo3Idxjfh8BV8Rrmln3EycbuETTEMS7o3c6/7SMxl5JY9C3Qf Sa7GJ1YheQl+klmAoOWu/1ElEam0CyJjcjq7DXDiJf4OlmZLh2ZcRO2yeEd6CvGYLVIl S6UB39fiVimHi/5fzGTDEDmuAXXm1K1Bn5sDhoyQ64skvx2S6tkNM52butqqyvJJZsDu U8R8M57nFsH/p4CSiE8yTbrm4ffgS0SludxZ6HkCOpfTx8Dg24AbU+ooo0KzGTX/WavD ZSrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FBbnUCC5G/tQ0vdiErusgxBBIUGpds9aO3c9lpVDmmw=; b=VXdRJdp2J5lnJWAvOJPVsdB3u8QWu05GWwmUB2vHSAJO/OphAw4cXbOpg0QakHiass /t/Y8cyFqYLsSgZMMkEirQx/pTAClb0F88gYnLtuCTx/ZSclgsg2U8OQ6O7CWiI1pQNm 3qkAr9EkIOaaWK15gTwcR0pD6jcIKBekkmkKni+cwBo/q06MRVFdM8u0wK4OYM60B3Yh +0+fTTiUhjYWVU4AtliNE3FIF/M/OBPLS7V8lJey2Zf61Bw7dEDhjLwhK1xYMfO0Yw0p h4qLZ8OXKkm0+qkjmdPuzw+n7SAV8DWcamoq3p+LO91DrTcq7V2z4cbXBAQWVKFLn9Sz Xl+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hzrc//JE"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id el24-20020a056870f69800b00163df612a05si16043321oab.305.2023.02.08.12.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 12:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hzrc//JE"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9207F85F47; Wed, 8 Feb 2023 21:54:51 +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="hzrc//JE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F93485F40; Wed, 8 Feb 2023 21:54:42 +0100 (CET) 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-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 E6A5885EFA for ; Wed, 8 Feb 2023 21:54:38 +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-pl1-x635.google.com with SMTP id i2so239730ple.13 for ; Wed, 08 Feb 2023 12:54:38 -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=FBbnUCC5G/tQ0vdiErusgxBBIUGpds9aO3c9lpVDmmw=; b=hzrc//JEaHEhJdkNWPjAb2VXnFWj4/PIb407tRUGUrhI1e3lOXw/t+YGLcHBU85xQB pPHPx9n8btT/Y4donnoucpE2CIROG9vx1eC98USvsCzWftqj/41OvL1aYUZFgyCBOlLf fhnltTohntqVrcpDr8qu/Zj3vvkvPOxyL5m9odGWa6LEndnQmtFN5wPDCE/11px3jSJu i/k5EVzVGlbo98qxMlyh7U+0RQ3bH+OeCBk63CunGg+nVZ7Kjv1LnlQ0JBOdIqDTGX3P scd1fiNXGBAYLltvIt18mdYUXYoWpnNh0ze+4tOdhx51YMPISljmpWrFnxbpCZwtsmjr X94g== 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=FBbnUCC5G/tQ0vdiErusgxBBIUGpds9aO3c9lpVDmmw=; b=FqZZtgmI4aztRYJHgYOIRlCW5dtDaotr2dabx6tpnEAmTEdTl9C8BQIbEfRgzJA5yX wH+SBAUECetp2YWmBaL7YIw9fgCMrKlMumn8rri8CNnpX20yVyWOxnDUR2xiobsEUEjT osGenww7Mw8P2CmMU6to/cQ5Ys9h3UUQMl79MT2BpikyFkUNSvEyo30irMF/sOfB2oQs yRm0DORAyXYlWOFQip4122igu3csnvkChm6Bm3g4YswNIrNiVQbL8iLdXQY3+Xql3DnB OGiAMnR6p1kA06W0tFqNv7xoWi35obECuij8LVkDmY3+F+K7LAC1FQNTwVn0MvqMJRuG 5sew== X-Gm-Message-State: AO0yUKUarkuDJicrHBFk9YYl0mHN0CFIbq4zts6sLekMUVJeUrUh53Jm qlY9fUqDwNH5z5vP0u2h1kwAB1Hf5nCvwCHm X-Received: by 2002:a17:902:d409:b0:198:9f09:7412 with SMTP id b9-20020a170902d40900b001989f097412mr6538732ple.18.1675889676999; Wed, 08 Feb 2023 12:54:36 -0800 (PST) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id q16-20020a170902dad000b00186cf82717fsm11446923plx.165.2023.02.08.12.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 12:54:36 -0800 (PST) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: =?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?= , Ying-Chun Liu , Tom Rini Subject: [PATCH v2 2/2] arm64: Initialize TLB memory if CMO_BY_VA_ONLY Date: Thu, 9 Feb 2023 04:54:28 +0800 Message-Id: <20230208205428.1083689-3-paul.liu@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208205428.1083689-1-paul.liu@linaro.org> References: <20230208205428.1083689-1-paul.liu@linaro.org> 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.6 at phobos.denx.de X-Virus-Status: Clean From: Pierre-Clément Tosi 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: Pierre-Clément Tosi [ Paul: pick from the Android tree. Fix checkpatch warnings, and rebased to the upstream. ] Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Tom Rini Link: https://android.googlesource.com/platform/external/u-boot/+/e3ceef4230b772186c6853cace4a676a407e6ab7 --- v2: Fix the Signed-off-by list. --- 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;