Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2774305pxb; Sat, 30 Jan 2021 14:14:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv1Qfc8QTuOFqF9lOvG9kdwQWQPP1ktvNDeD8bY1vdasjlIO3EjichhE+RnLeIJmqPDcKd X-Received: by 2002:a17:906:8057:: with SMTP id x23mr10931626ejw.179.1612044876795; Sat, 30 Jan 2021 14:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612044876; cv=none; d=google.com; s=arc-20160816; b=xB34JZK3BrwZ16IezSbHNOP/6b9ysm9LLaDRMbSyK8wVvtDE5Vb2fI9RplsPicx6J1 /b13Xb2dfeIWdDjSsvVU29i1U7foNQctAnpZcWwAXyGB1yNYtWRJrPX5bEsdGXr+EhBz 7Al6gYp+dJE5ZUSxeoLKc5lmfFxW3jO7rej6pzOMY10K3Se0IaXLykpzSVuG99WCNzxN sSWno0WNAACzglqsomoWNcM0rp0uOpqyR1fK78y9J/v4pOcb0pFMcKm0LEa6MVEJKwX3 vOQ86i+5DCd/SFzzpEoljaHTAzUwmSJc1MMxg/4OGG9bVH3RbInkuz8icmhLSkcm0CD5 Lgew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nt65mlBfZ1mab0tFNEXBtnJLCKYufKXZEIbw/oJLrNg=; b=evgN6OpTeGAvBvJ76+dFVuiAl+LH/una/kmSLCkPbD54dCjN77TEarwnrTuXxiE79R BxMeteItriOmoNbC6VLAPAjtti4sGOt7xzdSTMRigSg0cB3EXkTSpeJKLgVScAfCfkRp gFCa8HdtwL7f4grja/m1DSDEmZ2n01BiZuDWuoeMG1HQfbV6FSM8tw3DWWpyHcyX2FU1 K8SFGlgUfp3nuZlCd6y+o9cm3/MxK+wJZZpLD7Y3ThyC1gg7fsraXQLwWKcZsYc0L4lW JE+wB39szcQ/lK6IZVxN/HW/KZOxsZ+hxb5uEC1XPWhzInTQNKKAai0WI6KdK2XFO0h/ DEnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tYLXvtrD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si9123791edu.567.2021.01.30.14.14.05; Sat, 30 Jan 2021 14:14:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tYLXvtrD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232280AbhA3WLn (ORCPT + 99 others); Sat, 30 Jan 2021 17:11:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:57772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbhA3WLb (ORCPT ); Sat, 30 Jan 2021 17:11:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ABFC764E13; Sat, 30 Jan 2021 22:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612044651; bh=NwGBqLKT4lv56fTEcCR2ndp0EzU/2WJrIaR7bVOuDq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tYLXvtrD8alXfHilnW1A5oTqydktopfoSZwHOS/QQOtED+KBZs1Z4I7MOL76yYe8s 6+CwAGpI0JrW0/OlZiYuELzreA0SC5h4cD7i7Np7kCuvLU0oAKFY0o4Lw60DYTjnKW N45agfUnpbuLNPpTPE5V32wNZF+GlF04S/NT/zC/NmYZaA/BjLQFFlX1opyi6rX5wh rDYj8xd63/Ud1rgDL3atULvLHGnCu7Qg9NkR2BxLecey5T7/jP6+LzdKuI8gBCKFAl 9kukhwBWOhdrDmuYxmvRjcLE9/9boF1GFllpfX6wJdC2PgBtHeF44sfWDoYpmGWfel +OYGPt9m96CFg== From: Mike Rapoport To: Andrew Morton Cc: Andrea Arcangeli , Baoquan He , Borislav Petkov , Chris Wilson , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , Linus Torvalds , =?UTF-8?q?=C5=81ukasz=20Majczak?= , Mel Gorman , Michal Hocko , Mike Rapoport , Mike Rapoport , Qian Cai , "Sarvela, Tomi P" , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, x86@kernel.org Subject: [PATCH v4 1/2] x86/setup: always add the beginning of RAM as memblock.memory Date: Sun, 31 Jan 2021 00:10:34 +0200 Message-Id: <20210130221035.4169-2-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210130221035.4169-1-rppt@kernel.org> References: <20210130221035.4169-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport The physical memory on an x86 system starts at address 0, but this is not always reflected in e820 map. For example, the BIOS can have e820 entries like [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009ffff] usable or [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x0000000000000fff] reserved [ 0.000000] BIOS-e820: [mem 0x0000000000001000-0x0000000000057fff] usable In either case, e820__memblock_setup() won't add the range 0x0000 - 0x1000 to memblock.memory and later during memory map initialization this range is left outside any zone. With SPARSEMEM=y there is always a struct page for pfn 0 and this struct page will have it's zone link wrong no matter what value will be set there. To avoid this inconsistency, add the beginning of RAM to memblock.memory. Limit the added chunk size to match the reserved memory to avoid registering memory that may be used by the firmware but never reserved at e820__memblock_setup() time. Fixes: bde9cfa3afe4 ("x86/setup: don't remove E820_TYPE_RAM for pfn 0") Signed-off-by: Mike Rapoport Cc: stable@vger.kernel.org --- arch/x86/kernel/setup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3412c4595efd..67c77ed6eef8 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -727,6 +727,14 @@ static void __init trim_low_memory_range(void) * Kconfig help text for X86_RESERVE_LOW. */ memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); + + /* + * Even if the firmware does not report the memory at address 0 as + * usable, inform the generic memory management about its existence + * to ensure it is a part of ZONE_DMA and the memory map for it is + * properly initialized. + */ + memblock_add(0, ALIGN(reserve_low, PAGE_SIZE)); } /* -- 2.28.0