You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* `pfn`: add three zeroes to it, and you have the physical address.
4656
+
+
4657
+
Three zeroes is 12 bits which is 4kB, which is the size of a page.
4658
+
+
4659
+
For example, the virtual address `0x601000` has `pfn` of `0x1a61`, which means that its physical address is `0x1a61000`
4660
+
+
4661
+
This is consistent with what `virt_to_phys_user.out` told us: the virtual address `0x601048` has physical address `0x1a61048`.
4662
+
+
4663
+
`048` corresponds to the three last zeroes, and is the offset within the page.
4664
+
+
4665
+
Also, this value falls inside `0x601000`, which as previously analyzed is the data section, which is the normal location for global variables such as ours.
4666
+
* `soft-dirty`: TODO
4667
+
* `file/shared`: TODO. `1` seems to indicate that the page can be shared across processes, possibly for read-only pages? E.g. the text segment has `1`, but the data has `0`.
4668
+
* `swapped`: TODO swapped to disk?
4669
+
* `present`: TODO vs swapped?
4670
+
* `library`: which executable owns that page
4671
+
4672
+
This program works in two steps:
4673
+
4674
+
* parse the human readable lines lines from `/proc/<pid>/maps`. This files contains lines of form:
** `7f8af99f8000-7f8af99ff000` is a virtual address range that belong to the process, possibly containing multiple pages.
4683
+
** `/lib/libuClibc-1.0.22.so` is the name of the library that owns that memory
4684
+
* loop over each page of each address range, and ask `/proc/<pid>/pagemap` for more information about that page, including the physical address
4685
+
4459
4686
=== Linux kernel tracing
4460
4687
4461
4688
Good overviews:
@@ -4880,6 +5107,12 @@ This example should handle interrupts from userland and print a message to stdou
4880
5107
4881
5108
TODO: what is the expected behaviour? I should have documented this when I wrote this stuff, and I'm that lazy right now that I'm in the middle of a refactor :-)
4882
5109
5110
+
UIO interface in a nutshell:
5111
+
5112
+
* blocking read / poll: waits until interrupts
5113
+
* `write`: call `irqcontrol` callback. Default: 0 or 1 to enable / disable interrupts.
5114
+
* `mmap`: access device memory
5115
+
4883
5116
Sources:
4884
5117
4885
5118
* link:kernel_module/user/uio_read.c[]
@@ -5805,7 +6038,7 @@ as:
5805
6038
Memory at feb54000
5806
6039
....
5807
6040
5808
-
Then you can try messing with that address with:
6041
+
Then you can try messing with that address with <<dev-mem>>:
5809
6042
5810
6043
....
5811
6044
devmem 0xfeb54000 w 0x12345678
@@ -6029,14 +6262,12 @@ Expected outcome after insmod:
6029
6262
* QEMU reports MMIO with printfs
6030
6263
* IRQs are generated and handled by this module, which logs to dmesg
6031
6264
6032
-
Also without insmoding this module, try:
6265
+
Without insmoding this module, try writing to the register with <<dev-mem>>:
6033
6266
6034
6267
....
6035
6268
devmem 0x101e9000 w 0x12345678
6036
6269
....
6037
6270
6038
-
which touches the register from userland through `/dev/mem`.
6039
-
6040
6271
We can also observe the interrupt with <<dummy-irq>>:
0 commit comments