Showing Real Kernel Addresses in 'dmesg' Output
In current kernel versions, if a pointer is to be printed in a message to the kernel log,
the commonly used format string %p
prints only a hash of the pointer value.
This is for security reasons, but not very helpful for debugging.
If a real pointer value is to be printed, e.g. %px
has to be used instead, e.g.
int i; printk( KERN_INFO "Address of i: %px\n", &i );
There is quite a number of variations for the %p
format specifier for different purposes, see e.g.:
- How to get printk format specifiers right
https://www.kernel.org/doc/html/v5.3/core-api/printk-formats.html
The new format specifier %px
was introduced around Linux kernel 4.15 and may not be supported by older kernels.
— Martin Burnicki martin.burnicki@burnicki.net, last updated 2022-01-19