From patchwork Sat Jul 15 13:53:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703218 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp157210wrt; Sat, 15 Jul 2023 06:55:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMQsebMfnfHnN4Bwj8rZ475fkzDKKQUnhNIaqEMkWTZvqIRIm0eNIbXArWbCi4p565x1Sf X-Received: by 2002:a0c:b25c:0:b0:635:e2c1:99e9 with SMTP id k28-20020a0cb25c000000b00635e2c199e9mr5712487qve.17.1689429341750; Sat, 15 Jul 2023 06:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429341; cv=none; d=google.com; s=arc-20160816; b=qubVOY+Dn3Mxe52Kg2wM4Ysdxj5Dm7I61SHnW+RykYzE5TtVqOjWjKfHKTo7Qh9E/P TkxHqLLpEL/kOhsYTQqHThxb2apdzHntzJi8KiMAeKXXZKtommLf/OdmbyMMypRMP+DD 5l9EkftiuNAblFRCgAkJ5jBMcBM9UsjS3Uq6qV1OOfovc92vcneTM9q8RGBwlVORjud/ 9aViZq2X2AUeq2mlZkegC+nV+913APyR+3IqxVeiHljnNZ7bMRUlxagoft7zO9CEqT6d 6GHbHRjIL5o96RIPmNNcJeMDUOMblcdHAyaGsUzwwx0r/iXTA8r0xyS/VayI81YGzYcy 7CtA== 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:to:from :dkim-signature; bh=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=QSI8nNI8McOvT3lrtsIG5fBB4xER8QOC9s1eVs7MhBP8RsDZcmVj7MsNJMynE5C0a0 fKoULb2cmHIafy01T5f3qtwsuXhbt86UuAik4NPmFnsFgJPptxFdfK/iJb/coi+Nf3h0 3Vy5YqcQFxPPg65YgstJXJoriihp6ZWoeip2N0RU0ZPhxQarCDhuAA00CBevxRLJ15YE 2QTGJq49ogEwwXNxUvTITdWSEOVZ4BcY4IULl3UEhFORzzKitDKkYw1MC2gyOlo7X3He Y2uq0EpAySPDoFmMZiKewocIYThNtfE/ztyJ1EMnSdsaBcOwGjiu0froEGB2GnCkl2Jl qjEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="N/4R3GDo"; 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 w14-20020a0cdf8e000000b006366264487bsi5885360qvl.359.2023.07.15.06.55.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 06:55:41 -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="N/4R3GDo"; 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 1qKfjX-0005g9-DI; Sat, 15 Jul 2023 09:54:51 -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 1qKfid-00049A-TC for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:59 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKfiZ-0001LE-Pq for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:54 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3143b88faebso3164980f8f.3 for ; Sat, 15 Jul 2023 06:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429229; x=1692021229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; b=N/4R3GDos6flYUkfDXuuINj+MwWeqSLkmO5dPE6Qw/ip5eF2hKewx4fUpm0D+RT+FI El4+RwMrBc0aBICbCRZyF7VOkipYBfN1KcdYSWRJL6pX5DQjxlgrv+mYxvwoMAG5Pxpd zaVl3udtP82F/HdLFvgWCWPP1S/2laQ4X22wzLsIOOFA6AE+M6c3/gO5qAWQwEB1/GM/ h/kWjKJWeqm2lHKXNT17rud7xFjPiJXMGV1aSVEsAWekmT8Moy+HdAFYSe9rmJ58L7U+ 86LGEmXBdDannawlg68H3OiYgVFpg/3Os9CKqDuIz+RjKqDgZKcOYT9OEAU3PB2UaQ+Q /Kmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429229; x=1692021229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t83L6VQqehKor298fA996V/rrvqxT+XEe+3FbTWkw4k=; b=KzLNTD7h6d9pnEzLyKPwHjNBAQUkoAHT7/g+jGquy6S7E2T8nK5ATFM4Zlpnws5dlu OQZ97LDgu3eXKtohzqo4w+CVqm7n3P2c3uRVwRhwO+u6PYquWIHj8bi8BBr9MNw/W+5i Bfgznxv7AeJepG9tvAtgSMzIVdWridrLDy4bAiWr2m1AJ2qEeH+AIPWgD2znq/bfhqjM YoZtFYzBehwahv0EfM2eD4bmaN3Lmb3nErwMUPKZx16SwmQCTqLRoEzyimkWqJVXnuX6 Dp23RgluYn8Ta6No70SoJiRsZkqg2BMr8VT8oxy69n/xGERANanXEPJrZtMkR2uH1BzF aZ3Q== X-Gm-Message-State: ABy/qLav4yV0Qmgv6y1ZzUMSeKl0f/agXGgYQVgfDOil6p4fWtMIkjzb 0ASMTwW3JSn97llDXOK6cFxSZqqu7DLgSq5hWTX7UA== X-Received: by 2002:a5d:4844:0:b0:314:10d6:8910 with SMTP id n4-20020a5d4844000000b0031410d68910mr6581195wrs.63.1689429229392; Sat, 15 Jul 2023 06:53:49 -0700 (PDT) Received: from stoup.lan ([51.219.12.49]) by smtp.gmail.com with ESMTPSA id k10-20020a5d66ca000000b00313f9085119sm13838014wrw.113.2023.07.15.06.53.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:53:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 39/47] linux-user: Simplify target_munmap Date: Sat, 15 Jul 2023 14:53:09 +0100 Message-Id: <20230715135317.7219-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715135317.7219-1-richard.henderson@linaro.org> References: <20230715135317.7219-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.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 Message-Id: <20230707204054.8792-23-richard.henderson@linaro.org> --- 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 22c2869be8..c0946322fb 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,