0
votes

I am allocating a block of memory with kmalloc in a device driver in Linux. The address that I get is 0xffff880000180000. I am using an IvyBridge processor with a 46-bit physical address space. That means that the CPU doesn't have more than 46 addressing pins, so it can't access any address above 0x00003fffffffffff. The address I'm getting is obviously greater than that, as it has bit 47 set.

Assuming that kmalloc returns a physical pointer (that is, a pointer where the virtual, linear and physical addresses are the same), how can I be getting such an address, if it's not accessible by the CPU?


This question is related to "Why am I getting a high address when I use kmalloc with GFP_DMA in Linux?". However, it is not identical. This question is about the physical addresses kmalloc returns in general, whereas the linked question is about use of GFP_DMA and its relationship to the returned address.

1
The physical address space has usually both small and big addresses, so 0xffff880000180000 could be inside it.Basile Starynkevitch
But the CPU doesn't have that many address bits. How can it access such high bits if it doesn't have the full 64 bits, or even the canonical 48?Nathan Fellman
I think that x86-64 requires that a bunch of most significant bits of the address are all 0 or all 1.Basile Starynkevitch
right, bits 63:48 must all be the same, but that goes for virtual and linear addresses, not (to the best of my knowledge) for physical addresses.Nathan Fellman
Assuming that kmalloc returns a physical pointer? It always give virtual address! use virt_to_phys.J-16 SDiZ

1 Answers

3
votes

It's clearly not a physical address but a linear or virtual address, and is in 'canonical form' where the value of bit 47 is 'sign extended' up to bit 63.