All of lore.kernel.org
 help / color / mirror / Atom feed
* Suspicious code in p2m_set_altp2m_mem_access
@ 2019-04-03 14:52 Alexandru Stefan ISAILA
  2019-04-03 15:17 ` George Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Stefan ISAILA @ 2019-04-03 14:52 UTC (permalink / raw)
  To: xen-devel, jbeulich, George.Dunlap, tamas, Andrew Cooper

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.

http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/mm/mem_access.c;h=a144bb0ce494318b0493dcff31bb5e4e8a742969;hb=refs/heads/staging#l272

Is this behavior wanted?

Regards,
Alex
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Suspicious code in p2m_set_altp2m_mem_access
  2019-04-03 14:52 Suspicious code in p2m_set_altp2m_mem_access Alexandru Stefan ISAILA
@ 2019-04-03 15:17 ` George Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: George Dunlap @ 2019-04-03 15:17 UTC (permalink / raw)
  To: Alexandru Stefan ISAILA
  Cc: xen-devel, tamas, George Dunlap, jbeulich, Andrew Cooper



> On Apr 3, 2019, at 3:52 PM, Alexandru Stefan ISAILA <aisaila@bitdefender.com> wrote:
> 
> 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.
> 
> http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/arch/x86/mm/mem_access.c;h=a144bb0ce494318b0493dcff31bb5e4e8a742969;hb=refs/heads/staging#l272
> 
> 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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-03 15:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 14:52 Suspicious code in p2m_set_altp2m_mem_access Alexandru Stefan ISAILA
2019-04-03 15:17 ` George Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.