From patchwork Fri Jul 7 20:40:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700043 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4065406wrs; Fri, 7 Jul 2023 13:42:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5EC/qi5xQ99SP4Qj+x9W8hT9gU1R/l4aAIhiNUrAbke6V7g93NuYSyJHvHFjoOeqShR4T X-Received: by 2002:a0c:e108:0:b0:628:6879:ee48 with SMTP id w8-20020a0ce108000000b006286879ee48mr5434267qvk.50.1688762543687; Fri, 07 Jul 2023 13:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688762543; cv=none; d=google.com; s=arc-20160816; b=OyzhONbiRVlw+rhmdRBASlz/Gez6yluCL2FYNnqOpaTBLKKzYjgrsghF9LS2QlcdCO axHUyGHojkIlxwS+MS9OoDE08JWgkPOS5yVD/fIHzbbjTmtkcNxh1ksiijuuOf/58ZVG UsYtxS06EBzh8iQCgXDWpl4EskdjOBM9CkF187l2zdw2J74VBwQlHm1sr3XoKS1MmNhC THiFLkhJh8CuScP/Kvyr7fsOp4iI3pq15tf64LJMCn3vUczY2b7v4ydiILcDI67bZ9VI Yd15h3YH3xMn0f3MFvTtzJVYL3xOo+skkE33Lxb99koldx2uKqmxO35+OwJz1d19r83s FM3A== 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=QWcGYI7xB8LlKTPPYJbQ3MPkeMAscTRkJ+piG/iDAy8=; fh=c5yfIwOUC8JO1RlChQuc3YChZ5JSRT1D/lDsc4eQOLI=; b=x5TXnfopoZJmFXppe1RpilbbSROWmTnuO21w9fWPcnCke1Nnhi0tt59QDGlzcCuWRN unpNRPEcfx8Qxykj3HJf7BBuOv3U0m1q3lOuSX5/US3qjw7CzkXrZwYeGcLctvmwrlBB jbib7I25N+5jnIzuYyxSg9aLwhMZTP6GRSlLHbWrVhOmTTITy2ZMcIMmLOirBCZR74y9 Dhdo5e4M0qgOdEeTHVoLtmTGyLDtzamwYK4XeFs6lY3Bno3nRt7TVT8+czQ4suRNwJvv m9KqmF5uohXFgEAcToRtYCTQegljYgFN2oyrNI/a4CLqkufipDUZlh8YR1sQ1B5/I/SS McrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kgLd9JZg; 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 e13-20020a0ce3cd000000b00636f4bbef27si3164721qvl.193.2023.07.07.13.42.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jul 2023 13:42:23 -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=kgLd9JZg; 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 1qHsGM-0004o3-6s; Fri, 07 Jul 2023 16:41:10 -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 1qHsGK-0004nR-ML for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:08 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHsGG-0004g8-Ro for qemu-devel@nongnu.org; Fri, 07 Jul 2023 16:41:08 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f76a0a19d4so3614421e87.2 for ; Fri, 07 Jul 2023 13:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688762463; x=1691354463; 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=QWcGYI7xB8LlKTPPYJbQ3MPkeMAscTRkJ+piG/iDAy8=; b=kgLd9JZgzUCnBaWwYIHeSliIdqz/CKARNj85jImEDDcsHeY0pgtIW7ztsTJ0HGyNcN 3clYBcy+0OZjalk998XWFASrSjp3abW4rwS7y3S4R2b0qN6FWOxmalGJTintaRw0RnPG kHvJDrR/eO15Q8h93eztPsNlg4Qqsr4FKX72T+gSqpVxwatto76A189TqhpleV5+/q6n MDFl/OUUtEwgcjq++8UvajWgQkkhnLa2eralseRgVwySLsFyuUN1fKa1OPIaUovEpcR+ DG7PmQ/qfxBic6aeiYMY6IrkYifAQ5tf96IgTHQPzR3FrAGNvi6Nvm53FyvOy4uL8LuJ 5ClQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688762463; x=1691354463; 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=QWcGYI7xB8LlKTPPYJbQ3MPkeMAscTRkJ+piG/iDAy8=; b=HpsNav8kOVWj/jsBdflaO5VtlVKq01RpAcRc4FvzcSlpqKS7vOwS7lA22kbD0KGksE 6n6ddlSmJ7RAzMiQEQBI/1sI0av2maU2acHNfBQq6YNth2MR22IGJQqunUDMsi1IVLLn PqTcD+iZCVWz7Pk0LhgaOGGWKFr1GQDaLEsv0tFhqpUx0mWbZylJZVBQuRQXuxtNHFZD Yy/nmEpIHanG8IZ1NrOqWlkAV6VojLLBK5HsZ4jUZ0VMkVP/8frHIdH266SH52q/G7xa 16vBn8QImuQCtr3LRrx9uel4FGzqtNmEj4aEdrdG6O/rwc1yj0qWD1/Qp6+gf7xw+MLn lEHA== X-Gm-Message-State: ABy/qLbM/E/yynev8LtAeADtEXES+lp6mTZXNlf9D0fMQblhpPPP8/F3 ErBXUs/WFnJs8z3LOZY0WZpFyBNfGRAl4xcZakrGdA== X-Received: by 2002:a05:6512:3b83:b0:4f6:45af:70b8 with SMTP id g3-20020a0565123b8300b004f645af70b8mr5412257lfv.58.1688762463004; Fri, 07 Jul 2023 13:41:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 13:41:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, mjt@tls.msk.ru, Warner Losh , Kyle Evans Subject: [PATCH v2 08/24] bsd-user: Use page_check_range_empty for MAP_EXCL Date: Fri, 7 Jul 2023 21:40:38 +0100 Message-Id: <20230707204054.8792-11-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::133; envelope-from=richard.henderson@linaro.org; helo=mail-lf1-x133.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 The previous check returned -1 when any page within [start, start+len) is unmapped, not when all are unmapped. Cc: Warner Losh Cc: Kyle Evans Signed-off-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 565b9f97ed..07b5b8055e 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -609,7 +609,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } /* Reject the mapping if any page within the range is mapped */ - if ((flags & MAP_EXCL) && page_check_range(start, len, 0) < 0) { + if ((flags & MAP_EXCL) && !page_check_range_empty(start, end - 1)) { errno = EINVAL; goto fail; }