From patchwork Fri Aug 18 17:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714668 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp629856wrs; Fri, 18 Aug 2023 10:16:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNalXzV+jp2lsdsDINCVTwbDEoZGU+t76lXLe0mW1fBos10k7q4AUTouCTdQt+sPFr725M X-Received: by 2002:a0c:e3c5:0:b0:64a:2b04:c10d with SMTP id e5-20020a0ce3c5000000b0064a2b04c10dmr4235172qvl.25.1692378985583; Fri, 18 Aug 2023 10:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692378985; cv=none; d=google.com; s=arc-20160816; b=n/dOKvOsU2qCk8HjgxepEGzbTqkJOpUUboMXOqRBjXFqsgb4RXVFyhpWIBVwmjPOh3 pb3kUoT5mzV+CTiGevOR9+UuWD+lQRUckjf1E5ut98iCVihGbxuiSWV2ZyqIvfA7+7FW qewIHk4xuZlSW9tV32FfOw3hPbYOHkl5yJDcGtXLgvw4M0qzVyGvWe7TRmrdA78tWEji gQVbHDX7RJyE2BK8/mBl5ElqG/4gIdN+HZJ1bX00jkqYrISA6Oz3Dp+J9zvTKGHSYl6V Rm75hEXfOebVdK4blSWe202vXxsnCa7SPRcNCOesSSIfJhWTqc7YF2r5/KYJX3gT4Yfb LXKw== 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=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=bm3/NaF6ueGD97f+lZT6Ht3sOPUIDWK2qo6d06S6k9f4fOUL3zYa2davqTHQ3ScvGE +yBFim7itUJxwBb/7xbFA8eD2mkKCekiC/dO2DoRWZ48h+ldhEqBlPUHzmlnmIUyzk+F bUysZvoXB32D0N9MOVdQClmZb6pNgocdbauHXs060wjHsaY3ZSzE0aPxdKqQb1nEm1OG 2Gttc96eStIBOGWbVC7mdQk8aNR+aJfj9nAig0sMpTghElsqBz4DnwNv9cz33ZezDgiX DXRKdIEAiMeZ24K8e+c1QC030ueYqP7lIGnSQmfEcm9xAzBmWEHux5O3Ud9tWHNh/9uB d0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xxMLexHM; 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 c23-20020a0ca9d7000000b0063c75fece4csi1515536qvb.170.2023.08.18.10.16.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:16:25 -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=xxMLexHM; 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 1qX325-0008Qm-4p; Fri, 18 Aug 2023 13:13:09 -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 1qX322-0008Lf-4W for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX31z-00087J-Gd for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:05 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bc83a96067so8714425ad.0 for ; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378782; x=1692983582; 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=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; b=xxMLexHMqP8i5m0FMT0NADayUZknlyJRIIYFL8eWEwXV6jJGdWRCS4sLu4DF/piUwz GbJTwGmIUiYDna90YiP4As0HNWz0SPyhdwOY6olF9PVFXucjjBqju/5qXXmgpPMAKZ2a wTsAOGAp1yCFkOwBfqathxMe4qkyr9DJVj6QiiyzkLO+VHSGGEQ0qClq8bAPCpeLjDg5 W54Kc7zPuhhXGEUbK8sn33i+mxyzH447Kgb9clvl5NHgR9JOWDkwUX3LCbI1dXylOz4v JxBSdJ40c6fKpo8qxTpHKT8W75OGtaERaLSthB6tQlKn80rZh4AjFY+y4/vUFFXozxcj RqOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378782; x=1692983582; 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=xRESX9nFR6tNCpUYhPFWnwcFBDJbo9xNbLHublG/Dkk=; b=N+KuRaKi7fHRNQUVDZblshYOfvFQSH+Qp6OrGtiGOlpmxccU/KWUv8BNI4IZgXEpk4 /bIjlPjNiQPcbzgBK5ctxgALscUzBIs6PHGyDo7mfBrO1mLj2YpS8dFh6mTS75NcU+6z 1UVJinQSVgnHSlks4wPJ9atSJkR0xy/Dss5K30MmSCMuHGaEGgqznfnH0Xzi+awS4V4j ywKkQxv9WTma/JhlhqVCUcUULRWSog0X0AIuq1gSx2D1tDv5/soRb1eCeK6q57sHb9WE otMBq3l8kPJJr6QEYRFO27ukE91x93s8lZGEDxLNVS1FAn5SmdZD4mM0lKs+haUQlfTt uvnQ== X-Gm-Message-State: AOJu0YyNhNrwT1q4tYEGUEROeJRDI2YlXrz+MX0LEs7uEcCmW/l3WJoK beWfpoh3iKy3fffHSKLiMWLh43FNTx+JhniR89Y= X-Received: by 2002:a17:902:e88b:b0:1b8:9ecd:8b86 with SMTP id w11-20020a170902e88b00b001b89ecd8b86mr4006618plg.5.1692378782039; Fri, 18 Aug 2023 10:13:02 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Fri, 18 Aug 2023 10:12:22 -0700 Message-Id: <20230818171227.141728-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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) { }