qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 38/47] linux-user: Rename mmap_reserve to mmap_reserve_or_unma


From: Andreas Schwab
Subject: Re: [PULL 38/47] linux-user: Rename mmap_reserve to mmap_reserve_or_unmap
Date: Mon, 18 Sep 2023 10:35:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Jul 15 2023, Richard Henderson wrote:

> @@ -776,9 +776,15 @@ static void mmap_reserve(abi_ulong start, abi_ulong len)
>      real_len = real_last - real_start + 1;
>      host_start = g2h_untagged(real_start);
>  
> -    ptr = mmap(host_start, real_len, PROT_NONE,
> -               MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 
> 0);
> -    assert(ptr == host_start);
> +    if (reserved_va) {
> +        void *ptr = mmap(host_start, real_len, PROT_NONE,
> +                         MAP_FIXED | MAP_ANONYMOUS
> +                         | MAP_PRIVATE | MAP_NORESERVE, -1, 0);
> +        assert(ptr == host_start);
> +    } else {
> +        int ret = munmap(host_start, real_len);
> +        assert(ret == 0);

munmap can fail if vm.max_map_count is exceeded.  See the attached test
(must be run from the current directory):

$ qemu-riscv64 ./test-free 
qemu-riscv64: ../linux-user/mmap.c:801: mmap_reserve_or_unmap: Assertion `ret 
== 0' failed.
**
ERROR:../accel/tcg/cpu-exec.c:532:cpu_exec_longjmp_cleanup: assertion failed: 
(cpu == current_cpu)
Bail out! ERROR:../accel/tcg/cpu-exec.c:532:cpu_exec_longjmp_cleanup: assertion 
failed: (cpu == current_cpu)

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Attachment: test-free
Description: test-free (from gnulib tests)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]