forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/arm/mm/dump.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Debug helper to dump the current kernel pagetables of the system
34 * so that we can see what the various memory ranges are set to.
....@@ -6,11 +7,6 @@
67 * (C) Copyright 2008 Intel Corporation
78 *
89 * Author: Arjan van de Ven <arjan@linux.intel.com>
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License
12
- * as published by the Free Software Foundation; version 2
13
- * of the License.
1410 */
1511 #include <linux/debugfs.h>
1612 #include <linux/fs.h>
....@@ -20,7 +16,6 @@
2016 #include <asm/domain.h>
2117 #include <asm/fixmap.h>
2218 #include <asm/memory.h>
23
-#include <asm/pgtable.h>
2419 #include <asm/ptdump.h>
2520
2621 static struct addr_marker address_markers[] = {
....@@ -211,6 +206,7 @@
211206 static struct pg_level pg_level[] = {
212207 {
213208 }, { /* pgd */
209
+ }, { /* p4d */
214210 }, { /* pud */
215211 }, { /* pmd */
216212 .bits = section_bits,
....@@ -312,7 +308,7 @@
312308
313309 for (i = 0; i < PTRS_PER_PTE; i++, pte++) {
314310 addr = start + i * PAGE_SIZE;
315
- note_page(st, addr, 4, pte_val(*pte), domain);
311
+ note_page(st, addr, 5, pte_val(*pte), domain);
316312 }
317313 }
318314
....@@ -346,7 +342,7 @@
346342 addr = start + i * PMD_SIZE;
347343 domain = get_domain_name(pmd);
348344 if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
349
- note_page(st, addr, 3, pmd_val(*pmd), domain);
345
+ note_page(st, addr, 4, pmd_val(*pmd), domain);
350346 else
351347 walk_pte(st, pmd, addr, domain);
352348
....@@ -354,14 +350,14 @@
354350 addr += SECTION_SIZE;
355351 pmd++;
356352 domain = get_domain_name(pmd);
357
- note_page(st, addr, 3, pmd_val(*pmd), domain);
353
+ note_page(st, addr, 4, pmd_val(*pmd), domain);
358354 }
359355 }
360356 }
361357
362
-static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)
358
+static void walk_pud(struct pg_state *st, p4d_t *p4d, unsigned long start)
363359 {
364
- pud_t *pud = pud_offset(pgd, 0);
360
+ pud_t *pud = pud_offset(p4d, 0);
365361 unsigned long addr;
366362 unsigned i;
367363
....@@ -370,7 +366,23 @@
370366 if (!pud_none(*pud)) {
371367 walk_pmd(st, pud, addr);
372368 } else {
373
- note_page(st, addr, 2, pud_val(*pud), NULL);
369
+ note_page(st, addr, 3, pud_val(*pud), NULL);
370
+ }
371
+ }
372
+}
373
+
374
+static void walk_p4d(struct pg_state *st, pgd_t *pgd, unsigned long start)
375
+{
376
+ p4d_t *p4d = p4d_offset(pgd, 0);
377
+ unsigned long addr;
378
+ unsigned i;
379
+
380
+ for (i = 0; i < PTRS_PER_P4D; i++, p4d++) {
381
+ addr = start + i * P4D_SIZE;
382
+ if (!p4d_none(*p4d)) {
383
+ walk_pud(st, p4d, addr);
384
+ } else {
385
+ note_page(st, addr, 2, p4d_val(*p4d), NULL);
374386 }
375387 }
376388 }
....@@ -385,7 +397,7 @@
385397 for (i = 0; i < PTRS_PER_PGD; i++, pgd++) {
386398 addr = start + i * PGDIR_SIZE;
387399 if (!pgd_none(*pgd)) {
388
- walk_pud(st, pgd, addr);
400
+ walk_p4d(st, pgd, addr);
389401 } else {
390402 note_page(st, addr, 1, pgd_val(*pgd), NULL);
391403 }
....@@ -450,7 +462,7 @@
450462 static int ptdump_init(void)
451463 {
452464 ptdump_initialize();
453
- return ptdump_debugfs_register(&kernel_ptdump_info,
454
- "kernel_page_tables");
465
+ ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
466
+ return 0;
455467 }
456468 __initcall(ptdump_init);