diff mbox series

[Xen-devel,MM-PART2,v2,18/19] xen/arm: mm: Check start is always before end in {destroy, modify}_xen_mappings

Message ID 20190514122136.28215-27-julien.grall@arm.com
State Superseded
Headers show
Series xen/arm: Clean-up & fixes in boot/mm code | expand

Commit Message

Julien Grall May 14, 2019, 12:21 p.m. UTC
The two helpers {destroy, modify}_xen_mappings don't check that the
start is always before the end. This should never happen but if it
happens, it will result to unexpected behavior.

Catch such issues earlier on by adding an ASSERT in destroy_xen_mappings
and modify_xen_mappings.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andrii Anisov <andrii_anisov@epam.com>

---
    Changes in v2:
        - Add Andrii's reviewed-by
---
 xen/arch/arm/mm.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index eacc1647e0..b408de7c75 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1077,11 +1077,13 @@  int populate_pt_range(unsigned long virt, unsigned long nr_mfns)
 
 int destroy_xen_mappings(unsigned long v, unsigned long e)
 {
+    ASSERT(v <= e);
     return create_xen_entries(REMOVE, v, INVALID_MFN, (e - v) >> PAGE_SHIFT, 0);
 }
 
 int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
 {
+    ASSERT(s <= e);
     return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT,
                               flags);
 }