x86/p2m: guard (in particular) identity mapping entries
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:17:32 +0000 (14:17 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:17:32 +0000 (14:17 +0200)
commit753cb68e653002e89fdcd1c80e52905fdbfb78cb
tree6b64e2323833ce2beab2992ec89211c7ae7cef5b
parent0bf755e2c856628e11e93c76c3e12974e9964638
x86/p2m: guard (in particular) identity mapping entries

Such entries, created by set_identity_p2m_entry(), should only be
destroyed by clear_identity_p2m_entry(). However, similarly, entries
created by set_mmio_p2m_entry() should only be torn down by
clear_mmio_p2m_entry(), so the logic gets based upon p2m_mmio_direct as
the entry type (separation between "ordinary" and 1:1 mappings would
require a further indicator to tell apart the two).

As to the guest_remove_page() change, commit 48dfb297a20a ("x86/PVH:
allow guest_remove_page to remove p2m_mmio_direct pages"), which
introduced the call to clear_mmio_p2m_entry(), claimed this was done for
hwdom only without this actually having been the case. However, this
code shouldn't be there in the first place, as MMIO entries shouldn't be
dropped this way. Avoid triggering the warning again that 48dfb297a20a
silenced by an adjustment to xenmem_add_to_physmap_one() instead.

Note that guest_physmap_mark_populate_on_demand() gets tightened beyond
the immediate purpose of this change.

Note also that I didn't inspect code which isn't security supported,
e.g. sharing, paging, or altp2m.

This is CVE-2021-28694 / part of XSA-378.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/arch/x86/mm/p2m-pod.c
xen/arch/x86/mm/p2m.c
xen/common/memory.c
xen/include/asm-x86/p2m.h