From 8de0dd9f368c5f2d047213c1196c67cd22563915 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 30 Sep 2023 23:26:21 +0300 Subject: [PATCH] lightrec: must use MAP_FIXED_NOREPLACE otherwise it'll destroy existing mappings notaz/pcsx_rearmed#109 CC @pcercuei --- libpcsxcore/lightrec/mem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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"); -- 2.39.5