It seems that casting a void* pointer (allocated by kmalloc) to unsigned long long changes it. Printing them with %p and %llx gives different values. Why is it so? Can anyone explain?
Following is a simple repro for that:
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
void* kbuff;
int init_module(void)
{
kbuff = kzalloc(sizeof(char), GFP_KERNEL);
pr_info("%p %llx\n",kbuff, (unsigned long long)kbuff);
return 0;
}
void cleanup_module(void)
{
kfree(kbuff);
}
The dmesg output comes out to be as follows
[67355.673465] 000000003aeb0247 ffff9ef657a58c00