]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commit
x86/P2M: synchronize fast and slow paths of p2m_get_page_from_gfn()
authorJan Beulich <jbeulich@suse.com>
Mon, 31 Mar 2025 07:21:12 +0000 (09:21 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 31 Mar 2025 07:21:12 +0000 (09:21 +0200)
commita8325f981ce4ff8ac8bcc73735f357846b0a0fbb
tree903ceecac62d6a440cba7c3d8c4563cdc4620ede
parent4d8cd1a5b7228816ca07eb02033f1a3d1b2d69ad
x86/P2M: synchronize fast and slow paths of p2m_get_page_from_gfn()

Handling of both grants and foreign pages was different between the two
paths.

While permitting access to grants would be desirable, doing so would
require more involved handling; undo that for the time being. In
particular the page reference obtained would prevent the owning domain
from changing e.g. the page's type (after the grantee has released the
last reference of the grant). Instead perhaps another reference on the
grant would need obtaining. Which in turn would require determining
which grant that was.

Foreign pages in any event need permitting on both paths.

Introduce a helper function to be used on both paths, such that
respective checking differs in just the extra "to be unshared" condition
on the fast path.

While there adjust the sanity check for foreign pages: Don't leak the
reference on release builds when on a debug build the assertion would
have triggered. (Thanks to Roger for the suggestion.)

Fixes: 80ea7af17269 ("x86/mm: Introduce get_page_from_gfn()")
Fixes: 50fe6e737059 ("pvh dom0: add and remove foreign pages")
Fixes: cbbca7be4aaa ("x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/mm/p2m.c