From patchwork Fri Jun 30 13:21:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 697945 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp451552wrs; Fri, 30 Jun 2023 06:25:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNdQUbGHjv5hkJh7o8Oy9cpPSM3Opdho9TWT2214xX1fcGZv2J2zIYL1qX4rtpyN7xH9fo X-Received: by 2002:a05:6214:2a8d:b0:626:29d4:9a26 with SMTP id jr13-20020a0562142a8d00b0062629d49a26mr3308228qvb.37.1688131557968; Fri, 30 Jun 2023 06:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688131557; cv=none; d=google.com; s=arc-20160816; b=aqj4Fa8mnbvlHLfEB1m7UV8j/VZNCsjo9rguc75n1hLXdyxbsKgg2RRH+PlRMvQemL 8/etEZcZMjd5+uAOPI0eB25MDSLNdB3xQixm4rTNjsDrkFHlw3f/iHX8rwzOJlouQYTB AlETdhdsl+BTsI2UDZrO/OXObTV0xpKTZ2esUx/YFpzGQpD13/a9zbh6+wEkkU37FseW K0ABGojzmycMm3kHf0kEO+tCmSkB8Le3JOvnnyDauvX0oOGujQipZTPey1MAqyhWS5P2 JwFHNu+o0yBVYo+/FwR9A0zhVBmmQj1zGGHSEyJZMReFWmLnwIeNPewBOB8J5zf+NkZ4 qRPw== 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=lUkCksRepDyJ8GSSdRoBq8cm8bf7/10tPEy1hDkGHcA=; fh=6bnXD+ip8BuPvzTWf97csbR5QVhpZvBV1AID0n9STS8=; b=AvBugQmO/6YF7WtMwDTWdkpBUo6zCL92rMGeCN5F1sIWg6F61nxD7olvAuutNajrov dOrVpQSAVnkPmZPr5yG+k4fKFFSepsXyZQvQ3lyjxxRdFNtsRbG1jOitxoa8THNxD0Pa 7tAfwCo7rW/UZ1PgFlUc+NPCNWdTz3T62LoMPQ+2fkRNra31tvwzuieKMArp1+enle7b Q/e91CITJGbXlMlblwkT/rmUBeOKzDpdqwhMI+I72pmYYIUAmSZ1/irf1xk5/9IdEOZV yiZZzwW6GN0g2lIcTtd25Dmn79jCNUoffqYL5Y2S2iOhU90fF6jgNj4R7DjHASQiqaQn D3Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ovDjW/I6"; 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 gw12-20020a0562140f0c00b00635e6968076si6521321qvb.509.2023.06.30.06.25.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Jun 2023 06:25:57 -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="ovDjW/I6"; 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 1qFE4h-0007cY-UK; Fri, 30 Jun 2023 09:22:11 -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 1qFE4g-0007bZ-9S for qemu-devel@nongnu.org; Fri, 30 Jun 2023 09:22:10 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFE4e-0003N3-HN for qemu-devel@nongnu.org; Fri, 30 Jun 2023 09:22:10 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc0981756so15774345e9.0 for ; Fri, 30 Jun 2023 06:22:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688131326; x=1690723326; 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=lUkCksRepDyJ8GSSdRoBq8cm8bf7/10tPEy1hDkGHcA=; b=ovDjW/I62QwH9YT8eIZnAFSsRNPFYn3voVOh4biYZxPk4jfjdfHVUa/BbHgsR0425w 1zH4yxitjLx78dmngkoF7gq3i1FJ8DLhtxvY9ONXjCrrp3kdCmS+u5mQG2rAWiAWJrxA B8efsqj+ciwpNdyZPYRA+cTeHdqnVLP/c7s/dF46ZcSiZV75KGLJu6QzGP9XZV/4zGdE 1NshZmcYk1LwqX4GPvGGNhmxRH9TLbfB2uujuGN7UnCpT8w+X8qQbccqjNbKkzZojHQv V7kWFuGQr9GFYeD5r5WEpeDPnaNYioXO+u6xvq1FGyv4nKquyk66QrqRr6dGdM7iPqk6 q2MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688131326; x=1690723326; 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=lUkCksRepDyJ8GSSdRoBq8cm8bf7/10tPEy1hDkGHcA=; b=aMYkywIiI++CXwOad83EnrKUQ8hl4a8WJaQbRYmIUh2DGjEvsATljn2fz7hEszAUIe GShP1eZx3v+Tw6rn2hAwTdXEazlBNBWLfnfZ43SUdj2Np3aWY4jHaNkmUfOdP0HIeq5J UinvKzaLJP76Hzi4nwXLu68LjC0XNzuvA1sfkQzbdc/DSphnktdHF90VDi8FAl7zXDnb D/4GAycjzbq0VMgqTOFa/v7Z1UVlr6qR+7U/d3pNQ0ggJKXWeX6vhXEH9AK6ZyQkOtqP lRNEvmdMip/6yQxH2csP3aL0aHemTwNvGF7Om5FevcOFvxXffBOYYWXl5z0rGIteZ+Bo bxKg== X-Gm-Message-State: AC+VfDwE/dBHg9cTQkWT+oAAkYQIwfJ76jtreSBR5ZrTe0GzTXWzoEFr xbOm5feN5JE8HnijD6MiRBLN/HvIVCWNhVhIqWcOYw== X-Received: by 2002:a7b:c393:0:b0:3fb:403d:90c0 with SMTP id s19-20020a7bc393000000b003fb403d90c0mr1792388wmj.39.1688131326194; Fri, 30 Jun 2023 06:22:06 -0700 (PDT) Received: from localhost.localdomain ([139.47.41.96]) by smtp.gmail.com with ESMTPSA id a16-20020adfdd10000000b00313ef2150dcsm14571092wrm.45.2023.06.30.06.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 06:22:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mjt@tls.msk.ru, laurent@vivier.eu Subject: [PATCH 07/24] accel/tcg: Introduce page_check_range_empty Date: Fri, 30 Jun 2023 15:21:42 +0200 Message-Id: <20230630132159.376995-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230630132159.376995-1-richard.henderson@linaro.org> References: <20230630132159.376995-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.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. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/exec/cpu-all.h | 11 +++++++++++ accel/tcg/user-exec.c | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 8018ce783e..5b2c230d52 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -224,6 +224,17 @@ 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 + * + * Return true if the entire range [@start, @last] is unmapped. + * The memory lock must be held, as the caller will want to 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 8fbcbf9771..25c605dc1b 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;