From patchwork Sat Jul 15 13:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703217 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp157145wrt; Sat, 15 Jul 2023 06:55:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEEYvOezDCn13xF+cxI019VO1W82Itl5GL5dREyYzOA9STrXZ32n5uhoo5aX3YW+AWjacMF X-Received: by 2002:ac8:5a8e:0:b0:403:3583:68eb with SMTP id c14-20020ac85a8e000000b00403358368ebmr8713887qtc.19.1689429331271; Sat, 15 Jul 2023 06:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429331; cv=none; d=google.com; s=arc-20160816; b=s35TwGnzZwBm1piFH1uaSZe3wm2BBB4aD8YKjzPIrrUDHST0iI/AudjsxJIygxBmp2 ySxJeaUHzM3w9sdtHI2jPjJ1iWrRTma/DYpiNs6ToGAAdS6zQb/ySGof5inI0SjQixx1 HHO8UmIpRbir0J00SLLR5MICxnCspN7SFlQRw2rRCbm5XncHCBY+U+uEB01IES4hKt5E lOd6g3JQN1WcT/RcbQhQkb/0p2dv9SwKMYMYyzz0/dejuocUwWjS3UFRCGJhHuULZi8t HmUbgh80sN9QwWcha0JJzFAj53fbmiNR34X7wB0nqYp5n4qRTBaj7MnraoRg9X0ZD6GB Mmbg== 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=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; fh=n5QY4Tpv4/lI7qJJHJjODuMehB6ug+e1S/4zpncWpMY=; b=lZZd70nfJy274h4hv95lmdVlMvrkxPIT9nRJz4ELzEFPaSqcfqb7SgJRYlqOE/5vTc u74LSi0ZxmDbjWOraGXCWOJai0WGJ91sR6P+1i9z7xSDpu0jRvVkHCzn9d5rFUF71OAu 2ldbfmvt9Q33oGIgBK53o4g4Dh2y3hv84N9eJwSAGJGvRix94t1qGfKyzFXqKbvpmxJ8 9bKCYKZ9L75WHUeZ0W8+zOLbkNUBAOgwiUlMOg7OouOWAqx0BUJLMXqnQHJIOsjDKGLX qwvxEBG/BK/c+zd/jgHsF3VrA0ODTjqZQH1/cTChmKvzasO4Q60ry3l1zMGdVXrhyGC6 cvTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HYaI6atZ; 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 u13-20020a05622a010d00b00403a3001308si5924940qtw.197.2023.07.15.06.55.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 06:55:31 -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=HYaI6atZ; 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 1qKfiz-0004Wq-Ox; Sat, 15 Jul 2023 09:54:18 -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 1qKfiX-00047o-QE for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:51 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKfiR-0001JA-PL for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:48 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fb7589b187so4758393e87.1 for ; Sat, 15 Jul 2023 06:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429221; x=1692021221; 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=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; b=HYaI6atZuOFWX/lNaR6czwKdnlIwNyXfftQGPYPTeXRgBrO+uCJoalpekxMHGszfqd 4kRTOmZssF4JQALW+Io1TFHfV0JMaI+r+/nW0KmOnACvnS4zPzSBJQJhaGPdv8RroUcp 4CH/jZZ4M0bot94PE98thNMfJ4YnHXhSKanfIp/0oQ55lWhgQ+btCaMAd0I1PunaEzsk nNINaAQVJpmzFE178OFg7mu1qgbQHijHui+ney+PbiLeFeejdU83k6h4V5+GAl31zxa1 lVQwPTOaivdJJdyq8/f0BrVwRxC6ExI0zE23UhIMLU7MqEBR4YFvlYp+JgiEDv9TTaOR TsiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429221; x=1692021221; 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=ZraICE1rSSuyJwFU+r8vOCOFS1v3NI7u5DpDqpVSLj4=; b=DTWlpSSYnb69HakhUW2TKj4zuvy8u6jQjnLzXQV2mcsWdJKg/CeYpd0Ke5U8ulGju6 CuPkCPAKcIN/V4yRFxv0wm48ZW1KJUhcpt394DVgi96WUNP1VreRKs+juQJ+azvKb2J3 Yrir3MjZX/BXjMR7dkG19C+CgwN0ADiewJ52KbNPo1vqGVdR/BxyrnSI3zaCAzsaYRdu Y4ZEQF9/LFG8taWX03eL/0BHDmMhBGdf65jAdtCoCDN/fl3g+GWtgn3mM1rWYN7owyF6 M/H0zI54chk/sKmeUMJz2Tmma5zHG6bUsS/K78Mdwq+OEUpnv7N72IuLUvwH/mSya1CW lcCQ== X-Gm-Message-State: ABy/qLYfeOmvf4l2xGi6fSa5BgIncto0JpQFOrq8AbYzgAPr5E3qFD3k foLs+nS8Dl6IMpl4RdpLgXndfFaRX6orrneapwRRTg== X-Received: by 2002:a05:6512:45a:b0:4f8:5696:6bbc with SMTP id y26-20020a056512045a00b004f856966bbcmr4467263lfk.29.1689429221141; Sat, 15 Jul 2023 06:53:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:53:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans Subject: [PULL 27/47] bsd-user: Use page_check_range_empty for MAP_EXCL Date: Sat, 15 Jul 2023 14:52:57 +0100 Message-Id: <20230715135317.7219-28-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::12b; envelope-from=richard.henderson@linaro.org; helo=mail-lf1-x12b.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 Message-Id: <20230707204054.8792-11-richard.henderson@linaro.org> --- 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; }