X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fplat.c;h=2842691e5e22d2e65be373eb10a26b27942ea8ea;hb=39b2c61e1d4ef370b0f84cb5a601f9f2d3a1d35a;hp=06c315e830212e7b394344c649aab84cc534e176;hpb=26ea18173c1228dd5ce39e2a88ffe1ae10fcb365;p=libpicofe.git diff --git a/linux/plat.c b/linux/plat.c index 06c315e..2842691 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -216,8 +216,18 @@ void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) void *ret; ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE); - if (ret == MAP_FAILED) - return NULL; + if (ret == MAP_FAILED) { + fprintf(stderr, "mremap %p %zd %zd: ", + ptr, oldsize, newsize); + perror(NULL); + // might be because huge pages can't be remapped, + // just make a new mapping + ret = plat_mmap(0, newsize, 0, 0); + if (ret == MAP_FAILED) + return NULL; + memcpy(ret, ptr, oldsize); + munmap(ptr, oldsize); + } if (ret != ptr) printf("warning: mremap moved: %p -> %p\n", ptr, ret);