From patchwork Sun Jul 9 18:29:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700914 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4830133wrs; Sun, 9 Jul 2023 11:42:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVT8y2cSh+MSZnb+2J8JpT8fDE6iv3E/yXXBtCDksW/n9bvDhXMXgszo9gNZFYoFlpya+2 X-Received: by 2002:a0c:f443:0:b0:636:668e:7e6e with SMTP id h3-20020a0cf443000000b00636668e7e6emr8023673qvm.45.1688928169707; Sun, 09 Jul 2023 11:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688928169; cv=none; d=google.com; s=arc-20160816; b=NzEdDiis9ok6TDiggkRgWksifvYowAXsaWb0Q2CBmqzytbzRmp4LuXLP7qP/gkKjfY tj9llT2cMoy8qapZkl02P8079WnxnbPjltvMQyaZnm+a+kuMdfUh4bZhCm9Os0SkN2pq jKzMQa4fOa/7cn5Bg01PJih5Yad6+1iEs2s4i5vPJomToEVhehJ0HoCNm7VYVURxUl0y dLE/bxQDelPo4tnJuGC0cLUFIT5OkCnM+8b2KgoGympT/JeRk75tgWnMPJ0uNuqCBo0x qeQnySUlUv77lOmVFyfwMWPreOzEu0tvBcGtWmaUnsBVaqEK/z9OScism8B37AvbYXiI 1o+Q== 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=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; fh=4nfr0hkxlMpWE4oToQ1q4rzQVecv6te3cGVRc3YFjiI=; b=Y1VKruq1CkrIB2bpscMIkWSSU6+xOpMDecp0ktmURfHWEPwacX3Ub0mhzHCbfkR8/l p93vBGpMLVfYskF21gsRbJFYDeIrCPXCaLcy5LfQqckdBrI48UkLMX9Y2Bp3iclQMlbw wmEV9IG7YkuNhVIyF4/d2CPEBez1h3pxslKIsCiXX2sJ4DejnHPuLnOX1t9t1uUl4+TY NYPZW5auHCVspvfBTmdR6esBrgwFy4HAWUX31V8LRk9FPKixklJYBLUK3UTXzyRS/oP6 T6vaduD5FApK7F6U8Q85B8+Xz/rOPO8i9p1+KNtj3WhPT2sBV3rTDXU7aMRWZImZr4AL 2eFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="POT/JoZr"; 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 s5-20020a05620a030500b00763978e06f7si5014118qkm.384.2023.07.09.11.42.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:42:49 -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="POT/JoZr"; 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 1qIZHI-0003tU-Ri; Sun, 09 Jul 2023 14:37:00 -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 1qIZH7-0003pg-Iw for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:50 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZH4-00051j-BJ for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:36:47 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbc0609cd6so37270055e9.1 for ; Sun, 09 Jul 2023 11:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927805; x=1691519805; 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=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; b=POT/JoZrzkE6XvE3VWyv+BKAhZKWkHqbLjOAKAE/ZZ+pmGDcLSUgUevY47h8+fWOCT 4YWh71Gps1pvOn8bEnzbGXPif1FtW79MkyyAq0wIzCUD+gFSwNgsHIZZKHTOngK7mA4g 5xPjlJHOE2T5KVLyyb98R11yOnOTs7Yvbp0piYORFE1sw3qUvljXWl3l3IAstCGchzhI tNMwU5TEUkH/cSA7w71MJgg6eaWaApan25AAh6Z4F7UCLsNhBtE7LQJjCmtVm45Jvg4C qBR4b/vG+dHg7tTph6cV+zKJU935jJNz9MQ6RgsP/MnPSNfCyDDbNKCdfWAaZxkPbep+ PUUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927805; x=1691519805; 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=vXDNUHkoHKMJOTYkZxcm9eNGIwvNIgvNekBczYJkm1c=; b=G+grdaF63CLkeOKlxzRTlvMcWJruDFyKPkPnAaSMSiFhdKAoKwxvfzpuczJ1b49mGo Mrl82LhKlXTpWf7z8PjzNdq/aKYBv6EJST2NH/jT++0hfq9Fg6pzciNgUPM5JSaTY2oL 6EaHzEsLoytaSPy96hGYE9IxtD6bZTIKmTJof6+qnBrLvKR3pM3RubfWppae9yEhIk2y uI5GoBKGLJneHRK6ja5M9GvCcvoghXGKJrmgSD6yrQl6hrbVcThiWnFYKNSuP1JL6r/7 cDqeqY5V42hSriGIEcVativGV/G+xY8o4QGvoWIE/xKox6W8jbhq/hNrgBNWimxkeiAG NiAw== X-Gm-Message-State: ABy/qLZPFQUlVu9iVayyqC9Z/PP6J1LDrH6RD8/fSH8wnLW9TI6EhoV4 TxHCG++PUdflCBiE4UGEefLBEezG7xa3/ING+Xhm6Q== X-Received: by 2002:a05:600c:286:b0:3fc:4e0:be97 with SMTP id 6-20020a05600c028600b003fc04e0be97mr2790670wmk.6.1688927804950; Sun, 09 Jul 2023 11:36:44 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id i6-20020a5d6306000000b00313de682eb3sm9735832wru.65.2023.07.09.11.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:36:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 43/45] linux-user: Simplify target_madvise Date: Sun, 9 Jul 2023 19:29:32 +0100 Message-Id: <20230709182934.309468-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32b.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 trivial length 0 check can be moved up, simplifying some of the other cases. The end < start test is handled by guest_range_valid_untagged. Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-27-richard.henderson@linaro.org> --- linux-user/mmap.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 49cfa873e0..44b53bd446 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -900,28 +900,17 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) { - abi_ulong len, end; + abi_ulong len; int ret = 0; if (start & ~TARGET_PAGE_MASK) { return -TARGET_EINVAL; } - len = TARGET_PAGE_ALIGN(len_in); - - if (len_in && !len) { - return -TARGET_EINVAL; - } - - end = start + len; - if (end < start) { - return -TARGET_EINVAL; - } - - if (end == start) { + if (len_in == 0) { return 0; } - - if (!guest_range_valid_untagged(start, len)) { + len = TARGET_PAGE_ALIGN(len_in); + if (len == 0 || !guest_range_valid_untagged(start, len)) { return -TARGET_EINVAL; }