From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH] x86: get_page_from_gfn() should not return misleading type Date: Thu, 08 Jun 2017 09:21:09 -0600 Message-ID: <593987850200007800160F0E@prv-mh.provo.novell.com> References: <593987850200007800160F0E@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part162E7B75.1__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIzFJ-0003vO-2G for xen-devel@lists.xenproject.org; Thu, 08 Jun 2017 15:21:13 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part162E7B75.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline It is not impossible that the page owner is dom_io. While no current caller cares about this case, let's nevertheless return an appropriate type even in that case. Signed-off-by: Jan Beulich --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -479,9 +479,9 @@ static inline struct page_info *get_page if ( paging_mode_translate(d) ) return get_page_from_gfn_p2m(d, p2m_get_hostp2m(d), gfn, t, NULL, = q); =20 - /* Non-translated guests see 1-1 RAM mappings everywhere */ - if (t) - *t =3D p2m_ram_rw; + /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */ + if ( t ) + *t =3D likely(d !=3D dom_io) ? p2m_ram_rw : p2m_mmio_direct; page =3D __mfn_to_page(gfn); return mfn_valid(_mfn(gfn)) && get_page(page, d) ? page : NULL; } --=__Part162E7B75.1__= Content-Type: text/plain; name="x86-gpfg-type.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-gpfg-type.patch" x86: get_page_from_gfn() should not return misleading type=0A=0AIt is not = impossible that the page owner is dom_io. While no current=0Acaller cares = about this case, let's nevertheless return an appropriate=0Atype even in = that case.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/include/asm-x86/p2m.h=0A+++ b/xen/include/asm-x86/p2m.h=0A@@ -479,9 = +479,9 @@ static inline struct page_info *get_page=0A if ( paging_mode_= translate(d) )=0A return get_page_from_gfn_p2m(d, p2m_get_hostp2m(d= ), gfn, t, NULL, q);=0A =0A- /* Non-translated guests see 1-1 RAM = mappings everywhere */=0A- if (t)=0A- *t =3D p2m_ram_rw;=0A+ = /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */=0A+ = if ( t )=0A+ *t =3D likely(d !=3D dom_io) ? p2m_ram_rw : p2m_mmio_di= rect;=0A page =3D __mfn_to_page(gfn);=0A return mfn_valid(_mfn(gfn)= ) && get_page(page, d) ? page : NULL;=0A }=0A --=__Part162E7B75.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__Part162E7B75.1__=--