xen/arm: mm: Add more ASSERT() in {destroy, modify}_xen_mappings()
authorJulien Grall <jgrall@amazon.com>
Sat, 16 Jul 2022 14:37:57 +0000 (15:37 +0100)
committerJulien Grall <julien@xen.org>
Sun, 17 Jul 2022 13:10:08 +0000 (14:10 +0100)
Both destroy_xen_mappings() and modify_xen_mappings() will take in
parameter a range [start, end[. Both end should be page aligned.

Add extra ASSERT() to ensure start and end are page aligned. Take the
opportunity to rename 'v' to 's' to be consistent with the other helper.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
----
    Changes in v2:
        - Also modify prototype. Note that on x86, the first parameter
          was not matching in the declaration and prototype.
        - Add Bertrand's reviewed-by

xen/arch/arm/mm.c
xen/include/xen/mm.h

index 009b8cd9ef64d489bdf60d0f31b36d655a7f7139..9a2a29abe2c22f7bab59015f389ffdf69560481c 100644 (file)
@@ -1368,14 +1368,18 @@ int populate_pt_range(unsigned long virt, unsigned long nr_mfns)
     return xen_pt_update(virt, INVALID_MFN, nr_mfns, _PAGE_POPULATE);
 }
 
-int destroy_xen_mappings(unsigned long v, unsigned long e)
+int destroy_xen_mappings(unsigned long s, unsigned long e)
 {
-    ASSERT(v <= e);
-    return xen_pt_update(v, INVALID_MFN, (e - v) >> PAGE_SHIFT, 0);
+    ASSERT(IS_ALIGNED(s, PAGE_SIZE));
+    ASSERT(IS_ALIGNED(e, PAGE_SIZE));
+    ASSERT(s <= e);
+    return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, 0);
 }
 
 int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
 {
+    ASSERT(IS_ALIGNED(s, PAGE_SIZE));
+    ASSERT(IS_ALIGNED(e, PAGE_SIZE));
     ASSERT(s <= e);
     return xen_pt_update(s, INVALID_MFN, (e - s) >> PAGE_SHIFT, flags);
 }
index 3be754da926c981b338c4a5fc575fdb5f69f3fbe..6dee421bb8bd12d2523caa6a100cf41b6d5beb42 100644 (file)
@@ -101,7 +101,7 @@ int map_pages_to_xen(
     unsigned int flags);
 /* Alter the permissions of a range of Xen virtual address space. */
 int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags);
-int destroy_xen_mappings(unsigned long v, unsigned long e);
+int destroy_xen_mappings(unsigned long s, unsigned long e);
 /* Retrieve the MFN mapped by VA in Xen virtual address space. */
 mfn_t xen_map_to_mfn(unsigned long va);