Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp2839064pjo; Mon, 16 Mar 2020 05:40:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvzOgNrd9/QjLd3A/pNd7GlkrLu1HIu/Ajz6vLzdC8ysMICzJsqavE7hPy43ZcLZ6eRBoSC X-Received: by 2002:a05:6830:204c:: with SMTP id f12mr22254189otp.356.1584362440219; Mon, 16 Mar 2020 05:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584362440; cv=none; d=google.com; s=arc-20160816; b=EyOH3+n5iJNIzOnKLEGHbRby+YPPuot9kvT/3Z13qqI+GRvy/smI7giYKv+uN8wTGp qfJr+4x3bo6MRJqgf9xNkMCOo4l6p60p6+/S8wL+otz7QFvTt2u94l5D1OTAiVuLUFl6 10rpR8XYh3hEQ1QQ34Uh74UEyDpk1CgDok/M3sZFXm+yd96spuyoJSJP6MpLrtBaPUzj hRwmqoMa4Ay2EbZFEpUQ7+3bECTHLiamP8XppNXL1g1jRucdQ3KMfbVr1XJKawoPTign JLel8Q67QF7alg48+VZJXJ+19/hndBw4kR6NdwW9UNzgeGB7InsKpz5rvTalHvFUhD9u zLuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=58rfjZahjqar+Bs/L8k5MbBDqVxxpbXTMhnkBU5JBXg=; b=l9m6VDfqTE2ci2iVafFmlCQbndn256LVGf2okCNFL441IY1VwwJ0lVbiB+oJzv1p4H ka1RrASZT42LhtX0pwyGtfdj2XG3TUb29n1zYS2dvEI/jdFLv3TusoGUyIOzTXOg5egJ fWdzu2inhpIaqDcNNUCPtvVYg4QDXDRSzAfdSrbm34rdaUW84HxNqfStmHXmc2BXJs3L AJyGsm+OeC3THNNICRDxz4Mkwd7udMrmc7LFeeFeaVtqfEA4AB9V5NVKScPcshAEqejA IbhvJ1NKCnWXGnEXdGHrPdsW2rnRZkezty7YwUjx94lVFxT1BF5NWeN/mbxBqRyEKvTr J14Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=RSSO8TPK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w26si9820952otk.156.2020.03.16.05.40.27; Mon, 16 Mar 2020 05:40:40 -0700 (PDT) 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=@c-s.fr header.s=mail header.b=RSSO8TPK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731456AbgCPMiG (ORCPT + 99 others); Mon, 16 Mar 2020 08:38:06 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:43841 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731092AbgCPMgA (ORCPT ); Mon, 16 Mar 2020 08:36:00 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48gwkx66Gpz9v02h; Mon, 16 Mar 2020 13:35:53 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=RSSO8TPK; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Hja4kzBlAaGA; Mon, 16 Mar 2020 13:35:53 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48gwkx523Mz9v02g; Mon, 16 Mar 2020 13:35:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1584362153; bh=58rfjZahjqar+Bs/L8k5MbBDqVxxpbXTMhnkBU5JBXg=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=RSSO8TPKq3GkxMA3nPVzRAsOYOUT4q0nLBGJYEkc8DrDrO6m/CHWg5VONSa/xk+87 b6emhPvzzloX60mpDP/D8DGdGcGQ4uCEgwRhLI5q3C+r5jHkU01r1pMbjJoP5Ma/p2 LHmqOdtYdD8I1mrmFWuwOp7pLiidWzdmB6Nz9yu8= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A79068B7D0; Mon, 16 Mar 2020 13:35:58 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id KuWFnRklsRFg; Mon, 16 Mar 2020 13:35:58 +0100 (CET) Received: from pc16570vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 622098B7CB; Mon, 16 Mar 2020 13:35:58 +0100 (CET) Received: by pc16570vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 58DAE65595; Mon, 16 Mar 2020 12:35:58 +0000 (UTC) Message-Id: <879a5d42ddd8c48df106a85211f843dceafbc2d7.1584360344.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 13/46] powerpc/ptdump: Properly handle non standard page size To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 16 Mar 2020 12:35:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to properly display information regardless of the page size, it is necessary to take into account real page size. Signed-off-by: Christophe Leroy Fixes: cabe8138b23c ("powerpc: dump as a single line areas mapping a single physical page.") Cc: stable@vger.kernel.org --- arch/powerpc/mm/ptdump/ptdump.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c index 1f97668853e3..64434b66f240 100644 --- a/arch/powerpc/mm/ptdump/ptdump.c +++ b/arch/powerpc/mm/ptdump/ptdump.c @@ -60,6 +60,7 @@ struct pg_state { unsigned long start_address; unsigned long start_pa; unsigned long last_pa; + unsigned long page_size; unsigned int level; u64 current_flags; bool check_wx; @@ -168,9 +169,9 @@ static void dump_addr(struct pg_state *st, unsigned long addr) #endif pt_dump_seq_printf(st->seq, REG "-" REG " ", st->start_address, addr - 1); - if (st->start_pa == st->last_pa && st->start_address + PAGE_SIZE != addr) { + if (st->start_pa == st->last_pa && st->start_address + st->page_size != addr) { pt_dump_seq_printf(st->seq, "[" REG "]", st->start_pa); - delta = PAGE_SIZE >> 10; + delta = st->page_size >> 10; } else { pt_dump_seq_printf(st->seq, " " REG " ", st->start_pa); delta = (addr - st->start_address) >> 10; @@ -195,10 +196,11 @@ static void note_prot_wx(struct pg_state *st, unsigned long addr) } static void note_page(struct pg_state *st, unsigned long addr, - unsigned int level, u64 val) + unsigned int level, u64 val, int shift) { u64 flag = val & pg_level[level].mask; u64 pa = val & PTE_RPN_MASK; + unsigned long page_size = 1 << shift; /* At first no level is set */ if (!st->level) { @@ -207,6 +209,7 @@ static void note_page(struct pg_state *st, unsigned long addr, st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size; pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name); /* * Dump the section of virtual memory when: @@ -218,7 +221,7 @@ static void note_page(struct pg_state *st, unsigned long addr, */ } else if (flag != st->current_flags || level != st->level || addr >= st->marker[1].start_address || - (pa != st->last_pa + PAGE_SIZE && + (pa != st->last_pa + st->page_size && (pa != st->start_pa || st->start_pa != st->last_pa))) { /* Check the PTE flags */ @@ -246,6 +249,7 @@ static void note_page(struct pg_state *st, unsigned long addr, st->start_address = addr; st->start_pa = pa; st->last_pa = pa; + st->page_size = page_size; st->current_flags = flag; st->level = level; } else { @@ -261,7 +265,7 @@ static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start) for (i = 0; i < PTRS_PER_PTE; i++, pte++) { addr = start + i * PAGE_SIZE; - note_page(st, addr, 4, pte_val(*pte)); + note_page(st, addr, 4, pte_val(*pte), PAGE_SHIFT); } } @@ -278,7 +282,7 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start) /* pmd exists */ walk_pte(st, pmd, addr); else - note_page(st, addr, 3, pmd_val(*pmd)); + note_page(st, addr, 3, pmd_val(*pmd), PTE_SHIFT); } } @@ -294,7 +298,7 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start) /* pud exists */ walk_pmd(st, pud, addr); else - note_page(st, addr, 2, pud_val(*pud)); + note_page(st, addr, 2, pud_val(*pud), PMD_SHIFT); } } @@ -313,7 +317,7 @@ static void walk_pagetables(struct pg_state *st) /* pgd exists */ walk_pud(st, pgd, addr); else - note_page(st, addr, 1, pgd_val(*pgd)); + note_page(st, addr, 1, pgd_val(*pgd), PUD_SHIFT); } } @@ -368,7 +372,7 @@ static int ptdump_show(struct seq_file *m, void *v) /* Traverse kernel page tables */ walk_pagetables(&st); - note_page(&st, 0, 0, 0); + note_page(&st, 0, 0, 0, 0); return 0; } -- 2.25.0