Received: by 10.223.148.5 with SMTP id 5csp6482461wrq; Wed, 17 Jan 2018 14:26:37 -0800 (PST) X-Google-Smtp-Source: ACJfBovpJFEA8ToYeL/WgVTcKjn8zgio/R+r6MNMFQhN1Qp4WI5acu7reLh08UqrPWWuQmyVTrrd X-Received: by 10.99.114.5 with SMTP id n5mr22667936pgc.211.1516227997709; Wed, 17 Jan 2018 14:26:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516227997; cv=none; d=google.com; s=arc-20160816; b=jQGIM72FAJRF0vFAC8dsR31nqwAKMUHA3LR03jottqoCAUCxB63ljj8mi+VZEW9k6o qW3XY5FoVqXumxeIvBicAvZ4EFEzYCTKBkB76dNitmE78YNVdZCWyMHn/xnujJp9Zrla UXGCbs82T1oTD82pOtIxD8jEjka/BrPD34DuJkr6jpEzLeT4AzTdR2x2g34HJ0DU1G/r HX+4vYhm3i7r18EpS6qONlnvGlXjrDzvBpzQdhR3eXuGIldG0avjvovukYHeaSBFg5jm oD/wkZruVHks7yeDhtkY3q7UAkrhl+PjyKD+5wneRsvdr/yicKhzLGG1c5iX6Xp3XnOT HcmQ== 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=/RA2GscUDpJWczp6CLDzuq/7nYSVri95Jhta2l7mMQI=; b=QNyd6Y0VIkPgY/SJvIYzGOkMaINh4dSoKLmvqKEqrWUwBg/j5HKUMJc4TLzkAMOtwz Rpy6Wdf1LFycecDnZFLG/K/h4Y419a2rKQ8PEqhP/0Y4CfQNjELUBO5g1COqbXFKU5Co SiR1+Z2qG5DUoggK3llt/NQXIjZctFvrWxLWKc7CzNNjcCbpZMCs0p59g834Ye8lNG9L fSmREmfcQq9+dWMCQSRu1ZaLABffxcEGgiWFlpmOH1QoKc36Zu9z4tFe70vgb53wQfz7 h/OVvulPfSPYdngSrIeMEwxq0y20obF8ngZF/mpAcwgR5Xb5aXyL5aPgeK5OGYZ3wO/c LZNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U6eQ71si; 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 h1si4469576pgs.693.2018.01.17.14.26.23; Wed, 17 Jan 2018 14:26:37 -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=U6eQ71si; 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 S932234AbeAQWYV (ORCPT + 99 others); Wed, 17 Jan 2018 17:24:21 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33234 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754016AbeAQWXf (ORCPT ); Wed, 17 Jan 2018 17:23:35 -0500 Received: by mail-lf0-f65.google.com with SMTP id t139so9224370lff.0 for ; Wed, 17 Jan 2018 14:23:34 -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=/RA2GscUDpJWczp6CLDzuq/7nYSVri95Jhta2l7mMQI=; b=U6eQ71sik8rjiFxfDoS5JoaZycMSCWUerasefJI2z20E8vE5VpNL4DtVuZlTpiZhKG OCa/nK8eABGu2YXQ16zsVKE0InLJm6ampfhBmPZ38umidcZdBgkFLIOHrprGdxIQl/A2 seHtmME86TQc3uVb1PPTTvt6D273tQjJJt9Wa9MZj+8gg8XL3iYoHGusxoIBgVmt5Y+Q RvclbpcKywz/owZ8ZOY49i0hBYPnPK020iLe2hHFbJn9aRqyIJogWv/dcz18J/+cXyKV w2/kDHtXbkb/avxlvQAT/ByyVHLeNoCaM+jzNDHgV46MbZ5t3B5sZvH1jVjEqUo1q03x szOQ== 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=/RA2GscUDpJWczp6CLDzuq/7nYSVri95Jhta2l7mMQI=; b=I0KCmbTv76FwISkOl2LNBAeI2SIrSm0S7adwV73LZKL3Vaki/WUdDN5uaDUQJ9rEUb 2YGpU6J+bvWhiB0ltSwwbvqOlRF5htvNFYbmeNcKKorMb2kPZn2hLuhWLTJdxYfzCzNo qxIR1PpOgZtwDlfZUW9XWnAEeR44OhUNiQAPWa3DvoV0UTHWZUXCDdZjVUvK/6UXs/g3 qd3e4stonjvwhQEwJgwLisrIKjggawC3QBiXhZ3pbHqt6XNm9364mkPbus7pt/JI0YRH 0ly3hNtg+bYwA0+/0PMerXxGwtTeGvaJBdX4da6qKB4fg0RDmZ0sqtEQV6pc3sYXDF69 1CZw== X-Gm-Message-State: AKwxytcOR6v4AIP7yb3rvoR4keIzNpX6fSqKYb9wLFR85sR46bZPKxWV C07RnTcUTWmafiJ/gkwWa88= X-Received: by 10.46.60.15 with SMTP id j15mr1308205lja.140.1516227813983; Wed, 17 Jan 2018 14:23:33 -0800 (PST) Received: from linux.local ([95.79.164.146]) by smtp.gmail.com with ESMTPSA id l203sm953867lfb.59.2018.01.17.14.23.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jan 2018 14:23:33 -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 11/14] MIPS: memblock: Print out kernel virtual mem layout Date: Thu, 18 Jan 2018 01:23:09 +0300 Message-Id: <20180117222312.14763-12-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180117222312.14763-1-fancer.lancer@gmail.com> References: <20180117222312.14763-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 | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 15040266b..d3e6bb531 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,51 @@ 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 __maybe_unused mem_print_kmap_info(void) +{ + pr_notice("Kernel virtual memory layout:\n" + " lowmem : 0x%pK - 0x%pK (%4ld MB)\n" + " .text : 0x%pK - 0x%pK (%4td kB)\n" + " .data : 0x%pK - 0x%pK (%4td kB)\n" + " .init : 0x%pK - 0x%pK (%4td kB)\n" + " .bss : 0x%pK - 0x%pK (%4td kB)\n" + " vmalloc : 0x%pK - 0x%pK (%4ld MB)\n" +#ifdef CONFIG_HIGHMEM + " pkmap : 0x%pK - 0x%pK (%4ld MB)\n" +#endif + " fixmap : 0x%pK - 0x%pK (%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); +} +#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 +514,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