<div dir="ltr">Hi Arun,<div><br></div><div>Thanks for your responses. Here's some additional details.</div><div><br></div><div>We were calling memblock_reserve() very early in the game when even kernel is calling to do the reservation.</div><div>The reason I think memblock_reserve() was not working was that kernel was already reserving a big chunk (0 to 0xbfffffff). Our page which was falling in between would become a no-op.</div><div>Call to request_mem_region() fails when the page is already reserved by the kernel.</div><div>It's only when we removed it does the call to request_mem_region() succeed.</div><div><br></div><div>About the corruption, What my understanding was, it cannot be caused by any application, since it will not have any privilege to modify the text segment. But are you saying that any application can still do it via /dev/mem route? In our system we have couple of other suspects as well which can cause such a corruption (DMA, DSP etc), It is unlike a standard linux machine running some application.</div><div><br></div><div>Another question, will the removed page be off-limits to the buddy allocator as well if we call it soon enough?</div><div>(That's what it looks like based on our tests but would be good to get a confirmation of it)</div><div>Since the problem is not easy to reproduce, it's difficult to be certain that we have successfully avoided the corruption. (We ran 300+ iterations of a test successfully. The problem could be seen within 20-80 iterations)</div><div><br></div><div>-Thanks</div><div>Nikhil</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 6:15 PM, Arun Sudhilal <span dir="ltr"><<a href="mailto:getarunks@gmail.com" target="_blank">getarunks@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Oct 3, 2016 at 6:02 PM, Arun Sudhilal <<a href="mailto:getarunks@gmail.com">getarunks@gmail.com</a>> wrote:<br>
> Hello Nikhil,<br>
><br>
</span><span class="">> On Wed, Sep 28, 2016 at 6:55 PM, Nikhil Utane<br>
> <<a href="mailto:nikhil.subscribed@gmail.com">nikhil.subscribed@gmail.com</a>> wrote:<br>
>> base1 = 0xA4D000; size1=0x1000;<br>
>> memblock_reserve (base1, size1);<br>
<br>
</span>Most probably your memblock_reserve() function is not affecting. It<br>
depends on when you are calling this function as explained<br>
earlier(after or before hand-off to buddy allocator).<br>
<br>
Lets say you are calling it pretty late and if<br>
CONFIG_ARCH_DISCARD_MEMBLOCK is disabled in your build,<br>
memblock_reserve() just go ahead and modifies the memblock structures<br>
but does not have any effect as buddy allocator has already taken<br>
control of memory management. That might be the reason you were not<br>
able to make this page reserved.<br>
<div class="HOEnZb"><div class="h5"><br>
>><br>
>> (In a separate static driver code)<br>
>> request_mem_region_exclusive (0x00A4D000, 4096, "csSIGILL")<br>
><br>
> Thanks for details. Looks strange.<br>
> One possible case I can think of is, when you use<br>
> request_mem_region_exclusive, user space cannot access it using<br>
> /dev/mem. May be any of your user space task is corrupting this region<br>
> before. now he is not able to access this location because you have<br>
> marked it as EXCLUSIVE for kernel.<br>
><br>
>><br>
>> If a driver requests for a memory region, shouldn't the kernel then not<br>
>> allocate it for any other purpose?<br>
> To remove pages from kernel allocation, you need to have only<br>
> successful invocation of memblock_reserve() function.<br>
><br>
> Regards,<br>
> Arun<br>
><br>
>><br>
>> -Regards<br>
>> Nikhil<br>
>><br>
>> On Wed, Sep 28, 2016 at 3:12 PM, Arun Sudhilal <<a href="mailto:getarunks@gmail.com">getarunks@gmail.com</a>> wrote:<br>
>>><br>
>>> Hello Nikhil,<br>
>>><br>
>>> On Wed, Sep 28, 2016 at 2:41 PM, Nikhil Utane<br>
>>> <<a href="mailto:nikhil.subscribed@gmail.com">nikhil.subscribed@gmail.com</a>> wrote:<br>
>>> > Arun,<br>
>>> ><br>
>>> > What seems to have done the trick is calling memblock_remove() followed<br>
>>> > by a<br>
>>> > call to request_mem_region(). This creates a hole which can be confirmed<br>
>>> > in<br>
>>> > the output of /proc/iomem.<br>
>>> ><br>
>>> > Do you see any issue with this approach?<br>
>>><br>
>>> I really don't know how it works for you. Marking address of a page as<br>
>>> iomem. How buddy allocator ignores this page?<br>
>>> request_mem_region() is a way of managing IO resource memory, to avoid<br>
>>> two drivers using same IO memory. It has not relation with buddy<br>
>>> allocator.<br>
>>><br>
>>> Can you post code snippet?<br>
>>><br>
>>> Regards,<br>
>>> Arun<br>
>>><br>
>>> ><br>
>>> > -Thanks<br>
>>> > Nikhil<br>
>>> ><br>
>>> > On Tue, Sep 27, 2016 at 4:14 PM, Arun Sudhilal <<a href="mailto:getarunks@gmail.com">getarunks@gmail.com</a>><br>
>>> > wrote:<br>
>>> >><br>
>>> >> Hello Nikhil,<br>
>>> >><br>
>>> >> On Fri, Sep 9, 2016 at 7:01 AM, Nikhil Utane<br>
>>> >> <<a href="mailto:nikhil.subscribed@gmail.com">nikhil.subscribed@gmail.com</a>> wrote:<br>
>>> >> > I want to reserve a physical memory page with a fixed PFN. I do not<br>
>>> >> > want<br>
>>> >> > this page to be used by anyone else. I am calling memblock_reserve()<br>
>>> >> > to<br>
>>> >> > supposedly reserve the page. I am writing some content into this<br>
>>> >> > page.<br>
>>> >> > What<br>
>>> >> > I see is that during some runs the content of this page is modified<br>
>>> >> > (either<br>
>>> >> > fully or sometimes partially). In few runs, I see it as intact. Is it<br>
>>> >> > expected that even after calling memblock_reserve() the kernel can<br>
>>> >> > allocate<br>
>>> >> > this physical page for any other purpose? How is memblock_remove()<br>
>>> >> > different<br>
>>> >> > from memblock_reserve? I tried reading up but didn't see any useful<br>
>>> >> > information. What I understood is memblock_remove will completely<br>
>>> >> > remove<br>
>>> >> > from kernel's allocation mechanism. Should I then be using remove<br>
>>> >> > instead of<br>
>>> >> > reserve?<br>
>>> >><br>
>>> >> when a DT entry is added to #reserved-memory node, what<br>
>>> >> drivers/of/fdt.c does is to call memblock_remove() and<br>
>>> >> memblock_reserve().<br>
>>> >> This happens after the memblock driver is initialized but before buddy<br>
>>> >> allocator up. Did you try this approach? This should work for you.<br>
>>> >><br>
>>> >> Only option once the kernel boot is complete is to try out the<br>
>>> >> technique what mm/memory_hotplug.c does while offline memory.<br>
>>> >> isolate_page_range and then migrate.<br>
>>> >><br>
>>> >> Regards,<br>
>>> >> Arun<br>
>>> >><br>
>>> >><br>
>>> >> ><br>
>>> >> > -Thanks<br>
>>> >> > Nikhil<br>
>>> >> ><br>
>>> >> > ______________________________<wbr>_________________<br>
>>> >> > Kernelnewbies mailing list<br>
>>> >> > <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.<wbr>org</a><br>
>>> >> > <a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.<wbr>org/mailman/listinfo/<wbr>kernelnewbies</a><br>
>>> >> ><br>
>>> ><br>
>>> ><br>
>><br>
>><br>
</div></div></blockquote></div><br></div>