From patchwork Tue Nov 6 11:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 150255 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3775307ljp; Tue, 6 Nov 2018 03:37:44 -0800 (PST) X-Google-Smtp-Source: AJdET5dYClKBqH0SUYqkCJ6qZ8wM1DmJrEJPbzoSTmLyQxkreA3jgtxptWhngKa4y1hmPGe3oSjM X-Received: by 2002:a63:5442:: with SMTP id e2-v6mr23662437pgm.316.1541504263922; Tue, 06 Nov 2018 03:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541504263; cv=none; d=google.com; s=arc-20160816; b=bCRdfNfVVnkIW5/RYPg95ZChlSTgdKWQkEZLGRol0ZstWLcuWpjCnDuwjgpRaewSUX AhX5RGhA6YhmwAKdFehXjvTWN7UZdTj1p2KwlCaYhef2n4iq/yWrJ0CMf4/j+0e/3Sv/ DiFVvQMxVb4HTsLfqnshN8LsXWU/0y5ZmdeMJ5Xc6rRYAHZPFMy8/YXOAGqfCD5iXgeo ICWy4TYsvsr7fg0+1O0kPmsoZTERzsHsXaA0d/oC6/NomBXD5BB06cg07sdyq0EYl58m FuSJQCbRzK988z0wNe5KdckD8nLIaxbFSsc5vM7sa1V0+VmCdKkXCGhV4fU8oqH9mIjF E9Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZGPqz/MYWANycuG9Tb+ISa8UHJfaVM9dxj3YR/jxCQc=; b=UwKZH6prj4GYGdAqW46zZyOcZWQC4tJv/QBeNm8iJglQQwZFS9/TSd25k74jUAy3eQ 4ebf1awAitWUOb/oOOVKZAJ7S5G01KQ8U1gy8UCMreUy4aHrbLyWW79SPi4MAiIPbgVW Dd2MUGKVZjz6vWd/J8Bt+qjU7SYgp/W884j+0/Opv6fKewwQirEuYMGsC5LK6GN4T9DW ht6xpCM7TAeC4IwWV2DpxszIHbykhntT1NtAv8e59WIwk1KnrB+tgqcV3lzS763o8pqu IKOrtzdZDcRgvBS6z63xem2sLLhTEcULmgeHkBw2YYIWE7kNLWz5aCDac768iJjVQpjt x6aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iXexW/bi"; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si44073084pls.344.2018.11.06.03.37.43; Tue, 06 Nov 2018 03:37:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iXexW/bi"; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730335AbeKFVC3 (ORCPT + 3 others); Tue, 6 Nov 2018 16:02:29 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43197 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729728AbeKFVC3 (ORCPT ); Tue, 6 Nov 2018 16:02:29 -0500 Received: by mail-wr1-f65.google.com with SMTP id y3-v6so12784676wrh.10 for ; Tue, 06 Nov 2018 03:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZGPqz/MYWANycuG9Tb+ISa8UHJfaVM9dxj3YR/jxCQc=; b=iXexW/biYTNUhWdmJoVHrYaLBUxS9dw8I/G3tucCH+p95OGNX6ijjWO59gjeD2n/2U RnsyiQbZYJgQ3PkIgAL8/IYxhU6McBwd/IKXMhIghu/XQmf5H/+gX6PA/0LVj0mIKY+E m+UcNC0MIescacXAFTK7Go1h1P/7YxFNSJnhI= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZGPqz/MYWANycuG9Tb+ISa8UHJfaVM9dxj3YR/jxCQc=; b=Gt/PWCkZCLbgoy5kRTpqf8u8oo9kYSjU9shy77IsqSDO76lS5BU0qkr188aV9N37cI BQ7FyVQAm5h++tn6vOXu0X3LVA+pquhdAg9+F2bG+66NBtftknU/DVclNOVuu/BQw7Q2 QyPL+/UFkOvyg2IyLlkVOv9m1WjlipGxJIFlcaccw6qOnrV6Dn+6PjJDZDZ+jVCWHGFF M983PvAatihl5EXZc0SR4HUQTtkhsbRJHa2XWpeJtdfOrG0EErJjGN/pX/AhLJ5JrOgH OWzUe+SLu2Ug2COBuHgffS4JBqujMh/X0QjajR2EkY7cW2QFxWbQDvZ8+mNeSCLJWEMo 5WPw== X-Gm-Message-State: AGRZ1gIhxUCOBzbOxR87g60+8N0Y9b7KC0dy+q8/UIydQVxxsDsNPR9s axUgcs7j45vt/UpbyCp8t0oup6N7Rek= X-Received: by 2002:adf:c550:: with SMTP id s16-v6mr22802200wrf.264.1541504261269; Tue, 06 Nov 2018 03:37:41 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3117:2b29:5ef7:a9e5]) by smtp.gmail.com with ESMTPSA id t187-v6sm1431529wmt.45.2018.11.06.03.37.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 03:37:40 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: bhsharma@redhat.com, linux-efi@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com, Ard Biesheuvel Subject: [PATCH 1/4] arm64: memblock: don't permit memblock resizing until linear mapping is up Date: Tue, 6 Nov 2018 12:37:29 +0100 Message-Id: <20181106113732.16351-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181106113732.16351-1-ard.biesheuvel@linaro.org> References: <20181106113732.16351-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Bhupesh reports that having numerous memblock reservations at early boot may result in the following crash: Unable to handle kernel paging request at virtual address ffff80003ffe0000 ... Call trace: __memcpy+0x110/0x180 memblock_add_range+0x134/0x2e8 memblock_reserve+0x70/0xb8 memblock_alloc_base_nid+0x6c/0x88 __memblock_alloc_base+0x3c/0x4c memblock_alloc_base+0x28/0x4c memblock_alloc+0x2c/0x38 early_pgtable_alloc+0x20/0xb0 paging_init+0x28/0x7f8 This is caused by the fact that we permit memblock resizing before the linear mapping is up, and so the memblock_reserved() array is moved into memory that is not mapped yet. So let's ensure that this crash can no longer occur, by deferring to call to memblock_allow_resize() to after the linear mapping has been created. Reported-by: Bhupesh Sharma Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 2 -- arch/arm64/mm/mmu.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.19.1 Acked-by: Will Deacon diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d9582cac6c4..9b432d9fcada 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -483,8 +483,6 @@ void __init arm64_memblock_init(void) high_memory = __va(memblock_end_of_DRAM() - 1) + 1; dma_contiguous_reserve(arm64_dma_phys_limit); - - memblock_allow_resize(); } void __init bootmem_init(void) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 394b8d554def..d1d6601b385d 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -659,6 +659,8 @@ void __init paging_init(void) memblock_free(__pa_symbol(init_pg_dir), __pa_symbol(init_pg_end) - __pa_symbol(init_pg_dir)); + + memblock_allow_resize(); } /*