Received: by 10.223.176.5 with SMTP id f5csp263675wra; Thu, 1 Feb 2018 19:58:08 -0800 (PST) X-Google-Smtp-Source: AH8x225pDLjtxg+mMoXu2LiVnfPuhwpxDyVTp2VtmW92dtnq4b1EFNkdundrV3SF1rIUpjXOXRmT X-Received: by 10.99.142.66 with SMTP id k63mr1585293pge.278.1517543888676; Thu, 01 Feb 2018 19:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517543888; cv=none; d=google.com; s=arc-20160816; b=bK+sXfwr/H2y6KVYcLrefYAjyVbI4VbrQg22jzWlbFU4bvfmNtO7AQY0fQg6zPJrT+ 8R1dxJJjGg/l9vm4RfgddjMYTkp5JNya/5vgttNF7fildfeDXxgc1asF/VjflXee7Ko7 bVQsZxMJPcBIJ02Hx+ojpsJxuDvD1v8lcHu7AMxLH8bub2m9jpC5cPzFU3KBuuA0slmG QGsy0H3ds+/6YwVn25o0E3jcxzP0uFE6iMJNdhbW/J2yA+QdGB0ONKZQxqpBsR73L+0v 3bHVGMMx7c9Z/iBUaarZdksM81Mw6EGVune5gN6b4AHCkk0Ohd/9M54OJk1s76XfBGXk MAZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=stUVC8kueTevDIOxLSUIRSRvfp8B3oCnZBRDOk79Es8=; b=DCAxNZ5K2MksbZ0xyfAbSdjoxMtzn5HXYlIlPq03msewPy+PuIzeZSRdoYZssrQjy3 NZPYZY6emh7a7gvLY6YlNtCnwEWRiAZ/tH2nsFyshnNHei88Vw6010kf7NYkpdfW1qm5 j8SMZXRj/EeltnYG1ig9prkQ2jajbwoRTfan25pAUSGORNg31+qvK19FljYY8OxShuQT L1dTXlN5vxKWs3drKWcN3WduCWWvFJbmEVJWmY4AHMuoqaE98jenfTEfFZ4XA9YfWhso EL8hGhZUjzvQDuqBM+Pr5N2KsnznUwqGqF48VdLT8A+aO//H+wZMgzdmca0EVwhj3M6I Uk0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LXGGfZ0d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189si765502pgc.784.2018.02.01.19.57.54; Thu, 01 Feb 2018 19:58:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LXGGfZ0d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751709AbeBBD47 (ORCPT + 99 others); Thu, 1 Feb 2018 22:56:59 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33100 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751856AbeBBDzU (ORCPT ); Thu, 1 Feb 2018 22:55:20 -0500 Received: by mail-lf0-f68.google.com with SMTP id t139so29463702lff.0 for ; Thu, 01 Feb 2018 19:55:20 -0800 (PST) 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; bh=stUVC8kueTevDIOxLSUIRSRvfp8B3oCnZBRDOk79Es8=; b=LXGGfZ0dhKu3FEyB76dnmtzWIb48J7y/j24e+7jpzJcGVggyijcwy/3CUBhH+Mdj8G mJkGQ4LEQcULQPPaNm2a3ytVBKliSH9eLi7cclgrYajOtJjGivJitD940Lbo21LxjR07 p+UrYqsZtsBjiqViHHXLSCdgjCa/ey93dT3U3Ahy4a6tlbqReSnf2pkhxEfzYfGGINNZ f5iSf3N4cKiuRML0g6/DXjVN/VIDEK3Hkpx5V5UfJYUQiSelsm512fU8gbk1ObV92WFX GuMhOvOsqpHio69tpXpcMXOVYtKlXWbYPrbb88TuhMvsCNlxL3RFV2kB1gVnEuBwNE7v qoyw== 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; bh=stUVC8kueTevDIOxLSUIRSRvfp8B3oCnZBRDOk79Es8=; b=FzDKCfV3kaqkXpUu/IHOk8yLMfPkyhVy0Vcacc7jiEX1KEFuZKzMsRUVD09lfqFz5T 8jTejZglU+DjiToznEAxFYLZeIyJPtMrBxbetQtel26mBdTosEgFIneEwo+hb3Blf54R YLnWbG/RXK/512IY4tw6/99ktkR65Ln26+8Rt2VhnmHHIyF+IGhIe5TPkLG1xx6oPa7K UF11H2Y9ho3szQ/JQSrIuXwGdze83X+Pijv8Le+oRDZHBxruVhC7Ci17/whDzQ03liKu HFnItHla/zOwxrgOND+etrQT3hg9461SiENB05Meu9uq9Ytss5wiribQaDaWMziMBiUz wa7A== X-Gm-Message-State: AKwxyteGVe4dxUHCslWLwVmRc0CLM+mztBh1bbiYW+I8MTaT0iPnQB6D t4jwplF8/yI7GTDrw7RAFd4= X-Received: by 10.46.80.88 with SMTP id v24mr7236837ljd.86.1517543719266; Thu, 01 Feb 2018 19:55:19 -0800 (PST) Received: from linux.local ([95.79.164.146]) by smtp.gmail.com with ESMTPSA id f14sm190934lje.84.2018.02.01.19.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Feb 2018 19:55:18 -0800 (PST) From: Serge Semin To: ralf@linux-mips.org, miodrag.dinic@mips.com, jhogan@kernel.org, goran.ferenc@mips.com, david.daney@cavium.com, paul.gortmaker@windriver.com, paul.burton@mips.com, alex.belits@cavium.com, Steven.Hill@cavium.com Cc: alexander.sverdlin@nokia.com, matt.redfearn@mips.com, kumba@gentoo.org, marcin.nowakowski@mips.com, James.hogan@mips.com, Peter.Wotton@mips.com, Sergey.Semin@t-platforms.ru, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH v2 12/15] MIPS: memblock: Print out kernel virtual mem layout Date: Fri, 2 Feb 2018 06:54:55 +0300 Message-Id: <20180202035458.30456-13-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180202035458.30456-1-fancer.lancer@gmail.com> References: <20180117222312.14763-1-fancer.lancer@gmail.com> <20180202035458.30456-1-fancer.lancer@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is useful to have the kernel virtual memory layout printed at boot time so to have the full information about the booted kernel. In some cases it might be unsafe to have virtual addresses freely visible in logs, so the %pK format is used if one want to hide them. 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 84b7b592b834..eec92194d4dc 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,53 @@ 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 */ void setup_zero_pages(void) @@ -468,6 +516,7 @@ void __init mem_init(void) free_all_bootmem(); setup_zero_pages(); /* Setup zeroed pages. */ mem_init_free_highmem(); + mem_print_kmap_info(); mem_init_print_info(NULL); #ifdef CONFIG_64BIT -- 2.12.0