From patchwork Thu Feb 15 06:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 772850 Delivered-To: patch@linaro.org Received: by 2002:adf:9dc2:0:b0:33b:4db1:f5b3 with SMTP id q2csp681185wre; Wed, 14 Feb 2024 22:24:37 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWxnshdlnJigkpm6Qvgi+3Yhl4/WXZd1w6FLKUZUGWU0TkwTMCoalzW5yv+EJwQ9qA6i9cuAi5cUftt2N6wxsfa X-Google-Smtp-Source: AGHT+IHqqCb8Ku2FmMoSVRkXsB4ixJHcJ16xy/o1IjXHDr3rGYh91uM9tT8c7bkWPx87Xt+jRnZM X-Received: by 2002:a0c:e487:0:b0:68c:67aa:c056 with SMTP id n7-20020a0ce487000000b0068c67aac056mr951702qvl.39.1707978277272; Wed, 14 Feb 2024 22:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707978277; cv=none; d=google.com; s=arc-20160816; b=L4Ju+tuDt48RKEost5isbKVawcmFc2FaxC2VE1i3Kui/1APFZjIUAncWt6AjJBSncq zlNZtO8jSjBqi08TAh/1KOJUK3GRoqVgp8uy6d4ZRcXSr1hkOHI6b7yZmrlIjBe4tbaa DdYjvm3THuNfgNpj5lnplPUW626g6M4SG7Q6Do6BfeP3JAA70Jkw5tnsIKS5kN4og75B 56HfQZcjq5GRrxOwecZiBu7Gkjxb4xp+X68LZwbwDEwmvZAQwsX+ryn37JciK9cTG9se fZ8ksKsKG0+IgHxhufuyX7ogf8XaNW61K8U3w3Q90aKHVsbDgwNFctDivIUj/gr5JzL+ Yjzg== 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; fh=H/IsS+LNYM6dBDHt5BZPsM5V9tnyjdUlJ92VVuTs62g=; b=E7qLEUgmbuvD97/RGlo23JUvwR3nso6R+8ioi+UXjUMrjOsUg7R9Em6W0Ovo7DexGG cFTgk/y69yk0zUFTFtEbD4m+1wlXGEzLOAQps9Qxnki6NZAKxUxCCvNFMPy6nWfDEW0g 6QrfwKjXm7AUWc43jRDKs5PfJsNjxU/z9FpS/SD55YDrYVmcZzFZ8dS0fxq8H1m2lNFm nQA6+60yljn4NexbKx6PDZoQUALG95hhLXfttuTDDWSqpak470Q0LghrOZLxIFpA5Pw/ t5cZZuMPtuo4+bK+KE8o4NH67XMHKUNRXaaDzZYUh/JItxwNtezlkznedPPgFXUCOQg9 qblg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ON0vDx1j; 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 jq12-20020ad45fcc000000b0068c879eb37esi762355qvb.438.2024.02.14.22.24.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2024 22:24:37 -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=ON0vDx1j; 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 1raV7P-0002wn-OE; Thu, 15 Feb 2024 01:21:11 -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 1raV7N-0002o1-GV for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7L-0005av-Oo for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1db51e55023so2969545ad.1 for ; Wed, 14 Feb 2024 22:21:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978065; x=1708582865; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=ON0vDx1jfOO6XNXhgRG2bwbv9GCJZfaIHvQ0gRfZ/3ZBCT2LAboGCvSn/9+olyqgwb DGy9s8tD/N2dii9MXRJu33ZtLpKVNZybb5edCSBgJFgs4kWBbiyySu3wlgcPgvn4zGkd Y46i3EFX85mwaCnhbKxcIGDIiOWI6Yp7jK5sOiJ9Rg9vw3aPlOj7G//q0GnzqFwdAQZI +6sQPH2zFHBdXn47qwmeAbf7i0p2ip2kDJchghD82dClha0DrFiejjaTN+SuMEMNPEPI bD82pw0eBIp2Dm00ukt4OLzTj05gDRfThmMTIIuCqpFhzunTAmfriHBsj5Edi5dT9Xxk m6mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978065; x=1708582865; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=pCZyrwXDLTFxWHuD4+6PasWKwaTZyTHEEabfplUYI7oSACDzijMR2bM5kW5Cp02DvK phzb0mkZR2Psy385O5Ttdbb26KvCUasvcn3xYbtx1zVuj8yXwum68hAhs6MJsNRf7Xf7 rN4bay1zJNcAxnCnQ+T8GpvKs1+4dKXomVJxYPob7tMrjwi/yenYE8zcIvJoO+ufoxfs BpuzN0cS2I9zPxdCcR5iyFH5IIQ+BvH/Jnr56NZb+f/kriWDMomIN0MyvJjHL6nInq6Q 3++3OMw8GVyvV7r+qwNiNNOXIcsyjC2G+K0strkkN5EYk1Hml9Q+b73dxpZr++p49JRf 9/Gw== X-Gm-Message-State: AOJu0YyCUyGnxGCmfmh50tvBCpCMU2jAsucDur3gkSXViqH+4TODnCYT M60mwFk6olrHGb5D3JmRIy9gzUHMEQBYlH2tJmrQEHOLA25C+EVbb0pGzktJnxL/cGsv+a4SFEz B X-Received: by 2002:a17:903:1cc:b0:1da:15c5:bc06 with SMTP id e12-20020a17090301cc00b001da15c5bc06mr1195475plh.58.1707978065257; Wed, 14 Feb 2024 22:21:05 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 30/36] accel/tcg: Disconnect TargetPageDataNode from page size Date: Wed, 14 Feb 2024 20:20:12 -1000 Message-Id: <20240215062018.795056-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> --- 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 69b7429e31..3cac3a78c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -864,7 +864,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; @@ -902,7 +902,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); } } @@ -910,7 +911,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; @@ -926,7 +927,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; @@ -936,7 +938,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) { }