From patchwork Fri Mar 1 23:05:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 777122 Delivered-To: patch@linaro.org Received: by 2002:adf:e94d:0:b0:33d:f458:43ce with SMTP id m13csp1604550wrn; Fri, 1 Mar 2024 15:19:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVtA6h/u1IcpZyY1q6OILeXfHcWUO7kus9t4V0UzpSB4CwXEr2ybwn+aYQeBcuPIyScmHOa4De6GTTvoJ8RsxnX X-Google-Smtp-Source: AGHT+IHZ51/UOzXoWr06nAxjCaw/2pQzJ5oL5Q36FrClKc6+C56rL8svNxqVLoWzvJDg79rp+2Bo X-Received: by 2002:a0c:f882:0:b0:690:b11:36c2 with SMTP id u2-20020a0cf882000000b006900b1136c2mr3069267qvn.63.1709335155810; Fri, 01 Mar 2024 15:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709335155; cv=none; d=google.com; s=arc-20160816; b=GxHv390WoKWymds8dHxKU+qb8StN3a5Ev+CN5fY9bdCoSZxrXsOyjd2rmQDD07dXxU 9oXS9TzFMjuY+93o07yzbaRN2EOFvaISIQ9Gio9flWV6WgG3GgRihLPhhxCItZqpruTR 1toqlq9LZTjBNj/q8hIJ6zWnpHLp3wc2VYrKG3p0gB9WFA5diEtgRYfZUbi/yNfeZpy5 wjh0yxg6B+it2nSc5LKQOFEg0KtSpWgf6q+/tWUKU6uqW26bKxs1Yg9PmR85y4ivDLeH E+RonXYjKFCKiUHgiLO6MRTxHO9sG11yIsSdbgqtYZdqT5njiKMr1qlQo+0m8Fg8WzYD QTOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=ddzBgUyJAVe+F/Q3l/i3Fk4fYKIJYLhSkbTZkAgRZw5Oikf0WgfdkQiONaPq1rT9i1 3R51dhxSAliii3MXjnbfP2KsQOyO3CjOG73awcvGRglgN0GPCYuEbVkGbwkqtR37XXQS r2n6PldKqfrxdcl0yCbGQ5nZrErwHQCoJxco1FkWMelb6lEP2jjWwzXrT2NsUMFe7JN2 5VEEY9dSatJkQyOtQoF3Dvr9PAYF6IF2Mqmvm+qyHaDGOGbTiSmoSkxBgi8sPgvpjFaj m5YKDXgdV6TV2CJ+zKAkzWPho0zienIQCi6F3aS7deoT0zF6W2kD1id/kSCbT1s0k3EI lvXQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R29xo807; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 7-20020ad45ba7000000b00690193b676fsi4550188qvq.350.2024.03.01.15.19.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2024 15:19:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R29xo807; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgC2b-0005Ia-2s; Fri, 01 Mar 2024 18:11:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgC1M-0003eU-SH for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:31 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgC1H-0005c5-8H for qemu-devel@nongnu.org; Fri, 01 Mar 2024 18:10:28 -0500 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3bb9b28acb4so1913228b6e.2 for ; Fri, 01 Mar 2024 15:10:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709334622; x=1709939422; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; b=R29xo8072fvODYHj6CO3zejN6mxhmTEJ0HQshz1Lf8k/VLxRtv5g45pI8ai+KVX7Rn +NRgpwSq9CUhLSpgYQCpZjvgumr+D/snm9+1UOEGGEd4S42ijuqsHCOdsKRIRAZwGG3E GnvuRkT+8D5O3OmfsfyxYkywCh+uGpJfm4gxYdkYgbhLReRseBHfaaaZFd5BjSQ0Uo4Q Chcfr7Hu9KPvSyoxr9ej4CcC5OmT2q4Cyf1AeE8sE+tcaHgA4eonHUMzrfHndiVqM37p AksAe78DIn1v0D5W5KEx3PwCdD505sdDHFmtpeopby3wFK6z4eld4pdWulur69iH6QhI 8yYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709334622; x=1709939422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; b=uuq9ucBd0ssyoUOGYErc7H+vGdl2R8t0QqAO9hB0KCV0UGHQPo+s1TLNdJM2rYPY0L ibVDpxaDLMI4Awhc/aFlXAW+mrFk17qy1Hagt/CF/srdnSzHx5RF5ztiND+hHVV1HH5B DgQpW0e263So9qtAlf0Pw2ZF2iBtB5x1LvqUOPiRiah0C1zvRYhVSiSNNVe75X9a3U6S entMt2bYPndE1hdaxYCHhRFg91wz0rAH48Rlu0arV8htDSUO8Z+f3RsvMf6oZOwjupg8 Ss5VYd1JzJ/lcvkeCjUFDDb/OmBA4dH+HFb4C2m6tDu0vkazEMGZYOwSXd2S7IQBVzcB l8RQ== X-Gm-Message-State: AOJu0YwA4pEM0/2w7cxvdME/ojmeIhy7HyhGNYKql9Ezk5/kjSVcyIp5 X/iXky02imUCuo4rO3bcdjtRscd4A41swjiouBD5KqHbBFTChvVV7fpBMNwkHK8GNZOXc3DvI8E o X-Received: by 2002:a05:6808:3c8d:b0:3c1:8066:7531 with SMTP id gs13-20020a0568083c8d00b003c180667531mr4725912oib.26.1709334621827; Fri, 01 Mar 2024 15:10:21 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id c2-20020a634e02000000b005e438fe702dsm3449407pgb.65.2024.03.01.15.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:10:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 40/60] linux-user: Use do_munmap for target_mmap failure Date: Fri, 1 Mar 2024 13:05:59 -1000 Message-Id: <20240301230619.661008-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301230619.661008-1-richard.henderson@linaro.org> References: <20240301230619.661008-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For the cases for which the host mmap succeeds, but does not yield the desired address, use do_munmap to restore the reserved_va memory reservation. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- linux-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8ebcca4444..cbcd31e941 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -326,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong last, flags | MAP_ANONYMOUS, -1, 0); if (p != host_start) { if (p != MAP_FAILED) { - munmap(p, host_page_size); + do_munmap(p, host_page_size); errno = EEXIST; } return false; @@ -622,7 +622,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, p = mmap(g2h_untagged(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); if (p == MAP_FAILED) { - munmap(g2h_untagged(start), host_len); + do_munmap(g2h_untagged(start), host_len); return -1; } host_start += offset - host_offset; @@ -735,7 +735,7 @@ static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, flags, fd, offset1); if (p != want_p) { if (p != MAP_FAILED) { - munmap(p, len1); + do_munmap(p, len1); errno = EEXIST; } return -1;