From: notaz Date: Sat, 30 Sep 2023 20:26:21 +0000 (+0300) Subject: lightrec: must use MAP_FIXED_NOREPLACE X-Git-Tag: r24l~156 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8de0dd9f368c5f2d047213c1196c67cd22563915;p=pcsx_rearmed.git lightrec: must use MAP_FIXED_NOREPLACE otherwise it'll destroy existing mappings notaz/pcsx_rearmed#109 CC @pcercuei --- diff --git a/libpcsxcore/lightrec/mem.c b/libpcsxcore/lightrec/mem.c index 91bd9084..efabdb00 100644 --- a/libpcsxcore/lightrec/mem.c +++ b/libpcsxcore/lightrec/mem.c @@ -93,7 +93,7 @@ static int lightrec_mmap_ram(bool hugetlb) for (j = 0; j < 4; j++) { map = mmap_huge((void *)(base + j * 0x200000), 0x200000, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_FIXED, memfd, 0); + MAP_SHARED | MAP_FIXED_NOREPLACE, memfd, 0); if (map == MAP_FAILED) break; } @@ -142,7 +142,7 @@ int lightrec_init_mmap(void) map = mmap((void *)(base + 0x1f000000), 0x10000, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS, 0, 0); + MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS, -1, 0); if (map == MAP_FAILED) { err = -EINVAL; fprintf(stderr, "Unable to mmap parallel port\n"); @@ -153,7 +153,7 @@ int lightrec_init_mmap(void) map = mmap_huge((void *)(base + 0x1fc00000), 0x200000, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS, 0, 0); + MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS, -1, 0); if (map == MAP_FAILED) { err = -EINVAL; fprintf(stderr, "Unable to mmap BIOS\n"); @@ -176,7 +176,7 @@ int lightrec_init_mmap(void) map = mmap_huge((void *)(base + 0x800000), CODE_BUFFER_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED_NOREPLACE | MAP_ANONYMOUS, - 0, 0); + -1, 0); if (map == MAP_FAILED) { err = -EINVAL; fprintf(stderr, "Unable to mmap code buffer\n");