mem_sharing: fix sharability check during fork reset
authorTamas K Lengyel <tamas.lengyel@intel.com>
Fri, 24 Apr 2020 13:05:33 +0000 (15:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Apr 2020 13:05:33 +0000 (15:05 +0200)
commitf5500c3196455572f0c79fb7b6d8e5141a7385c8
tree2e3eb83b3688fdf8710d1b5d8692d7e3211a6905
parente321576f4047661111c7e069f03fc96294d7bb32
mem_sharing: fix sharability check during fork reset

When resetting a VM fork we ought to only remove pages that were allocated for
the fork during it's execution and the contents copied over from the parent.
This can be determined if the page is sharable as special pages used by the
fork for other purposes will not pass this test. Unfortunately during the fork
reset loop we only partially check whether that's the case. A page's type may
indicate it is sharable (pass p2m_is_sharable) but that's not a sufficient
check by itself. All checks that are normally performed before a page is
converted to the sharable type need to be performed to avoid removing pages
from the p2m that may be used for other purposes. For example, currently the
reset loop also removes the vcpu info pages from the p2m, potentially putting
the guest into infinite page-fault loops.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/mm/mem_sharing.c