Yes, your explanation and patch solve the pain. Thanks very much!<div><br></div><div>Regards,</div><div>Jinghao<br><br><div class="gmail_quote">On Mon, May 21, 2012 at 9:11 PM, Simon Gerber <span dir="ltr">&lt;<a href="mailto:simugerber@student.ethz.ch" target="_blank">simugerber@student.ethz.ch</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jinghao,<br>
<br>
The problem seems to be in the x86_32 version of do_map (in<br>
lib/barrelfish/target/x86_32/pmap_target.c) on line 208, where the<br>
newly created vnode&#39;s offset is set to zero instead of i (see also the<br>
attached patch).<br>
<br>
Right now, if you modify the flags of the second four kB of a Frame<br>
capability, what you really do is unmap the second four kB and map the<br>
first four kB with the new flags.<br>
<br>
Hope this helps,<br>
-- Simon G.<br>
<br>
PS:<br>
<br>
2012/5/21 Shi Jinghao &lt;<a href="mailto:jhshi@cs.hku.hk">jhshi@cs.hku.hk</a>&gt;:<br>
<div class="HOEnZb"><div class="h5">&gt; Hi Simon,<br>
&gt;<br>
&gt; Yes, according to the output, it works correctly on X86_64. But do you have<br>
&gt; any insights about why it would fail on X86_32? Here is my output here with<br>
&gt; arch x86_32 on qemu.<br>
&gt;<br>
&gt; pmaptest.0: begin monothelic_frame test...<br>
&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 60000000 IP 400548 error 7<br>
&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 60001000 IP 400548 error 7<br>
&gt; pmaptest.0: array init done!<br>
&gt; pmaptest.0: array check fail, a[0] = 1024<br>
&gt; pmaptest.0: two page&#39;s content are identical<br>
&gt; a[0] = 1024, a[1024] = 1024<br>
&gt; a[1] = 1025, a[1025] = 1025<br>
&gt; a[2] = 1026, a[1026] = 1026<br>
&gt; a[3] = 1027, a[1027] = 1027<br>
&gt; pmaptest.0: checking if the two virtual page share the same physical page...<br>
&gt; no<br>
&gt; pmaptest.0: begin one_page_one_frame test...<br>
&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 68000000 IP 4007b0 error 7<br>
&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 68001000 IP 4007b0 error 7<br>
&gt; pmaptest.0: array init done<br>
&gt; pmaptest.0: array check done!<br>
&gt;<br>
&gt; During the porting, I&#39;ve only changed find_ptable to get_ptable, Is it a<br>
&gt; problem?<br>
&gt;<br>
&gt; For you convenience, I attached a patch for<br>
&gt; /lib/barrelfish/target/x86_32/pmap_target.c:modify_flags, in case you want<br>
&gt; to test it by yourself.<br>
&gt;<br>
&gt; Thanks for your concern!<br>
&gt;<br>
&gt; Jinghao<br>
&gt;<br>
&gt; On Mon, May 21, 2012 at 8:08 PM, Simon Peter &lt;<a href="mailto:speter@inf.ethz.ch">speter@inf.ethz.ch</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Jinghao,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;ve compiled your code for x86-64 and ran it on QEMU. Here&#39;s the output I<br>
&gt;&gt; get:<br>
&gt;&gt;<br>
&gt;&gt; pmaptest.0: begin monothelic_frame test...<br>
&gt;&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 60000000 IP 4003a0, error<br>
&gt;&gt; 0x7<br>
&gt;&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 60001000 IP 4003a0, error<br>
&gt;&gt; 0x7<br>
&gt;&gt; pmaptest.0: array init done!<br>
&gt;&gt; pmaptest.0: begin one_page_one_frame test...<br>
&gt;&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 68000000 IP 400560, error<br>
&gt;&gt; 0x7<br>
&gt;&gt; kernel 0: user page fault in &#39;pmaptest&#39;: addr 68001000 IP 400560, error<br>
&gt;&gt; 0x7<br>
&gt;&gt; pmaptest.0: array init done<br>
&gt;&gt; pmaptest.0: array check done!<br>
&gt;&gt;<br>
&gt;&gt; This seems to be working?<br>
&gt;&gt;<br>
&gt;&gt; Simon<br>
&gt;&gt;<br>
&gt;&gt; On 20.05.2012 16:00, <a href="mailto:jhshi@cs.hku.hk">jhshi@cs.hku.hk</a> wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Here is my previous email, FYI.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; <a href="https://lists.inf.ethz.ch/pipermail/barrelfish-users/2012-May/000593.html" target="_blank">https://lists.inf.ethz.ch/pipermail/barrelfish-users/2012-May/000593.html</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Quoting <a href="mailto:jhshi@cs.hku.hk">jhshi@cs.hku.hk</a>:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; For some reason, I need to work on x86_32 instead of x86_64. And I<br>
&gt;&gt;&gt;&gt; found that x86_32&#39;s pmap-&gt;f.modify_flags is NYI. So I ported it from<br>
&gt;&gt;&gt;&gt;  x86_64, as described by my previous email (link). But then I found<br>
&gt;&gt;&gt;&gt; that the port won&#39;t work properly. Personally, I don&#39;t think the<br>
&gt;&gt;&gt;&gt; problem lies in the porting but in the modify_flags itself.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Here is my test case workflow:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; First allocate two pages using frame_alloc and map them at some<br>
&gt;&gt;&gt;&gt; &quot;safe&quot;  virtual address as read-only using pmap-&gt;f.map. Then fill<br>
&gt;&gt;&gt;&gt; the two  pages with different content. Since they are read-only,<br>
&gt;&gt;&gt;&gt; page faults  will occur when filling. I catch them and map the fault<br>
&gt;&gt;&gt;&gt; page as  read-write using pmap-&gt;f.modify_flags in the fault handler.<br>
&gt;&gt;&gt;&gt; But then I  found that the two page&#39;s content are identical, which<br>
&gt;&gt;&gt;&gt; is not supposed  to be.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Then I found that if I allocate one frame for each page, instead of<br>
&gt;&gt;&gt;&gt; one monolithic frame, everything is fine.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I&#39;ve summarized my test in the attached C file, which should be<br>
&gt;&gt;&gt;&gt; compiled and run under x86_32. Apology for not being able to test it<br>
&gt;&gt;&gt;&gt;  under X86_64 since I encounter some weird errors when compiling<br>
&gt;&gt;&gt;&gt; arch  x86_64. But if you substitute all the X86_32 to X86_64 in the<br>
&gt;&gt;&gt;&gt; test  file, it should work under x86_64 as well.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; However, if the test goes all fine under x86_64, then please give<br>
&gt;&gt;&gt;&gt; some  hint about why its x86_32&#39;s port would fail.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks in advance!<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt;&gt; Jinghao<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Barrelfish-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:Barrelfish-users@lists.inf.ethz.ch">Barrelfish-users@lists.inf.ethz.ch</a><br>
&gt;&gt;&gt; <a href="https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Barrelfish-users mailing list<br>
&gt; <a href="mailto:Barrelfish-users@lists.inf.ethz.ch">Barrelfish-users@lists.inf.ethz.ch</a><br>
&gt; <a href="https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users</a><br>
&gt;<br>
</div></div></blockquote></div><br></div>