mmap: Remember the MAP_FIXED flag as VM_FIXED
authorBen Hutchings <ben@decadent.org.uk>
Wed, 5 Jul 2017 12:32:43 +0000 (13:32 +0100)
committerBastian Blank <waldi@debian.org>
Fri, 22 Jun 2018 09:50:22 +0000 (10:50 +0100)
Since 4.15 there are no spare bits, but we can use VM_ARCH_1 as
VM_FIXED wil only be needed on x86.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Topic bugfix/x86
Gbp-Pq: Name mmap-remember-the-map_fixed-flag-as-vm_fixed.patch

include/linux/mm.h
include/linux/mman.h

index cfbfc16f2bb5ae017068e38de72b988666335651..4ee67eebf86a9abd4fca9f3b37029c5ea30abb1d 100644 (file)
@@ -201,6 +201,11 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_HUGETLB     0x00400000      /* Huge TLB Page VM */
 #define VM_SYNC                0x00800000      /* Synchronous page faults */
 #define VM_ARCH_1      0x01000000      /* Architecture-specific flag */
+#ifdef CONFIG_X86
+#define VM_FIXED       VM_ARCH_1       /* Allocated at fixed address */
+#else
+#define VM_FIXED       0
+#endif
 #define VM_WIPEONFORK  0x02000000      /* Wipe VMA contents in child. */
 #define VM_DONTDUMP    0x04000000      /* Do not include in the core dump */
 
index 6a4d1caaff5c229903f905c04a41dc633b7ac009..393970e55bb28cc722fea6e0aaf4bf142dfa8628 100644 (file)
@@ -131,7 +131,9 @@ calc_vm_flag_bits(unsigned long flags)
        return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
               _calc_vm_trans(flags, MAP_DENYWRITE,  VM_DENYWRITE ) |
               _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    ) |
-              _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      );
+              _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
+              (VM_FIXED ?
+               _calc_vm_trans(flags, MAP_FIXED,     VM_FIXED     ) : 0);
 }
 
 unsigned long vm_commit_limit(void);