Suspicious code in p2m_set_altp2m_mem_access
Hi all,
I came across some code in the p2m_set_altp2m_mem_access() that does not seem right. On the invalid mfn branch there is a try to set_entry() and if that is not successful then the function does not return and calls set_entry again for PAGE_ORDER_4K even if there was a check that page order is different from PAGE_ORDER_4K.
Is this behavior wanted?
Regards,
Alex
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 12 lines · Alexandru Stefan ISAILA
Hi all,
I came across some code in the
p2m_set_altp2m_mem_access()that does not seem right. On the invalid mfn branch there is a try toset_entry()and if that is not successful then the function does not return and callsset_entryagain forPAGE_ORDER_4Keven if there was a check that page order is different fromPAGE_ORDER_4K.
Quoted 3 lines
Is this behavior wanted?
Yes.
The code checks to see if the *altp2m* for that entry is invalid. If so, it then goes and reads the *hostp2m*. If the altp2m entry is invalid, and the hostp2m entry is valid, *and* the hostp2m entry is > 4k (say, 2MiB), then it first makes a complete copy of the hostp2m entry, then does the originally-requested (4k) write.
The result of the first write will be a 2MiB entry that’s a copy of the hostpm; the result of the second write will be to break that 2MiB entry into 4k entries, then overwrite that single entry.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel