Re: [PATCH] memremap: Fix NULL pointer BUG in get_zone_device_page()

From: Dan Williams
Date: Wed Aug 24 2016 - 00:48:26 EST


On Tue, Aug 23, 2016 at 9:28 PM, Kani, Toshimitsu <toshi.kani@xxxxxxx> wrote:
>> On Tue, Aug 23, 2016 at 7:53 PM, Dan Williams <dan.j.williams@xxxxxxxxx>
>> wrote:
>> > On Tue, Aug 23, 2016 at 6:29 PM, Kani, Toshimitsu <toshi.kani@xxxxxxx>
>> wrote:
>> >>> On Tue, Aug 23, 2016 at 4:47 PM, Kani, Toshimitsu
>> <toshi.kani@xxxxxxx>
>> >>> wrote:
> :
>> >>
>> >> crash> p {struct vmem_altmap} 0xffff88046d045410
>> >> $6 = {
>> >> base_pfn = 0x480000,
>> >> reserve = 0x2, // PHYS_PFN(SZ_8K)
>> >> free = 0x101fe,
>> >> align = 0x1fe,
>> >> alloc = 0x10000
>> >> }
>> >
>> > Ah, so, on second look the 0x490200000 data offset looks correct. The
>> > total size of the address range is 16GB which equates to 256MB needed
>> > for struct page, plus 2MB more to re-align the data on the next 2MB
>> > boundary.
>> >
>> > The question now is why is the guest faulting on an access to an
>> > address less than 0x490200000?
>>
>> Does the attached patch fix this for you?
>
> Yeah, that makes sense. I will test it tomorrow.
>
> BTW, why does devm_memremap_pages() put a whole range to pgmap_radix
> as device memory, but only initialize page->pgmap for its data range? Is there
> particular reason for this inconsistency?
>

The radix tree is indexed by section number, but we don't always
initialize a full section. The cases when we don't use a full section
is when it overlaps device metadata, or if a platform multiplexes the
device memory range with another resource within the same section.