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: 10670153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DFAC15A6 for ; Tue, 6 Nov 2018 11:38:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BEFE2A26B for ; Tue, 6 Nov 2018 11:38:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 607C12A29B; Tue, 6 Nov 2018 11:38:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 008952A26B for ; Tue, 6 Nov 2018 11:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dU2JEoQ9AFa0+nUfw1nn44PDCfQgcOotSGB4oocdIA8=; b=t4u+ySPZ6nwsEs n/Z9Os6fn/GNq2+SHyYpfEY4RQjwXmOUwj0oJFI/h1DbgSK3VbzXJULJiICX4/AI4BpW6XasN87om aSHrIWJF809pGrvDsh11RQcn2z/NR6qVAIv/T6UgSv1xOU4buMwG/b/r4tFLKDvW/vT8bVQHQ9BJm M3xekglEspI76QUi+t1uxSmEBIYej4oTvGBqXxdWBMuyYwN+vlG4nLmnYINPwJJbQxOcjKI75FK+u 6xU9phLcXwc96zu2u7tden5GaNqJxhTz13+B3LveLhFnV9lxbJ9IG1nzqBbtYhm5HIfwFD0A33apZ lqCIO5kkpRckdE3pSJ0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJzgJ-0007o7-E4; Tue, 06 Nov 2018 11:38:03 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJzg9-0007bh-Bm for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2018 11:37:55 +0000 Received: by mail-wr1-x442.google.com with SMTP id o15-v6so9463586wrv.4 for ; Tue, 06 Nov 2018 03:37:43 -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=RJLB5/Xvv/d7D27+I3I8R6KnNk9drLFVRVOeKoqOiRpTtoGUoGtoOWbq/oafY2Vj11 B1/IibnG5zMhXtbACI4ZfRXCtTgsIXnDtLnDQBPkLWwbIX9m5hv+GYNhHK60ZETyL0vh hXM6DZse1Cv+5b99C5WKZFaCqlet5E00jrjxPWS/9h3LC0hYCUi47/qPWSBhMab50Krc 6LBi/cuZvBq2WqfF9kElmZMg+D2MgTvRGC+66whqfqU2xqO7gd2BdZkfhZKeiZ9+JE8Z /SL2E1W8vyH0y05We1kULln2fB6Gr6Yb5c1PYbrNhKUcuV7hzl+XNQLZokRbR6+bHNj2 /E7A== X-Gm-Message-State: AGRZ1gJgD+1VI366ZymC4YFD1OhgoA45Ei8nLSYnjAlF6i+g0eJ5ymVY 1Y0K/x2h08wSkVoetmLohUblv/LWz8o= X-Google-Smtp-Source: AJdET5eIX6q3C5TxP9+WdZ1YCLB1SnrDAcikjrtJHzCa4mYyVXpJutKo+Bbn9IRXZk3f6s7ZpLkUHw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181106_033753_398184_02B157AE X-CRM114-Status: GOOD ( 13.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-efi@vger.kernel.org, Ard Biesheuvel , marc.zyngier@arm.com, bhsharma@redhat.com, will.deacon@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Will Deacon --- arch/arm64/mm/init.c | 2 -- arch/arm64/mm/mmu.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) 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(); } /*