From patchwork Tue Jan 2 01:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759342 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856224wrw; Mon, 1 Jan 2024 17:59:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLWvzRMYvjv+UVkZ092YejetIGtfPWJ8MeHsvfM+ZGh0ZTl7jrHdWmWvzAgcmrP+MA0Vus X-Received: by 2002:ac8:5a46:0:b0:428:1915:57f8 with SMTP id o6-20020ac85a46000000b00428191557f8mr4977264qta.121.1704160791524; Mon, 01 Jan 2024 17:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160791; cv=none; d=google.com; s=arc-20160816; b=lORLHaK/tJcRBSORyPK/RRQZJWLKo1zemhIJDySlu4Hxs5Sk/j99eGewBHs9vV1BRS oXd/4C+w0qOhibHePByp5oBGRn86hrYLovB1EWKtNtmM7TKyQGxka0yUM84SFOHXs6s3 cqNVdclMYx6cSlWFfAAJinS8IFg2kQsyqPfi2yGpI8GwrhwZZZMT81WPUckq9cGU2hrG R5pgqyUeotE5Ad1la3nZfu9XkK09gV5BONItFzZ3SLj3YrO9SjNhJbWkl+FgSRulkAnW XANRtEUppG8y6JgtiT+5PbPVCJfoREpYHC29QcB9zicaDKG4mrOGGaMQc7WWQks7m33H J70g== 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:to:from :dkim-signature; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=qG88rcWMaed1u0MUMi+x0Lf8UkdX0DkhoANmKKzu5M3PG3qx/KwVs95yGiiK1o/Wbo WSZAL7wgzqDZ+B5XS2r4545SVBagETRPqIeb92UB9TS6XAuYu2hxfvbV1Y2URFSHPv6G c/zsvqfMdhNZsPMQLpe4yObMAy5dwaaORj13G6GjOmTieP9K/jPqbHshW4oCaUKrwXKH wtSlblfNRUgaRm1cy2sMx00NRloSoPl9hLyvYFfobigSZEiRCkyFtrH88If+J9L0mK2L EpvPK0xiC3xmCuJduoDfijd9xcDahoQ8ix1h6LOxQpJJKPhzdb3X2i5C3m/GsI/l5Gxf fx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GwM1sn00; 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 n1-20020ac85a01000000b00427913eb778si26379230qta.749.2024.01.01.17.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:51 -0800 (PST) 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=GwM1sn00; 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 1rKU2t-0003Do-NI; Mon, 01 Jan 2024 20:58:19 -0500 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 1rKU2t-0003DM-37 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:19 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2r-0006yI-IH for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:18 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6da55cc8e78so1691795b3a.0 for ; Mon, 01 Jan 2024 17:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160696; x=1704765496; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=GwM1sn00+uFANYpDwleArGWWQbKqb+x2Ye8uELpxezt6ly8lDViscHGf9GLmTboUnL IZg+/ZPrF7HxqwANSXE6SNHe+X29hKHKy8Z38DIV79ry+DGppCeesqdHLq8eHiAJLd2Z ybZBziNa8SDpM0KVHQ3Ck8ZfvzUfeLdCjfLHZlC3StYzWyF1QyVhRMWU4FtRGOTwcGv5 cQ3rgLRdHtvxR5GB2oFpX7VaR73saI5OxTKViJwJiFl3i4KNP+a8hlf6Yc/VuFQJzO9I ZxvuCyprDe6yF8Mj7ChPn0JaEpOGzltnLKDtcoPwPNb/F9GbCDBhM0zoCcTxio7pBoXd /4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160696; x=1704765496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=xRLLyMUnEdIBmoTBxLlntkS+dBkeWBLq5GqG93Uootsk+pV7bdrQ3+KNLGc2WpFp5i Q47kg3anNqHsJFQO957a4JO3U3C41Eem88oTZ7duzzyJxnBZX3IZji88c5Csr7CfoPYr qK924bpYbHJ35ykSt3iu+Y4CjHa37ga3QVIYwobsDtCz2/rB9cdTQ2QQLY9ly3CpSHo7 u8aY9ayv1kQvTBcJ1D5LCOX69sdGLtk/0Pm/boI1swjlUUZ0sHFck2LEM2Ad3R41SD90 WC80RNVcgZ78a10FDxi6vHOoTVqJHdi/OktlN51dQWbZuBUDb6NU4ZQ7fGQkT8o86gbu KBPg== X-Gm-Message-State: AOJu0Ywahs/kArV8N7G/v6MEpw9J3/YjwqgfzPSrzsmmqLf2sZn2xnwF llPCSOqBUbH6s/Jl1WY9G26Bq8IGtJyEky8ljsO56Wi6Kvg= X-Received: by 2002:a05:6a00:6a04:b0:6d9:9277:b702 with SMTP id hy4-20020a056a006a0400b006d99277b702mr15270836pfb.1.1704160696186; Mon, 01 Jan 2024 17:58:16 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/33] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Tue, 2 Jan 2024 12:57:36 +1100 Message-Id: <20240102015808.132373-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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 Use qemu_real_host_page_size instead. Except for the final mprotect within page_protect, we already handled host < target page size. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ilya Leoshkevich --- accel/tcg/user-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 68b252cb8e..69b7429e31 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -651,16 +651,17 @@ void page_protect(tb_page_addr_t address) { PageFlagsNode *p; target_ulong start, last; + int host_page_size = qemu_real_host_page_size(); int prot; assert_memory_lock(); - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; last = start + TARGET_PAGE_SIZE - 1; } else { - start = address & qemu_host_page_mask; - last = start + qemu_host_page_size - 1; + start = address & -host_page_size; + last = start + host_page_size - 1; } p = pageflags_find(start, last); @@ -671,7 +672,7 @@ void page_protect(tb_page_addr_t address) if (unlikely(p->itree.last < last)) { /* More than one protection region covers the one host page. */ - assert(TARGET_PAGE_SIZE < qemu_host_page_size); + assert(TARGET_PAGE_SIZE < host_page_size); while ((p = pageflags_next(p, start, last)) != NULL) { prot |= p->flags; } @@ -679,7 +680,7 @@ void page_protect(tb_page_addr_t address) if (prot & PAGE_WRITE) { pageflags_set_clear(start, last, 0, PAGE_WRITE); - mprotect(g2h_untagged(start), qemu_host_page_size, + mprotect(g2h_untagged(start), last - start + 1, prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE); } } @@ -725,18 +726,19 @@ int page_unprotect(target_ulong address, uintptr_t pc) } #endif } else { + int host_page_size = qemu_real_host_page_size(); target_ulong start, len, i; int prot; - if (qemu_host_page_size <= TARGET_PAGE_SIZE) { + if (host_page_size <= TARGET_PAGE_SIZE) { start = address & TARGET_PAGE_MASK; len = TARGET_PAGE_SIZE; prot = p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated = tb_invalidate_phys_page_unwind(start, pc); } else { - start = address & qemu_host_page_mask; - len = qemu_host_page_size; + start = address & -host_page_size; + len = host_page_size; prot = 0; for (i = 0; i < len; i += TARGET_PAGE_SIZE) {