From bc480c3bbacc0bdd12d67715783166c8362361d0 Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Thu, 4 Dec 2025 10:24:31 +0800 Subject: [PATCH] KZT, fix: Fixed desired memory protection of the mapping for pages need readable --- linux-user/elfload.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index dc505069823..8f4f8127e69 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2785,10 +2785,18 @@ static void load_elf_image(const char *image_name, const ImageSource *src, * In both cases, we will overwrite pages in this range with mappings * from the executable. */ - load_addr = target_mmap(loaddr, len, PROT_NONE, - MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | - (ehdr->e_type == ET_EXEC ? MAP_FIXED : 0), - -1, 0, 1); +#ifdef CONFIG_LATX_KZT + if (option_kzt) + load_addr = target_mmap(loaddr, len, PROT_READ, + MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | + (ehdr->e_type == ET_EXEC ? MAP_FIXED : 0), + -1, 0, 1); + else +#endif // CONFIG_LATX_KZT + load_addr = target_mmap(loaddr, len, PROT_NONE, + MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | + (ehdr->e_type == ET_EXEC ? MAP_FIXED : 0), + -1, 0, 1); if (load_addr == -1) { goto exit_mmap; }