From patchwork Tue Apr 23 22:47:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913791 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 860F114DB for ; Tue, 23 Apr 2019 22:49:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 776AB2887A for ; Tue, 23 Apr 2019 22:49:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BB3A28924; Tue, 23 Apr 2019 22:49:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1356628913 for ; Tue, 23 Apr 2019 22:49:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbfDWWt0 (ORCPT ); Tue, 23 Apr 2019 18:49:26 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46644 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfDWWt0 (ORCPT ); Tue, 23 Apr 2019 18:49:26 -0400 Received: by mail-lj1-f195.google.com with SMTP id h21so14970055ljk.13; Tue, 23 Apr 2019 15:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7741/2a1/SrR4PpN1R0HoKZL/IBWcdVAEL0l49IfvUY=; b=fpbLIdu5Sft9yYIVNXT84yBNZa2bkD54EFhIaCN07y+9Jytm6XEDD+ehA3w3R6JDhf Um8W7TcrFRFtFPuplbtNRQIZv8KofmqqF1D7HDltZW6dBLIAsECFGawUxGtS06N6fWEH U9Fijh1cbNs+31hS5do4yZ4RnPyecdTOeKqLWoPuv9PCKNyLPpONK93lN4X7RYyEvOQR QNqSmjqOkR6Yv3AicISGmIfk4WJfbRiAPt7dO8loLgtT0ZGCi7X09vuYrtbuw1yYSqvB QMOj1H4KyR1Klj5k/ZhaOMETYMHk4YxaduJHZsRnNTzvtPcCFxKuFll6DYWOnlYUGQrO zaOw== 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=7741/2a1/SrR4PpN1R0HoKZL/IBWcdVAEL0l49IfvUY=; b=kNYd1wRlChtpSbbcqPYjMY0qnZ5+Bg1rTSUNPNWgddtEQ7jIPBfe/RTgVClPJIUo5X fs9rnXy+XCFXQcCp62kYXxv059UPTk/qjvpFTMv6t7edjSLcoJUUtmV3wL1Ujhozx11P l5+KZYZ1r9TBShUJEIb8r8jvTYWyNFzo2NIiOOa7TvzYoEix7owNSKziCUofHlAyrr5F gstv/PB/wslk0NQRGIzl/9Nyu9Dtowaoj206p3H6GskTc+N91QU3K2sOWGtYM0icKbOJ sNVT55fuq1iPn+q3exDSH63fPjEZ57Lv5+xU2w16OfNNhey11E1GOMDdaip7t8yK6/Tf 73aA== X-Gm-Message-State: APjAAAWHYijZ9LloYTgl8+nK+lRU9bLSNhDmjHQ7Eyz9k4fd9O7Rwc0D Uu/k2R3yOsP2zL1ib4bIIj0= X-Google-Smtp-Source: APXvYqwBZMORXOuppvcbzkF7hkDJD97M3ZKhmzvmLYFzhOqz1gVXQzJN1+V97c8olF86LQ//E41xvw== X-Received: by 2002:a2e:9b13:: with SMTP id u19mr15286090lji.134.1556059764254; Tue, 23 Apr 2019 15:49:24 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:23 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 01/12] mips: Make sure kernel .bss exists in boot mem pool Date: Wed, 24 Apr 2019 01:47:37 +0300 Message-Id: <20190423224748.3765-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current MIPS platform code makes sure the kernel text, data and init sections are added to the boot memory map pool right after the arch-specific memory setup method has been executed. But for some reason the MIPS platform code skipped the kernel .bss section, which definitely should be in the boot mem pool as well in any case. Lets fix this just be adding the space between __bss_start and __bss_stop. Reviewed-by: Matt Redfearn Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 8d1dc6c71173..0ee033c44116 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -809,6 +809,9 @@ static void __init arch_mem_init(char **cmdline_p) arch_mem_addpart(PFN_UP(__pa_symbol(&__init_begin)) << PAGE_SHIFT, PFN_DOWN(__pa_symbol(&__init_end)) << PAGE_SHIFT, BOOT_MEM_INIT_RAM); + arch_mem_addpart(PFN_DOWN(__pa_symbol(&__bss_start)) << PAGE_SHIFT, + PFN_UP(__pa_symbol(&__bss_stop)) << PAGE_SHIFT, + BOOT_MEM_RAM); pr_info("Determined physical RAM map:\n"); print_memory_map(); From patchwork Tue Apr 23 22:47:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913813 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 B844B1708 for ; Tue, 23 Apr 2019 22:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7DC828956 for ; Tue, 23 Apr 2019 22:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BE7B28952; Tue, 23 Apr 2019 22:50:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AA1B28956 for ; Tue, 23 Apr 2019 22:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728545AbfDWWta (ORCPT ); Tue, 23 Apr 2019 18:49:30 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46645 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727189AbfDWWt2 (ORCPT ); Tue, 23 Apr 2019 18:49:28 -0400 Received: by mail-lj1-f195.google.com with SMTP id h21so14970102ljk.13; Tue, 23 Apr 2019 15:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZTU8dE2SxYXM9su1WKXdDX/bmKYoBJJtJQ58Oc3+2AM=; b=bM04lvZlR/QIEQrYDfguOHrc2NVRvjS04Zb+CHhgQZ4+MZEqLjigjm7RldS/1KhEi0 7xinAMJ8nM8zRkYkVGuHEsYUwgu75aLdPfyzL7FQqc9fsUgNh0YjGyXUfg3NeBDHbwO9 JCHmV/sfaZFAIB+Nvl6BPclex7P0yV4ITLXWVHyXyegN65N7F0u3vHvzzfVzOueGAbEB 5Ay0BFaKcRedr6yjzA9w/Lnt2BLAD1jmR7B9IFZzC2Ra4QnXyZ+pVJsDY2m04HpFHkbn rcZprPGUhuhjE+wmZ3VPWPnukvikhwl1AEwz4de3dWIAEDzagXN08prneD6o5GL9OqLQ cSrw== 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=ZTU8dE2SxYXM9su1WKXdDX/bmKYoBJJtJQ58Oc3+2AM=; b=BGCNZzEd8KDwA4TE2Zl31q4CdZ/FXjVJimvIFuytwWw6fSigmxnltAyp/you7LmyuS iRDU/X6WPcEL3KcpnAoX2Rnv/knoB/+BObsyv4S/iopQrqfD2sTSg+qy68jxEsCZBJ32 JJolZwRaUwWmnc9/14hBJnLNTMxncjtnGD/KQ3Mwo44+TafnWK9h8xAn43c5ixd1CTat wcegl3BB9FqHqNjjjGkSh8ie9tBnSmVHmuognXpqnE7FZbiDwByouza9Zv21P+3mAM7G x3CZCvJyuFFc7MkxxJYDwhhlBctmFgcfAQZObBPZRfeSJYIkcYeVAVRByAEXRTwX+Eyo WiLA== X-Gm-Message-State: APjAAAXbII5oPm9/DyGjuFzGnwwfjYVKe44/p+JxqSpz5lmfZ0i0jjWp qjfip5pD5ZvcMASliJJkbY4= X-Google-Smtp-Source: APXvYqwRUZSbTDgAkv4wVpcfzgRiCXMR3K44bZnjhDIvSqz1H26dIkLXwHtE6Rjbu6+yTbDZV6X4hg== X-Received: by 2002:a2e:309:: with SMTP id 9mr16039852ljd.114.1556059765706; Tue, 23 Apr 2019 15:49:25 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:25 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 02/12] mips: Discard rudiments from bootmem_init Date: Wed, 24 Apr 2019 01:47:38 +0300 Message-Id: <20190423224748.3765-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is a pointless code left in the bootmem_init() method since the bootmem allocator removal. First part resides the PFN ranges calculation loop. The conditional expressions and continue operator are useless there, since nothing is done after them. Second part is in RAM ranges installation loop. We can simplify the conditions cascade a bit without much of the logic redefinition, so to reduce the code length. In particular the end boundary value can be verified after the possible reduction to be below max_low_pfn. Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 0ee033c44116..53d93a727d1a 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -394,10 +394,7 @@ static void __init bootmem_init(void) min_low_pfn = ~0UL; max_low_pfn = 0; - /* - * Find the highest page frame number we have available - * and the lowest used RAM address - */ + /* Find the highest and lowest page frame numbers we have available. */ for (i = 0; i < boot_mem_map.nr_map; i++) { unsigned long start, end; @@ -427,13 +424,6 @@ static void __init bootmem_init(void) max_low_pfn = end; if (start < min_low_pfn) min_low_pfn = start; - if (end <= reserved_end) - continue; -#ifdef CONFIG_BLK_DEV_INITRD - /* Skip zones before initrd and initrd itself */ - if (initrd_end && end <= (unsigned long)PFN_UP(__pa(initrd_end))) - continue; -#endif } if (min_low_pfn >= max_low_pfn) @@ -474,6 +464,7 @@ static void __init bootmem_init(void) max_low_pfn = PFN_DOWN(HIGHMEM_START); } + /* Install all valid RAM ranges to the memblock memory region */ for (i = 0; i < boot_mem_map.nr_map; i++) { unsigned long start, end; @@ -481,21 +472,15 @@ static void __init bootmem_init(void) end = PFN_DOWN(boot_mem_map.map[i].addr + boot_mem_map.map[i].size); - if (start <= min_low_pfn) + if (start < min_low_pfn) start = min_low_pfn; - if (start >= end) - continue; - #ifndef CONFIG_HIGHMEM + /* Ignore highmem regions if highmem is unsupported */ if (end > max_low_pfn) end = max_low_pfn; - - /* - * ... finally, is the area going away? - */ +#endif if (end <= start) continue; -#endif memblock_add_node(PFN_PHYS(start), PFN_PHYS(end - start), 0); } From patchwork Tue Apr 23 22:47:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913811 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 3406F922 for ; Tue, 23 Apr 2019 22:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2478828956 for ; Tue, 23 Apr 2019 22:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18114289FC; Tue, 23 Apr 2019 22:50:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9300F289D6 for ; Tue, 23 Apr 2019 22:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728684AbfDWWuT (ORCPT ); Tue, 23 Apr 2019 18:50:19 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45988 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfDWWta (ORCPT ); Tue, 23 Apr 2019 18:49:30 -0400 Received: by mail-lj1-f196.google.com with SMTP id y6so14964746ljd.12; Tue, 23 Apr 2019 15:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nf5p2Hszyn7zksK8vUlbN9/At8QF1xygcv19ymXYW3s=; b=t8OafW3s67dc/e2f5ea3EKPsRNwVMA+tSDMPuKeRJfh+A7l7j3BT+LhzhKkcgV9Djy YQ75W3UTwjty7OcwReU8rwTZlkmf3YzYQpGlLorRFGY+/j7bXViz3vX3cetkHN4Iz2Qw TqM4NitL9g1h5fz8ZcQh3mT0GGosgBZX2kvNxkfxcoP4ioMBqpuiCcw1sZhrBx/DDzyA KexhVilA/my06BDZM6oeb+oZ72yMNVj3PiSdwODG9QZl+dzQb9grqg3qjGgzlvGHBuQI EW9Tq2juRtaSST6bZXW7cQWxAzSjuuVMnUBrMc6awP+8fptOxjvIXEGKGdMbdN3XHDgc RZ6w== 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=nf5p2Hszyn7zksK8vUlbN9/At8QF1xygcv19ymXYW3s=; b=thtozZOTsocJ0iKrUppW984pipSwDZYs3QOVR6be6w4GHTqYjcC5hAj9ncfYaYL2+U /P5/xmQxYW/wtXM7Ujs6MZqeqzI1YgRS9O0kXMrxXm+P62bIyuLbf7ceDUPa3tVSJPlT SVUPB2qMZJpJQZ3m8i06fKS3TGGiT+xBUO3oS9RqiVvKH1UXW7sDFpKmlS58UMsFlkPN yOuxXvV+W/Xo/13kysSicbPpqtcbu00u6yuV2nnP97Ey+6MxbwLsbLrrkm04Uoy/bRUp le1OaQMBXhyhzccu0u1KZMdrYr7iHqn1Q+gVgKVLnfjAm92Hn7NDEWIva2PFUFasRDiE tgJA== X-Gm-Message-State: APjAAAUULnGdlrAnChhult5Bf81ada12LQuTQyYDIYiiUkMr8Zc7jqr2 dVJDXJXrz1pcedf3N/OKOqc= X-Google-Smtp-Source: APXvYqx3NfW75naO0rRCrxSVqpPFHGqC3Y3W2/GsE/V2uKHOBfmNUOiAcTk9Si95omHfgqBDlsCJsw== X-Received: by 2002:a2e:97d3:: with SMTP id m19mr1224671ljj.63.1556059767142; Tue, 23 Apr 2019 15:49:27 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:26 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 03/12] mips: Combine memblock init and memory reservation loops Date: Wed, 24 Apr 2019 01:47:39 +0300 Message-Id: <20190423224748.3765-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Before bootmem was completely removed from the kernel, the last loop in the bootmem_init() had been used to reserve the correspondingly marked regions, initialize sparsemem sections and to free the low memory pages, which then would be used for early memory allocations. After the bootmem removing patchset had been merged the loop was left to do the first two things only. But it didn't do them quite well. First of all it leaves the BOOT_MEM_INIT_RAM memory types unreserved, which is definitely bug (although it isn't noticeable due to being used by the kernel region only, which is fully marked as reserved). Secondly the reservation is supposed to be done for any memory including the high one. (I couldn't figure out why the highmem was ignored in the first place, since platforms and dts' may declare any memory region for reservation) Thirdly the reserved_end variable had been used here to not accidentally free memory occupied by kernel. Since we already reserved the corresponding region higher in this method there is no need in using the variable here anymore. Fourthly the sparsemem should be aware of all the memory types in the system including the ROM_DATA even if it is going to be reserved for the whole system uptime. Finally after all these notes are fixed the loop of memory reservation can be freely merged into the memory installation loop as it's done in this patch. Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 48 ++++++---------------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 53d93a727d1a..185e0e42e009 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -483,55 +483,21 @@ static void __init bootmem_init(void) continue; memblock_add_node(PFN_PHYS(start), PFN_PHYS(end - start), 0); - } - - /* - * Register fully available low RAM pages with the bootmem allocator. - */ - for (i = 0; i < boot_mem_map.nr_map; i++) { - unsigned long start, end, size; - - start = PFN_UP(boot_mem_map.map[i].addr); - end = PFN_DOWN(boot_mem_map.map[i].addr - + boot_mem_map.map[i].size); - /* - * Reserve usable memory. - */ + /* Reserve any memory except the ordinary RAM ranges. */ switch (boot_mem_map.map[i].type) { case BOOT_MEM_RAM: break; - case BOOT_MEM_INIT_RAM: - memory_present(0, start, end); - continue; - default: - /* Not usable memory */ - if (start > min_low_pfn && end < max_low_pfn) - memblock_reserve(boot_mem_map.map[i].addr, - boot_mem_map.map[i].size); - - continue; + default: /* Reserve the rest of the memory types at boot time */ + memblock_reserve(PFN_PHYS(start), PFN_PHYS(end - start)); + break; } /* - * We are rounding up the start address of usable memory - * and at the end of the usable range downwards. - */ - if (start >= max_low_pfn) - continue; - if (start < reserved_end) - start = reserved_end; - if (end > max_low_pfn) - end = max_low_pfn; - - /* - * ... finally, is the area going away? + * In any case the added to the memblock memory regions + * (highmem/lowmem, available/reserved, etc) are considered + * as present, so inform sparsemem about them. */ - if (end <= start) - continue; - size = end - start; - - /* Register lowmem ranges */ memory_present(0, start, end); } From patchwork Tue Apr 23 22:47:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913809 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 0F77414DB for ; Tue, 23 Apr 2019 22:50:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00D31288A6 for ; Tue, 23 Apr 2019 22:50:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8CE5289A3; Tue, 23 Apr 2019 22:50:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81C95288A6 for ; Tue, 23 Apr 2019 22:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728603AbfDWWtc (ORCPT ); Tue, 23 Apr 2019 18:49:32 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40414 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728350AbfDWWta (ORCPT ); Tue, 23 Apr 2019 18:49:30 -0400 Received: by mail-lj1-f195.google.com with SMTP id q66so14984975ljq.7; Tue, 23 Apr 2019 15:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kL5scIjwN0bnNKZh/MvkqfH0S+/rftNhOfsf9udhKXo=; b=RL7nJj2AP0HIjtqrrU7fZT1SPPW3Q7aOlP+LazRT5TRh7JlanscVoo3IB8u1my4em0 3wHtkzlNbjMCiZ/ROm9mg2ShF/y+1S/UdZzCD66KhP5V9aKJ6DyZP+LPJZVrzy7UHTrd 3qBdEQFqteAoeefh4HtRRW91SMHlshy4Up23Zi891elRwf2sfU6gqFu/NVfFfdBVe0N/ 24olgUFdAofsNaO2cg4ZqeTewGCp/PHoN0eieY0W1CiskXLfi9/zF3pCZO/ieiwxRr+u FGD83jHs+iQvA64j3I4QajnwaC/B88ZJqV2XedGoN9TndOARXHGFMe5tN5nBVHwmNaYM 3Idg== 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=kL5scIjwN0bnNKZh/MvkqfH0S+/rftNhOfsf9udhKXo=; b=n/lc6o+y4wQ5EiE6SaAWhxxUKM4CcTGbhV1GJsYe8TC0V9bZM43ce2+b/QUT2ppEP6 qoil68389EhgvWMNC8Zste4H7B79+xviqHMZF0VC/0CkMtDLNBXypMoxuTTUY4Of7NiI Itdwm/wfmML1z22XWSlwGN9pf3MUKjKh9CAQqAckZ6fB2pbTi0bIIuKt56jS2nBcHMJO sCVqG9hmP1lBsIHlJ72yzoI/ti2XtlNJbnhzGkmp96/528Od91GRTvkfvKRgrBJej/fk pFlIjE6/6/TaiFX96/bhb7XhfLLhyOcJ497i79oY3NTyVjxQw3B4xAReaTlsj/3+AZUK Smww== X-Gm-Message-State: APjAAAVJvBHtZEN5Qdj3a4KxqOdHbJBFl0gKx7nQJkr8V5w3a2tvXZ6C 4o94xggEAD8mK8GTn7N09Cg= X-Google-Smtp-Source: APXvYqyHxLB2YUcQTKUlMkatOsiRjG5aj7qenaEg42Q+Vt1Mc0MuOkVgotaJK5cYFdfXlOG5eCNVTw== X-Received: by 2002:a2e:93d0:: with SMTP id p16mr14767084ljh.197.1556059768630; Tue, 23 Apr 2019 15:49:28 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:27 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 04/12] mips: Reserve memory for the kernel image resources Date: Wed, 24 Apr 2019 01:47:40 +0300 Message-Id: <20190423224748.3765-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The reserved_end variable had been used by the bootmem_init() code to find a lowest limit of memory available for memmap blob. The original code just tried to find a free memory space higher than kernel was placed. This limitation seems justified for the memmap ragion search process, but I can't see any obvious reason to reserve the unused space below kernel seeing some platforms place it much higher than standard 1MB. Moreover the RELOCATION config enables it to be loaded at any memory address. So lets reserve the memory occupied by the kernel only, leaving the region below being free for allocations. After doing this we can now discard the code freeing a space between kernel _text and VMLINUX_LOAD_ADDRESS symbols since it's going to be free anyway (unless marked as reserved by platforms). Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 185e0e42e009..f71a7d32a687 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -371,7 +371,6 @@ static void __init bootmem_init(void) static void __init bootmem_init(void) { - unsigned long reserved_end; phys_addr_t ramstart = PHYS_ADDR_MAX; int i; @@ -382,10 +381,10 @@ static void __init bootmem_init(void) * will reserve the area used for the initrd. */ init_initrd(); - reserved_end = (unsigned long) PFN_UP(__pa_symbol(&_end)); - memblock_reserve(PHYS_OFFSET, - (reserved_end << PAGE_SHIFT) - PHYS_OFFSET); + /* Reserve memory occupied by kernel. */ + memblock_reserve(__pa_symbol(&_text), + __pa_symbol(&_end) - __pa_symbol(&_text)); /* * max_low_pfn is not a number of pages. The number of pages @@ -501,29 +500,6 @@ static void __init bootmem_init(void) memory_present(0, start, end); } -#ifdef CONFIG_RELOCATABLE - /* - * The kernel reserves all memory below its _end symbol as bootmem, - * but the kernel may now be at a much higher address. The memory - * between the original and new locations may be returned to the system. - */ - if (__pa_symbol(_text) > __pa_symbol(VMLINUX_LOAD_ADDRESS)) { - unsigned long offset; - extern void show_kernel_relocation(const char *level); - - offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); - memblock_free(__pa_symbol(VMLINUX_LOAD_ADDRESS), offset); - -#if defined(CONFIG_DEBUG_KERNEL) && defined(CONFIG_DEBUG_INFO) - /* - * This information is necessary when debugging the kernel - * But is a security vulnerability otherwise! - */ - show_kernel_relocation(KERN_INFO); -#endif - } -#endif - /* * Reserve initrd memory if needed. */ From patchwork Tue Apr 23 22:47:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913793 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 21E5A922 for ; Tue, 23 Apr 2019 22:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EF902887A for ; Tue, 23 Apr 2019 22:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0017328924; Tue, 23 Apr 2019 22:49:34 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDD432887A for ; Tue, 23 Apr 2019 22:49:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728627AbfDWWtd (ORCPT ); Tue, 23 Apr 2019 18:49:33 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36973 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728594AbfDWWtc (ORCPT ); Tue, 23 Apr 2019 18:49:32 -0400 Received: by mail-lf1-f68.google.com with SMTP id h126so2367687lfh.4; Tue, 23 Apr 2019 15:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FrbxXCzbduE6bxqzUV5O8VcSJ/8bNCEge0K7+QXqWcw=; b=C5Z0Eri1E/MgiwW5s2hJ0I1+mpTOAalvY1gdEQyVcQyh4k+SOdcbvwPxE/PwmN+QEI 6L5RaXXhRNFfMEXXelOg9V8ff+GNNUNB5C40hqDz4G3Q8Djt0uRDxI/WKSP1cFdit0PI fUlugbB+qa0GPzP4IFVCeqRQV/h8ikqJ8erozIB8Ox/8stkwW3YGwHHuv0vjfGFOurMw ryncVMimSMKti+L1l0/QyZufwrnCCDY+aMc3X0oGHwajcD6vwD/0GidUyJwf1A1OPpqs 6x84dc+Z39ecs9vxLaVKwJospMybQWYrIoUmyohkvCAo8y4mDNYX9qZiF4rKrdic6hUi hqyA== 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=FrbxXCzbduE6bxqzUV5O8VcSJ/8bNCEge0K7+QXqWcw=; b=Cy9wh4o1vzU1fQMt8WDaDiCwjt2zro2KDcorfi8q2hzGqwlVZzWN3i8cK3fKbFMNIE ELojqGAKAKk3/PdoPCS1KqfdUt04SXBT66mhIcTRSgHuayXUY1DD9VDTGgWk4KB7m9iG /J65sa/G3aNaPjnrjF/LcfqOYmevOXS6swYX8fNtafB1rCviNoT5pn4Iq282JDFzPTaA DHK9JagLrNi7cnLeM4kpN+/m6V/m9h58X+foaa7vRg1hHyfvqyJHk3AsG+oO64KgcgPu BvbosEAOyP1YvN0OHuEqm6IeXH4SGl86DYZqe0tqfx0a5IyI33XT5G74Cw44THBjtIgv YcYg== X-Gm-Message-State: APjAAAUmTvFxl6mLEBo1YGfoRhdnBtZu9IWb1mQYDxDl/60kwkGSPrbN U54HUEe9TPczdAaQVaVidCU= X-Google-Smtp-Source: APXvYqyCSnXCGC9FnalNaC5sKIc9QmhN7maCues08BcUfbwk7TStnH3zAzRnlwt60y5xL5hD2JrT3w== X-Received: by 2002:ac2:51a1:: with SMTP id f1mr7455057lfk.129.1556059770067; Tue, 23 Apr 2019 15:49:30 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:29 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 05/12] mips: Discard post-CMA-init foreach loop Date: Wed, 24 Apr 2019 01:47:41 +0300 Message-Id: <20190423224748.3765-6-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Really the loop is pointless, since it walks over memblock-reserved memory regions and mark them as reserved in memblock. Before bootmem was removed from the kernel, this loop had been used to map the memory reserved by CMA into the legacy bootmem allocator. But now the early memory allocator is memblock, which is used by CMA for reservation, so we don't need any mapping anymore. Reviewed-by: Matt Redfearn Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index f71a7d32a687..2ae6b02b948f 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -708,7 +708,6 @@ static void __init request_crashkernel(struct resource *res) */ static void __init arch_mem_init(char **cmdline_p) { - struct memblock_region *reg; extern void plat_mem_setup(void); /* @@ -814,10 +813,6 @@ static void __init arch_mem_init(char **cmdline_p) plat_swiotlb_setup(); dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); - /* Tell bootmem about cma reserved memblock section */ - for_each_memblock(reserved, reg) - if (reg->size != 0) - memblock_reserve(reg->base, reg->size); reserve_bootmem_region(__pa_symbol(&__nosave_begin), __pa_symbol(&__nosave_end)); /* Reserve for hibernation */ From patchwork Tue Apr 23 22:47:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913807 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 297C414DB for ; Tue, 23 Apr 2019 22:50:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BFC1288B6 for ; Tue, 23 Apr 2019 22:50:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1087B2892A; Tue, 23 Apr 2019 22:50:15 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B46B028956 for ; Tue, 23 Apr 2019 22:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbfDWWte (ORCPT ); Tue, 23 Apr 2019 18:49:34 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35418 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728604AbfDWWtd (ORCPT ); Tue, 23 Apr 2019 18:49:33 -0400 Received: by mail-lj1-f193.google.com with SMTP id t4so14996575ljc.2; Tue, 23 Apr 2019 15:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aXXFjDICVLHmB6TL7TDcc/fdg+nH2204TOTWUCRzYEg=; b=OqY4f2Qg+SvkuiMeosJuX95MfMFGoTNriaI6utt3x8o3I6xwPow4OO7gqYv/+llykL 62HjAu16vB65YXYjKFjdPf/DmuBCMoLS6fZPZucgFGZbfZ8w+OZJIbJyLjZBJ9M0Flqo wZJozoEXaNTEeUhOf5XZGkARNprGInv5w6NeCH90mU2x84vuL84AWFKovn32gRREPw5v 7TbODywdIAZKBO9sILxrnRAun/ziRqOa9jzv+7bAgtNtzkkmOHr3tKjo1i/c4TzDUCNk ZUT/WeIDla1x/uce1uLJUPf4gKMV7eu7Uzs66t5ExJGBOibFl6sp/N+yqKEGnsa+ec93 py3w== 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=aXXFjDICVLHmB6TL7TDcc/fdg+nH2204TOTWUCRzYEg=; b=J6l10NFoO8PR4FhzjV6w8V+31ywocCCphnQlFum8IU0unsydH3ztBaMGmFjwDIWI4c C2A8OC0LQ/OxtKW6zCOEyb873r2TpYXB9AkSKl9mBqD6rZrgnIMSsrE7N/25Ntwgajbb ZIfcuS1rIQXz4yD+itg/wlRYqeNJWW/4TRPu3emcGuJbpVctQ48AWxJ91d3T1niZAFTq i0BVRB2KuqodWVZmUeI8kai6fRWuxdVOvIyEQNQGAjROJGXR2IFRRed1fKb88aYlgXX+ dvHHpVX1LY3xsWnP9AZ28qyz4+h2wjMungjl8Tr/kz1v3cqj4Df/+IMlNWlKHMwLGEde vB8g== X-Gm-Message-State: APjAAAX6lQ2VekfofDYo0cHfriII7PRnKRJ+v6/86u3tgsHLPTUyAmzg e2hU0Z1DzEiAitYm+mPvpdQ= X-Google-Smtp-Source: APXvYqwP+pmsbapZQ/k9VBR241gD0yNb1W4SFh7e0nH6MQ44QpDjHkhfpt87rwY36NhY6fwyyhqqkg== X-Received: by 2002:a2e:8057:: with SMTP id p23mr4560923ljg.33.1556059771521; Tue, 23 Apr 2019 15:49:31 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:30 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 06/12] mips: Use memblock to reserve the __nosave memory range Date: Wed, 24 Apr 2019 01:47:42 +0300 Message-Id: <20190423224748.3765-7-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Originally before legacy bootmem was removed, the memory for the range was correctly reserved by reserve_bootmem_region(). But since memblock has been selected for early memory allocation the function can be utilized only after paging is fully initialized (as it is done by memblock_free_all() function). So calling it from arch_mem_init() method is prone to errors, and at this stage we need to reserve the memory in the memblock allocator. Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 2ae6b02b948f..3a5140943f54 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -814,8 +814,9 @@ static void __init arch_mem_init(char **cmdline_p) dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); - reserve_bootmem_region(__pa_symbol(&__nosave_begin), - __pa_symbol(&__nosave_end)); /* Reserve for hibernation */ + /* Reserve for hibernation. */ + memblock_reserve(__pa_symbol(&__nosave_begin), + __pa_symbol(&__nosave_end) - __pa_symbol(&__nosave_begin)); } static void __init resource_init(void) From patchwork Tue Apr 23 22:47:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913805 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 B77BA922 for ; Tue, 23 Apr 2019 22:50:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A995C286C4 for ; Tue, 23 Apr 2019 22:50:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E122288C4; Tue, 23 Apr 2019 22:50:13 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9244289B1 for ; Tue, 23 Apr 2019 22:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728698AbfDWWtf (ORCPT ); Tue, 23 Apr 2019 18:49:35 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46696 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728647AbfDWWtf (ORCPT ); Tue, 23 Apr 2019 18:49:35 -0400 Received: by mail-lf1-f68.google.com with SMTP id k18so12985303lfj.13; Tue, 23 Apr 2019 15:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HJRvj8BujR+p5SOja4FAemkZIFG1n37I1t4IGxaN5rI=; b=VHY48LhM8TNgdZneoiW3y8NkrZcdRSFuXgtVdkM2iPWLaxjrMRw4rE96YnsFQ07M4J AWYVCKEDNcEFOXjLZ2j7PtdunmbuhnwdaIXS9tdwv5rWB3iL0mXJMm481chlaFJ+QLmG x9wyok20vv7GlzltLfYRx4BhrZXJcjE0SI5nuvVJHENzkQ8D2VNZfQaH7RbrTEF7/JVR L6qlMVv5rcKbyVck7ddB6unYKfdZz02Zl6ujqiC35edvcsESnuXql+zbAAe2RNee1Iu8 Z7wBsMUcxy6d6IwRwvjc/0KXt/LrphI3gSBGOpG++jjcdnWbQ9Vxzsh89tJ3kW71MoYX mQtg== 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=HJRvj8BujR+p5SOja4FAemkZIFG1n37I1t4IGxaN5rI=; b=R3oWy11YLH80dvMmwF5HcrdEpe+rp4qmuC6gp22lnIdnjUHtYN1QqATBeA6z5qzcsh GTuOH/H4nfxzffmK4DJ2vDu4/ZFD3Mq5+9BjHdWPHXoqwrWvGS/xYu1Fi9ENDLqKCqpC nOPqQd9XEagVXdKTkbl6wZ/ZmrAKnaophyNSjuWrMxE5cbat0Tmtc2pLxoIwJ98nNKBk TVBkJtToOXck/6Q49UrJDXjAOa1ekfR83rcCe22Vty2LVVo4w642eiiUt990e7h1z9Ny dM1FRkIlblt8/fvK3uM6PO8JnsORnk4reuFI8KT6l+bVr0s1Ua1HY1rRzXClcRJqxO5A jy1g== X-Gm-Message-State: APjAAAUP7CGvQyL8bGNxcNCWQMj3nm/fgsxfJIhnDfOQvMAR9IOXkA8C XqfoxQdKJtlKPIX0R0Yhr/A= X-Google-Smtp-Source: APXvYqzBPfY2roDZJC/cvUS8pRWGCB3Y6qBzQOGp021YLe4yOcN5c+tUwToi5RT5Wjzp3e+XNVEaTA== X-Received: by 2002:a19:7014:: with SMTP id h20mr15944340lfc.158.1556059772953; Tue, 23 Apr 2019 15:49:32 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:32 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 07/12] mips: Add reserve-nomap memory type support Date: Wed, 24 Apr 2019 01:47:43 +0300 Message-Id: <20190423224748.3765-8-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It might be necessary to prevent the virtual mapping creation for a requested memory region. For instance there is a "no-map" property indicating exactly this feature. In this case we need to not only reserve the specified region by pretending it doesn't exist in the memory space, but completely remove the range from system just by removing it from memblock. The same way it's done in default early_init_dt_reserve_memory_arch() method. Signed-off-by: Serge Semin --- arch/mips/include/asm/bootinfo.h | 1 + arch/mips/kernel/prom.c | 4 +++- arch/mips/kernel/setup.c | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h index a301a8f4bc66..235bc2f52113 100644 --- a/arch/mips/include/asm/bootinfo.h +++ b/arch/mips/include/asm/bootinfo.h @@ -92,6 +92,7 @@ extern unsigned long mips_machtype; #define BOOT_MEM_ROM_DATA 2 #define BOOT_MEM_RESERVED 3 #define BOOT_MEM_INIT_RAM 4 +#define BOOT_MEM_NOMAP 5 /* * A memory map that's built upon what was determined diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 93b8e0b4332f..437a174e3ef9 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -47,7 +47,9 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) int __init early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, bool nomap) { - add_memory_region(base, size, BOOT_MEM_RESERVED); + add_memory_region(base, size, + nomap ? BOOT_MEM_NOMAP : BOOT_MEM_RESERVED); + return 0; } diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 3a5140943f54..2a1b2e7a1bc9 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -178,6 +178,7 @@ static bool __init __maybe_unused memory_region_available(phys_addr_t start, in_ram = true; break; case BOOT_MEM_RESERVED: + case BOOT_MEM_NOMAP: if ((start >= start_ && start < end_) || (start < start_ && start + size >= start_)) free = false; @@ -213,6 +214,9 @@ static void __init print_memory_map(void) case BOOT_MEM_RESERVED: printk(KERN_CONT "(reserved)\n"); break; + case BOOT_MEM_NOMAP: + printk(KERN_CONT "(nomap)\n"); + break; default: printk(KERN_CONT "type %lu\n", boot_mem_map.map[i].type); break; @@ -487,6 +491,9 @@ static void __init bootmem_init(void) switch (boot_mem_map.map[i].type) { case BOOT_MEM_RAM: break; + case BOOT_MEM_NOMAP: /* Discard the range from the system. */ + memblock_remove(PFN_PHYS(start), PFN_PHYS(end - start)); + continue; default: /* Reserve the rest of the memory types at boot time */ memblock_reserve(PFN_PHYS(start), PFN_PHYS(end - start)); break; @@ -861,6 +868,7 @@ static void __init resource_init(void) res->flags |= IORESOURCE_SYSRAM; break; case BOOT_MEM_RESERVED: + case BOOT_MEM_NOMAP: default: res->name = "reserved"; } From patchwork Tue Apr 23 22:47:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913803 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 6A17814DB for ; Tue, 23 Apr 2019 22:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BC6B286C4 for ; Tue, 23 Apr 2019 22:50:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FAE1289A3; Tue, 23 Apr 2019 22:50:12 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FC6E2887B for ; Tue, 23 Apr 2019 22:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728647AbfDWWuF (ORCPT ); Tue, 23 Apr 2019 18:50:05 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39491 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728684AbfDWWtg (ORCPT ); Tue, 23 Apr 2019 18:49:36 -0400 Received: by mail-lj1-f193.google.com with SMTP id l7so15003296ljg.6; Tue, 23 Apr 2019 15:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ki42UVersVgO0drl3EkT6trUyKrYAuiSL6uO+XLp8qo=; b=LFDhkYGwUUcKL70nD/YT5mltsCFyWgMDGN3Dn/2DwKPy0rQeT4DQXnHKUyxY8HsTBK yi1BLa1BXycY5hqy/YfoP8PWDEMR0JBFm/R41nYasE3vRzPGEhOD4oFH/RyoPiNU3Ep6 LV+XmZ76hfjGidRj8XI5hMBbLqT22GkpkTR62BD9cJ1lJ2D37k6xCG7b5p2RCj5Qhcxp mf27AX0S0mBWIe5Gg+f6iGOAAqRwXwIVFqe+dPDl3sCOdDtRlQJHhEMy8eV91Ym7WjRs rEXk2bWeymhIQjFimpFfWuaxOhNwjid9g4l/TAt4tlMD3rHHR0T3r84qX60wXGqrfa2X r/oA== 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=Ki42UVersVgO0drl3EkT6trUyKrYAuiSL6uO+XLp8qo=; b=pI4xo3W8JLXLhJQ+L0oWxb1nNgO7avU0d4Z/ZYiq3ofmK8eIzi6R10Jdv0Vv9aamk1 YzOaF6DKR3hCgi1TaqLWdCIvIALsWInuhn9ym1Ijcx67uxSEij469p24tZPjdXCvJCcs XTFn3znvQMb/JnW3cjlFZBKZClJqjs/4pMgf0CtQnWTa13j31cidptRptq+LzV2ym2jT UsHOIYITAzP4nXeJSVn5sBTkOvAFQcWOkqA2+DyG6BhiTRjoWcSmWxLmfIJWMOX2ePSQ qKTm/9n2QKQGSC2d0G0cfbFA836hAKVe7yrJMg1wnB0osEYrTkR3nLH85+TcOLsXcy19 I9ew== X-Gm-Message-State: APjAAAX/XJSKqm2+CFQMk8VFuGM0RPRpBEDHKA+i00pyJZko4U1VMujT MI8IxeUGJg8X30MXiWFDZXM= X-Google-Smtp-Source: APXvYqwHm2THQU6zCobvLE+tKU93UaRP+BFZTKpIkqXcvxv+kqV5eZ2b+FyYUwvDUdgWsuiU9GZM9Q== X-Received: by 2002:a2e:7e0f:: with SMTP id z15mr15308271ljc.122.1556059774454; Tue, 23 Apr 2019 15:49:34 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:33 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 08/12] mips: Dump memblock regions for debugging Date: Wed, 24 Apr 2019 01:47:44 +0300 Message-Id: <20190423224748.3765-9-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is useful to have the whole memblock memory space printed to console when basic memlock initializations are done. It can be performed by ready-to-use method memblock_dump_all(), which prints the available and reserved memory spaces if MEMBLOCK_DEBUG config is enabled. Lets call it at the very end of arch_mem_init() function, when all memblock memory and reserved regions are defined, but before any serious allocation is performed. Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 2a1b2e7a1bc9..ca493fdf69b0 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -824,6 +824,8 @@ static void __init arch_mem_init(char **cmdline_p) /* Reserve for hibernation. */ memblock_reserve(__pa_symbol(&__nosave_begin), __pa_symbol(&__nosave_end) - __pa_symbol(&__nosave_begin)); + + memblock_dump_all(); } static void __init resource_init(void) From patchwork Tue Apr 23 22:47:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913797 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 245C114DB for ; Tue, 23 Apr 2019 22:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12B60287EA for ; Tue, 23 Apr 2019 22:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06D3F288A2; Tue, 23 Apr 2019 22:49:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAFDB287EA for ; Tue, 23 Apr 2019 22:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfDWWtl (ORCPT ); Tue, 23 Apr 2019 18:49:41 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33079 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728712AbfDWWti (ORCPT ); Tue, 23 Apr 2019 18:49:38 -0400 Received: by mail-lj1-f195.google.com with SMTP id f23so15031255ljc.0; Tue, 23 Apr 2019 15:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QQUuLg/zS2tfsDPJ/SWrp4NtSrhhV6zRMowLIWOaos8=; b=ZBRqseJkYxfE/CzTHrtM2oFui4WHlgpHFxVNRrXxCKi7N8X3XTPlsNGSc4ixdgXSQL Ft4N3un8giuvHukO+rUIqFqg0gQrFi37NydhXvzZUYY3sYVerTDnePzuqzPJtTLFZsT9 /RDd7oy6OmJCrxdT41pBlHXf5a4QRlDK7UhVj+HzeR4vmCoJHiI4eIolL/He31Q98u/K 3TErh/CFzHNTVNGq5mKSfaj8nWGvk+J8dlJFoShbrWWdsl++e1FObF2V7gTXntamcVK4 IBurUD9I0DGT57g4pVBixhVip8XowygvDGao0r7jv/60dGysobUJVkxU7zxL6rbpBfk4 MeXg== 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=QQUuLg/zS2tfsDPJ/SWrp4NtSrhhV6zRMowLIWOaos8=; b=B4hrCaNSALucr1a/FeHK7GnIIpqOvo3auje6MAk8UP3teCS13Emih96SHFwADdllj0 SxQMG4Xgy9ZcU6tMi7LB1QxJPz3DNdBCh+Oiq6xLwZSdoU65p4KqGyutapwf1GfFIh5y NyC7KF4rbF81lo0oe0j9WTFVupCQ+YAq5pyo3WqxSoaS95GqZzpmIh0vX/Diw8loH4jj 2mrxNsd8TYQ69e1xkrOdmvEMbj4Dr2Qui/x/l/5AX3YdzWy2YwqE+QM00VDkBe3N2dwE L5MxL2vwBEsWjM8ddpTme24gfHsdmCg+ly3/gt1cYoAY4PcAW8U9MnfSk9NkRM19c2Vb Rfwg== X-Gm-Message-State: APjAAAV407CG9p2tG0/J/JoY3zIAWXaLFu7MUTgLTVpMoUJvJD0wREXA zKvKoHUfFLZHbm706YV9mo4= X-Google-Smtp-Source: APXvYqyhjnkT+9LePvjgG7sTJaXhnCTfU1OegGJVSuxkNhWhUGd6uARyyWDHWvGNqBt2JV2gzkzWhw== X-Received: by 2002:a2e:5d94:: with SMTP id v20mr14093334lje.138.1556059775938; Tue, 23 Apr 2019 15:49:35 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:35 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 09/12] mips: Perform early low memory test Date: Wed, 24 Apr 2019 01:47:45 +0300 Message-Id: <20190423224748.3765-10-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP memblock subsystem provides a method to optionally test the passed memory region in case if it was requested via special kernel boot argument. Lets add the function at the bottom of the arch_mem_init() method. Testing at this point in the boot sequence should be safe since all critical areas are now reserved and a minimum of allocations have been done. Reviewed-by: Matt Redfearn Signed-off-by: Serge Semin --- arch/mips/kernel/setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index ca493fdf69b0..fbd216b4e929 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -826,6 +826,8 @@ static void __init arch_mem_init(char **cmdline_p) __pa_symbol(&__nosave_end) - __pa_symbol(&__nosave_begin)); memblock_dump_all(); + + early_memtest(PFN_PHYS(min_low_pfn), PFN_PHYS(max_low_pfn)); } static void __init resource_init(void) From patchwork Tue Apr 23 22:47:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913799 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 5A524922 for ; Tue, 23 Apr 2019 22:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48B0E287EA for ; Tue, 23 Apr 2019 22:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C9B02887B; Tue, 23 Apr 2019 22:49:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC2C72887A for ; Tue, 23 Apr 2019 22:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728769AbfDWWtl (ORCPT ); Tue, 23 Apr 2019 18:49:41 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40422 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbfDWWtk (ORCPT ); Tue, 23 Apr 2019 18:49:40 -0400 Received: by mail-lj1-f194.google.com with SMTP id q66so14985225ljq.7; Tue, 23 Apr 2019 15:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cKcAZCZmHBkOFZOBdJVKsgxHPiEdHR2uf5o4k8h8weQ=; b=LI9TjAH2Xp9ixng6oGKtwlyVvGBV0Fx3cil6kEE6VDXWbDUjU1XTGg+FizGETTXW67 YDDoDxm8MTqseKi0zaxuiRK2QkBETCd3LXSkrO8o0AAVmU1wKb0uzbx/e2n9y6DGgl9j 8UMIzPXDtHKc6OqVsWU7Bmf2+bDoP/FiqxXVtX8g53Mzzy2aKTVrQyjH7q13qJX4JlpM pquXrOjO0L9MnrXj1DsHdnKU3+LzhEq9U73nSXz6JQ/jmi4za/p31L1RM6d9flYT3j2D M5VNynMz37LEji78Td9OOkWz1p9CuZG5xgPonZloenFwKbZvLRZ6sd3eCVBp6MpZR+76 968g== 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=cKcAZCZmHBkOFZOBdJVKsgxHPiEdHR2uf5o4k8h8weQ=; b=cuGFJkxC3kMfkDEqHpDPepuv+gxaNg1vA5NJ9/9D0XR2Qf+gPVFj5UmuemXMPr5T4c vkQ12T8YihmXw5yq1OFj3+PmvSpCxGx+/MpiU/dketJEhJOQHNo84FuZfqYsjFx7w9pO 5CnsFdVoLocNnlul3v9AYZEu+i+zpkGqgcy0US+fXa1w5aTbV+8E1CDJil/iwtuK9PH1 9WlqFi4nZlXOTAdMf7j37mKmTf3oaI/oxTIETSsn22vTLvrvnsqMaEUw7KOGHvytP2NU iCi7+arwdwpwBpRcTYDhMfsRgcuwU7nA/jVCY2AV5BiGDcKpWY4rA1wAcbEDOZzr04cN QU4w== X-Gm-Message-State: APjAAAXEa8jEr+9sicc8YFmfQ2ydEbkqkTvJ4KuS8lsaECWf6pny4NUu PY1rQNCNXfCAfr+6thKptr8= X-Google-Smtp-Source: APXvYqyAXeBiz4mUBF6HYRBCUA5Zqa5vUYs5oJ1JyAbZ+J454fbF0zypcDVYEV6KCeBX8Hm2mj46vA== X-Received: by 2002:a2e:97da:: with SMTP id m26mr8576895ljj.115.1556059777939; Tue, 23 Apr 2019 15:49:37 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:37 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 10/12] mips: Print the kernel virtual mem layout on debugging Date: Wed, 24 Apr 2019 01:47:46 +0300 Message-Id: <20190423224748.3765-11-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is useful at least for debugging to have the kernel virtual memory layout printed at boot time so to have the full information about the booted kernel. Make the printing optional and available only when DEBUG_KERNEL config is enabled so not to leak a sensitive kernel information. Signed-off-by: Serge Semin --- arch/mips/mm/init.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index bbb196ad5f26..c338bbd03b2a 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,53 @@ unsigned long empty_zero_page, zero_page_mask; EXPORT_SYMBOL_GPL(empty_zero_page); EXPORT_SYMBOL(zero_page_mask); +/* + * Print out the kernel virtual memory layout + */ +#define MLK(b, t) (void *)b, (void *)t, ((t) - (b)) >> 10 +#define MLM(b, t) (void *)b, (void *)t, ((t) - (b)) >> 20 +#define MLK_ROUNDUP(b, t) (void *)b, (void *)t, DIV_ROUND_UP(((t) - (b)), SZ_1K) +static void __init mem_print_kmap_info(void) +{ +#ifdef CONFIG_DEBUG_KERNEL + pr_notice("Kernel virtual memory layout:\n" + " lowmem : 0x%px - 0x%px (%4ld MB)\n" + " .text : 0x%px - 0x%px (%4td kB)\n" + " .data : 0x%px - 0x%px (%4td kB)\n" + " .init : 0x%px - 0x%px (%4td kB)\n" + " .bss : 0x%px - 0x%px (%4td kB)\n" + " vmalloc : 0x%px - 0x%px (%4ld MB)\n" +#ifdef CONFIG_HIGHMEM + " pkmap : 0x%px - 0x%px (%4ld MB)\n" +#endif + " fixmap : 0x%px - 0x%px (%4ld kB)\n", + MLM(PAGE_OFFSET, (unsigned long)high_memory), + MLK_ROUNDUP(_text, _etext), + MLK_ROUNDUP(_sdata, _edata), + MLK_ROUNDUP(__init_begin, __init_end), + MLK_ROUNDUP(__bss_start, __bss_stop), + MLM(VMALLOC_START, VMALLOC_END), +#ifdef CONFIG_HIGHMEM + MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE)), +#endif + MLK(FIXADDR_START, FIXADDR_TOP)); + + /* Check some fundamental inconsistencies. May add something else? */ +#ifdef CONFIG_HIGHMEM + BUILD_BUG_ON(VMALLOC_END < PAGE_OFFSET); + BUG_ON(VMALLOC_END < (unsigned long)high_memory); + BUILD_BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) < PAGE_OFFSET); + BUG_ON((PKMAP_BASE) + (LAST_PKMAP)*(PAGE_SIZE) < + (unsigned long)high_memory); +#endif + BUILD_BUG_ON(FIXADDR_TOP < PAGE_OFFSET); + BUG_ON(FIXADDR_TOP < (unsigned long)high_memory); +#endif /* CONFIG_DEBUG_KERNEL */ +} +#undef MLK +#undef MLM +#undef MLK_ROUNDUP + /* * Not static inline because used by IP27 special magic initialization code */ @@ -479,6 +527,7 @@ void __init mem_init(void) setup_zero_pages(); /* Setup zeroed pages. */ mem_init_free_highmem(); mem_init_print_info(NULL); + mem_print_kmap_info(); #ifdef CONFIG_64BIT if ((unsigned long) &_text > (unsigned long) CKSEG0) From patchwork Tue Apr 23 22:47:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913801 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 5C78314DB for ; Tue, 23 Apr 2019 22:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D966287EA for ; Tue, 23 Apr 2019 22:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E8472887A; Tue, 23 Apr 2019 22:50:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D276A2887A for ; Tue, 23 Apr 2019 22:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbfDWWt5 (ORCPT ); Tue, 23 Apr 2019 18:49:57 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:46699 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728647AbfDWWtm (ORCPT ); Tue, 23 Apr 2019 18:49:42 -0400 Received: by mail-lf1-f66.google.com with SMTP id k18so12985435lfj.13; Tue, 23 Apr 2019 15:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VJ3xwWJXog1KPx7zXkBt+0FT1onV4wm00T3cYGUdK8o=; b=dfuEeI/xqrZujHXykgX4UeKXjmUGMkHpprck0gZu6b9Bl+E4QQtmhiG0xc2Hno05dN 8NwdxoNghrzZa9uBXrKYxfALB8W0i2pkIt9A6r8VGoZIp4MJw/gte2dfoBfDvQaE9YoX 5qKAZfvywTQAZJ1LFEqWlqlbkL7uAqlkt/3kzxq16ZwCtG2CH8rNUjnacYPTjQHY4Q4T 5MBHpcQ6QrTZXh1oLEDtsPMmOGPJaHaSRO4wKCk389PNku/iR15uRauOVW2a/qWln0/y ScMdJNPbgjTei27drIJdmMnqPBQgtP3o4YsBPActjbdsufmqVipYWtTnNySptsptVU2V rvBg== 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=VJ3xwWJXog1KPx7zXkBt+0FT1onV4wm00T3cYGUdK8o=; b=bAGyEwtIF9JKMFfYJxnIqf/kbgITNZycpdv3ZWK2dDIkPK4u+d+sMvY6xyaTtQTBIf 33qCDv6PcskbPqRnxVIbKCob4WX6t/YOMhobcsLqmCdHLe124a5bh4ASFb2U/Of3uiTb pUoBplqTda/Jge84aJ0+YS5wcshNESiqp4dhlI8667HUr+EURMeOJbF/6sgelsmL4uEV IHqK8QDXnPZQZGgYN1IFZNtnmuSPYMw3Hd1IoRaJL7D0P2IU8Alcdm0jOknXJGaahJx8 fqUSCB/VwGx27Z8OYWs4aTAz/vcCskdPhyGApR8SuD9GrVWy8LfLzypjoRtsH13AxcV7 6ouA== X-Gm-Message-State: APjAAAWcYMTmqnJ9BDf+c7Z1hhaC/jK7xNoi/F9C0Hjnzo3sSMfQLUxD G4CLol9d6E/Xov9PP1MdkdM= X-Google-Smtp-Source: APXvYqyST+f6mO8FvKsw8ef7ytV8eNa4Hb8jVjd1N5jWDJW1Qzvmq1+c+eepJUlQYzYSmUbWjijskQ== X-Received: by 2002:a19:c216:: with SMTP id l22mr14887697lfc.112.1556059779541; Tue, 23 Apr 2019 15:49:39 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:38 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 11/12] mips: Make sure dt memory regions are valid Date: Wed, 24 Apr 2019 01:47:47 +0300 Message-Id: <20190423224748.3765-12-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are situations when memory regions coming from dts may be too big for the platform physical address space. It especially concerns XPA-capable systems. Bootleader may determine more than 4GB memory available and pass it to the kernel over dts memory node, while kernel is built without XPA support. In this case the region may either simply be truncated by add_memory_region() method or by u64->phys_addr_t type casting. But in worst case the method can even drop the memory region if it exceedes PHYS_ADDR_MAX size. So lets make sure the retrieved from dts memory regions are valid, and if some of them isn't just manually truncate it with a warning printed out. Signed-off-by: Serge Semin --- arch/mips/kernel/prom.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 437a174e3ef9..28bf01961bb2 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -41,7 +41,19 @@ char *mips_get_machine_name(void) #ifdef CONFIG_USE_OF void __init early_init_dt_add_memory_arch(u64 base, u64 size) { - return add_memory_region(base, size, BOOT_MEM_RAM); + if (base >= PHYS_ADDR_MAX) { + pr_warn("Trying to add an invalid memory region, skipped\n"); + return; + } + + /* Truncate the passed memory region instead of type casting */ + if (base + size - 1 >= PHYS_ADDR_MAX || base + size < base) { + pr_warn("Truncate memory region %llx @ %llx to size %llx\n", + size, base, PHYS_ADDR_MAX - base); + size = PHYS_ADDR_MAX - base; + } + + add_memory_region(base, size, BOOT_MEM_RAM); } int __init early_init_dt_reserve_memory_arch(phys_addr_t base, From patchwork Tue Apr 23 22:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 10913795 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 DB89314DB for ; Tue, 23 Apr 2019 22:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA118287EA for ; Tue, 23 Apr 2019 22:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC56F2887B; Tue, 23 Apr 2019 22:49:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7196287EA for ; Tue, 23 Apr 2019 22:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728831AbfDWWtv (ORCPT ); Tue, 23 Apr 2019 18:49:51 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34151 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbfDWWtn (ORCPT ); Tue, 23 Apr 2019 18:49:43 -0400 Received: by mail-lf1-f65.google.com with SMTP id h5so13027069lfm.1; Tue, 23 Apr 2019 15:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W583DLuATb7569DJlQOwhhtkLZ1xhL86KTFMSp+wLl8=; b=XTANTI43m3AqXZ4watOgFQeVz3GWMCysvKAZ0BfLNAThnGYXFOUOqXPbpHlZ/b5mWF SxrGA7+nbNZj1x/pfWHhkJgxchG8jbokMXfnPvGcl5DWTPJ5TDsfnGehXJg2ibXkmGgX iVFNCL1BhDKT0FQNIMe3a23an6wwHEWm5qqpfs641NYNrpKZ5gSrtPSpqeQWjbk0T4lL DNNC596STlOWBaGvH6oOGVUAA5/xi1V0Be0f6biL51DarZiWJrqeUBhCnBQ23q+1gzS5 pppQo9LWICIxLxGfV7ncQ25IdC8ybOv5uDt1CTojMOsHdl1pPxpDXbRMVdZlh6qZlNbp ERIA== 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=W583DLuATb7569DJlQOwhhtkLZ1xhL86KTFMSp+wLl8=; b=Kykzn8KtXue4xJm7VEhEBgqk2hHVC9UXmXZVd6AdwVaiZydYM5yMjfrwzQgjoheH0v zk17oTccMiUMV9fGS7uGM7VX4xNfXDaUoMGhF3a4J0Z60k6BKBNYjA+t1gRC+jnaufOM HaQmFzf7Kks53JG3yKEVhbLMiKuTd+5ufXikNM5MgwbRhtq6pUJ4JLA71oTTSvJkp7eH UzcdiSOqP6hebC4XKL9N4bnVzq6HrLLwqeVh40MlMN3mbQ1h6F7omhVM9zchKcgK6PNq y02Tp1kxONQF8rkUHUYF0BJEzDLWU9pJYQu6gbsnSMuzNuSRm5cXvymkBk+HDhDn/loo 4gXQ== X-Gm-Message-State: APjAAAV151/GmvpiorYEKDpFLv93ilPBY9SRGVkPeckedoUixCyHpbMv 8MWMTcICWVUyRLC67ZokqVM= X-Google-Smtp-Source: APXvYqwnO9pXPqQ9DzSRJfPbh+83mSvQndOn/tiKT0UkXAkjkZULPQWfg5M6vmofbJom3WJnp5GDBA== X-Received: by 2002:ac2:51d9:: with SMTP id u25mr4013003lfm.91.1556059781008; Tue, 23 Apr 2019 15:49:41 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:40 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 12/12] mips: Enable OF_RESERVED_MEM config Date: Wed, 24 Apr 2019 01:47:48 +0300 Message-Id: <20190423224748.3765-13-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since memblock-patchset was introduced the reserved-memory nodes are supported being declared in dt-files. So these nodes are actually parsed during the arch setup procedure when the early_init_fdt_scan_reserved_mem() method is called. But some of the features like private reserved memory pools aren't available at the moment, since OF_RESERVED_MEM isn't enabled for the MIPS platform. Lets fix it by enabling the config. But due to the arch-specific boot mem_map container utilization we need to manually call the fdt_init_reserved_mem() method after all the available and reserved memory has been moved to memblock. The function call performed before bootmem_init() fails due to the lack of any memblock memory regions to allocate from at that stage. Signed-off-by: Serge Semin --- arch/mips/Kconfig | 1 + arch/mips/kernel/setup.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 4a5f5b0ee9a9..0bf9e89e4023 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2988,6 +2988,7 @@ config USE_OF bool select OF select OF_EARLY_FLATTREE + select OF_RESERVED_MEM select IRQ_DOMAIN config UHI_BOOT diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index fbd216b4e929..ab349d2381c3 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -825,6 +826,8 @@ static void __init arch_mem_init(char **cmdline_p) memblock_reserve(__pa_symbol(&__nosave_begin), __pa_symbol(&__nosave_end) - __pa_symbol(&__nosave_begin)); + fdt_init_reserved_mem(); + memblock_dump_all(); early_memtest(PFN_PHYS(min_low_pfn), PFN_PHYS(max_low_pfn));