From patchwork Fri Jul 7 20:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700053 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4066027wrs; Fri, 7 Jul 2023 13:44:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlENSQDCDuoNGDr45A4J2/lSTtrBXhxjach8k3icd0ojrT9DBQncodghZaZTkOgRgOCP6nEO X-Received: by 2002:a1f:3fca:0:b0:47e:672e:304c with SMTP id m193-20020a1f3fca000000b0047e672e304cmr4816722vka.4.1688762657759; Fri, 07 Jul 2023 13:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688762657; cv=none; d=google.com; s=arc-20160816; b=HW4C4RXE4g0pqF37qM08cI9uW9gaTOJQB4EAGoeQzin5CZw/+55Rb7TzV6fcd8twT7 2MrO4XJzn/V//DL833+BZ9viFOFW8eM1x7rAkBwhPMYiy8NCZqiqFCEGiaF82dV9AuEA j5jKOfRGLCJ5x2IIaFrPYOsPHgGwtcMCra3cX9SjJyiAs409S+vWNtDinFgRcbitkaer xA9zgCB5fF5OxfIoIC9bQkV2V7l24Q6tueBGchGJ0cTlpnmbC1e8O094N/QrenqWiSLj BkbQk18KFPfIzPoF2n2bBec1diDNHuEUE9cHvAJr12JV+uA/oh6t2d341OrHycBi9FOL ZTzA== 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=RSslPOCtrCKSd7/qnt5s8BU5QI6BNVbM4GALvEx3wRA=; fh=jVqwU2n6uDjg7kXqsBiuuwMdTrtXxwX52l5dkNb4FWE=; b=Lzz8o49r7+zjv+bzzwx0zJTafOvwy0ddRoAkatB23VCKrBArWZOxDhrHS32c5QUhvW b7BdKnEn/BgxlOqbkMsNO9QE9eV6JZIaNa4OTZZxOK9uAAPCcGmQh2HVI9q/afTUha3O cJwpADzUMjH3yy0pts/08Y9+/EzIIxw2s0BusG7IIs/9hevW/aitwkVQr9kXoyoQUXJK F6LV3HKqZKkUbzZbziihdIpqFm693R7MBfN1ArJga81LQq6Q2JJHhZ/paOOS4KDHhL26 wJBmCaZ9KgF8O3BsVjtWeQmGdCllK3iz9ZjEk5zfz/y2CP5RVIVhZoPdJPDYmfPbqAPQ 7+bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dh+xFwKl; 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 i17-20020a0cf391000000b0061964c0b8ddsi3105734qvk.12.2023.07.07.13.44.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jul 2023 13:44:17 -0700 (PDT) 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=Dh+xFwKl; 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 1qHsGc-000516-8I; Fri, 07 Jul 2023 16:41:26 -0400 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 1qHsGP-0004qI-Oe for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:13 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHsGN-0004qX-Sh for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:13 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fbca8935bfso25738385e9.3 for ; Fri, 07 Jul 2023 13:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762470; x=1691354470; 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=RSslPOCtrCKSd7/qnt5s8BU5QI6BNVbM4GALvEx3wRA=; b=Dh+xFwKlUvBRt4/Q+YLBkxEuTJnw2WmaPoAOr9RVl3xweMDf0YZErCpnq19FJ2/Z2c lXfq69IG8FcRqQpEjuXVl8RK8zKmQNjeJUeFP3Irfg3Hf633eeWaSe20wFZHOlExvxfd DN6PG24bcdtokPSHZl0fNGomfWCQuvHo8fNoARgKRWp/G3k8xU+wkAgdABQ3aYCAko4l HIS9COBxXShLrSMlUCEMQjtoCiNHpG4qI9tPyHhCyJ0PC8U7FpcTMF1dN5kquWApoGSl 9BBT8gDRxepEFAm6KLK/WZHGZMktpmyqWtHMb2t9qQjZYjPQA++Ckgx7qjnIWt4D3MiZ 7bJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762470; x=1691354470; 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=RSslPOCtrCKSd7/qnt5s8BU5QI6BNVbM4GALvEx3wRA=; b=KjTlAtWGUJghyIfeNVVleJ95B5IO0cxtNFRwHKKQc1udtKkfHw2vim3WWoWMngREtO KU4DwPfeEBpbo2fQYxe8yT01X3Ab4iu5UzqSpTgDHa6vZhn97Tw3VxMAcHgtTTe2oxOm rzELBNhHIcPyZBf2A55SQJMgcB1Lrt7NKVdATmxfvVDO48mFX7XuNaViirbCcBkYlXOo Fe4HgtoTNd2YX2lS6aNAeLHjr+zK9C4eb6+fofVLBxRvLIGfkQVEUirubrptF+L8+ing Ui1y700Qcxw+U7AyJffmQeq86Zdg98ix9tgp11cOEzjiqkNWTFOxyOHIbrAzQ7yCiT4E IGhA== X-Gm-Message-State: ABy/qLZ4y5KFcKiOtaUvX2tsJjxsc0F0eg7LzZY6Ha4JFQ/IrY+6VuFP iFpHRZ9OlzIiPrNylSdgJ4yQkQrb1bnpdvH75/3QIg== X-Received: by 2002:a7b:c3d7:0:b0:3fb:a6ee:4cec with SMTP id t23-20020a7bc3d7000000b003fba6ee4cecmr4499609wmj.33.1688762470660; Fri, 07 Jul 2023 13:41:10 -0700 (PDT) Received: from localhost.localdomain (host-92-23-208-66.as13285.net. [92.23.208.66]) by smtp.gmail.com with ESMTPSA id q10-20020a1ce90a000000b003fbb25da65bsm3337736wmc.30.2023.07.07.13.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:41:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, mjt@tls.msk.ru Subject: [PATCH v2 20/24] linux-user: Simplify target_munmap Date: Fri, 7 Jul 2023 21:40:50 +0100 Message-Id: <20230707204054.8792-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707204054.8792-1-richard.henderson@linaro.org> References: <20230707204054.8792-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 All of the guest to host page adjustment is handled by mmap_reserve_or_unmap; there is no need to duplicate that. There are no failure modes for munmap after alignment and guest address range have been validated. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8c90a690dd..e6463ecd8d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -789,9 +789,6 @@ static void mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) int target_munmap(abi_ulong start, abi_ulong len) { - abi_ulong end, real_start, real_end, addr; - int prot, ret; - trace_target_munmap(start, len); if (start & ~TARGET_PAGE_MASK) { @@ -803,47 +800,11 @@ int target_munmap(abi_ulong start, abi_ulong len) } mmap_lock(); - end = start + len; - real_start = start & qemu_host_page_mask; - real_end = HOST_PAGE_ALIGN(end); - - if (start > real_start) { - /* handle host page containing start */ - prot = 0; - for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - if (real_end == real_start + qemu_host_page_size) { - for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - end = real_end; - } - if (prot != 0) { - real_start += qemu_host_page_size; - } - } - if (end < real_end) { - prot = 0; - for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { - prot |= page_get_flags(addr); - } - if (prot != 0) { - real_end -= qemu_host_page_size; - } - } - - ret = 0; - /* unmap what we can */ - if (real_start < real_end) { - mmap_reserve_or_unmap(real_start, real_end - real_start); - } - - if (ret == 0) { - page_set_flags(start, start + len - 1, 0); - } + mmap_reserve_or_unmap(start, len); + page_set_flags(start, start + len - 1, 0); mmap_unlock(); - return ret; + + return 0; } abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,