From patchwork Thu Oct 6 03:10:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 612840 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1189835pvb; Wed, 5 Oct 2022 20:12:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5RfO1Ro3Ku6VZXW2F7VwhuTukCFh0d4aCy/ANsqQxiD4e3L8QS3pWgyWH0jhSYpJwNuUZt X-Received: by 2002:a05:620a:1b98:b0:6ce:9f9e:6d4 with SMTP id dv24-20020a05620a1b9800b006ce9f9e06d4mr1925059qkb.542.1665025959825; Wed, 05 Oct 2022 20:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665025959; cv=none; d=google.com; s=arc-20160816; b=AnTBna+fURBnq/STT+hL2LSFFy5CC3Kk/jvEjMo266+6+L05/mKM+H/NCugyHcI1L1 POdFG4XrhCRVubJ3Fiq/KSQXxsU+dcuoSyT0v1WksLuqbppYboZ90+FuZihMSt/fOaIf 7TKOP19Pc0SmaPQiX98LIb8hc7TJKxofhB9+0VjaF3HPHxYia7JVbNLZZL8bWGNEfQV7 NLfJwRX1jxxvyJUt+7uBl5Gj+8AnRX0HP0zrtWHudxc2uhR9jRnLTuZmDB88IwuuqG+6 JetjgaQ3b4c3M0cBvcWsihXC2Nr/feCmLLf4oTibfU1LY0z1RyvqdOUXR3o+QjlsrHUX TvbQ== 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=GNx/wZFYP3b5pXqqccbxReodi1Cirhgoe15NhYoUnUs=; b=i1rwfhDZywQH8+aJrcnvU8nQg9sdiKXTQ2myOnah6iGoZl3SYAdwwe8OVlaYGtvM/q 3V5omYVHLAh5eyg9rbsmOjQsjOW4VrUyZB0NbK9aGFDaXxK0y/Gwf3GuUmV20w8gB/8x oVkFwXoeGMPMxczasiZ8jQL1caf30UkH1BNN9LXaVeW7axJ9QuGZ9j4/e4ErQGEfVtFZ Krerho/6gECagmimLLWdRPG3nSyidgcVkSGB3nmGSu8AFxnI3xZeoPNBVHmXd85O5www EwNln3gOLEl9eI2jAsCLwauxg6eS4Wb7lPvIb1QM0xL2Q72ggkfgDHQDxSfUNGCPgKnZ l9pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s1+LYIqD; 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 7-20020a0562140d6700b004a33e35bf11si2901011qvs.112.2022.10.05.20.12.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Oct 2022 20:12:39 -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=s1+LYIqD; 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]:42146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogHJP-0005DT-9m for patch@linaro.org; Wed, 05 Oct 2022 23:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogHI9-0005BE-NX for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:11:21 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:37504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogHI7-0006vn-L9 for qemu-devel@nongnu.org; Wed, 05 Oct 2022 23:11:21 -0400 Received: by mail-pj1-x102a.google.com with SMTP id p3-20020a17090a284300b0020a85fa3ffcso3143070pjf.2 for ; Wed, 05 Oct 2022 20:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=GNx/wZFYP3b5pXqqccbxReodi1Cirhgoe15NhYoUnUs=; b=s1+LYIqD+rV3i6IsETTLOP2oNElBn0LmkiV3JGqNeWov79OBS3jgsd53xW1KP5hyyp le0gvc63XBkxcWa1SxWITLiBPdq14YA3jWABnvPV2X0ZnSUjISN/rFdxKChMWg941I1g y5+d8N63MivO+SQKtBClbWaSn896FasmDxwLmvEIrC4dJclzRjrKEwGuz3WxaD5jam6t rkVYmFLwLK/CUcdiEgPaSRk3IMMiZjzWYXZlyGox8FQcLTOepA6vplzQqnpsGErU5mPM k2xJT2DF7EpHcwlMFampCKsbubJYQL+ERBO2mDqES1deFHqgp4QTA8oWZQhotsw3Cv9j /1TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=GNx/wZFYP3b5pXqqccbxReodi1Cirhgoe15NhYoUnUs=; b=Fp5kdfF00sAdbYijwFU7KzIaq2yWN5e49UCQk30Uu+iGH1lYcb80oqbfSCNTBI96Bj 5hIxFdDEP+7bQIFeNbwZ9ZE64jg5HJ1NcI8OPTaGUxxsJ4jisjTL8s6qhT+jqJ9jdGIJ PnuDO29Zo5WRE+OfKMb7Np5bSZbF3jzmGOub4Dang0j+1bcLj1HzLLxIYwRPMcTW0ZHE WL4Z7EfqKOjC/OUf2MqWFOb3mnn8nKapELrurpWiWxJZdmg+rIz6MZClfLPcDNknmcP+ cAunfPzpp/2DQ4q4FJp7SmNpPF6DmOHHIU+4g2P4vtcvd1+9xRd+obNe/xTiq72U7op6 fjuA== X-Gm-Message-State: ACrzQf3KqecpeV8FHPq7vzSgaegpbBSjiIlZ6Hw/vctG64kRwPBL1TN9 1bK/OjLC0ibolv6LL5AK87uc7AVYZlhSuA== X-Received: by 2002:a17:90b:3b81:b0:202:597a:c71d with SMTP id pc1-20020a17090b3b8100b00202597ac71dmr8066080pjb.105.1665025878171; Wed, 05 Oct 2022 20:11:18 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:9ad0:4307:7d39:bb61]) by smtp.gmail.com with ESMTPSA id u128-20020a627986000000b0056281da3bcbsm58360pfc.149.2022.10.05.20.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 20:11:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, laurent@vivier.eu, pbonzini@redhat.com, imp@bsdimp.com, f4bug@amsat.org Subject: [PATCH 02/24] accel/tcg: Make page_alloc_target_data allocation constant Date: Wed, 5 Oct 2022 20:10:51 -0700 Message-Id: <20221006031113.1139454-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006031113.1139454-1-richard.henderson@linaro.org> References: <20221006031113.1139454-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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" Use a constant target data allocation size for all pages. This will be necessary to reduce overhead of page tracking. Since TARGET_PAGE_DATA_SIZE is now required, we can use this to omit data tracking for targets that don't require it. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/exec/cpu-all.h | 9 ++++----- target/arm/cpu.h | 8 ++++++++ target/arm/internals.h | 4 ---- accel/tcg/translate-all.c | 8 ++++++-- target/arm/mte_helper.c | 3 +-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 16b7df41bf..854adc4ac2 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -281,19 +281,18 @@ void page_reset_target_data(target_ulong start, target_ulong end); int page_check_range(target_ulong start, target_ulong len, int flags); /** - * page_alloc_target_data(address, size) + * page_alloc_target_data(address) * @address: guest virtual address - * @size: size of data to allocate * - * Allocate @size bytes of out-of-band data to associate with the - * guest page at @address. If the page is not mapped, NULL will + * Allocate TARGET_PAGE_DATA_SIZE bytes of out-of-band data to associate + * with the guest page at @address. If the page is not mapped, NULL will * be returned. If there is existing data associated with @address, * no new memory will be allocated. * * The memory will be freed when the guest page is deallocated, * e.g. with the munmap system call. */ -void *page_alloc_target_data(target_ulong address, size_t size); +void *page_alloc_target_data(target_ulong address); /** * page_get_target_data(address) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 429ed42eec..2f44f7afc7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3423,6 +3423,14 @@ static inline MemTxAttrs *typecheck_memtxattrs(MemTxAttrs *x) #define PAGE_MTE PAGE_TARGET_2 #define PAGE_TARGET_STICKY PAGE_MTE +/* We associate one allocation tag per 16 bytes, the minimum. */ +#define LOG2_TAG_GRANULE 4 +#define TAG_GRANULE (1 << LOG2_TAG_GRANULE) + +#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1)) +#endif + #ifdef TARGET_TAGGED_ADDRESSES /** * cpu_untagged_addr: diff --git a/target/arm/internals.h b/target/arm/internals.h index 307a596505..d94efbaf5b 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1165,10 +1165,6 @@ void arm_log_exception(CPUState *cs); */ #define GMID_EL1_BS 6 -/* We associate one allocation tag per 16 bytes, the minimum. */ -#define LOG2_TAG_GRANULE 4 -#define TAG_GRANULE (1 << LOG2_TAG_GRANULE) - /* * SVE predicates are 1/8 the size of SVE vectors, and cannot use * the same simd_desc() encoding due to restrictions on size. diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4ed75a13e1..64a2601f9f 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2271,6 +2271,7 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) void page_reset_target_data(target_ulong start, target_ulong end) { +#ifdef TARGET_PAGE_DATA_SIZE target_ulong addr, len; /* @@ -2293,15 +2294,17 @@ void page_reset_target_data(target_ulong start, target_ulong end) g_free(p->target_data); p->target_data = NULL; } +#endif } +#ifdef TARGET_PAGE_DATA_SIZE void *page_get_target_data(target_ulong address) { PageDesc *p = page_find(address >> TARGET_PAGE_BITS); return p ? p->target_data : NULL; } -void *page_alloc_target_data(target_ulong address, size_t size) +void *page_alloc_target_data(target_ulong address) { PageDesc *p = page_find(address >> TARGET_PAGE_BITS); void *ret = NULL; @@ -2309,11 +2312,12 @@ void *page_alloc_target_data(target_ulong address, size_t size) if (p->flags & PAGE_VALID) { ret = p->target_data; if (!ret) { - p->target_data = ret = g_malloc0(size); + p->target_data = ret = g_malloc0(TARGET_PAGE_DATA_SIZE); } } return ret; } +#endif /* TARGET_PAGE_DATA_SIZE */ int page_check_range(target_ulong start, target_ulong len, int flags) { diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index fdd23ab3f8..62d36c127f 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -96,8 +96,7 @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, tags = page_get_target_data(clean_ptr); if (tags == NULL) { - size_t alloc_size = TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1); - tags = page_alloc_target_data(clean_ptr, alloc_size); + tags = page_alloc_target_data(clean_ptr); assert(tags != NULL); }