From: notaz Date: Wed, 11 Oct 2023 18:22:17 +0000 (+0300) Subject: lightrec: handle a case of ignored MAP_FIXED_NOREPLACE X-Git-Tag: r24l~136 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5937ccce520c4bddc986f741737465e2e8d94605;p=pcsx_rearmed.git lightrec: handle a case of ignored MAP_FIXED_NOREPLACE --- diff --git a/libpcsxcore/lightrec/mem.c b/libpcsxcore/lightrec/mem.c index b5caa783..9134d893 100644 --- a/libpcsxcore/lightrec/mem.c +++ b/libpcsxcore/lightrec/mem.c @@ -95,11 +95,16 @@ static int lightrec_mmap_ram(bool hugetlb) base = supported_io_bases[i]; for (j = 0; j < 4; j++) { - map = mmap_huge((void *)(base + j * 0x200000), - 0x200000, PROT_READ | PROT_WRITE, + void *base_ptr = (void *)(base + j * 0x200000); + map = mmap_huge(base_ptr, 0x200000, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED_NOREPLACE, memfd, 0); if (map == MAP_FAILED) break; + // some systems ignore MAP_FIXED_NOREPLACE + if (map != base_ptr) { + munmap(map, 0x200000); + break; + } } /* Impossible to map using this base */