From patchwork Fri Sep 1 02:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719473 Delivered-To: patch@linaro.org Received: by 2002:ab3:1981:0:b0:23f:8cfb:5ad7 with SMTP id 1csp16953lti; Thu, 31 Aug 2023 19:25:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ90PQtpEyWtqifY6NpMK5FZum/uJRrwTV/Wnk2o9qrkZ26tl78bhUEGSl4Pos4Iu3us6H X-Received: by 2002:ac8:5e13:0:b0:410:8bf0:6b1a with SMTP id h19-20020ac85e13000000b004108bf06b1amr1508856qtx.51.1693535114333; Thu, 31 Aug 2023 19:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693535114; cv=none; d=google.com; s=arc-20160816; b=TfvUcDRSW9kjURztufWrrE4yFYxmG3CQ90OoJHdE999YaXhuEnF0WG/b9xuEI7bL/S ZwWnUGGltx26VOXrsA91X2okzkGcS2NpRcYeTaWYBMtLMgwQoCOYWMAbs3q0gwCVtrO5 UfT+sJwy/CC2KmsA5wzkfj5IOdSLj3l0PyKqZGdxNMpyeMERt5LFKc+wFJeLPNGqM8Zv Y/HAl8OUTf4DIKh6XWXVic7D4VbA6pFGpEE/T14bmOMmcc8rrCWo9ZeO3vFchNvLuxDr aogAfZ9WZ/iAYiJ5eFQiE09kU7Ol9wkwDX7WiO5ss4PIFXY8jWPTq48p2kOhVTOmetYd SFDQ== 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; fh=SfxhhCERWPFe9EfsSkQ0zw+VJgdUi+jLlAbxANM8dQo=; b=PD1SDmzVr13w3VL+2TSlqPJGeIUTqYhfktow+tJ0S/96sdmb8DcTstaVbetpT/WU7m 4Eet6oOJPvV9VV9VHwJPnGS7u9bh6I+6P5STDPEyJbUlyTY1JjQlPP46WDldH7xrP8+D ebm4KLUnmC1QzBZ1u13N60uZnNOspf8Pq+1ypA7rwoShwW5tV0eQxDr+oNPF3BjrEuoq Br+/e9LczVd04ioE1ft9NmrNMMf2CnqtJzV3cWYMMetrzBby/uhnw/g9Uofx+F/17WYa XkYtWcXAaw6Vzb3KYFLa7i1m2msd4XRRY75uOgbFnXeuqDIsHXrYUgQkGLD98AhWeRzf 2+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uQAacoMe; 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 j8-20020ac85c48000000b0040a11467cb6si1761882qtj.569.2023.08.31.19.25.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 19:25:14 -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=uQAacoMe; 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 1qbtpe-0007iF-OD; Thu, 31 Aug 2023 22:24:22 -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 1qbtpZ-0007Aw-M7 for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:17 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbtpJ-0001St-VQ for qemu-devel@nongnu.org; Thu, 31 Aug 2023 22:24:13 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1c26bb27feeso960863fac.0 for ; Thu, 31 Aug 2023 19:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693535035; x=1694139835; darn=nongnu.org; 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; b=uQAacoMe2WjDYLW0a/J/nKVA7w/hLcOTOn6aS9DCQ5TJB+VvahbbScmhjVUXXA7Dpn cnspQc+B18oKBa343SW4kMEu3C+SrvIBa+uWYDUpmUj3gJ6tp99n400BzHcrKYYyWd2T l9CvXQysmkX2i6elqlfThbFG4KnOzhIvoxe+JKqAhvgg8a5mbxrCO2CI5oo4uCN5UIfI P0Xp4/sfqxN20/QuSfM3TAe2wQnH91yzBFp9iR69nnpz+eqEYE7AMZqCOl2ZcNSNdZPD GyB9t7OVuFZ+V/Fz1qde/+2pl/m2yDH9/jpwNeJv1VXMemzRghv+ipEiZQhAWz0HTqBt eF9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693535035; x=1694139835; 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=v2oMFltgopchvkCHTnrNxCsJsKx6S/nBlH+XZvf6iJQ=; b=dzxa+Vxo6OVKuCf7gYoSSf1xOjvXG1tGpTwEMF0Vt14VupbQoDqwyYJE6xjDZvHcYj /4EeAz6Nspa/XS0Wem+KHfd0bPctvA+G0PG9bT8LSy8Y5joqTihcjkiwdPa8N+jXRKQc P5yz7Z85jmO/Gy2xjncPK/aelDwUwHYKhHgHGK31zRmMoDBddwca5RUbtjuvr/XDhKx6 IhDg+Bp86AjnbkQAaav5tQ3hw3lZie24Y9jdCVTkV42zZb0tgGhczZM2H5t4PPGwrjGZ 4b9VOjVl9z25l61kSVtyQ8Fp8luEBxy9RE2V/T2qLUI1di0yfgqki9xc3hQTzJnm1t1R Yh9w== X-Gm-Message-State: AOJu0Yw6+ZF0kqUu1cTbJ1MVQGG1AIJ3yuOew/7pODt16RdCElsGQCX5 AtuG8BJ5Kyvc1ia2SXImb4GIQvh2Le26Ek0yD5U= X-Received: by 2002:a05:6870:7021:b0:1b4:4a2e:33f1 with SMTP id u33-20020a056870702100b001b44a2e33f1mr1523556oae.29.1693535035472; Thu, 31 Aug 2023 19:23:55 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id c25-20020aa781d9000000b0068a54866ca8sm1906977pfn.134.2023.08.31.19.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Aug 2023 19:23:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Subject: [PATCH v2 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Thu, 31 Aug 2023 19:23:26 -0700 Message-Id: <20230901022331.115247-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901022331.115247-1-richard.henderson@linaro.org> References: <20230901022331.115247-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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 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 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 4c1697500a..09dc85c851 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -863,7 +863,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; static IntervalTreeRoot targetdata_root; @@ -901,7 +901,8 @@ void page_reset_target_data(target_ulong start, target_ulong last) n_last = MIN(last, n->last); p_len = (n_last + 1 - n_start) >> TARGET_PAGE_BITS; - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } @@ -909,7 +910,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; page = address & TARGET_PAGE_MASK; region = address & TBD_MASK; @@ -925,7 +926,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n = interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t = g_new0(TargetPageDataNode, 1); + t = g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n = &t->itree; n->start = region; n->last = region | ~TBD_MASK; @@ -935,7 +937,8 @@ void *page_get_target_data(target_ulong address) } t = container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs = (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { }