From patchwork Wed Nov 7 14:16:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 150391 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5220963ljp; Wed, 7 Nov 2018 06:16:25 -0800 (PST) X-Google-Smtp-Source: AJdET5c69GUYG+USFSC82Ad6tvM7In05a0bzo2LuoEl8pb1MnyyPoNv4yRXDsKdqR0iZYZ23ddC5 X-Received: by 2002:a63:be4d:: with SMTP id g13mr329844pgo.378.1541600185747; Wed, 07 Nov 2018 06:16:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541600185; cv=none; d=google.com; s=arc-20160816; b=y7Ae6p6r49gGAF2PRAyq77xZ6YOf0vDmmIekUhvGKHSoPHCQIEXpfwjTXKmnzXWeSu nOMwXZxcJy+8cg+yDJYueGacQghMiaN1/kSKQb4zaRwKDgafoBbPizRI1Sk1qATnzApV nHMIdhCt9G9DtF2GHTK6gtJdys/Cs9I5YhVMfAF480oYqhGXsX1Ftp3rfFM4zsQ2FD5t soezNGkweI7pgRnXztJdJO+uohuHOPIayR3/w+aZbzdubYZmxu1V89iiue1PAR4fpZB+ w98vY6C1oNNGOsOP007oJynT5sp1KNgtznGhU0XoRtKtp9C9MuOilHP5IVdHS20OItr6 TC0Q== 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=8Adw24IB3R0fxokSO7y06jI60Vj0FlFjArtGGAaVO9w=; b=YiGg+Rgd4fEegC0GwIuXmNpHJNjOSO5G/46W6ur0j883iMWoAEqLozypSlpyXqGlDL s1ppo5OurwEKdbVFxt5Y2dPtoJsSt+LHucoJypTcnzUAz8HOTUTdTY4lPo25bNOuHfbo KZy7zg0Rf0jArqgoxYWJ1V3BQgmPDPCt6f8618ktz+nvj2o7XQkCU05svg2i51ee1TV0 EQHSVXOrqOOTW3IWVGrT7fb0X4xWh4ATO8moq8oukqoNx6QFcMvy0jKQIvPBd1LXPYIJ 4Nih/u2hUcbc+m66Uydvor0xKsUFryBZaJXLG8tQHnN50c56l5V5OAqRjcwxteu4Ljqu eDQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cJDPPAHl; 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 r3-v6si703022pgn.313.2018.11.07.06.16.25; Wed, 07 Nov 2018 06:16:25 -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=cJDPPAHl; 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 S1727781AbeKGXq6 (ORCPT + 3 others); Wed, 7 Nov 2018 18:46:58 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45203 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbeKGXq6 (ORCPT ); Wed, 7 Nov 2018 18:46:58 -0500 Received: by mail-wr1-f68.google.com with SMTP id k15-v6so14594290wre.12 for ; Wed, 07 Nov 2018 06:16:24 -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=8Adw24IB3R0fxokSO7y06jI60Vj0FlFjArtGGAaVO9w=; b=cJDPPAHl6mQsFU+Nvg0K6+vY9w/85ZJQzLRx9qWBDQWz/vRdeqF5uGgfR1zX9kgKPA 0SXEj7FspPmkOY1IGx2wc9Zk6nVC0tqibzSpfhEeKvHALmtuf60IJ22p8MwyXN2/Pd1O 7LlQYQrktWtObqnCcy9z58fS24sTupnEapkwg= 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=8Adw24IB3R0fxokSO7y06jI60Vj0FlFjArtGGAaVO9w=; b=ii8A70Lcn7UvIL8jPmALf0cpPX8Q5a5e6PwuGPj+e2Ofay41hJ/BdZizSKIYZHqw8a eyoolsf8D0+JylPkPmfKHE+F/qRNx3yuHvgJVtgIpsoh+0xU6DZTEGv3vlcuIRFAgq4g E+BNjQMudoUUa44Ek9oBgebYKip6X6XDEgSnnDN1b8RYyuSjO726k4wKX1NoO0YkGfW5 TW5/REDc+hz8VZovUUCII0VuL8m5nGDqwNtNCfQ2HNWf0cqZWPRlvGdRPDCj9jbkCoMs VYsBj1+RU3oCqFXtrbwD5O0A1X3dcT25KBbX2XCUAVbL92WHsCmrEDnZc/GPMQJu3kIB yhVQ== X-Gm-Message-State: AGRZ1gJEBBoGWnHf3asuq4OOAQM2r58NPzeQAe0B/OfmBEKpGorXzS+u eun9YvvG7f4u3Hz5NOeEgpIFjw== X-Received: by 2002:adf:df82:: with SMTP id z2-v6mr384571wrl.118.1541600183576; Wed, 07 Nov 2018 06:16:23 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id q2sm948447wrx.77.2018.11.07.06.16.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 06:16:22 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: marc.zyngier@arm.com, will.deacon@arm.com, bhsharma@redhat.com, linux-efi@vger.kernel.org, Ard Biesheuvel Subject: [PATCH v2 1/6] arm64: memblock: don't permit memblock resizing until linear mapping is up Date: Wed, 7 Nov 2018 15:16:06 +0100 Message-Id: <20181107141611.12076-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181107141611.12076-1-ard.biesheuvel@linaro.org> References: <20181107141611.12076-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 Acked-by: Will Deacon Tested-by: Marc Zyngier 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 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 d6d05c8c5c52..e1b2d58a311a 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -671,6 +671,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(); } /*