From patchwork Sat Jul 15 13:52:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 703245 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp158827wrt; Sat, 15 Jul 2023 07:00:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlHP9ZPXog6m/yBJUjrKSJdhdeWfFB6HFqjTQXJd0sqSc6EzbK//4SKZgy6gtSdyvorKnAVK X-Received: by 2002:ac8:7c44:0:b0:403:be5e:9ce7 with SMTP id o4-20020ac87c44000000b00403be5e9ce7mr10026435qtv.64.1689429606815; Sat, 15 Jul 2023 07:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689429606; cv=none; d=google.com; s=arc-20160816; b=B+fvDDMW5BxRqe+ec1s8XOF/S0tllM7/svEh/BG9K8P1WZrTlmoRpyWqo1Xrucvz9r mcc89rpyOz3qcbE83Qsvb2SnPCwdCvniJgVH31y2xlBNBqMcr5Mwxm7YFJymizmUdEqv bG/PUdP93QSV/h/SbsW4x+w3B62Kea4MJz/OW/i7TEvtYJgxXf5aEun7zeI72Of0OTLs Zald2bDYd8FVPri57ywsQRr18EZBQ0wQKuUA/25+hzqMmuDfkTmM3+jHWbwJewo4cvnD oTsPr1Fyb6ieVfhSlyQO0ag3KoWg9DdGi7gc7FUqr3F35hYdOJ7KEzhGuy9XdVU92jjV ekRg== 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=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; fh=ZuLSLtzpwbOj79Lm6HQkAzCl7AYBeBRT4Q/1zeFcrQg=; b=VjZUAlXxSDxKIV0zEAjJwPO/nL+/YEGJxwtbf+DplCKDse0+fHouTE7YWOrRU8Fxr4 9kga0kvYW5lpLrVY789b0grlYABo6UTZ+D2CQjdRdXNG32rUTT1fBmtb8WET2MGrhk7B 5/ulct0hMVTeVqHhIxK6H+VanxYcpO0bzhnpG6amUdb0zcv5WpL+A/wScQ0noD6E/+9K 8cRzN+g2zeFyfU0enNQO8vPQQIFG/1Sm4ta0h8gKW3shHwli45hs6pN5YEq5ifnEz5xE 3E+jL8Y//rp84IlNozvY9Key9g1OTZGdVNBhJNNj+Ei3j9hELMOnjevLI0JfxdVa+C7B 4JKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pnld6Wn9; 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 z26-20020a0c8f1a000000b006377ab7c9edsi5835099qvd.508.2023.07.15.07.00.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jul 2023 07:00:06 -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=pnld6Wn9; 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 1qKfjj-0006WQ-LP; Sat, 15 Jul 2023 09:55:04 -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 1qKfiR-000466-4Y for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:47 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKfiP-0001Is-LZ for qemu-devel@nongnu.org; Sat, 15 Jul 2023 09:53:42 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-307d58b3efbso2971675f8f.0 for ; Sat, 15 Jul 2023 06:53:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689429220; x=1692021220; 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=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; b=pnld6Wn9wt7S295hr6wOEUse81Ubsg6JhK81XigM8Ow7P/8V3lj46tf0gVRZZwlBle dvpp8c9bZBagQspOOc+jTqzII+CiVY7L4SI/qWq0+Md6ROon/6B1np7zXF9yAbcJEVg0 gCiEGEZpdKddUyy2gMYeHKIxlVC84gy73CcJZ2Pye01k2SfsTAa2UAkTIBHVdLP+STP8 7Fpv7Xz7t00IyJWpsLzHO69iLmP14aiDpFN5fdKDT5oImTfE49a0m+CEdV0C717vwvMA O3I+Qr/l5BOhLIKp+eaI1bviY6woyegSbxcuWfB04t4umgq5a23pGXYko+mixy7sL/29 uNPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689429220; x=1692021220; 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=viFchcHGsP+nKMHrpwcA4jNmykwjrSvjDrmv/nDVIvw=; b=B/kboN6ISWH3OpC+HMa8/9UnelDTYZLEXWwk5RRtuZco2UnxRmAkLjBumKkc0gdJL8 szvdTcyFdq8+c3GSTnrJmnMJM0IH8rwZUFPYySnF/c6NMNILukn27+oE+P756uTqdLde M/3LOy+siIqCnMHiuMuXZ5prrTs4yiZkaXmaGBP9Av5BaXHYPKJNYtWzvSiVA6XOZJr3 8a/1gNccIqXKSd+ZkmB/QLiIZASmajSA7pjWtN9Ys+bRQfTV/5vdzICghIYJWkOXupID gaBkMUjBJaOfp8pMMCUSAL3/HRl0EVGuJYcYK2ka/Bry0gSDvamnOvuykaz3rZTT3pb+ WWsw== X-Gm-Message-State: ABy/qLbgqsqoyLSmYUmGAs7/m6OuGIsAK8NuFud+cIgrX0viS6St6E9+ awuwMgi4eWx5ABzBDRDNodocJrGU2W528Y1OojTYhQ== X-Received: by 2002:adf:d84e:0:b0:313:f6bb:ec2b with SMTP id k14-20020adfd84e000000b00313f6bbec2bmr5756555wrl.47.1689429220394; Sat, 15 Jul 2023 06:53:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 06:53:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 26/47] accel/tcg: Introduce page_check_range_empty Date: Sat, 15 Jul 2023 14:52:56 +0100 Message-Id: <20230715135317.7219-27-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::42b; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42b.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 Examine the interval tree to validate that a region has no existing mappings. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20230707204054.8792-10-richard.henderson@linaro.org> --- include/exec/cpu-all.h | 12 ++++++++++++ accel/tcg/user-exec.c | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 472fe9ad9c..94f828b109 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -224,6 +224,18 @@ void page_set_flags(target_ulong start, target_ulong last, int flags); void page_reset_target_data(target_ulong start, target_ulong last); int page_check_range(target_ulong start, target_ulong len, int flags); +/** + * page_check_range_empty: + * @start: first byte of range + * @last: last byte of range + * Context: holding mmap lock + * + * Return true if the entire range [@start, @last] is unmapped. + * The memory lock must be held so that the caller will can ensure + * the result stays true until a new mapping can be installed. + */ +bool page_check_range_empty(target_ulong start, target_ulong last); + /** * page_get_target_data(address) * @address: guest virtual address diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index d95b875a6a..ab684a3ea2 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -598,6 +598,13 @@ int page_check_range(target_ulong start, target_ulong len, int flags) return ret; } +bool page_check_range_empty(target_ulong start, target_ulong last) +{ + assert(last >= start); + assert_memory_lock(); + return pageflags_find(start, last) == NULL; +} + void page_protect(tb_page_addr_t address) { PageFlagsNode *p;