memory: XENMEM_add_to_physmap (almost) wrapping checks
authorJan Beulich <jbeulich@suse.com>
Wed, 2 Feb 2022 09:26:06 +0000 (10:26 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 2 Feb 2022 09:26:06 +0000 (10:26 +0100)
commitef0f94a48fd7b6a33b4460e545572c65573cc3e0
tree4fbeb3eb322afc894dcb9be106279a248e6e9536
parente3abdc626a732c780f54c783075694c3f951edae
memory: XENMEM_add_to_physmap (almost) wrapping checks

Determining that behavior is correct (i.e. results in failure) for a
passed in GFN equaling INVALID_GFN is non-trivial. Make this quite a bit
more obvious by checking input in generic code - both for singular
requests to not match the value and for range ones to not pass / wrap
through it.

For Arm similarly make more obvious that no wrapping of MFNs passed
for XENMAPSPACE_dev_mmio and thus to map_dev_mmio_region() can occur:
Drop the "nr" parameter of the function to avoid future callers
appearing which might not themselves check for wrapping. Otherwise
the respective ASSERT() in rangeset_contains_range() could trigger.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/arch/arm/include/asm/p2m.h
xen/arch/arm/mm.c
xen/arch/arm/p2m.c
xen/common/grant_table.c
xen/common/memory.c