From patchwork Fri May 3 17:50: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: 10929095 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 D7B2015A6 for ; Fri, 3 May 2019 17:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C95FA28721 for ; Fri, 3 May 2019 17:51:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD35A28724; Fri, 3 May 2019 17:51:39 +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 5F9CF28721 for ; Fri, 3 May 2019 17:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728802AbfECRvj (ORCPT ); Fri, 3 May 2019 13:51:39 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36738 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbfECRvi (ORCPT ); Fri, 3 May 2019 13:51:38 -0400 Received: by mail-lj1-f196.google.com with SMTP id y8so5723147ljd.3; Fri, 03 May 2019 10:51:37 -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=PF+qWDN5jd+CubA/a3KTQRNF/nvw8rMXCf7kpE9998c=; b=I2+awwAwiEibJdRnk/03VwEeSUBUmh2e3C6pOFlL0I+i4tp1q+kOm5E24xPjgewa9F OBkyaKL+7m1GNG9n/smQ+z5u6r8AEl/Y2zsCY20DME8PYCvCLSUoS0o80qcphBYoGoYx gs0yVEy30WYJDPi7j1jneBGQgk09XAV7Dw2ifetUeV8N3kP7IdlgESqiBnb+Wm8/Zw6A WYPxemxxzf0QGXFSwxgNABX+/9aueX3Cl7hSu3aevLgWCzfEVZXXTGgoHTMSPO1Ybpy6 lxmm6DAwsPRnJByx+KErHRtcPaqbVEvMABNekMD7hLsqL6Bd7zqHABT2Yk8jF6aIQkpY RI0g== 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=PF+qWDN5jd+CubA/a3KTQRNF/nvw8rMXCf7kpE9998c=; b=GLzpJ4wI08CwgFs7jLeg6UoujVvyRa2d44ZpRJVHz3jHl+Nzu8bsRFzc/Z+08H49L+ ESWyieLSpaJvWHQnt53RD6PUL8nuGiTlj8WmoER2Oly3Vyx73fhWBTkfS+OZfDPnJWoq 4/60nkgzCIFogEacDFRY4DGslHx7m8fJW/3X9QH/mTY62E0V8BID0WXqjYaNdtIUUn0o GDceJBeqwtG1Q5vYOQA4p+Ghd3meY8++LQ70lllPQ/flXBlQT25OzIIImatCqJzeWwAo 6pursdWyc4Qf6+R8b3BLUwTRTMsQcsK2U1EWnLsY23msy+QJno8d6gcceckYRNE/SqNy CdYA== X-Gm-Message-State: APjAAAVi114augS8krEjhedPu0KATn1p+5mEky+IbYfRv29N27TYDXXH rU8zt/fMAH6ze8a3p4pfYAs= X-Google-Smtp-Source: APXvYqzJ2vuR8WIB+zQsiODkBqrOuSl800TR/BnWxsbsGfdH3zgDBClp+8qGxiTJGVblALPGI1qicA== X-Received: by 2002:a2e:9188:: with SMTP id f8mr3091066ljg.100.1556905896658; Fri, 03 May 2019 10:51:36 -0700 (PDT) Received: from localhost.localdomain ([5.164.217.122]) by smtp.gmail.com with ESMTPSA id z30sm533435lfb.87.2019.05.03.10.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 10:51:35 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: Serge Semin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] mips: Dump memblock regions for debugging Date: Fri, 3 May 2019 20:50:37 +0300 Message-Id: <20190503175041.7949-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503175041.7949-1-fancer.lancer@gmail.com> References: <20190503175041.7949-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 kernel parameter is specified. 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 --- Changelog v2 - Reword commit message since memblock debug printout is activated by memblock=debug kernel parameter --- 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 Fri May 3 17:50: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: 10929097 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 5521C15A6 for ; Fri, 3 May 2019 17:51:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4831E28722 for ; Fri, 3 May 2019 17:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C70728726; Fri, 3 May 2019 17:51:43 +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 DBF5528722 for ; Fri, 3 May 2019 17:51:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbfECRvm (ORCPT ); Fri, 3 May 2019 13:51:42 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34950 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728801AbfECRvk (ORCPT ); Fri, 3 May 2019 13:51:40 -0400 Received: by mail-lj1-f194.google.com with SMTP id z26so1121757ljj.2; Fri, 03 May 2019 10:51: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=QQUuLg/zS2tfsDPJ/SWrp4NtSrhhV6zRMowLIWOaos8=; b=tscQTSsdX0uvuETo/lXEstXhGPV0xHg/5z2O/HEl0htSa4teJd7jROGZofZeXoQZGh m1Bq80/JmIXmHOHRVSPOuqsOerDSouwC+CQpCGNWsrK1AwGmBg+ll2XvWyRTxyL7ILZ8 NPx4IpkHxAMGOGRlxRviY2nnK2LOgdYWyzhbCZgAU1AnXaS8oWVRARWcdoVhdIiKAQMo fESSlfH1Y1icYTKhb4BX5TGxLcS01E9wzo5MIcyPujHTLhwf3mEjuJg8t4BoKDDHqUbK 0qzZgWd94RIHJQ9A93WCcJv4f9WW+CGmYBsDn97N+8dpuWTH8pqM3GM+92rdkHdMDPVZ c1Gg== 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=alBdZexBALKFE229Ozs5wE1IxqFvokjR5zw24PPN+1aj68Rsn6Tu7Fg+QQWTYJuc44 6D7wxRXwjzXzh8LaR3hoCKAWk9kS+vSSdI/Q0rqevnVNVum1i9b7zyZVUmFIcXExYSuU ZbowZP/VZTRDinPAMY3m8U85pEnCzwT7JlaJDwrs3pZQu5kDBHkcff/8SkqJDE8vQ5cO 2WAR8Txi9wzIdgRWo8k7+dGhbocgzKO9rR5KvQsgDWQYh7zgn1LzZv76tAn8zbCZxGcY vsvtHyx0ZvkOKtqh7FwI+EcggfB3AJey3RUWPrL14OmEK1OjinD4FQBxzR1hocfQnoct aF8Q== X-Gm-Message-State: APjAAAUyk5L3nbm5rkjrFHVVK5MLCoXoYhy/9+S6IMYRJWQlNVk+YMqp mH812+Q6VufkwXm206HoW84= X-Google-Smtp-Source: APXvYqwiOJrUVTjSBUodRbF3hRfOWNf9xT5NZ7WKTZq2mTtJ9i2+MHvyJoWXpasFy5hhxntncNMv5w== X-Received: by 2002:a2e:2d02:: with SMTP id t2mr5293405ljt.148.1556905898225; Fri, 03 May 2019 10:51:38 -0700 (PDT) Received: from localhost.localdomain ([5.164.217.122]) by smtp.gmail.com with ESMTPSA id z30sm533435lfb.87.2019.05.03.10.51.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 10:51:37 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: Serge Semin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Matt Redfearn Subject: [PATCH v2 2/5] mips: Perform early low memory test Date: Fri, 3 May 2019 20:50:38 +0300 Message-Id: <20190503175041.7949-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503175041.7949-1-fancer.lancer@gmail.com> References: <20190503175041.7949-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 Fri May 3 17:50: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: 10929099 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 0861714B6 for ; Fri, 3 May 2019 17:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC0DD28721 for ; Fri, 3 May 2019 17:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE68728722; Fri, 3 May 2019 17:51:44 +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 08A1628724 for ; Fri, 3 May 2019 17:51:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbfECRvm (ORCPT ); Fri, 3 May 2019 13:51:42 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:34950 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbfECRvm (ORCPT ); Fri, 3 May 2019 13:51:42 -0400 Received: by mail-lj1-f193.google.com with SMTP id z26so1121805ljj.2; Fri, 03 May 2019 10:51: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=cKcAZCZmHBkOFZOBdJVKsgxHPiEdHR2uf5o4k8h8weQ=; b=WChiyw+F6v1NPibEOjSPo93/hjGV4IHlTo6QQQEZulhMkYkR+FGVhhrKBG4r4ETKy/ STMoT/XxuHQdybeo1/fjDFIZ7Nwshv/B7GCnSK1fVWA1DVRwcTQwLHZ3rIj0iOsTkEmp rOu4itBno7AWhcELDi9I+hgm/qsIhoVIQbEVEgvZOH+j8Zuma1oeul6CVlhDDcE9+NzA wr0eX+LmM140s5Zob19pSVYcUb6nrM69pM18zfH+f3JbXcfCkLjMiesrLJiqdps2JSiX U6qqROkFaXqLZNibwNOeS1d/Vdfmyh3ceo/KYNfPuL4c/+yBC6TfLVar31h3POx1NnfF QFhg== 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=RY65x9/M10nX4cMrelIvE0oJ9pPa3EtUfQh5qztzoKPPUiAVUIUlQJ3nOD2BmJCCa/ CC1r9OhKPmmJPUFmInrux6VL5yRa30j0wIsjY610Q5t6KVxoDeNliGhKVWoekZsZt9ue /l0gSjLIs44GFrKYDYtAw8MbNkUMxwvvZwFcATCKv13RJcUel+X8q7wNfiiDqH/dgsa3 roJMkVgHwBz5iYOLGqMaVz8SLdN3OSRHPJ/DMV8ooXREnanw9howEUpAUR915mMf4WE8 dAqFIrWl34ADx1TKJa7VKNK6S0zy4Zxbdd3VTMquDVGqoSWYZkGtjoIuraD6LATzLdji a5+A== X-Gm-Message-State: APjAAAUzQ89XZj24M6MM/Dx5JxvlIbJnlFelLzQCifLVYLmijrKT0ylk KYnsLqTRH52hVj65ByDsJ1s= X-Google-Smtp-Source: APXvYqzhP6rnqTPD3xb/yM41UDCfoPG59B2mCl7Nq5G9GnM1Wu/rUlWw0/ZDC6oLtHd2qhYPBH7E5A== X-Received: by 2002:a2e:89c8:: with SMTP id c8mr5963208ljk.73.1556905899737; Fri, 03 May 2019 10:51:39 -0700 (PDT) Received: from localhost.localdomain ([5.164.217.122]) by smtp.gmail.com with ESMTPSA id z30sm533435lfb.87.2019.05.03.10.51.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 10:51:39 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: Serge Semin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] mips: Print the kernel virtual mem layout on debugging Date: Fri, 3 May 2019 20:50:39 +0300 Message-Id: <20190503175041.7949-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503175041.7949-1-fancer.lancer@gmail.com> References: <20190503175041.7949-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 Fri May 3 17:50: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: 10929103 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 4FD16912 for ; Fri, 3 May 2019 17:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 413D728721 for ; Fri, 3 May 2019 17:52:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34B1228724; Fri, 3 May 2019 17:52:02 +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 D1D6128721 for ; Fri, 3 May 2019 17:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728561AbfECRv4 (ORCPT ); Fri, 3 May 2019 13:51:56 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40797 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728820AbfECRvn (ORCPT ); Fri, 3 May 2019 13:51:43 -0400 Received: by mail-lf1-f65.google.com with SMTP id o16so4986114lfl.7; Fri, 03 May 2019 10:51: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=v/LR8SgjCFeSasZGBO3FAtfYGfrjDhMD48wHn2t6CEQ=; b=cae9601wLSgRgqYUW45HHj8WE00Rab3oTgbbv7YEKZ7iWuBEXqVcvBvBFDC+Lj2rdF kxx5F4fsKKh+497U9XtItDjTmZ62zzgTWNSYrCQcMslr1pmTmJr8enHEs86QHdIV57uU hLlKQP6tr3OOlH9naxjGISBIjanifWnb7VUAVTXD0u5EVuSlo9FpA81YGfhpCnN+qY5w QofuZIULE2XmBTGzzy2a4of6xPWOzqC1p9gRvMT16chmiUccDlYQ6mtRwvw+544Fa3qv Z4LpBQwqFfR8w7EGMu50RdlZxXPR0yn9ZEkSeeuvdtft5vgKAU7FrZUB0SdPUl4efqW4 oVXQ== 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=v/LR8SgjCFeSasZGBO3FAtfYGfrjDhMD48wHn2t6CEQ=; b=g/2BGS8qWtdsCB0vlJfMAt0KS2y9VbVVB5RONiZfcXrD2b7Imqew+bIRSMkEG6Ivi7 SvLidOU0UMqWXh49sRZMdHKey3ichsx6BQjrViEOXYSxHMhZzwadF1ZkTK7FNgmoW+BK UHGprCoFDhSQDBqRfDkNxR9UaovcB4KXpjZBLdj1yvoR4r/bst75T6H9nzxpebyi/46B GBEKjAvl7g/I4IImYUbOl53wQRdWHz7afcYUHMgBBqy3X7fb9msgC7CC+mb7QJf4Csbf zpWDqr0SjA+WN9GGj85rGlakynIvCm0CCbI4CDMP2siIqPza50KZjSYXr2IdRkJsu80w XM1w== X-Gm-Message-State: APjAAAUe4Zu/WYejTGL7URR+a79Cd8xQMEsPbkU7Rimc0hfT5LFCcGN2 MfE+I/OvQCHriRivEWnLfmM= X-Google-Smtp-Source: APXvYqzaIswhZ16M/uyPSnSlhWFL6tGG02DM5yowGMDH/6Efa/U4+5qG1flLBtIwbdscxjig2TYs8w== X-Received: by 2002:ac2:44b2:: with SMTP id c18mr5577711lfm.86.1556905901150; Fri, 03 May 2019 10:51:41 -0700 (PDT) Received: from localhost.localdomain ([5.164.217.122]) by smtp.gmail.com with ESMTPSA id z30sm533435lfb.87.2019.05.03.10.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 10:51:40 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: Serge Semin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] mips: Make sure dt memory regions are valid Date: Fri, 3 May 2019 20:50:40 +0300 Message-Id: <20190503175041.7949-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503175041.7949-1-fancer.lancer@gmail.com> References: <20190503175041.7949-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. This especially concerns XPA-capable systems. Bootloader may determine more than 4GB memory available and pass it to the kernel over dts memory node, while kernel is built without XPA/64BIT 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 exceeds PHYS_ADDR_MAX size. So lets make sure the retrieved from dts memory regions are valid, and if some of them aren't, just manually truncate them 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 Fri May 3 17:50: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: 10929101 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 B54D415A6 for ; Fri, 3 May 2019 17:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A547C28721 for ; Fri, 3 May 2019 17:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FA728724; Fri, 3 May 2019 17:51:53 +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 30C5828721 for ; Fri, 3 May 2019 17:51:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbfECRvq (ORCPT ); Fri, 3 May 2019 13:51:46 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45222 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728830AbfECRvo (ORCPT ); Fri, 3 May 2019 13:51:44 -0400 Received: by mail-lj1-f194.google.com with SMTP id w12so5897809ljh.12; Fri, 03 May 2019 10:51:43 -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=JmSxHa0Jb+gcCHv31BEUSC8QaHpRnUhn+EbFUG/B/zA=; b=ehXrGeYPBduAiAN+pYlJuxR9myOL9LkDT+SBeozR/GlcyWZD+SjafvDmIg7Jkw3E0C +kZ0GRGFXTD1h53u03Ffeaf4Wn48OSpvLm1hRB1pwlZBREvnSGqXyXsKTj5ODB/FxDAa +Mm0elBcIu/j3fHc5TrKjiEcZn9GmEcMMUJmEfZtx1oJQsR4Pm9s4utanTWa52cU9ceY ZTy4VVmK8ls6SruDF8oGDwT1oKETV6HoQhVC3c4GEBL1ORuhTEa9gPORT4nNuy7Wv1hL R5hjEeqeUB0KM2L3i0lD65nE1XI5dpMXWfWCJ0MALzpUED7XngZwiTEMgOpwHacz+wFk Km3Q== 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=JmSxHa0Jb+gcCHv31BEUSC8QaHpRnUhn+EbFUG/B/zA=; b=iIjyqUB5+85vz7zrqQzPrIfHwDwzl/N4I09bEYQND4WoCrmhLxFYT5TOUBqfDgY4ZA /tvWBBcYnl8hKpGsl2B3uEMnyPpFmNPgNYiaBAj+/JbS8+v2q4xW7yzlCOcS0EzylLs6 78UqFS2g6y90M9EgfdoUlld0LaD6A83GO/8uTvj/SeDJUFbDLGOHZY/xSMOW1ZdD+xGf yPJA/3pGXQ+DmN8IvNcyjsKo9xfUHMKEOHS3VehKawGNKM9OoI5oMGDmrmrSVOnWG5rs r3u8XBXrrmrMRbKF7Ky691+l9JYMv6MOxB4wp8x6VHEXazxyvdkZPwKc0JxQEwI+iDQy sskg== X-Gm-Message-State: APjAAAUzQeeFjeToV9aWFkE9eOV9WKwR4EwFlvI9AIBMD4IngZR2XiaA 5QP6Kv+PsPWrl1kSfHM3h1g= X-Google-Smtp-Source: APXvYqybzXjUUojb/hjhiibGDOipaoKiCg/jrMZK18WrObD2Bjni1MODFWUlZy7imcDg+MIkb4L1vw== X-Received: by 2002:a2e:9e47:: with SMTP id g7mr5649130ljk.48.1556905902559; Fri, 03 May 2019 10:51:42 -0700 (PDT) Received: from localhost.localdomain ([5.164.217.122]) by smtp.gmail.com with ESMTPSA id z30sm533435lfb.87.2019.05.03.10.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 10:51:41 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: Serge Semin , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] mips: Manually call fdt_init_reserved_mem() method Date: Fri, 3 May 2019 20:50:41 +0300 Message-Id: <20190503175041.7949-6-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503175041.7949-1-fancer.lancer@gmail.com> References: <20190503175041.7949-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 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 first function call performed before bootmem_init() by the early_init_fdt_scan_reserved_mem() routine fails due to the lack of any memblock memory regions to allocate from at that stage. Signed-off-by: Serge Semin --- Changelog v2 - Discard forcible selection of OF_RESERVED_MEM config --- 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 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));