From patchwork Tue Jan 3 18:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638736 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391494pvb; Tue, 3 Jan 2023 10:20:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXvd5Zb9HVKAv+voK/oQueApesayiptU7W3GdYPF0gvjMGew1O7QyBg4HIMS9vr4WGbCHoqn X-Received: by 2002:a05:622a:244a:b0:3a8:27b9:5e18 with SMTP id bl10-20020a05622a244a00b003a827b95e18mr71798327qtb.67.1672770029972; Tue, 03 Jan 2023 10:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770029; cv=none; d=google.com; s=arc-20160816; b=M4mBcgYDOEQyFWcZVjOnRm7SY/fUcEi8aOA9l/6Xz/2PNMOjq7IOTXbTgEOzOpkma4 OzWb3AdMiPlhpSwOEZKWZah8UJ773wTlo4FwzS4HfeoP3ZUqdegBwvruOmTDXf8hI69M 81b9GIm0a3bqD+JUoHC1q2fW8/zOgccZrInToOGkqyFUSmD3uONjZHm2PIagX2/dJopn rDpyeRg75mG/W4zSQLKdcRCmGOeyPNv4IBNxwB+7TnaRq9NlWpzAe89YyyFSh0lxh8vm z+nux0cg5LOWt5yVLBp+GIJoemDx0REWxfttG/t3dyUvlLVkWChraFiF8lzvBedDRYMs x0Ww== 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=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=FhPegaYVG5B3D8TTIBLmzTEvTsDK2H3P9NCQUofSs7+g7Kbrv4rGVndJq7IPDe0AVy 1q2En47wjkpv/I0XwF3wx4BY8JD+j/hXQBskvqoQMQrLdvoNLvuEGxmUj92qJweVnpED ZkyY2FFDxjHrZTORJRMR+62i3aCnxDlRUxetw8l0A8JSDhUgAC8K8bdsSeX4to41e9jh XbR1wZ0jQqKErcfKy3j2XI8YTssN13BTT1fuj9EENrU0G0NBPu43jXPTrgKKqkN8irx2 eaK1VSxeqZQopaoyENvwxHem+WV+Ukk3IRWs+ia/+tXoL7wlx5TktZuJ2RjOrB/qSr/E gyDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kq6RkKmG; 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 l24-20020ac87258000000b00397ce0788ffsi16040853qtp.525.2023.01.03.10.20.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:20:29 -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=Kq6RkKmG; 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 1pClrg-0000Li-JX; Tue, 03 Jan 2023 13:18:20 -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 1pClr5-0008KT-1n for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:45 -0500 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClr3-0005FO-Gh for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:42 -0500 Received: by mail-vk1-xa2d.google.com with SMTP id f184so11693113vkh.2 for ; Tue, 03 Jan 2023 10:17:41 -0800 (PST) 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 :message-id:reply-to; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=Kq6RkKmGAD4JxZwhoyY+Iee5QDYces8Mf405BzHxPBOoVc3qcFn0X7wa0Q8aZB+RMb 4qnSG+7EA2uGHlBSEtj84zQDzo1bCEyr3kgPmz/4rfFwfaMn6hS5qLveO5JZ5fMb3lab dfCe8JqEA5Mk1PLMgvOKp8ymvoKDE4pn0ZHY1QLOXOon0vvSyHuWrORuQgiA8t1XhW7/ C2ZHNrunlOdlCQoaA9ydXa77+uMYzqDRCWv/MUxqgs2sGVE69h/lQWa4yA0uPBFH8IMD YJ2tdutKUgenjvwzsoyN2yg2STVn4zm+IjTUvh3zNUHwebVXQ7ke//FAXBNh5l6zR5SC KkrQ== 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:message-id:reply-to; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=L53i9OVtvt+H0W2h9rjcS7IdvOyk49JMRFPEwKmNba+xbb65NgRYOiu+93Sr4t50pp ijCXxdvVx6iErCeDsVg5IG1dBbPoNZNyLXRurOi4y+Vtz2JcxRFqwLJQgh6BdP4L8Kjx bw57/dSC8nO7//7YAw70GGIY4xtTQd5zGwRTs/bWbJhFWVrUqFA3z+4pV0abA/HwvY9r aAcBYZlXI+7JE+1R936NAgzipX5pwXF2eQ39616QdFNRDFMFBxlrcKGu8z8qiO+KhUh1 q8uVdvRtPrdWp4oY+S6QW57LUdWo8sdNSWoK86zrEQJUme4lsLUaVOAEU/FbuVVx+zsl iISg== X-Gm-Message-State: AFqh2kqnVxdIdDxq3ZsaF3Q8j6kM5v9MvFogPFvP7TW1xxVGlJuiZLvv xw5HWjp5pI6IInB5wL30dKSzqCwCdbZOKLbzIH0= X-Received: by 2002:a1f:24ce:0:b0:3d5:5cd4:8835 with SMTP id k197-20020a1f24ce000000b003d55cd48835mr13557926vkk.15.1672769860366; Tue, 03 Jan 2023 10:17:40 -0800 (PST) Received: from stoup.. ([2607:fb90:8060:51a2:184b:6e49:c396:be2]) by smtp.gmail.com with ESMTPSA id v2-20020a05620a440200b006fed2788751sm23042354qkp.76.2023.01.03.10.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, ajones@ventanamicro.com, alex.bennee@linaro.org Subject: [RFC PATCH 17/40] target/arm: Copy cp_regs from ARMCPUClass Date: Tue, 3 Jan 2023 10:16:23 -0800 Message-Id: <20230103181646.55711-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230103181646.55711-1-richard.henderson@linaro.org> References: <20230103181646.55711-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::a2d; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2d.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 Create a hash table of cpregs in ARMCPUClass and copy to the instance in arm_cpu_init. Population of this new table will come in a future patch. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 832b2cccf9..36d7fa9779 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -111,6 +111,9 @@ struct ARMCPUClass { DeviceRealize parent_realize; ResettablePhases parent_phases; + /* Coprocessor information */ + GHashTable *cp_regs; + /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a46fa424d3..da58f1fae7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1178,14 +1178,29 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz) return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } +static void copy_cp_regs_1(gpointer key, gpointer value, gpointer user) +{ + GHashTable *new_table = user; + ARMCPRegInfo *new_reg = g_memdup(value, sizeof(ARMCPRegInfo)); + bool ok = g_hash_table_insert(new_table, key, new_reg); + g_assert(ok); +} + +static GHashTable *copy_cp_regs(GHashTable *cp_regs) +{ + GHashTable *ret = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, g_free); + + g_hash_table_foreach(cp_regs, copy_cp_regs_1, ret); + return ret; +} + static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); cpu_set_cpustate_pointers(cpu); - cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, g_free); QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); @@ -1219,6 +1234,8 @@ static void arm_cpu_initfn(Object *obj) cpu->gic_pribits = acc->gic_pribits; cpu->kvm_target = acc->kvm_target; + cpu->cp_regs = copy_cp_regs(acc->cp_regs); + #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 /* @@ -2337,6 +2354,8 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) const ARMCPUInfo *info = data; acc->info = info; + acc->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, g_free); if (info->class_init) { info->class_init(acc); }