818
819 pfn = (pfn_t)addr;
820 if (mflag)
821 pfn = mdb_mfn_to_pfn(pfn);
822
823 return (do_report_maps(pfn));
824 }
825
826 static int
827 do_ptable_dcmd(pfn_t pfn, uint64_t level)
828 {
829 struct hat *hatp;
830 struct hat hat;
831 htable_t *ht;
832 htable_t htable;
833 uintptr_t base;
834 int h;
835 int entry;
836 uintptr_t pagesize;
837 x86pte_t pte;
838 x86pte_t buf;
839 physaddr_t paddr;
840 size_t len;
841
842 /*
843 * The hats are kept in a list with khat at the head.
844 */
845 for (hatp = khat; hatp != NULL; hatp = hat.hat_next) {
846 /*
847 * read the hat and its hash table
848 */
849 if (mdb_vread(&hat, sizeof (hat), (uintptr_t)hatp) == -1) {
850 mdb_warn("Couldn't read struct hat\n");
851 return (DCMD_ERR);
852 }
853
854 /*
855 * read the htable hashtable
856 */
857 paddr = 0;
858 for (h = 0; h < hat.hat_num_hash; ++h) {
882 mdb_printf("htable=%p\n", ht);
883 if (level == (uint64_t)-1) {
884 level = htable.ht_level;
885 } else if (htable.ht_level != level) {
886 mdb_warn("htable has level %d but forcing level %lu\n",
887 htable.ht_level, level);
888 }
889 base = htable.ht_vaddr;
890 pagesize = mmu.level_size[level];
891 } else {
892 if (level == (uint64_t)-1)
893 level = 0;
894 mdb_warn("couldn't find matching htable, using level=%lu, "
895 "base address=0x0\n", level);
896 base = 0;
897 pagesize = mmu.level_size[level];
898 }
899
900 paddr = mmu_ptob((physaddr_t)pfn);
901 for (entry = 0; entry < mmu.ptes_per_table; ++entry) {
902 len = mdb_pread(&buf, mmu.pte_size,
903 paddr + entry * mmu.pte_size);
904 if (len != mmu.pte_size)
905 return (DCMD_ERR);
906 pte = buf;
907
908 if (pte == 0)
909 continue;
910
911 mdb_printf("[%3d] va=0x%p ", entry,
912 VA_SIGN_EXTEND(base + entry * pagesize));
913 do_pte_dcmd(level, pte);
914 }
915
916 done:
917 return (DCMD_OK);
918 }
919
920 /*
921 * Dump the page table at the given PFN
922 */
923 /*ARGSUSED*/
924 int
925 ptable_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
926 {
|
818
819 pfn = (pfn_t)addr;
820 if (mflag)
821 pfn = mdb_mfn_to_pfn(pfn);
822
823 return (do_report_maps(pfn));
824 }
825
826 static int
827 do_ptable_dcmd(pfn_t pfn, uint64_t level)
828 {
829 struct hat *hatp;
830 struct hat hat;
831 htable_t *ht;
832 htable_t htable;
833 uintptr_t base;
834 int h;
835 int entry;
836 uintptr_t pagesize;
837 x86pte_t pte;
838 physaddr_t paddr;
839 size_t len;
840
841 /*
842 * The hats are kept in a list with khat at the head.
843 */
844 for (hatp = khat; hatp != NULL; hatp = hat.hat_next) {
845 /*
846 * read the hat and its hash table
847 */
848 if (mdb_vread(&hat, sizeof (hat), (uintptr_t)hatp) == -1) {
849 mdb_warn("Couldn't read struct hat\n");
850 return (DCMD_ERR);
851 }
852
853 /*
854 * read the htable hashtable
855 */
856 paddr = 0;
857 for (h = 0; h < hat.hat_num_hash; ++h) {
881 mdb_printf("htable=%p\n", ht);
882 if (level == (uint64_t)-1) {
883 level = htable.ht_level;
884 } else if (htable.ht_level != level) {
885 mdb_warn("htable has level %d but forcing level %lu\n",
886 htable.ht_level, level);
887 }
888 base = htable.ht_vaddr;
889 pagesize = mmu.level_size[level];
890 } else {
891 if (level == (uint64_t)-1)
892 level = 0;
893 mdb_warn("couldn't find matching htable, using level=%lu, "
894 "base address=0x0\n", level);
895 base = 0;
896 pagesize = mmu.level_size[level];
897 }
898
899 paddr = mmu_ptob((physaddr_t)pfn);
900 for (entry = 0; entry < mmu.ptes_per_table; ++entry) {
901 len = mdb_pread(&pte, mmu.pte_size,
902 paddr + entry * mmu.pte_size);
903 if (len != mmu.pte_size)
904 return (DCMD_ERR);
905
906 if (pte == 0)
907 continue;
908
909 mdb_printf("[%3d] va=0x%p ", entry,
910 VA_SIGN_EXTEND(base + entry * pagesize));
911 do_pte_dcmd(level, pte);
912 }
913
914 done:
915 return (DCMD_OK);
916 }
917
918 /*
919 * Dump the page table at the given PFN
920 */
921 /*ARGSUSED*/
922 int
923 ptable_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
924 {
|