造case,拿到一个system memory 的 VA。
gl@pc:~/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/build$ gdb
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file kfdtest
Reading symbols from kfdtest...
(gdb) b KFDMemoryTest.cpp:560
Breakpoint 1 at 0x49971e: file /home/gl/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/src/KFDMemoryTest.cpp, line 560.
(gdb) b KFDQMTest.cpp:115
Breakpoint 2 at 0x4c9662: file /home/gl/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/src/KFDQMTest.cpp, line 115.
(gdb) r --gtest_filter=KFDQMTest.SubmitPacketCpQueue
Starting program: /home/gl/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/build/kfdtest --gtest_filter=KFDQMTest.SubmitPacketCpQueue
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[ ] Profile: Full Test
[ ] HW capabilities: 0x9
Note: Google Test filter = KFDQMTest.SubmitPacketCpQueue
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from KFDQMTest
[ RUN ] KFDQMTest.SubmitPacketCpQueue
leiDebug: args.doorbell_offset: 0xd134c00000000000
leiDebug: doorbell_mmap_offset: 0xd134c00000000000
leiDebug: doorbell_offset: 0x0
Breakpoint 2, KFDQMTest_SubmitPacketCpQueue_Test::TestBody (this=0x555556314b20) at /home/gl/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/src/KFDQMTest.cpp:115
115 EXPECT_TRUE(WaitOnValue(destBuf.As<unsigned int*>(), 0));
(gdb) p destBuf
$1 = {static Null = {static Null = <same as static member of an already seen type>, m_Flags = {{ui32 = {NonPaged = 0, CachePolicy = 0, ReadOnly = 0, PageSize = 0, HostAccess = 0, NoSubstitute = 0,
GDSMemory = 0, Scratch = 0, AtomicAccessFull = 0, AtomicAccessPartial = 0, ExecuteAccess = 0, CoarseGrain = 0, AQLQueueMemory = 0, FixedAddress = 0, NoNUMABind = 0, Uncached = 0, Reserved = 0},
Value = 0}}, m_Size = 0, m_pUser = 0x0, m_pBuf = 0x0, m_Local = false, m_Node = 0, m_MappedNodes = 0}, m_Flags = {{ui32 = {NonPaged = 0, CachePolicy = 0, ReadOnly = 0, PageSize = 0, HostAccess = 1,
NoSubstitute = 0, GDSMemory = 0, Scratch = 0, AtomicAccessFull = 0, AtomicAccessPartial = 0, ExecuteAccess = 0, CoarseGrain = 0, AQLQueueMemory = 0, FixedAddress = 0, NoNUMABind = 1, Uncached = 0,
Reserved = 0}, Value = 65600}}, m_Size = 4096, m_pUser = 0x0, m_pBuf = 0x7ffff7fc5000, m_Local = false, m_Node = 1, m_MappedNodes = 2}
使用UMR读取
gl@pc:~/code/ROCm5.2/ROCT-Thunk-Interface/tests/kfdtest/build$ sudo umr -i 1 -vm 0x8@0x7ffff7fc5000 1
=== VM Decoding of address 8@0x7ffff7fc5000 ===
mmVM_CONTEXT8_PAGE_TABLE_START_ADDR_LO32=0x0
mmVM_CONTEXT8_PAGE_TABLE_START_ADDR_HI32=0x0
mmVM_CONTEXT8_PAGE_TABLE_END_ADDR_LO32=0xffffffff
mmVM_CONTEXT8_PAGE_TABLE_END_ADDR_HI32=0xf
mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR_LO32=0xfebfa001
mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR_HI32=0x3
mmVM_CONTEXT8_CNTL=0x7ffe07
VMID8.page_table_block_size=0
VMID8.page_table_depth=3
mmVGA_MEMORY_BASE_ADDRESS=0x0
mmVGA_MEMORY_BASE_ADDRESS_HIGH=0x0
mmMC_VM_FB_OFFSET=0x0
mmMC_VM_MX_L1_TLB_CNTL=0x0
mmMC_VM_SYSTEM_APERTURE_LOW_ADDR=0x0
mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR=0x0
mmMC_VM_FB_LOCATION_BASE=0x8000
mmMC_VM_FB_LOCATION_TOP=0x83ff
mmMC_VM_AGP_BASE=0x0
mmMC_VM_AGP_BOT=0x0
mmMC_VM_AGP_TOP=0x0
BASE=0x00000003febfa001, VA=0x7f8000000000, PBA==0x0003febfa000, V=1, S=0, C=0, P=0, FS=0
\-> PDE2@{0x3febfa7f8/ff}=0x00000000007bc001, VA=0x7f8000000000, PBA==0x0000007bc000, V=1, S=0, C=0, P=0, FS=0
\-> PDE1@{0x7bcff8/1ff}=0x00000000007bd001, VA=0x007fc0000000, PBA==0x0000007bd000, V=1, S=0, C=0, P=0, FS=0
\-> PDE0@{0x7bddf8/1bf}=0x00000000007be001, VA=0x000037e00000, PBA==0x0000007be000, V=1, S=0, C=0, P=0, FS=0
\-> PTE@{0x7bee28/0x1c5}=0x06000007f24cb077, VA=0x0000001c5000, PBA==0x0007f24cb000, V=1, S=1, C=1, Z=0, X=1, R=1, W=1, FS=0, T=0, MTYPE=UC
\-> Computed address we will read from: sys:7f24cb000, (reading: 4096 bytes)
=== Completed VM Decoding ===
使用pagemap读取
gl@pc:~/data/github/pagemap$ sudo ./pagemap 2451104 0x7ffff7fc5000 0x7ffff7fc5004
0x7ffff7fc5000 : pfn 7f24cb soft-dirty 1 file/shared 0 swapped 0 present 1
可以看到不论是umr还是pagemap,都能拿到pfn 7f24cb