On 19/01/2024 10:44, Amit Daniel Kachhap wrote:
+ /* Ensure that this range is within the reservation bound */ + vma = find_vma(mm, addr); + if (!vma || !reserv_vma_valid_address(vma, addr, len)) + return -ERESERVATION; + return addr; + } else if (!test_bit(MMF_PCUABI_RESERVE, &mm->flags)) + return addr; +#else return addr; +#endif + } if (addr) { addr = PAGE_ALIGN(addr); +#if defined(CONFIG_CHERI_PURECAP_UABI) + if (test_bit(MMF_PCUABI_RESERVE, &mm->flags)) + addr = round_up(addr, CHERI_REPRESENTABLE_ALIGNMENT(len));
round_down() surely?
This function is generic_get_unmapped_area() where free memory are in increasing order so round_up is used. In generic_get_unmapped_area_top_down(), this will be otherwise.
Ah yes I see, I also missed that PAGE_ALIGN() above is also aligning up. Sorry for the confusion.
+#endif vma = find_vma_prev(mm, addr, &prev); - if (mmap_end - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vm_start_gap(vma)) && + if (mmap_end - align_len >= addr && addr >= mmap_min_addr && + (!vma || addr + align_len <= vm_start_gap(vma)) && (!prev || addr >= vm_end_gap(prev))) return addr; +#if defined(CONFIG_CHERI_PURECAP_UABI) + else if (flags & MAP_FIXED) + /* This non-tagged fixed address overlaps with other reservation */ + return -ERESERVATION;
I don't think this is ever hit, considering that we always return above if flags & MAP_FIXED.
This is a fallback when non-tagged fixed address is not free and overlapping and hence cannot be used.
My point is that we already have an if (flags & MAP_FIXED) about 25 lines above, and we always return if the condition is true. So I don't see how this return statement can ever be reached.
Kevin