From patchwork Thu Feb 11 12:04:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1439417 X-Patchwork-Delegate: trini@ti.com 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=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=NODkRzEN; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DbwLH3x59z9sVS for ; Thu, 11 Feb 2021 23:04:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B6C4A825F5; Thu, 11 Feb 2021 13:04:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="NODkRzEN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4BC82825F5; Thu, 11 Feb 2021 13:04:43 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (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 A87DB82627 for ; Thu, 11 Feb 2021 13:04:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=igor.opaniuk@foundries.io Received: by mail-lf1-x12e.google.com with SMTP id w36so7731840lfu.4 for ; Thu, 11 Feb 2021 04:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kNYJ0O40ArUK3sWNVMIKpuKTTmIH3TXpncwamBf834c=; b=NODkRzENpi1g2OCgrsTqT6CAzCV7+g4wYOSHIyNMhZ9YLSePEeAwz4N3Yb11glPuZi IuDWGZ/I3MvfBkTNWhpSUvQCg8FPzZWK77YX6VA6pwMmzFWFoYjHiXQHrogKY8dL7uZi c36hNrspzx9Vc/h1jPKxI2kuCQtjIt8lmfTBMqJdbNwEoIesHtZwEXvFEqSGOJnFDDRP AXntdy7Ym6GaflVeQCdYueCWz3dXdnXQeiJ6hn+CBqLv13XOQJOcGq5a/GzMldM3H7LJ /qla3DQqcBplcj2TZmGsX/4ziiqMPvjH1DSoa/Tcen+HM4XnBnHLNUaCJeX8T9cYsCWt vt7A== 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=kNYJ0O40ArUK3sWNVMIKpuKTTmIH3TXpncwamBf834c=; b=Q5l+NigZKs28KmMMlF8M+EVLQsXoi2u23wa4OoiG7iC7tw6jYEnxd+qDv/dsYzjKic sG02WIpWq8Kqk/fU/AX82SloFpU43k78nnrrpcUzKnqHFhzAyMMaOxQQWmt/lkepxRwb X5K9Cj8LWP6+ojGUXz8z1SFl49Ur4ymeIjlW5jTIcOe5aRL0hO72CSjsJxB0SLAck8gj zvR1aJZymjlt4ThJhfMHSSTHNBQgKx4bUQepKq8ZqStvYCAk4J9AI/OE9COG07vWMJrC FVrSsoY2ItPOHTezR3ZY5IHu/N/4UhTNIHHIpXqpanNCuLVgjQNkWM/ibD9QcjeK3y5V rU5g== X-Gm-Message-State: AOAM5335Z1ARkb/lru3PrhAIcXHKjvvJZR884QmNaJeDr0TOqY3YRY+f TDOr2PaXLm4RFRHnPX/YC1ZcDDZifPzAkJD8 X-Google-Smtp-Source: ABdhPJwgcLUM3aWOYKj4113Rxy/j35TRa+T91OK14+9gWd4zYWUYFaR6ncqbHJGjSqu+DqLJV7jkyQ== X-Received: by 2002:ac2:4477:: with SMTP id y23mr3440698lfl.234.1613045079615; Thu, 11 Feb 2021 04:04:39 -0800 (PST) Received: from localhost ([109.108.76.111]) by smtp.gmail.com with ESMTPSA id r2sm796660ljj.81.2021.02.11.04.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 04:04:38 -0800 (PST) From: Igor Opaniuk X-Google-Original-From: Igor Opaniuk To: u-boot@lists.denx.de Cc: jens.wiklander@linaro.org, xypron.glpk@gmx.de, ardb@kernel.org, andre.przywara@arm.com, Igor Opaniuk , Tuomas Tynkkynen Subject: [PATCH v1] qemu-arm: round down memory to multiple of 2MB Date: Thu, 11 Feb 2021 14:04:26 +0200 Message-Id: <20210211120426.159999-1-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.25.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.3 at phobos.denx.de X-Virus-Status: Clean From: Igor Opaniuk When LPAE is enabled, 1:1 mapping is created using 2 MB blocks. In case amount of memory provided to QEMU is not multiple of 2 MB, round down the amount of available memory to avoid hang during MMU initialization. How to reproduce: qemu-system-arm -machine virt -m 1058 -nographic -bios u-boot.bin - boots qemu-system-arm -machine virt -m 1057 -nographic -bios u-boot.bin - hangs DRAM: 1 GiB initcall: 60011df8 initcall: 60011904 New Stack Pointer is: 80fffe90 initcall: 60011a20 initcall: 60011bcc initcall: 60011bd4 initcall: 600119b4 Relocation Offset is: 22042000 Relocating to 82042000, new gd at 81001ed0, sp at 80fffe90 initcall: 60011b8c initcall: 82053ea0 initcall: 82053ea8 initcall: 60012040 (relocated to 82054040) dram_bank_mmu_setup: bank: 0 --- hang here during mmu init --- Fixes: 3fa914af82("arm: qemu: implement enable_caches()") Signed-off-by: Igor Opaniuk --- board/emulation/qemu-arm/qemu-arm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index aa68bef469..841dd7af0e 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -84,6 +84,18 @@ int dram_init(void) if (fdtdec_setup_mem_size_base() != 0) return -EINVAL; + /* + * When LPAE is enabled (ARMv7), + * 1:1 mapping is created using 2 MB blocks. + * + * In case amount of memory provided to QEMU + * is not multiple of 2 MB, round down the amount + * of available memory to avoid hang during MMU + * initialization. + */ + if (CONFIG_IS_ENABLED(ARMV7_LPAE)) + gd->ram_size -= (gd->ram_size % 0x200000); + return 0; }